示例#1
0
    void Build()
    {
        GhostBuilding gb = currentObject.GetComponent <GhostBuilding>();

        if (!gb.IsTriggered() && Input.GetMouseButtonDown(0))
        {
            if (currentObject == wallGhost)
            {
                if (goldPile.getGold() > wallCost)
                {
                    goldPile.deductGold(wallCost);
                    GameObject wall = (GameObject)Instantiate(wallGhostPrefab, currentObject.transform.position, currentObject.transform.rotation);
                }
                else
                {
                    // NOT ENOUGH MINERALS
                    Debug.Log("NOT ENOUGH MINERALS: " + goldPile.getGold() + ", Need: " + (wallCost + 1));
                }
            }
            else if (currentObject == gateGhost)
            {
                if (goldPile.getGold() > gateCost)
                {
                    goldPile.deductGold(gateCost);
                    GameObject gate = (GameObject)Instantiate(gateGhostPrefab, currentObject.transform.position, currentObject.transform.rotation);
                }
                else
                {
                    // NOT ENOUGH MINERALS
                    Debug.Log("NOT ENOUGH MINERALS: " + goldPile.getGold() + ", Need: " + (gateCost + 1));
                }
            }
            else if (currentObject == towerGhost)
            {
                if (goldPile.getGold() > towerCost)
                {
                    goldPile.deductGold(towerCost);
                    GameObject tower = (GameObject)Instantiate(towerGhostPrefab, currentObject.transform.position, currentObject.transform.rotation);
                }
                else
                {
                    // NOT ENOUGH MINERALS
                    Debug.Log("NOT ENOUGH MINERALS: " + goldPile.getGold() + ", Need: " + (towerCost + 1));
                }
            }
            else if (currentObject == barracksGhost)
            {
                if (goldPile.getGold() > barracksCost)
                {
                    goldPile.deductGold(barracksCost);
                    GameObject barracks = (GameObject)Instantiate(barracksGhostPrefab, currentObject.transform.position, currentObject.transform.rotation);
                }
                else
                {
                    // NOT ENOUGH MINERALS
                    Debug.Log("NOT ENOUGH MINERALS: " + goldPile.getGold() + ", Need: " + (barracksCost + 1));
                }
            }
        }
    }
示例#2
0
 // Update is called once per frame
 void Update()
 {
     if (goldPile)
     {
         if (goldPile.getGold() == 0 && !END)
         {
             GameOver();
         }
     }
 }