Пример #1
0
    /// <summary>Instantiates the clicked tower into the game somewhere.</summary>
    private void TowerClicked(GameObject prefab)
    {
        // Return if already purchasing to avoid nasty bugs :P
        if (selectedTowerForPurchase != null || bSelling)
        {
            return;
        }

        AudioHandler.ClickSound();

        GameObject ins = Object.Instantiate(prefab, TowerManager.towersContainer);

        ins.GetComponent <RectTransform>().anchoredPosition = new Vector2(GameManager.CANVAS_WIDTH / 2.0f, GameManager.CANVAS_HEIGHT / -2.0f);
        ins.SetActive(true);
        selectedTowerForPurchase = ins.GetComponent <ITower>();
        selectedCp         = ins.GetComponent <TowerClickPoint>();
        selectedCp.enabled = false;                                                                   // Don't allow clicking for sell while purchasing.
        selectedTd         = selectedTowerForPurchase.GetRangeCircle().AddComponent <TowerDisplay>(); // To allow dragging.
        selectedTd.Initialise();
        selectedTowerForPurchase.ShowRangeCircle(true);
        selectedTowerForPurchase.SetEnabled(false);

        // Show the buy options
        buyOptions.alpha = 1.0f;
        buyOptions.gameObject.SetActive(true);

        label_selectedInfoHeader.text  = selectedTowerForPurchase.MyInfo().towerName;
        label_selectedInfoContent.text = selectedTowerForPurchase.MyInfo().towerDescription;

        bBuying = true;
    }
Пример #2
0
    private void TowerPurchaseConfirm()
    {
        // Return if it's on the path.
        if (!selectedTd.validPosition)
        {
            return;
        }

        AudioHandler.ClickSound();

        //Debug.Log(selectedTowerForPurchase.GetGameobject().name);

        selectedTowerForPurchase.ShowRangeCircle(false);
        selectedTowerForPurchase.SetEnabled(true);
        selectedTowerForPurchase.LockMovement();

        selectedCp.enabled = true;

        // Remove the cost from the health (needs to be down here)
        healthFlag     = true;
        Player.health -= selectedTowerForPurchase.MyInfo().cost;
        healthFlag     = false;

        HideBuyOptions();
    }
Пример #3
0
 /// <summary>Restarts the game</summary>
 public void Fn_RestartGame()
 {
     // Restart the game...
     AudioHandler.ClickSound();
     Debug.Log("Restarting");
     behav.StartCoroutine(RestartCr());
 }
Пример #4
0
    private void TowerSellConfirm()
    {
        AudioHandler.ClickSound();

        // Sell the selected tower.
        Player.health += selectedTowerForSell.SellPrice();
        GameObject.Destroy(selectedTowerForSell.GetGameobject());

        HideSellOptions();
    }
Пример #5
0
    /// <summary>Show the pause menu</summary>
    private void Fn_PauseMenu()
    {
        AudioHandler.ClickSound();
        pauseMenuShowing = true;

        if (crPause != null)
        {
            behav.StopCoroutine(crPause);
        }
        crPause = behav.StartCoroutine(PauseMenuCr(true));
    }
Пример #6
0
 private void TowerSellCancel()
 {
     AudioHandler.ClickSound();
     HideSellOptions();
 }
Пример #7
0
 private void TowerPurchaseCancel()
 {
     AudioHandler.ClickSound();
     GameObject.Destroy(selectedTowerForPurchase.GetGameobject());
     HideBuyOptions();
 }
Пример #8
0
 /// <summary>To be run from </summary>
 public void Fn_QuitGame()
 {
     AudioHandler.ClickSound();
     Debug.Log("Quitting");
     Application.Quit();
 }