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 FormationClicked(int i)
    {
        Bench bench  = new Bench();
        int   iBench = Bench.iBench;

        if (iBench < Bench.SIZE)
        {
            if (!occupied[i])
            {
                AddUnit(Bench.units[iBench], i);
                bench.Destroy(iBench);
            }
            else
            {
                Unit temp = units[i];
                AddUnit(Bench.units[iBench], i);
                bench.AddUnit(temp, iBench);
            }
        }

        else if (iFormation == SIZE && !occupied[i])
        {
            iFormation = SIZE;
        }
        else if (iFormation == SIZE)
        {
            iFormation = i;
            Info info = new Info();
            info.ShowUnit(units[i]);
        }
        else
        {
            if (iFormation != i)
            {
                if (occupied[iFormation] || occupied[i])
                {
                    if (!occupied[iFormation])
                    {
                        AddUnit(units[i], iFormation);
                        Destroy(i);
                    }
                    else if (!occupied[i])
                    {
                        AddUnit(units[iFormation], i);
                        Destroy(iFormation);
                    }
                    else
                    {
                        Unit temp = units[i];
                        AddUnit(units[iFormation], i);
                        AddUnit(temp, iFormation);
                    }
                }
            }
            iFormation = SIZE;
        }
        Bench.iBench = Bench.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.";
        }
    }