Exemplo n.º 1
0
        public void GenerateUnits(int numOfBuildingsToSpawn, int xMap, int yMap)//Gets Called Only Once
        {
            //buildings = new List<Building>();

            //Spawns Buildings
            for (int b = 0; b < numOfBuildingsToSpawn; b++)
            {
                buildingRd = r.Next(0, 5);

                if (buildingRd >= 3)
                {
                    ResourceBuilding rb = new ResourceBuilding(r.Next(0, xmapsize),
                                                               r.Next(0, ymapsize),
                                                               200,
                                                               r.Next(0, 10),
                                                               "R");

                    buildings.Add(rb);
                }
                else
                {
                    FactoryBuilding fb = new FactoryBuilding(r.Next(0, xmapsize),
                                                             r.Next(0, ymapsize),
                                                             100,
                                                             r.Next(0, 10),
                                                             "F");

                    buildings.Add(fb);
                }
            }


            //Generates Melee Units
            //for (int i = 0; i < 20; i++)
            //{
            //    Melee_Unit mU = new Melee_Unit();
            //    mU.xPos = r.Next(2, xMapSize);
            //    mU.yPos = r.Next(2, yMapSize);
            //    mU.symbol = "{:}";
            //    mU.health = 200;

            //    units.Add(mU);
            //}

            ////Generates Ranged Units
            //for (int i = 0; i < 20; i++)
            //{
            //    Ranged_Unit rU = new Ranged_Unit();
            //    rU.xPos = r.Next(0, xMapSize);
            //    rU.yPos = r.Next(0, yMapSize);
            //    rU.symbol = "[!]";
            //    rU.health = 100;

            //    units.Add(rU);
            //}
        }
        public void readResourceBuilding()
        {
            FileStream   inFile = null;
            StreamReader reader = null;
            string       input;
            int          xPosition;
            int          yPosition;
            int          health;
            string       factionTeam;
            string       symbolImage;
            string       resourceType;
            int          resourcesPerGameTick;
            int          resourcesRemaining;

            try
            {
                inFile = new FileStream(@"Files\ResourceBuilding.txt", FileMode.Open, FileAccess.Read);
                reader = new StreamReader(inFile);
                input  = reader.ReadLine();
                while (input != null)
                {
                    xPosition            = int.Parse(input);
                    yPosition            = int.Parse(reader.ReadLine());
                    health               = int.Parse(reader.ReadLine());
                    factionTeam          = (reader.ReadLine());
                    symbolImage          = (reader.ReadLine());
                    resourceType         = (reader.ReadLine());
                    resourcesPerGameTick = int.Parse(reader.ReadLine());
                    resourcesRemaining   = int.Parse(reader.ReadLine());

                    Building tmp = new ResourceBuilding(xPosition, yPosition, health, factionTeam, symbolImage, resourceType, resourcesPerGameTick, resourcesRemaining);
                    map[tmp.XPosition, tmp.YPosition] = tmp.SymbolImage;
                    buildingsOnMap.Add(tmp);

                    input = reader.ReadLine();
                }
                reader.Close();
                inFile.Close();
            }
            catch (Exception fe)
            {
                Debug.WriteLine(fe.Message);
            }
            finally
            {
                if (inFile != null)
                {
                    reader.Close();
                    inFile.Close();
                }
            }
        }
        public void constructBuildings()
        {
            Random rnd = new Random();

            Building resouceBuilding = new ResourceBuilding(17, 17, 100, "Red", "$", "something", 10, 50);

            map[resouceBuilding.XPosition, resouceBuilding.YPosition] = resouceBuilding.SymbolImage;
            buildingsOnMap.Add(resouceBuilding);

            Building factoryBuilding = new FactoryBuilding(1, 1, 100, "Blue", "@", 55, 50, 50);

            map[factoryBuilding.XPosition, factoryBuilding.YPosition] = factoryBuilding.SymbolImage;
            buildingsOnMap.Add(factoryBuilding);

            Building gatewayBuilding = new GatewayBuilding(rnd.Next(0, (18)), rnd.Next(0, (18)), 100, "none", "%");

            map[gatewayBuilding.XPosition, gatewayBuilding.YPosition] = gatewayBuilding.SymbolImage;
            buildingsOnMap.Add(gatewayBuilding);
        }