Some stuff
This commit is contained in:
@@ -24,6 +24,11 @@ public class GameController : MonoBehaviour {
|
||||
SceneManager.LoadScene ("gameover");
|
||||
}
|
||||
|
||||
//track this
|
||||
if (Input.GetMouseButtonDown(0)) {
|
||||
PersistentData.clicks++;
|
||||
}
|
||||
|
||||
//update the texts
|
||||
timerText.text = "Time Remaining: " + PersistentData.timer;
|
||||
scoreText.text = "Score: " + PersistentData.score;
|
||||
|
||||
@@ -6,13 +6,17 @@ using UnityEngine.SceneManagement;
|
||||
|
||||
public class GameOverController : MonoBehaviour {
|
||||
public Text scoreText;
|
||||
Dictionary<string, Sprite> spriteSet;
|
||||
public Text creditText;
|
||||
public Text clickText;
|
||||
public GameObject background;
|
||||
|
||||
GameObject leftPage;
|
||||
GameObject rightPage;
|
||||
Dictionary<string, GameObject> objectSet;
|
||||
|
||||
bool open = false;
|
||||
int page = -1;
|
||||
|
||||
void Awake() {
|
||||
spriteSet = new Dictionary<string, Sprite> ();
|
||||
objectSet = new Dictionary<string, GameObject> ();
|
||||
|
||||
//prune "(clone)" from each monster name
|
||||
HashSet<string> hs = new HashSet<string> ();
|
||||
@@ -22,37 +26,66 @@ public class GameOverController : MonoBehaviour {
|
||||
PersistentData.monsterNames = hs;
|
||||
|
||||
//load each image
|
||||
float posX = 15f;
|
||||
foreach(string str in PersistentData.monsterNames) {
|
||||
Sprite spr = Resources.Load ("photos/" + str, typeof(Sprite)) as Sprite;
|
||||
spriteSet.Add (str, spr);
|
||||
GameObject obj = new GameObject ();
|
||||
obj.AddComponent<SpriteRenderer> ();
|
||||
obj.GetComponent<SpriteRenderer> ().sprite = spr;
|
||||
obj.transform.localScale = new Vector3 (0.5f, 0.5f, 1f);
|
||||
obj.transform.position = new Vector3 (posX, 0, 0);
|
||||
objectSet.Add (str, obj);
|
||||
|
||||
//increment
|
||||
posX += 10f; //NOTE: code duplication
|
||||
}
|
||||
|
||||
//configure the page objects
|
||||
leftPage = new GameObject ();
|
||||
rightPage = new GameObject ();
|
||||
leftPage.AddComponent<SpriteRenderer> ();
|
||||
rightPage.AddComponent<SpriteRenderer> ();
|
||||
|
||||
leftPage.transform.localScale = new Vector3 (0.5f, 0.5f, 1f);
|
||||
leftPage.transform.position = new Vector3 (-5f, 0, 0);
|
||||
rightPage.transform.localScale = new Vector3 (0.5f, 0.5f, 1f);
|
||||
rightPage.transform.position = new Vector3 (5f, 0, 0);
|
||||
|
||||
//test
|
||||
leftPage.GetComponent<SpriteRenderer> ().sprite = spriteSet["Nessie"] as Sprite;
|
||||
rightPage.GetComponent<SpriteRenderer> ().sprite = spriteSet["Nessie"] as Sprite;
|
||||
}
|
||||
|
||||
void Update() {
|
||||
//get the x & y of the mouse as a ratio
|
||||
float mouseX = Input.mousePosition.x / Screen.width;
|
||||
float mouseY = Input.mousePosition.y / Screen.height;
|
||||
|
||||
if (Input.GetButtonDown ("Quit")) {
|
||||
Application.Quit ();
|
||||
}
|
||||
|
||||
if (Input.GetMouseButtonDown(0)) {
|
||||
SceneManager.LoadScene ("gameplay");
|
||||
if (mouseX < 0.5f && page > 0) {
|
||||
JumpRight ();
|
||||
page--;
|
||||
}
|
||||
if (mouseX >= 0.5f && page < (objectSet.Count -1)/2) {
|
||||
if (open == false) {
|
||||
open = true;
|
||||
//TODO: animate the background
|
||||
}
|
||||
JumpLeft ();
|
||||
page++;
|
||||
}
|
||||
}
|
||||
|
||||
//update the texts
|
||||
scoreText.text = "Score: " + PersistentData.score;
|
||||
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";
|
||||
} else {
|
||||
scoreText.enabled = false;
|
||||
creditText.enabled = false;
|
||||
clickText.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
void JumpLeft() {
|
||||
foreach(KeyValuePair<string, GameObject> pair in objectSet) {
|
||||
pair.Value.transform.position = new Vector3 (pair.Value.transform.position.x - 20f, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void JumpRight() {
|
||||
foreach(KeyValuePair<string, GameObject> pair in objectSet) {
|
||||
pair.Value.transform.position = new Vector3 (pair.Value.transform.position.x + 20f, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
public static class PersistentData {
|
||||
public static int timer;
|
||||
public static int score;
|
||||
public static int clicks;
|
||||
|
||||
public static HashSet<string> monsterNames = new HashSet<string>();
|
||||
}
|
||||
Reference in New Issue
Block a user