示例#1
0
 // Method for when the buy button on the customise screen is pressed
 public void BuyButton()
 {
     // If player has enough gold, minus the gold and update car data and text data
     if (MainMenuScirpt.gold >= carsDetailsArray[currentCarPosition].price)
     {
         MainMenuScirpt.SetGold(MainMenuScirpt.GetGold() - carsDetailsArray[currentCarPosition].price);
         carsDetailsArray[currentCarPosition].unlocked = true;
         UpdateCarData();
         UpdateText();
     }
 }
示例#2
0
    // Method called when the game is over
    public void EndGameScreenDisplay()
    {
        FadeCameraToBlack();

        Vector3 oldPosition = LevelScoreText.GetComponent <RectTransform>().localPosition;
        Vector3 newPosition = new Vector3(oldPosition.x, 90, oldPosition.z);

        LevelScoreText.GetComponent <RectTransform>().localPosition = Vector3.Lerp(oldPosition, newPosition, 2);

        // Show end canvas and stop generation
        endGameCanvas.SetActive(true);

        // Set end score and end gold text
        endScoreText.text = Mathf.RoundToInt(levelScore).ToString();
        endGoldText.text  = Mathf.RoundToInt(levelScore).ToString();

        // Add gold to players playerprefs
        MainMenuScirpt.SetGold(MainMenuScirpt.GetGold() + Mathf.RoundToInt(levelScore));

        // Set game to end and levelscore text to empty
        gameEnded = true;
    }