Exemplo n.º 1
0
        public void InitialiseBuildings() //Creates the buildings
        {
            buildings = new Building[numBuildings];

            for (int i = 0; i < buildings.Length; i++)
            {
                int x             = r.Next(0, width);
                int y             = r.Next(0, height);
                int buildingIndex = r.Next(0, 2);
                int buildingType  = r.Next(0, 2);

                while (map[x, y] != null)
                {
                    x = r.Next(0, width);
                    y = r.Next(0, height);
                }

                if (buildingType == 0)
                {
                    buildings[i] = new ResourceBuilding(x, y, teams[buildingIndex]);
                }
                else
                {
                    buildings[i] = new FactoryBuilding(x, y, teams[buildingIndex]);
                }

                map[x, y] = buildings[i].Team[0] + "|" + buildings[i].Symbol;
            }
        }
Exemplo n.º 2
0
 void UpdateBuildings()
 {
     foreach (Building building in map.Buildings)
     {
         if (building is FactoryBuilding)
         {
             FactoryBuilding factoryBuilding = (FactoryBuilding)building;
             if (round % factoryBuilding.ProductionSpeed == 0)
             {
                 Unit newUnit = factoryBuilding.SpawnUnit();
                 map.AddInUnits(newUnit);
             }
         }
         else if (building is ResourceBuilding)
         {
             ResourceBuilding resourceBuilding = (ResourceBuilding)building;
             resourceBuilding.GenerateResources();
         }
     }
 }