예제 #1
0
    private void Update()
    {
        if (IsPlayerDead())
        {
            GameOver(false);
        }

        if (Input.GetKey("escape"))     //activates the pause menu and stops time
        {
            Time.timeScale = 0;
            pauseScreen.SetActive(true);
        }

        if (Input.GetMouseButtonDown(1))    //deselects the tower if rmb is pressed
        {
            TradeTower.setActiveTower(null);

            GameObject[] selectionBoxes = Resources.FindObjectsOfTypeAll <GameObject>();

            for (int i = 0; i < selectionBoxes.Length; i++)
            {
                if (selectionBoxes[i].CompareTag("SelectionBox"))
                {
                    selectionBoxes[i].SetActive(false);
                }
            }
        }

        if (killCounter.value >= numberNeededToWin)
        {
            GameOver(true);
        }
    }
예제 #2
0
    void OnMouseDown()           //if a tower is clicked, it will be set as the active tower and can be sold/upgraded
    {
        TradeTower.setActiveTower(this);
        GameObject[] selectionBoxes = Resources.FindObjectsOfTypeAll <GameObject>();

        for (int i = 0; i < selectionBoxes.Length; i++)
        {
            if (selectionBoxes[i].CompareTag("SelectionBox") && selectionBoxes[i].transform.IsChildOf(transform))
            {
                selectionBoxes[i].SetActive(true);
            }
            else if (selectionBoxes[i].CompareTag("SelectionBox"))
            {
                selectionBoxes[i].SetActive(false);
            }
        }
    }