Making some changes for v1.1

This commit is contained in:
2018-04-13 08:16:14 +10:00
parent f6ba424f08
commit 57d4683df8
17 changed files with 276 additions and 16 deletions
+1
View File
@@ -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++;
+7 -3
View File
@@ -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() {
+41 -4
View File
@@ -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);
}
}