Beispiel #1
0
 void Awake()
 {
     DontDestroyOnLoad(this);
     joystick     = GameObject.FindGameObjectWithTag("GameController").GetComponent <VirtualJoystick> ();
     mouseControl = GameObject.FindGameObjectWithTag("MouseArea").GetComponent <MouseController> ();
     fire         = GameObject.FindGameObjectWithTag("FireButton").GetComponent <UIbuttons> ();
     reload       = GameManagers.Instance.ReloadButton;
 }
Beispiel #2
0
    private void Update()
    {
        if (!gameOver)
        {
            //counterText.text = ((int)(10 * Time.timeSinceLevelLoad)).ToString();
            //score = (int)(10 * Time.timeSinceLevelLoad);
            gameTimer += Time.deltaTime;

            score = (int)(10 * gameTimer);
        }
        counterText.text          = ((int)(10 * gameTimer)).ToString();
        candiesCollectedText.text = candiesCollected.ToString();
        leftCollectedText.text    = leftCollected.ToString();
        rightCollectedText.text   = rightCollected.ToString();

        if (gameOver)
        {
            if (continueScreenOn)
            {
                if (PlayerPrefs.GetFloat("Highscore") < score)
                {
                    PlayerPrefs.SetFloat("Highscore", score);
                }
                if (PlayerPrefs.HasKey("TotalCandies"))
                {
                    totalCandies = PlayerPrefs.GetInt("TotalCandies");
                }
                totalCandies = totalCandies + candiesCollected;
                PlayerPrefs.SetInt("TotalCandies", totalCandies);
                //candiesCollected = 0;
                StartCoroutine(LoadContinueScreen());
                continueScreenOn = false; // I set it to false because I need this to run only once
            }
            //Destroy(levelUpAnim);
        }

        Tutorial();

        Levels();

        powerUps();

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            UIbuttons button = GameObject.Find("Canvas").GetComponent <UIbuttons>();
            button.MainMenuButton();
        }
    }