public void AppleDestroyed() { //// Destroy all of the falling Apples when one basket has been lost GameObject[] tAppleArray = GameObject.FindGameObjectsWithTag("Apple"); foreach (GameObject tGO in tAppleArray) { Destroy(tGO); } // Get the index of the last Basket in basketList and change it so that next time it only generates two baskets int basketIndex = basketList.Count - 1; // Get a reference to the basket being removes GameObject tBasketGO = basketList[basketIndex]; // Remove the Basket from the List and destroy the dead basket basketList.RemoveAt(basketIndex); Destroy(tBasketGO); // Restart the game if no baskets are remaining if (basketList.Count == 0) { HistoryMethods.addByScore(HistoryMethods.regLog(Basket.score.ToString()), GameData.Prefs.appleHist); //save apple history to server SceneManager.LoadScene("Apple_Splash"); //load splash screen } }
//Game Logic public void cardClicked(int index) { if (firstCard == null && cardsActive && !gameEnded){ //no cards assigned AudioController.speaker.playClip (0); //play click firstCard = cardList [index]; //keep reference to first card firstCard.flipBack (); //reveals the back side of the card } else if (secondCard == null && cardList[index] != firstCard && cardsActive && !gameEnded){ //first card assigned but second not, and card clicked is not first AudioController.speaker.playClip (0); //play click secondCard = cardList [index]; //keep reference to second card secondCard.flipBack(); //show the second card if (firstCard.getValue () == secondCard.getValue()) { //there is a match with firstCard cardsActive = false; cardsLeft -= 2; //Adjust cards left Invoke ("playWin", 0.3f); //give enough time to click Invoke ("yesMatch", 0.6f);//resets the cards } else { //there is not a match with firstCard cardsActive = false; score -= 40; //decrease score Invoke ("playLose", 0.3f); Invoke ("noMatch", 0.6f); } //GameOver Check if (cardsLeft == 0 || score == 0) { gameEnded = true; count = false; //stop = false HistoryMethods.addByScore (HistoryMethods.regLog (score.ToString ()), GameData.Prefs.dinoHist); //save history to server Invoke ("loadEnd", 2f); //invoke the game over screen in 2 seconds } } //end card match check } //end card clicked
//NEW loads the new game over screen void gameOver() { string temp; //Convert game level to string to record in the history switch (gameLevel) { case 0: temp = "Bronze"; break; case 1: temp = "Silver"; break; default: temp = "Gold"; break; } HistoryMethods.addByScore(HistoryMethods.spaceLog(points.ToString(), temp), GameData.Prefs.spaceHist); //save history to server SceneManager.LoadScene("Scene_SpaceGameOver"); }