コード例 #1
0
        public static float GetDefenseStrength(LogicArrayList <LogicGameObject> buildings, LogicArrayList <LogicGameObject> traps, LogicArrayList <LogicHeroData> heroes,
                                               int[] heroUpgLevel)
        {
            float heroStrength     = 0f;
            float buildingStrength = 0f;
            float trapStrength     = 0;

            for (int i = 0; i < heroes.Size(); i++)
            {
                heroStrength += LogicStrengthUtil.GetHeroStrength(heroes[i], heroUpgLevel[i], true);
            }

            for (int i = 0; i < buildings.Size(); i++)
            {
                LogicBuilding building = (LogicBuilding)buildings[i];

                if (!building.IsLocked())
                {
                    if (!building.IsConstructing() || building.IsUpgrading())
                    {
                        buildingStrength += LogicStrengthUtil.GetBuildingStrength(building.GetBuildingData(), building.GetUpgradeLevel());
                    }
                }
            }

            for (int i = 0; i < traps.Size(); i++)
            {
                LogicTrap trap = (LogicTrap)traps[i];

                if (!trap.IsConstructing() || trap.IsUpgrading())
                {
                    trapStrength += LogicStrengthUtil.GetTrapStrength(trap.GetTrapData(), trap.GetUpgradeLevel());
                }
            }

            return(buildingStrength + trapStrength + heroStrength);
        }