示例#1
0
        public void ManageBuildings()
        {
            for (int l = 0; l < map.buildings.Length; l++)
            {
                int amount = 0;

                if (map.buildings[l].Destroyed == false)
                {
                    if (map.buildings[l].GetType() == factoryCheck.GetType())
                    {
                        factoryCheck = (FactoryBuilding)map.buildings[l];

                        if (factoryCheck.Faction == 0)
                        {
                            if (rounds % factoryCheck.ProductionSpeed == 0 && teamResources0 >= 10)
                            {
                                Array.Resize(ref map.units, map.units.Length + 1);
                                map.units[map.units.Length - 1] = factoryCheck.SpawnUnit();
                                teamResources0 -= 10;
                            }
                        }
                        else
                        {
                            if (rounds % factoryCheck.ProductionSpeed == 0 && teamResources1 >= 10)
                            {
                                Array.Resize(ref map.units, map.units.Length + 1);
                                map.units[map.units.Length - 1] = factoryCheck.SpawnUnit();
                                teamResources1 -= 10;
                            }
                        }
                    }
                    else if (map.buildings[l].GetType() == resourceCheck.GetType())
                    {
                        resourceCheck    = (ResourceBuilding)map.buildings[l];
                        amount           = resourceCheck.Collect();
                        map.buildings[l] = resourceCheck;

                        if (resourceCheck.Faction == 0)
                        {
                            teamResources0 += amount;
                        }
                        else
                        {
                            teamResources1 += amount;
                        }
                    }
                }
            }
        }