Esempio n. 1
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            //Loads saved simulation from textfile into program and initializes the simulation
            load = true;
            int count;

            FileStream ufs = new FileStream("Saves/Units/units", FileMode.Open, FileAccess.Read);
            FileStream bfs = new FileStream("Saves/Buildings/buildings", FileMode.Open, FileAccess.Read);

            StreamReader usr = new StreamReader(ufs);
            StreamReader bsr = new StreamReader(bfs);

            for (int i = 0; i < 20; i++)
            {
                for (int k = 0; k < 20; k++)
                {
                    gameEngine.map.arrMap[i, k] = ',';
                }
            }

            count = File.ReadAllLines("Saves/Units/units").Length;
            gameEngine.map.arrUnits = new unit[count];
            for (int i = 0; i < count; i++)
            {
                string line = usr.ReadLine();



                string[] arrline = line.Split(',');

                char   uSymbol     = Convert.ToChar(arrline[0]);
                int    x           = Convert.ToInt32(arrline[1]);
                int    y           = Convert.ToInt32(arrline[2]);
                int    Maxhp       = Convert.ToInt32(arrline[3]);
                int    HP          = Convert.ToInt32(arrline[4]);
                string Name        = (arrline[5]);
                string Team        = (arrline[6]);
                int    Speed       = Convert.ToInt32(arrline[7]);
                bool   IsAttacking = Convert.ToBoolean(arrline[8]);
                int    Attack      = Convert.ToInt32(arrline[9]);
                int    AttackRange = Convert.ToInt32(arrline[10]);


                if (uSymbol == 'x' || uSymbol == 'X')
                {
                    MeleeUnit un = new MeleeUnit(Name, x, y, HP, Speed, Attack, AttackRange, Team, uSymbol, IsAttacking);
                    gameEngine.map.arrUnits[i] = un;
                    gameEngine.map.arrMap[un.xPos, un.yPos] = un.symbol;
                }
                else if (uSymbol == 'o' || uSymbol == 'O')
                {
                    RangedUnit un = new RangedUnit(Name, x, y, HP, Speed, Attack, AttackRange, Team, uSymbol, IsAttacking);
                    gameEngine.map.arrUnits[i] = un;
                    gameEngine.map.arrMap[un.xPos, un.yPos] = un.symbol;
                }
                else
                {
                    Wizard un = new Wizard(Name, x, y, HP, Speed, Attack, AttackRange, Team, uSymbol, IsAttacking);
                    gameEngine.map.arrUnits[i] = un;
                    gameEngine.map.arrMap[un.xPos, un.yPos] = un.symbol;
                }
            }

            ufs.Close();
            usr.Close();

            count = File.ReadAllLines("Saves/Buildings/buildings").Length;
            gameEngine.map.arrBuildings = new Building[count];
            for (int i = 0; i < count; i++)
            {
                string line = bsr.ReadLine();



                string[] arrline = line.Split(',');

                char   bSymbol = Convert.ToChar(arrline[0]);
                int    x       = Convert.ToInt32(arrline[1]);
                int    y       = Convert.ToInt32(arrline[2]);
                string team    = (arrline[3]);
                int    maxHP   = Convert.ToInt32(arrline[4]);
                int    HP      = Convert.ToInt32(arrline[5]);


                if (bSymbol == 'F')
                {
                    int    Production     = Convert.ToInt32(arrline[6]);
                    int    Yspawn         = Convert.ToInt32(arrline[7]);
                    string UnitProduction = (arrline[8]);
                    int    unitsProduced  = Convert.ToInt32(arrline[9]);

                    FactoryBuilding bld = new FactoryBuilding(x, y, HP, team, bSymbol, UnitProduction, Production, Yspawn);
                    gameEngine.map.arrBuildings[i]            = bld;
                    gameEngine.map.arrMap[bld.XPos, bld.YPos] = bld.Symbol;
                }
                else
                {
                    string Resource      = (arrline[6]);
                    int    GatheringRate = Convert.ToInt32(arrline[7]);
                    int    Gathered      = Convert.ToInt32(arrline[8]);
                    int    ResourcePool  = Convert.ToInt32(arrline[9]);

                    ResourceBuilding bld = new ResourceBuilding(x, y, HP, team, bSymbol, Resource, Gathered, GatheringRate, ResourcePool);
                    gameEngine.map.arrBuildings[i]            = bld;
                    gameEngine.map.arrMap[bld.XPos, bld.YPos] = bld.Symbol;
                }
            }
            bfs.Close();
            bsr.Close();
            lblMap.Text = gameEngine.map.MapDisplay();
            timer1.Start();
        }
Esempio n. 2
0
        //CLASS METHODS
        public void RandomBattlefield()
        {
            int randomX, randomY;
            int random;

            randomX = 1;
            randomY = 1;

            arrUnits     = new unit[sumUnits];
            arrBuildings = new Building[sumBuildings];
            Random rnd = new Random();

            for (int i = 0; i < 20; i++)
            {
                for (int k = 0; k < 20; k++)
                {
                    arrMap[i, k] = ',';
                }
            }

            for (int i = 0; i < sumUnits; i++)
            {
                randomX = rnd.Next(0, 20);
                randomY = rnd.Next(0, 20);


                random = rnd.Next(1, 5);

                while (arrMap[randomX, randomY] == 'x' || arrMap[randomX, randomY] == 'X' || arrMap[randomX, randomY] == 'o' || arrMap[randomX, randomY] == 'O')
                {
                    randomX = rnd.Next(0, 20);
                    randomY = rnd.Next(0, 20);
                }

                if (random == 1)
                {
                    MeleeUnit unit = new MeleeUnit("Knight", randomX, randomY, 100, 1, 5, 1, "Team1", 'X', false);
                    arrMap[unit.xPos, unit.yPos] = unit.symbol;
                    arrUnits[i] = unit;
                }
                else if (random == 2)
                {
                    MeleeUnit unit = new MeleeUnit("Knight", randomX, randomY, 100, 1, 5, 1, "Team2", 'x', false);
                    arrMap[unit.xPos, unit.yPos] = unit.symbol;
                    arrUnits[i] = unit;
                }
                else if (random == 3)
                {
                    RangedUnit unit = new RangedUnit("Archer", randomX, randomY, 80, 1, 3, 3, "Team1", 'O', false);
                    arrMap[unit.xPos, unit.yPos] = unit.symbol;
                    arrUnits[i] = unit;
                }
                else
                {
                    RangedUnit unit = new RangedUnit("Archer", randomX, randomY, 80, 1, 3, 3, "Team2", 'o', false);
                    arrMap[unit.xPos, unit.yPos] = unit.symbol;
                    arrUnits[i] = unit;
                }
            }

            for (int k = 0; k < sumBuildings; k++)
            {
                randomX = rnd.Next(0, 20);
                randomY = rnd.Next(0, 20);

                while (arrMap[randomX, randomY] == 'x' || arrMap[randomX, randomY] == 'X' || arrMap[randomX, randomY] == 'o' || arrMap[randomX, randomY] == 'O')
                {
                    randomX = rnd.Next(0, 20);
                    randomY = rnd.Next(0, 20);
                }

                random = rnd.Next(1, 7);

                int spawnYPos;
                spawnYPos = 0;

                if (randomY == 19)
                {
                    spawnYPos = 18;
                }
                else if (randomY == 0)
                {
                    spawnYPos = 1;
                }
                else
                {
                    spawnYPos = randomY - 1;
                }

                if (random == 1)
                {
                    ResourceBuilding building = new ResourceBuilding(randomX, randomY, 200, "Team1", 'R', "Tiberuim", 0, 5, 2000);
                    arrMap[building.xPos, building.yPos] = building.symbol;
                    arrBuildings[k] = building;
                }
                else if (random == 2)
                {
                    ResourceBuilding building = new ResourceBuilding(randomX, randomY, 200, "Team2", 'R', "Tiberuim", 0, 5, 2000);
                    arrMap[building.xPos, building.yPos] = building.symbol;
                    arrBuildings[k] = building;
                }
                else if (random == 3)
                {
                    FactoryBuilding building = new FactoryBuilding(randomX, randomY, 200, "Team1", 'F', "Melee Unit", 10, spawnYPos);
                    arrMap[building.xPos, building.yPos] = building.symbol;
                    arrBuildings[k] = building;
                }
                else if (random == 4)
                {
                    FactoryBuilding building = new FactoryBuilding(randomX, randomY, 200, "Team1", 'F', "Ranged Unit", 10, spawnYPos);
                    arrMap[building.xPos, building.yPos] = building.symbol;
                    arrBuildings[k] = building;
                }
                else if (random == 5)
                {
                    FactoryBuilding building = new FactoryBuilding(randomX, randomY, 200, "Team2", 'F', "Melee Unit", 10, spawnYPos);
                    arrMap[building.xPos, building.yPos] = building.symbol;
                    arrBuildings[k] = building;
                }
                else
                {
                    FactoryBuilding building = new FactoryBuilding(randomX, randomY, 200, "Team2", 'F', "Ranged  Unit", 10, spawnYPos);
                    arrMap[building.xPos, building.yPos] = building.symbol;
                    arrBuildings[k] = building;
                }
            }
        }
Esempio n. 3
0
        //
        public void GameLogic(unit[] arrUnits)
        {
            gameRounds++;
            Random rnd = new Random();
            bool   death;
            string direction;

            direction = " ";

            death = false;

            OutputString = "";
            for (int i = 0; i < this.arrUnits.Length; i++)
            {
                death = this.arrUnits[i].Death();
                if (death == true)
                {
                    this.arrUnits[i].HP = 0;
                }
                else
                {
                    unit closestunit;
                    closestunit = this.arrUnits[i].ClosestUnit(arrUnits);
                    if (this.arrUnits[i] == closestunit)
                    {
                    }
                    else
                    {
                        this.arrUnits[i].AttackRange(closestunit);
                        if (this.arrUnits[i].HP <= (this.arrUnits[i].maxHP * 0.25))
                        {
                            string randomDirection;
                            int    random;

                            random = rnd.Next(1, 5);

                            if (random == 1)
                            {
                                randomDirection = "left";
                            }
                            else if (random == 2)
                            {
                                randomDirection = "right";
                            }
                            else if (random == 3)
                            {
                                randomDirection = "up";
                            }
                            else
                            {
                                randomDirection = "down";
                            }

                            this.arrUnits[i].Move(randomDirection);

                            this.arrUnits[i].HP += 2;
                        }
                        else
                        {
                            if (this.arrUnits[i].isAttacking == true)
                            {
                                this.arrUnits[i].Combat(closestunit);
                            }
                            else
                            {
                                int oldX, oldY;
                                oldX      = this.arrUnits[i].xPos;
                                oldY      = this.arrUnits[i].yPos;
                                direction = Direction(this.arrUnits[i], closestunit);
                                this.arrUnits[i].Move(direction);
                                map.MapUpdate(this.arrUnits[i], oldX, oldY);
                            }
                        }
                    }
                }
                OutputString += "\n" + this.arrUnits[i].ToString();



                OutputString += "\n";
            }

            buildingOutput = " ";

            for (int i = 0; i < map.arrBuildings.Length; i++)
            {
                string   buildingType = map.arrBuildings[i].GetType().ToString();
                string[] buildingArr  = buildingType.Split('.');
                buildingType = buildingArr[buildingArr.Length - 1];


                if (buildingType == "ResourceBuilding")
                {
                    ResourceBuilding building = (ResourceBuilding)map.arrBuildings[i];
                    if (building.Death() == true)
                    {
                    }
                    else
                    {
                        building.ResourceManagement();
                    }
                }
                else if (buildingType == "FactoryBuilding")
                {
                    FactoryBuilding building = (FactoryBuilding)map.arrBuildings[i];

                    if (building.Death() == true)
                    {
                    }
                    else
                    {
                        if ((gameRounds % building.productionSpeed) == 0)
                        {
                            Array.Resize(ref this.arrUnits, this.arrUnits.Length + 1);;
                            this.arrUnits[this.arrUnits.Length - 1] = building.CreateUnit();
                        }
                    }
                }
                buildingOutput += "\n" + map.arrBuildings[i].toString();
                buildingOutput += "\n";
            }
        }
Esempio n. 4
0
        //all the logic that makes the units do their actions and make the game function
        public void GameLogic(unit[] arrUnits)
        {
            gameRounds++;
            Random rnd = new Random();
            bool   death;
            string direction;

            direction = " ";

            death = false;

            OutputString = "";
            for (int i = 0; i < this.arrUnits.Length; i++)
            {
                death = this.arrUnits[i].Death();



                unit closestunit = this.arrUnits[i].ClosestUnit(arrUnits);
                if (arrUnits[i].unitName == "Wizard")
                {                      //wizard check
                    if (death == true) //death check
                    {
                        arrUnits[i].HP = 0;
                    }
                    else
                    {
                        if (this.arrUnits[i] == closestunit)
                        {
                            closestunit = arrUnits[i].ClosestUnit(arrUnits);
                        }                                                   //makes sure closest unit worked correctly
                        else
                        {
                            this.arrUnits[i].AttackRange(closestunit);                  //checks if target is in range
                            if (this.arrUnits[i].HP <= (this.arrUnits[i].maxHP * 0.50)) //checks if units health is low enough to run away
                            {                                                           //makes unit run away in random direction
                                string randomDirection;
                                int    random;

                                random = rnd.Next(1, 5);

                                if (random == 1)
                                {
                                    randomDirection = "left";
                                }
                                else if (random == 2)
                                {
                                    randomDirection = "right";
                                }
                                else if (random == 3)
                                {
                                    randomDirection = "up";
                                }
                                else
                                {
                                    randomDirection = "down";
                                }

                                this.arrUnits[i].Move(randomDirection);

                                this.arrUnits[i].HP += 4;
                            }
                            else
                            {     //if hp above runaway amount
                                if (this.arrUnits[i].isAttacking == true)
                                { //makes unit attack
                                    Wizard unit = (Wizard)arrUnits[i];
                                    unit.WizardAOE(this.arrUnits);
                                }
                                else
                                {//makes unit move closer to target
                                    int oldX, oldY;
                                    oldX      = this.arrUnits[i].xPos;
                                    oldY      = this.arrUnits[i].yPos;
                                    direction = Direction(this.arrUnits[i], closestunit);
                                    this.arrUnits[i].Move(direction);
                                    map.MapUpdate(this.arrUnits[i], oldX, oldY);
                                }
                            }
                        }
                    }//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                }
                else
                {
                    if (death == true)
                    {
                        arrUnits[i].HP = 0;
                    }
                    else
                    {
                        Building closestBuilding = this.arrUnits[i].ClosestUnit(map.arrBuildings);


                        //sees if the building or unit is closer so that it knows witch one to attack
                        int xDistb     = Math.Abs(this.arrUnits[i].xPos - closestBuilding.xPos);
                        int yDistb     = Math.Abs(this.arrUnits[i].yPos - closestBuilding.yPos);
                        int totalDistb = xDistb + yDistb;

                        int xDistu     = Math.Abs(this.arrUnits[i].xPos - closestunit.xPos);
                        int yDistu     = Math.Abs(this.arrUnits[i].yPos - closestunit.yPos);
                        int totalDistu = xDistu + yDistu;



                        if (totalDistb < totalDistu && closestBuilding.hP > 0)
                        {//if building is closer
                            this.arrUnits[i].AttackRange(closestBuilding);
                            if (this.arrUnits[i].HP <= (this.arrUnits[i].maxHP * 0.25))
                            {
                                string randomDirection;
                                int    random;

                                random = rnd.Next(1, 5);

                                if (random == 1)
                                {
                                    randomDirection = "left";
                                }
                                else if (random == 2)
                                {
                                    randomDirection = "right";
                                }
                                else if (random == 3)
                                {
                                    randomDirection = "up";
                                }
                                else
                                {
                                    randomDirection = "down";
                                }

                                this.arrUnits[i].Move(randomDirection);

                                this.arrUnits[i].HP += 2;
                            }
                            else
                            {
                                if (this.arrUnits[i].isAttacking == true)
                                {
                                    this.arrUnits[i].Combat(closestBuilding);
                                }
                                else
                                {
                                    int oldX, oldY;
                                    oldX      = this.arrUnits[i].xPos;
                                    oldY      = this.arrUnits[i].yPos;
                                    direction = Direction(this.arrUnits[i], closestBuilding);
                                    this.arrUnits[i].Move(direction);
                                    map.MapUpdate(this.arrUnits[i], oldX, oldY);
                                }
                            }
                        }
                        else
                        {//if unit is closer
                            if (this.arrUnits[i] == closestunit)
                            {
                                closestunit = arrUnits[i].ClosestUnit(arrUnits);
                            }
                            else
                            {
                                this.arrUnits[i].AttackRange(closestunit);
                                if (this.arrUnits[i].HP <= (this.arrUnits[i].maxHP * 0.25))
                                {
                                    string randomDirection;
                                    int    random;

                                    random = rnd.Next(1, 5);

                                    if (random == 1)
                                    {
                                        randomDirection = "left";
                                    }
                                    else if (random == 2)
                                    {
                                        randomDirection = "right";
                                    }
                                    else if (random == 3)
                                    {
                                        randomDirection = "up";
                                    }
                                    else
                                    {
                                        randomDirection = "down";
                                    }

                                    this.arrUnits[i].Move(randomDirection);

                                    this.arrUnits[i].HP += 2;
                                }
                                else
                                {
                                    if (this.arrUnits[i].isAttacking == true)
                                    {
                                        this.arrUnits[i].Combat(closestunit);
                                    }
                                    else
                                    {
                                        int oldX, oldY;
                                        oldX      = this.arrUnits[i].xPos;
                                        oldY      = this.arrUnits[i].yPos;
                                        direction = Direction(this.arrUnits[i], closestunit);
                                        this.arrUnits[i].Move(direction);
                                        map.MapUpdate(this.arrUnits[i], oldX, oldY);
                                    }
                                }
                            }
                        }
                    }
                }


                //compiles a string to output all the tostring stats of the units
                OutputString += "\n" + this.arrUnits[i].ToString();



                OutputString += "\n";
            }

            buildingOutput = " ";

            for (int i = 0; i < map.arrBuildings.Length; i++)
            {//buildings do their actions
                string   buildingType = map.arrBuildings[i].GetType().ToString();
                string[] buildingArr  = buildingType.Split('.');
                buildingType = buildingArr[buildingArr.Length - 1];

                //typecheck and explicit cast
                if (buildingType == "ResourceBuilding")
                {
                    ResourceBuilding building = (ResourceBuilding)map.arrBuildings[i];
                    if (building.Death() == true)
                    {
                    }  //death check
                    else
                    {
                        building.ResourceManagement();
                        if (building.team == "Team1")
                        {//checks team and adds to their resources that have been gathered
                            t1Resources += building.resourcesGeneratedPerRound;
                        }
                        else
                        {
                            t2Resources += building.resourcesGeneratedPerRound;
                        }
                    }
                }
                else if (buildingType == "FactoryBuilding")
                {
                    FactoryBuilding building = (FactoryBuilding)map.arrBuildings[i];

                    if (building.Death() == true)
                    {
                    }
                    else
                    {
                        if (building.team == "Team1")
                        {
                            if (t1Resources >= 60)
                            {//checks team and if there are enough resources to be able to spawn a unit and subtracts from the total gathered resources if it creates a unit
                                Array.Resize(ref this.arrUnits, this.arrUnits.Length + 1);;
                                this.arrUnits[this.arrUnits.Length - 1] = building.CreateUnit();
                                map.arrUnits = this.arrUnits;
                                t1Resources -= 60;
                            }
                        }
                        else
                        {
                            if (t2Resources >= 60)
                            {
                                Array.Resize(ref this.arrUnits, this.arrUnits.Length + 1);;
                                this.arrUnits[this.arrUnits.Length - 1] = building.CreateUnit();
                                map.arrUnits = this.arrUnits;
                                t2Resources -= 60;
                            }
                        }
                    }
                }//outputs the buildings tostring
                buildingOutput += "\n" + map.arrBuildings[i].toString();
                buildingOutput += "\n";
            }//makes sure the two unit arrays dont differ
            map.arrUnits = this.arrUnits;
        }
Esempio n. 5
0
        //CLASS METHODS
        public void RandomBattlefield()
        {
            // method creates a random battlefield and initializes all of the buildings and units on the map

            int randomX, randomY;
            int random;

            randomX = 1;
            randomY = 1;

            arrUnits     = new unit[sumUnits];
            arrBuildings = new Building[sumBuildings];
            Random rnd = new Random();

            //populate map
            for (int i = 0; i < arrMap.GetLength(0); i++)
            {
                for (int k = 0; k < arrMap.GetLength(1); k++)
                {
                    arrMap[i, k] = ',';
                }
            }
            //makes units
            for (int i = 0; i < sumUnits; i++)
            {
                randomX = rnd.Next(0, arrMap.GetLength(0));
                randomY = rnd.Next(0, arrMap.GetLength(1));


                random = rnd.Next(1, 8);

                while (arrMap[randomX, randomY] == 'x' || arrMap[randomX, randomY] == 'X' || arrMap[randomX, randomY] == 'o' || arrMap[randomX, randomY] == 'O')
                {//checks that they dont spawn ontop of eachother
                    randomX = rnd.Next(0, arrMap.GetLength(0));
                    randomY = rnd.Next(0, arrMap.GetLength(1));
                }
                //randomises the unit that will spawn
                if (random == 1)
                {
                    MeleeUnit unit = new MeleeUnit("Knight", randomX, randomY, 100, 1, 5, 1, "Team1", 'X', false);
                    arrMap[unit.xPos, unit.yPos] = unit.symbol;
                    arrUnits[i] = unit;
                }
                else if (random == 2)
                {
                    MeleeUnit unit = new MeleeUnit("Knight", randomX, randomY, 100, 1, 5, 1, "Team2", 'x', false);
                    arrMap[unit.xPos, unit.yPos] = unit.symbol;
                    arrUnits[i] = unit;
                }
                else if (random == 3)
                {
                    RangedUnit unit = new RangedUnit("Archer", randomX, randomY, 80, 1, 3, 3, "Team1", 'O', false);
                    arrMap[unit.xPos, unit.yPos] = unit.symbol;
                    arrUnits[i] = unit;
                }
                else if (random == 4)
                {
                    RangedUnit unit = new RangedUnit("Archer", randomX, randomY, 80, 1, 3, 3, "Team2", 'o', false);
                    arrMap[unit.xPos, unit.yPos] = unit.symbol;
                    arrUnits[i] = unit;
                }
                else if (random == 5)
                {
                    Wizard unit = new Wizard("Wizard", randomX, randomY, 100, 1, 5, 2, "Team1", 'W', false);
                    arrMap[unit.xPos, unit.yPos] = unit.symbol;
                    arrUnits[i] = unit;
                }
                else if (random == 6)
                {
                    Wizard unit = new Wizard("Wizard", randomX, randomY, 100, 1, 5, 2, "Team2", 'w', false);
                    arrMap[unit.xPos, unit.yPos] = unit.symbol;
                    arrUnits[i] = unit;
                }
                else
                {
                    Wizard unit = new Wizard("Wizard", randomX, randomY, 150, 1, 7, 2, "neutral", 'M', false);
                    arrMap[unit.xPos, unit.yPos] = unit.symbol;
                    arrUnits[i] = unit;
                }
            }
            //spawns all the buildings
            for (int k = 0; k < sumBuildings; k++)
            {
                randomX = rnd.Next(0, arrMap.GetLength(0));
                randomY = rnd.Next(0, arrMap.GetLength(1));

                while (arrMap[randomX, randomY] == 'x' || arrMap[randomX, randomY] == 'X' || arrMap[randomX, randomY] == 'o' || arrMap[randomX, randomY] == 'O')
                {//checks that they dont spawn ontop of eachother
                    randomX = rnd.Next(0, arrMap.GetLength(0));
                    randomY = rnd.Next(0, arrMap.GetLength(1));
                }
                //randomises building that will spawn
                random = rnd.Next(1, 7);

                int spawnYPos;
                spawnYPos = 0;

                if (randomY == 19)
                {
                    spawnYPos = 18;
                }
                else if (randomY == 0)
                {
                    spawnYPos = 1;
                }
                else
                {
                    spawnYPos = randomY - 1;
                }

                if (random == 1)
                {
                    ResourceBuilding building = new ResourceBuilding(randomX, randomY, 200, "Team1", 'R', "Tiberuim", 0, 5, 2000);
                    arrMap[building.xPos, building.yPos] = building.symbol;
                    arrBuildings[k] = building;
                }
                else if (random == 2)
                {
                    ResourceBuilding building = new ResourceBuilding(randomX, randomY, 200, "Team2", 'r', "Tiberuim", 0, 5, 2000);
                    arrMap[building.xPos, building.yPos] = building.symbol;
                    arrBuildings[k] = building;
                }
                else if (random == 3)
                {
                    FactoryBuilding building = new FactoryBuilding(randomX, randomY, 200, "Team1", 'F', "Melee Unit", 20, spawnYPos);
                    arrMap[building.xPos, building.yPos] = building.symbol;
                    arrBuildings[k] = building;
                }
                else if (random == 4)
                {
                    FactoryBuilding building = new FactoryBuilding(randomX, randomY, 200, "Team1", 'F', "Ranged Unit", 20, spawnYPos);
                    arrMap[building.xPos, building.yPos] = building.symbol;
                    arrBuildings[k] = building;
                }
                else if (random == 5)
                {
                    FactoryBuilding building = new FactoryBuilding(randomX, randomY, 200, "Team2", 'f', "Melee Unit", 20, spawnYPos);
                    arrMap[building.xPos, building.yPos] = building.symbol;
                    arrBuildings[k] = building;
                }
                else
                {
                    FactoryBuilding building = new FactoryBuilding(randomX, randomY, 200, "Team2", 'f', "Ranged  Unit", 20, spawnYPos);
                    arrMap[building.xPos, building.yPos] = building.symbol;
                    arrBuildings[k] = building;
                }
            }
        }