示例#1
0
    private void UpdateNavyTable()
    {
        App          app          = UnityEngine.Object.FindObjectOfType <App>();
        Nation       player       = State.getNations()[app.GetHumanIndex()];
        MilitaryForm militaryForm = player.GetMilitaryForm();

        Text frigateAttack = navyTable.Rows[1].Cells[1].GetComponentInChildren <Text>();

        Debug.Log("frigate attack " + militaryForm.frigate.Attack.ToString());
        frigateAttack.text = militaryForm.frigate.Attack.ToString();
        Text ironcladAttack = navyTable.Rows[1].Cells[2].GetComponentInChildren <Text>();

        ironcladAttack.text = militaryForm.ironclad.Attack.ToString();
        Text dreadnoughtAttack = navyTable.Rows[1].Cells[3].GetComponentInChildren <Text>();

        dreadnoughtAttack.text = militaryForm.dreadnought.Attack.ToString();

        Text frigateMaxStrength = navyTable.Rows[2].Cells[1].GetComponentInChildren <Text>();

        frigateMaxStrength.text = militaryForm.frigate.GetStrength().ToString();
        Text ironcladMaxStrength = navyTable.Rows[2].Cells[2].GetComponentInChildren <Text>();

        ironcladMaxStrength.text = militaryForm.ironclad.GetStrength().ToString();
        Text dreadnoughtMaxStrength = navyTable.Rows[2].Cells[3].GetComponentInChildren <Text>();

        dreadnoughtMaxStrength.text = militaryForm.dreadnought.GetStrength().ToString();

        Text frigateMan = navyTable.Rows[3].Cells[1].GetComponentInChildren <Text>();

        frigateMan.text = militaryForm.frigate.Maneuver.ToString();
        Text ironcladMan = navyTable.Rows[3].Cells[2].GetComponentInChildren <Text>();

        ironcladMan.text = militaryForm.ironclad.Maneuver.ToString();
        Text dreadnoughtMan = navyTable.Rows[3].Cells[3].GetComponentInChildren <Text>();

        dreadnoughtMan.text = militaryForm.dreadnought.Maneuver.ToString();

        Text frigateAmmo = navyTable.Rows[4].Cells[1].GetComponentInChildren <Text>();

        frigateAmmo.text = militaryForm.frigate.AmmoUse.ToString();
        Text ironcladAmmo = navyTable.Rows[4].Cells[2].GetComponentInChildren <Text>();

        ironcladAmmo.text = militaryForm.ironclad.AmmoUse.ToString();
        Text dreadnoughtAmmo = navyTable.Rows[4].Cells[3].GetComponentInChildren <Text>();

        dreadnoughtAmmo.text = militaryForm.dreadnought.AmmoUse.ToString();

        Text frigateOil = navyTable.Rows[5].Cells[1].GetComponentInChildren <Text>();

        frigateOil.text = militaryForm.frigate.OilUse.ToString();
        Text ironcladOil = navyTable.Rows[5].Cells[2].GetComponentInChildren <Text>();

        ironcladOil.text = militaryForm.ironclad.OilUse.ToString();
        Text dreadnoughtOil = navyTable.Rows[5].Cells[3].GetComponentInChildren <Text>();

        dreadnoughtOil.text = militaryForm.dreadnought.OilUse.ToString();

        Text frigateCap = navyTable.Rows[6].Cells[1].GetComponentInChildren <Text>();

        frigateCap.text = militaryForm.frigate.Capacity.ToString();
        Text ironcladCap = navyTable.Rows[6].Cells[2].GetComponentInChildren <Text>();

        ironcladCap.text = militaryForm.ironclad.Capacity.ToString();
        Text dreadnoughtCap = navyTable.Rows[6].Cells[3].GetComponentInChildren <Text>();

        dreadnoughtCap.text = militaryForm.dreadnought.Capacity.ToString();

        Text frigateMov = navyTable.Rows[7].Cells[1].GetComponentInChildren <Text>();

        frigateMov.text = militaryForm.frigate.Movement.ToString();
        Text ironcladMov = navyTable.Rows[7].Cells[2].GetComponentInChildren <Text>();

        ironcladMov.text = militaryForm.ironclad.Movement.ToString();
        Text dreadnoughtMov = navyTable.Rows[7].Cells[3].GetComponentInChildren <Text>();

        dreadnoughtMov.text = militaryForm.dreadnought.Movement.ToString();

        Text NumFrig = navyTable.Rows[9].Cells[1].GetComponentInChildren <Text>();
        Text NumIC   = navyTable.Rows[9].Cells[2].GetComponentInChildren <Text>();
        Text NumDN   = navyTable.Rows[9].Cells[3].GetComponentInChildren <Text>();

        float frigCount = 0;
        float ICCount   = 0;
        float DNCount   = 0;

        for (int i = 0; i < player.GetFleets().Count; i++)
        {
            frigCount += player.GetFleet(i).GetFrigate();
            ICCount   += player.GetFleet(i).GetIronClad();
            DNCount   += player.GetFleet(i).GetDreadnought();
        }
        NumFrig.text = frigCount.ToString();
        NumIC.text   = ICCount.ToString();
        NumDN.text   = DNCount.ToString();

        Text recFrig = navyTable.Rows[10].Cells[1].GetComponentInChildren <Text>();
        Text recIC   = navyTable.Rows[10].Cells[2].GetComponentInChildren <Text>();
        Text recDN   = navyTable.Rows[10].Cells[3].GetComponentInChildren <Text>();

        recFrig.text = player.getNavyProducing(MyEnum.NavyUnits.frigates).ToString();
        recIC.text   = player.getNavyProducing(MyEnum.NavyUnits.ironclad).ToString();
        recDN.text   = player.getNavyProducing(MyEnum.NavyUnits.dreadnought).ToString();

        Button recruitFrigateButton = navyTable.Rows[11].Cells[1].GetComponentInChildren <Button>();

        if (PlayerCalculator.canBuildFrigate(player))
        {
            recruitFrigateButton.interactable = true;
        }
        else
        {
            recruitFrigateButton.interactable = false;
        }

        Button recruitIroncladButton = navyTable.Rows[11].Cells[2].GetComponentInChildren <Button>();

        if (PlayerCalculator.canBuildIronclad(player))
        {
            recruitIroncladButton.interactable = true;
        }
        else
        {
            recruitIroncladButton.interactable = false;
        }

        Button recruitDreadnoughtButton = navyTable.Rows[11].Cells[3].GetComponentInChildren <Button>();

        if (PlayerCalculator.canBuildDreadnought(player))
        {
            recruitDreadnoughtButton.interactable = true;
        }
        else
        {
            upgradeShipyard.interactable = false;
        }

        TextMeshProUGUI _shipyardLevel = shipyardLevel.GetComponent <TextMeshProUGUI>();

        _shipyardLevel.SetText("Shipyard Level: " + player.GetShipyardLevel().ToString());
        if (PlayerCalculator.canUpgradeShipyard(player) == true)
        {
            upgradeShipyard.interactable = true;
        }
        else
        {
            upgradeShipyard.interactable = false;
        }
    }
示例#2
0
    private void UpdateNavyTable()
    {
        App       app       = UnityEngine.Object.FindObjectOfType <App>();
        Nation    player    = State.getNations()[app.GetHumanIndex()];
        SeaForces seaForces = player.seaForces;

        Text frigateAttack = navyTable.Rows[1].Cells[1].GetComponentInChildren <Text>();

        Debug.Log("frigate attack " + seaForces.frigate.Attack.ToString());
        frigateAttack.text = seaForces.frigate.Attack.ToString();
        Text ironcladAttack = navyTable.Rows[1].Cells[2].GetComponentInChildren <Text>();

        ironcladAttack.text = seaForces.ironclad.Attack.ToString();
        Text dreadnoughtAttack = navyTable.Rows[1].Cells[3].GetComponentInChildren <Text>();

        dreadnoughtAttack.text = seaForces.dreadnought.Attack.ToString();

        Text frigateMaxStrength = navyTable.Rows[2].Cells[1].GetComponentInChildren <Text>();

        frigateMaxStrength.text = seaForces.frigate.HitPoints.ToString();
        Text ironcladMaxStrength = navyTable.Rows[2].Cells[2].GetComponentInChildren <Text>();

        ironcladMaxStrength.text = seaForces.ironclad.HitPoints.ToString();
        Text dreadnoughtMaxStrength = navyTable.Rows[2].Cells[3].GetComponentInChildren <Text>();

        dreadnoughtMaxStrength.text = seaForces.dreadnought.HitPoints.ToString();

        Text frigateMan = navyTable.Rows[3].Cells[1].GetComponentInChildren <Text>();

        frigateMan.text = seaForces.frigate.Capacity.ToString();
        Text ironcladMan = navyTable.Rows[3].Cells[2].GetComponentInChildren <Text>();

        ironcladMan.text = seaForces.ironclad.Capacity.ToString();
        Text dreadnoughtMan = navyTable.Rows[3].Cells[3].GetComponentInChildren <Text>();

        dreadnoughtMan.text = seaForces.dreadnought.Capacity.ToString();

        Text frigateAmmo = navyTable.Rows[4].Cells[1].GetComponentInChildren <Text>();

        frigateAmmo.text = seaForces.frigate.Colonial.ToString();
        Text ironcladAmmo = navyTable.Rows[4].Cells[2].GetComponentInChildren <Text>();

        ironcladAmmo.text = seaForces.ironclad.Colonial.ToString();
        Text dreadnoughtAmmo = navyTable.Rows[4].Cells[3].GetComponentInChildren <Text>();

        dreadnoughtAmmo.text = seaForces.dreadnought.Colonial.ToString();

        Text NumFrig = navyTable.Rows[6].Cells[1].GetComponentInChildren <Text>();
        Text NumIC   = navyTable.Rows[6].Cells[2].GetComponentInChildren <Text>();
        Text NumDN   = navyTable.Rows[6].Cells[3].GetComponentInChildren <Text>();


        NumFrig.text = player.seaForces.frigate.getNumber().ToString();
        NumIC.text   = player.seaForces.ironclad.getNumber().ToString();
        NumDN.text   = player.seaForces.dreadnought.getNumber().ToString();

        Text recFrig = navyTable.Rows[7].Cells[1].GetComponentInChildren <Text>();
        Text recIC   = navyTable.Rows[7].Cells[2].GetComponentInChildren <Text>();
        Text recDN   = navyTable.Rows[7].Cells[3].GetComponentInChildren <Text>();

        recFrig.text = player.getNavyProducing(MyEnum.NavyUnits.frigates).ToString();
        recIC.text   = player.getNavyProducing(MyEnum.NavyUnits.ironclad).ToString();
        recDN.text   = player.getNavyProducing(MyEnum.NavyUnits.dreadnought).ToString();

        shipyardLevelValue.SetText(player.GetShipyardLevel().ToString());
        if (PlayerCalculator.canUpgradeShipyard(player) == true)
        {
            upgradeShipyardButton.interactable = true;
        }
        else
        {
            upgradeShipyardButton.interactable = false;
        }

        if (PlayerCalculator.canBuildFrigate(player) && State.GerEra() != MyEnum.Era.Late)
        {
            recruitFrigateButton.interactable = true;
        }
        else
        {
            recruitFrigateButton.interactable = false;
        }
        if (PlayerCalculator.canBuildIronclad(player))
        {
            recruitIroncladButton.interactable = true;
        }
        else
        {
            recruitIroncladButton.interactable = false;
        }

        if (PlayerCalculator.canBuildDreadnought(player))
        {
            recruitBattleshipButton.interactable = true;
        }
        else
        {
            recruitBattleshipButton.interactable = false;
        }

        if (player.GetShipyardLevel() == 1)
        {
            shipyardUpgradeCostOne.SetActive(true);
            shipyardUpgradeCostTwo.SetActive(false);
        }
        else if (player.GetShipyardLevel() == 2)
        {
            shipyardUpgradeCostOne.SetActive(false);
            shipyardUpgradeCostTwo.SetActive(true);
        }

        else
        {
            shipyardUpgradeCostOne.SetActive(false);
            shipyardUpgradeCostTwo.SetActive(false);
        }
    }