public MainPage() { this.InitializeComponent(); wyswietlacz = new DigitDisplay(4); int[] modulesArg = new int[] { 04, 17, 27, 22 }; //pins GPIO from RPI for modules int[] segmenstArg = new int[] { 20, 16, 21, 05, 06, 13, 19, 26 }; //pins GPIO from RPI for segments wyswietlacz.Setup(modulesArg, segmenstArg, 50); }
private GameObject myDigit2; // For displaying CurrentScore // Use this for initialization void Start() { myDigit1 = (GameObject)Instantiate(digit, new Vector3(6.2f, 5.35f, -0.1f), Quaternion.identity); DigitDisplay myScript1 = myDigit1.transform.GetComponent <DigitDisplay>(); // Get the instance of class of DigitDisplay.cs for HighScore // PlayerPrefs : Stores and accesses player preferences between game sessions, similar to SharedPreferences in Android if (PlayerPrefs.HasKey("HighScore")) { myScript1.myStringScore = PlayerPrefs.GetInt("HighScore").ToString(); } else { myScript1.myStringScore = ""; } myDigit2 = (GameObject)Instantiate(digit, new Vector3(6.2f, 4.85f, -0.1f), Quaternion.identity); }
// Update is called once per frame void Update() { DigitDisplay myScript2 = myDigit2.transform.GetComponent <DigitDisplay>(); // Get the instance of class of DigitDisplay.cs for CurrentScore if (myScore == 0) // Current score { myScript2.myStringScore = ""; } else { myScript2.myStringScore = myScore.ToString(); } GameObject pigObject = GameObject.FindWithTag("pig"); // Try to find if there are still any pigs if (pigObject == null) // Pigs have all been defeated, we win { GameObject bird0Object = GameObject.FindWithTag("bird0"); // Try to find if there is still bird0 left (not used) GameObject bird2Object = GameObject.FindWithTag("bird1"); // Try to find if there is still bird2 left (not used) if (bird0Object != null) { if (myDisplayBird0 == null && indexBird0 == 1) { ScoreController.myScore += 10000; // My CurrentScore should be added with 10000 myDisplayBird0 = (GameObject)Instantiate(digit10000, bird0Object.transform.position, Quaternion.identity); // Display the 10000 points Destroy(myDisplayBird0, 1); // Display for one second indexBird0++; // Only display once } } if (bird2Object != null) { if (myDisplayBird2 == null && indexBird2 == 1) { ScoreController.myScore += 10000; // My CurrentScore should be added with 10000 myDisplayBird2 = (GameObject)Instantiate(digit10000, bird2Object.transform.position, Quaternion.identity); // Display the 10000 points Destroy(myDisplayBird2, 1); // Display for one second indexBird2++; // Only display once } } if (PlayerPrefs.GetInt("HighScore") < myScore) // If my score is better the HighScore { PlayerPrefs.SetInt("HighScore", myScore); PlayerPrefs.Save(); } StartCoroutine(PlaySound(gameCompleted)); StartCoroutine(WaitForTimes(2)); showPassWindow = true; // Show the wining window //PlayerPrefs.DeleteKey("HighScore"); } else if (TraceLine.birdsAllUsed) // Birds have all been used up, but there are still pigs, we lose { StartCoroutine(PlaySound(gameFailed)); StartCoroutine(WaitForTimes(2)); showFailWindow = true; // Show the losing window } }
void Start() { UICanvas.SetActive(false); digitDisplay = GameObject.Find("DigitDisplay").GetComponent <DigitDisplay>(); StartCoroutine(UpdateCoroutine()); }