private void UpgradeUnits(string title, int level)
    {
        AnimaText animaText = new AnimaText();

        for (int i = 0; i < Bench.SIZE; i++)
        {
            if (Bench.occupied[i])
            {
                if (Bench.units[i].title == title && Bench.units[i].level < level)
                {
                    Bench bench = new Bench();
                    bench.Destroy(i);
                    animaText.ShowText(Bench.benches[i], "Upgraded", Color.green);
                }
            }
        }
        for (int i = 0; i < Formation.SIZE; i++)
        {
            if (Formation.occupied[i])
            {
                if (Formation.units[i].title == title && Formation.units[i].level < level)
                {
                    Formation formation = new Formation();
                    formation.Destroy(i);
                    animaText.ShowText(Formation.formations[i], "Upgraded", Color.green);
                }
            }
        }
    }
    public void BenchClicked(int i)
    {
        Formation formation  = new Formation();
        int       iFormation = Formation.iFormation;

        if (iFormation < Formation.SIZE)
        {
            if (!occupied[i])
            {
                AddUnit(Formation.units[iFormation], i);
                formation.Destroy(iFormation);
            }
            else
            {
                Unit temp = units[i];
                AddUnit(Formation.units[iFormation], i);
                formation.AddUnit(temp, iFormation);
            }
        }

        else if (iBench == SIZE && !occupied[i])
        {
            iBench = SIZE;
        }
        else if (iBench == SIZE)
        {
            iBench = i;
            Info info = new Info();
            info.ShowUnit(units[i]);
        }
        else
        {
            if (iBench != i)
            {
                if (!occupied[i])
                {
                    AddUnit(units[iBench], i);
                    Destroy(iBench);
                }
                else
                {
                    Unit temp = units[i];
                    AddUnit(units[iBench], i);
                    AddUnit(temp, iBench);
                }
            }
            iBench = SIZE;
        }
        Formation.iFormation = Formation.SIZE;
    }
Beispiel #3
0
    public void SellClicked()
    {
        Money money = new Money();

        if (Bench.iBench < Bench.SIZE)
        {
            money.UseGold(-Bench.units[Bench.iBench].cost);
            Bench bench = new Bench();
            bench.Destroy(Bench.iBench);
            Bench.iBench = Bench.SIZE;
        }
        else if (Formation.iFormation < Formation.SIZE)
        {
            money.UseGold(-Formation.units[Formation.iFormation].cost);
            Formation formation = new Formation();
            formation.Destroy(Formation.iFormation);
            Formation.iFormation = Formation.SIZE;
        }
        else
        {
            Info.infos[0].GetComponentInChildren <Text>().text = "Select a unit.\nThen click 'Sell Unit' to refund all gold used on that unit.";
        }
    }