Esempio n. 1
0
        private Building GenerateRandomBuilding()
        {
            int whichBuilding = rand.Next(0, 2);

            if (whichBuilding == 0)
            {
                Point point = GetRandomOpenPosition();

                char   lSymbol;
                string lFaction;
                int    whichFaction = rand.Next(0, 2);
                if (whichFaction == 0)
                {
                    lSymbol  = 'H';
                    lFaction = "Horde";
                }
                else
                {
                    lSymbol  = 'A';
                    lFaction = "Alliance";
                }

                ResourceBuilding building = new ResourceBuilding(point.xPos, point.yPos, 10, lFaction, 'R', "Coal", 2, 1);
                return(building);
            }
            else
            {
                return(GenerateRandomFactory());
            }
        }
        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++;
        }
Esempio n. 3
0
        private Building GenerateBuilding()
        {
            Point point = GetRandomOpenPosition();
            int   xPos  = point.xPos;
            int   yPos  = point.yPos;

            int whichUnit = rand.Next(0, 2);
            int speed     = rand.Next(1, 4);

            string lFaction;
            int    whichFaction = rand.Next(0, 2);

            if (whichFaction == 0)
            {
                lFaction = "Horde";
            }
            else
            {
                lFaction = "Alliance";
            }

            Point Rpoint = GetRandomOpenPosition();
            int   RxPos  = point.xPos;
            int   RyPos  = point.yPos;

            ResourceBuilding RB = new ResourceBuilding(RxPos, RyPos, 20, lFaction, 'R', "Coal", 1, rand.Next(1, 4));

            Building building;

            if (whichUnit == 0)
            { //spawn a ranged Factory
                building = new FactoryBuilding <RangedUnit>(xPos, yPos, 20, lFaction, 'F', RB);
            }
            else
            { //spawn a melee Factory
                building = new FactoryBuilding <MeleeUnit>(xPos, yPos, 20, lFaction, 'F', RB);
            }

            return(building);
        }
Esempio n. 4
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;
            }
        }
Esempio n. 5
0
        public FactoryBuilding(int aXPos, int aYPos, int aHealth, string aFaction, char aSymbol, ResourceBuilding aRB)
            : base(aXPos, aYPos, aHealth, aFaction, aSymbol)
        {
            this.resourceBuilding = aRB;

            base.xPosition = aXPos;
            base.yPosition = aYPos;

            base.health    = aHealth;
            base.maxHealth = aHealth;

            base.faction = aFaction;
            base.symbol  = aSymbol;

            //Set spawn point
            SpawnPoint = aYPos + 1;
            if (SpawnPoint > Map.gridSize)
            {
                SpawnPoint = aYPos - 1;
            }
        }