This commit is contained in:
2018-04-12 17:14:52 +10:00
parent 2c823744f9
commit b2743d59b5
32 changed files with 1202 additions and 10 deletions
+21 -6
View File
@@ -26,19 +26,22 @@ public class GameOverController : MonoBehaviour {
PersistentData.monsterNames = hs;
//load each image
float posX = 15f;
float posX = 12.1f;
foreach(string str in PersistentData.monsterNames) {
Sprite spr = Resources.Load ("photos/" + str, typeof(Sprite)) as Sprite;
GameObject obj = new GameObject ();
obj.AddComponent<SpriteRenderer> ();
obj.GetComponent<SpriteRenderer> ().sprite = spr;
obj.transform.localScale = new Vector3 (0.5f, 0.5f, 1f);
obj.transform.localScale = new Vector3 (0.3f, 0.3f, 1f);
obj.transform.position = new Vector3 (posX, 0, 0);
objectSet.Add (str, obj);
//increment
posX += 10f; //NOTE: code duplication
posX += 8.05f; //NOTE: code duplication
}
//pause the background animation
background.GetComponent<Animator>().speed = 0;
}
void Update() {
@@ -59,6 +62,11 @@ public class GameOverController : MonoBehaviour {
if (open == false) {
open = true;
//TODO: animate the background
background.GetComponent<Animator>().speed = 1;
StartCoroutine (OpeningCoroutine ());
return;
}
JumpLeft ();
page++;
@@ -69,7 +77,7 @@ public class GameOverController : MonoBehaviour {
if (open == false) {
scoreText.text = "Player's Score: " + PersistentData.score + "\n";
scoreText.text += "Camera Clicks: " + PersistentData.clicks + "\n";
scoreText.text += "Monsters Captured: " + PersistentData.monsterNames.Count + "/10";
scoreText.text += "Monsters Captured: " + PersistentData.monsterNames.Count + "/4";
} else {
scoreText.enabled = false;
creditText.enabled = false;
@@ -77,15 +85,22 @@ public class GameOverController : MonoBehaviour {
}
}
IEnumerator OpeningCoroutine() {
yield return new WaitForSeconds (0.75f);
background.GetComponent<Animator> ().speed = 0;
JumpLeft ();
page++;
}
void JumpLeft() {
foreach(KeyValuePair<string, GameObject> pair in objectSet) {
pair.Value.transform.position = new Vector3 (pair.Value.transform.position.x - 20f, 0, 0);
pair.Value.transform.position = new Vector3 (pair.Value.transform.position.x - 16.1f, 0.5f, 0);
}
}
void JumpRight() {
foreach(KeyValuePair<string, GameObject> pair in objectSet) {
pair.Value.transform.position = new Vector3 (pair.Value.transform.position.x + 20f, 0, 0);
pair.Value.transform.position = new Vector3 (pair.Value.transform.position.x + 16.1f, 0.5f, 0);
}
}
}
+32
View File
@@ -4,6 +4,9 @@ using UnityEngine;
public class MonsterSpawner : MonoBehaviour {
public GameObject monsterPrefab;
public GameObject monsterPrefab2;
public GameObject monsterPrefab3;
public GameObject monsterPrefab4;
public Vector2 motion;
public float delay;
@@ -12,6 +15,16 @@ public class MonsterSpawner : MonoBehaviour {
void Awake() {
audioSource = GetComponent<AudioSource> ();
if (monsterPrefab2 == null) {
monsterPrefab2 = monsterPrefab;
}
if (monsterPrefab3 == null) {
monsterPrefab3 = monsterPrefab;
}
if (monsterPrefab4 == null) {
monsterPrefab4 = monsterPrefab;
}
StartCoroutine (SpawnMonster ());
}
@@ -22,6 +35,25 @@ public class MonsterSpawner : MonoBehaviour {
monster.transform.position = transform.position;
monster.GetComponent<Rigidbody2D> ().velocity = motion;
audioSource.Play ();
//ugly duplication
yield return new WaitForSeconds (delay);
monster = Instantiate (monsterPrefab2);
monster.transform.position = transform.position;
monster.GetComponent<Rigidbody2D> ().velocity = motion;
audioSource.Play ();
yield return new WaitForSeconds (delay);
monster = Instantiate (monsterPrefab3);
monster.transform.position = transform.position;
monster.GetComponent<Rigidbody2D> ().velocity = motion;
audioSource.Play ();
yield return new WaitForSeconds (delay);
monster = Instantiate (monsterPrefab4);
monster.transform.position = transform.position;
monster.GetComponent<Rigidbody2D> ().velocity = motion;
audioSource.Play ();
}
}
}