Exemplo n.º 1
0
        public void StartNewRound()
        {
            for (int i = 0; i < map.units.Count; i++)
            {
                if (map.units[i] is Unit)
                {
                    PerformAction(map.units[i]);
                }
            }

            for (int i = 0; i < map.buildings.Count; i++)
            {
                if (map.buildings[i] is ResourceBuilding)
                {
                    ResourceBuilding building = map.buildings[i] as ResourceBuilding;
                    building.GenerateResources();
                }
                else
                {
                    CheckBuildingProduction(i);
                }
            }

            map.PopulateMap();
            map.UpdateDisplay();

            roundsCompleted++;
        }
Exemplo n.º 2
0
        public void PopulateMap()
        {
            int index = 0;

            while (index < units.Count)
            {
                IUnit lUnit = units[index] as IUnit;
                if (lUnit.Health <= 0)
                {
                    //increases the resources for the opposing team if a unit was killed
                    if (units[index] is RangedUnit)
                    {
                        foreach (Building building in buildings)
                        {
                            if (building is ResourceBuilding)
                            {
                                ResourceBuilding b = building as ResourceBuilding;
                                if (b.Faction != lUnit.Faction)
                                {
                                    b.GenerateResources();
                                }
                            }
                        }
                    }
                    else if (units[index] is MeleeUnit)
                    {
                        foreach (Building building in buildings)
                        {
                            if (building is ResourceBuilding)
                            {
                                ResourceBuilding b = building as ResourceBuilding;
                                if (b.Faction != lUnit.Faction)
                                {
                                    b.GenerateResources();
                                }
                            }
                        }
                    }
                    else if (units[index] is MeleeUnit)
                    {
                        foreach (Building building in buildings)
                        {
                            if (building is ResourceBuilding)
                            {
                                ResourceBuilding b = building as ResourceBuilding;
                                if (b.Faction != lUnit.Faction)
                                {
                                    b.GenerateResources();
                                }
                            }
                        }
                    }

                    units.Remove(units[index]);
                }
                else
                {
                    index++;
                }
            }

            foreach (IUnit unit in units)
            {
                Battlefield[unit.xPos, unit.yPos] = unit;
            }
            foreach (IUnit building in buildings)
            {
                Battlefield[building.xPos, building.yPos] = building;
            }
        }