Making some changes for v1.1
This commit is contained in:
@@ -87,6 +87,7 @@ public class GameOverController : MonoBehaviour {
|
||||
|
||||
IEnumerator OpeningCoroutine() {
|
||||
yield return new WaitForSeconds (0.75f);
|
||||
background.GetComponent<Animator> ().Play ("ending_opening", 0, 1f);
|
||||
background.GetComponent<Animator> ().speed = 0;
|
||||
JumpLeft ();
|
||||
page++;
|
||||
|
||||
@@ -4,14 +4,18 @@ using UnityEngine;
|
||||
|
||||
public class Monster : MonoBehaviour {
|
||||
public int value;
|
||||
public float lifespan {
|
||||
set {
|
||||
//hackfix
|
||||
StartCoroutine (ReverseDirectionAfter (value / 2));
|
||||
StartCoroutine (DestroySelfAfter (value));
|
||||
}
|
||||
}
|
||||
|
||||
Rigidbody2D rigidBody;
|
||||
|
||||
void Awake() {
|
||||
rigidBody = GetComponent<Rigidbody2D> ();
|
||||
|
||||
StartCoroutine (ReverseDirectionAfter (2f));
|
||||
StartCoroutine (DestroySelfAfter (4f));
|
||||
}
|
||||
|
||||
void OnMouseOver() {
|
||||
|
||||
@@ -2,13 +2,23 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class MonsterSpawner : MonoBehaviour {
|
||||
public GameObject monsterPrefab;
|
||||
public GameObject monsterPrefab2;
|
||||
public GameObject monsterPrefab3;
|
||||
public GameObject monsterPrefab4;
|
||||
|
||||
public AudioClip twigOne;
|
||||
public AudioClip twigTwo;
|
||||
public AudioClip twigThree;
|
||||
public AudioClip water;
|
||||
public bool waterSoundOnly = false;
|
||||
|
||||
public Vector2 motion;
|
||||
public float delay;
|
||||
public float lifespan;
|
||||
|
||||
AudioSource audioSource;
|
||||
|
||||
@@ -34,26 +44,53 @@ public class MonsterSpawner : MonoBehaviour {
|
||||
GameObject monster = Instantiate (monsterPrefab);
|
||||
monster.transform.position = transform.position;
|
||||
monster.GetComponent<Rigidbody2D> ().velocity = motion;
|
||||
audioSource.Play ();
|
||||
monster.GetComponent<Monster> ().lifespan = lifespan;
|
||||
PlaySound ();
|
||||
|
||||
//ugly duplication
|
||||
yield return new WaitForSeconds (delay);
|
||||
monster = Instantiate (monsterPrefab2);
|
||||
monster.transform.position = transform.position;
|
||||
monster.GetComponent<Rigidbody2D> ().velocity = motion;
|
||||
audioSource.Play ();
|
||||
monster.GetComponent<Monster> ().lifespan = lifespan;
|
||||
PlaySound ();
|
||||
|
||||
yield return new WaitForSeconds (delay);
|
||||
monster = Instantiate (monsterPrefab3);
|
||||
monster.transform.position = transform.position;
|
||||
monster.GetComponent<Rigidbody2D> ().velocity = motion;
|
||||
audioSource.Play ();
|
||||
monster.GetComponent<Monster> ().lifespan = lifespan;
|
||||
PlaySound ();
|
||||
|
||||
yield return new WaitForSeconds (delay);
|
||||
monster = Instantiate (monsterPrefab4);
|
||||
monster.transform.position = transform.position;
|
||||
monster.GetComponent<Rigidbody2D> ().velocity = motion;
|
||||
audioSource.Play ();
|
||||
monster.GetComponent<Monster> ().lifespan = lifespan;
|
||||
PlaySound ();
|
||||
}
|
||||
}
|
||||
|
||||
void PlaySound() {
|
||||
AudioClip audioClip = new AudioClip();
|
||||
|
||||
if (waterSoundOnly) {
|
||||
audioClip = water;
|
||||
} else {
|
||||
int choice = Random.Range (0, 3);
|
||||
switch(choice) {
|
||||
case 0:
|
||||
audioClip = twigOne;
|
||||
break;
|
||||
case 1:
|
||||
audioClip = twigTwo;
|
||||
break;
|
||||
case 2:
|
||||
audioClip = twigThree;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
audioSource.PlayOneShot (audioClip, 0.3f);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user