コード例 #1
0
    public void ActiveUI()
    {
        if (ActiveTower == null)
        {
            Arrow.SetActive(true);
            Rock.SetActive(true);
            Mage.SetActive(true);
            Defese.SetActive(true);

            TileButton tb = Arrow.GetComponent <TileButton>();
            if (tb.canBuy())
            {
                tb.SetGrey = false;
            }
            else
            {
                tb.SetGrey = true;
            }

            tb = Rock.GetComponent <TileButton>();
            if (tb.canBuy())
            {
                tb.SetGrey = false;
            }
            else
            {
                tb.SetGrey = true;
            }

            tb = Mage.GetComponent <TileButton>();
            if (tb.canBuy())
            {
                tb.SetGrey = false;
            }
            else
            {
                tb.SetGrey = true;
            }

            tb = Defese.GetComponent <TileButton>();
            if (tb.canBuy())
            {
                tb.SetGrey = false;
            }
            else
            {
                tb.SetGrey = true;
            }
        }
        else
        {
            upgrade.SetActive(true);
            sell.SetActive(true);

            TowerUpgrade tu = ActiveTower.GetComponent <TowerUpgrade>();
            if (tu.CanUpgrade && resource.Money >= tu.Cost)
            {
                upgrade.GetComponent <TileButton>().SetGrey = false;
            }
            else
            {
                upgrade.GetComponent <TileButton>().SetGrey = true;
            }
        }
    }
コード例 #2
0
    public void ActiveUI()
    {
        if (ActiveTower == null)
        {
            Acid.SetActive(true);
            Espermicide.SetActive(true);
            Condom.SetActive(true);
            DIU.SetActive(true);

            TileButton tb = Acid.GetComponent <TileButton>();
            if (tb.canBuy())
            {
                tb.SetGrey = false;
            }
            else
            {
                tb.SetGrey = true;
            }

            tb = Espermicide.GetComponent <TileButton>();
            if (tb.canBuy())
            {
                tb.SetGrey = false;
            }
            else
            {
                tb.SetGrey = true;
            }

            tb = Condom.GetComponent <TileButton>();
            if (tb.canBuy())
            {
                tb.SetGrey = false;
            }
            else
            {
                tb.SetGrey = true;
            }

            tb = DIU.GetComponent <TileButton>();
            if (tb.canBuy())
            {
                tb.SetGrey = false;
            }
            else
            {
                tb.SetGrey = true;
            }
        }
        else
        {
            upgrade.SetActive(true);
            sell.SetActive(true);

            TowerUpgrade tu = ActiveTower.GetComponent <TowerUpgrade>();
            if (tu.CanUpgrade && resource.Money >= tu.Cost)
            {
                upgrade.GetComponent <TileButton>().SetGrey = false;
            }
            else
            {
                upgrade.GetComponent <TileButton>().SetGrey = true;
            }
        }
    }