public TowerPlacement(int mouseX, int mouseY, object mapGraph)
 {
     mX      = mouseX;
     mY      = mouseY;
     map     = (GUI_StatGraphics)mapGraph; // cast mapGraph object back into a class
     mapInts = map.MapInts;
 }
Exemple #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            font = Content.Load <SpriteFont>("mainFont");

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            //GUI content----------------------------------------------------------------------------------//
            towerGraphs             = new GUI_Anim[30];
            enemyGraphs             = new GUI_Anim[75];
            towerGraphsPlaceholders = new GUI_Anim[2];


            //font
            font = Content.Load <SpriteFont>("Arial"); //TEMP FONT

            //menu screen
            Texture2D menuImage = Content.Load <Texture2D>("GUI_Assets/menuscreen.png");

            menuScreen = new GUI_StatGraphics(menuImage, new Point(750, 600), 1, 1, 1, new Vector2(0, 0));

            //how to
            Texture2D howToImg1 = Content.Load <Texture2D>("GUI_Assets/htp1.png");

            howTo1 = new GUI_StatGraphics(howToImg1, new Point(600, 400), 1, 1, 1, new Vector2(75, 50));
            Texture2D howToImg2 = Content.Load <Texture2D>("GUI_Assets/htp2.png");

            howTo2 = new GUI_StatGraphics(howToImg2, new Point(600, 400), 1, 1, 1, new Vector2(75, 50));

            //map
            Texture2D mapImage    = Content.Load <Texture2D>("GUI_Assets/mapassets3type.png");
            Texture2D mapOverlay1 = Content.Load <Texture2D>("GUI_Assets/lv1_overlay.png");

            mapGraph  = new GUI_StatGraphics(mapImage, mapOverlay1, new Point(150, 50), 3, 1, 3, "newExampleMap1.txt");
            mapGraph2 = new GUI_StatGraphics(mapImage, mapOverlay1, new Point(150, 50), 3, 1, 3, "FinalExampleMap2.txt");

            //tower
            towerImage  = Content.Load <Texture2D>("GUI_Assets/towerplaceholder");
            lancerImage = Content.Load <Texture2D>("GUI_Assets/lancer");
            //enemy
            enemyImage = Content.Load <Texture2D>("GUI_Assets/enemyplaceholder");
            beeImage   = Content.Load <Texture2D>("GUI_Assets/bees");

            towerGraphsPlaceholders[0] = new GUI_Anim(towerImage, new Point(100, 150), 6, 3, 2, 1000, 0);
            towerGraphsPlaceholders[1] = new GUI_Anim(lancerImage, new Point(100, 150), 6, 3, 2, 1000, 0);


            //listing
            Texture2D listingImage = Content.Load <Texture2D>("GUI_Assets/storelistingplaceholder");

            listing1 = new GUI_StatGraphics(listingImage, new Point(150, 150), 1, 1, 1, new Vector2(450, 500));
            listing2 = new GUI_StatGraphics(listingImage, new Point(150, 150), 1, 1, 1, new Vector2(550, 500));
            listing3 = new GUI_StatGraphics(listingImage, new Point(150, 150), 1, 1, 1, new Vector2(650, 500));
            //store
            Texture2D backStoreImage = Content.Load <Texture2D>("GUI_Assets/storebackplaceholder");

            storeBack = new GUI_StatGraphics(backStoreImage, new Point(750, 100), 1, 1, 1, new Vector2(0, 500));
            //bought
            Texture2D boughtImage = Content.Load <Texture2D>("GUI_Assets/bought");

            boughtSym = new GUI_Anim(boughtImage, new Point(25, 25), 1, 1, 1, 1, 0);

            #region Load Map 1
            StreamReader load1 = new StreamReader("newExampleMap1.txt");
            string       line1;
            int          tile1Row    = 0;
            int          tile1Column = 0;
            level1Tiles   = new int[10, 15];
            level1MapTile = new Tile[10, 15];
            while ((line1 = load1.ReadLine()) != null)
            {
                if (line1 == "")//ignores the \n commands to split up rows in the array
                {
                    continue;
                }
                else
                {
                    char[] rowTiles = line1.ToCharArray();
                    foreach (char tile in rowTiles)
                    {
                        int    type    = 0;
                        string tileStr = tile.ToString();
                        int.TryParse(tileStr, out type);
                        level1Tiles[tile1Row, tile1Column] = type;
                        tile1Column++;
                    }
                    tile1Row++;
                    if (tile1Row > 9) //autobreaks if the loop exceeds number of rows in array
                    {
                        break;
                    }
                    tile1Column = 0;
                }
            }


            //converts recieved int array into tile array
            for (int row = 0; row < level1Tiles.GetLength(0); row++)
            {
                for (int column = 0; column < level1Tiles.GetLength(1); column++)
                {
                    level1MapTile[row, column] = new Tile(row, column, 50, 50, level1Tiles[row, column]);
                }
            }

            //finds the start tile for the enemies
            foreach (Tile obj in level1MapTile)
            {
                if (obj.TileValue == 2)
                {
                    startTile1 = obj;
                }
            }


            // values for first stage
            if (level == 1)
            {
                enemyNum = (level + 1) * 10 / 2;
                money    = 1000;
            }
            #endregion

            #region Load Map 2
            StreamReader load2 = new StreamReader("FinalExampleMap2.txt");
            string       line2;
            int          tile2Row    = 0;
            int          tile2Column = 0;
            level2Tiles   = new int[10, 15];
            level2MapTile = new Tile[10, 15];
            while ((line2 = load2.ReadLine()) != null)
            {
                if (line2 == "")//ignores the \n commands to split up rows in the array
                {
                    continue;
                }
                else
                {
                    char[] rowTiles = line2.ToCharArray();
                    foreach (char tile in rowTiles)
                    {
                        int    type    = 0;
                        string tileStr = tile.ToString();
                        int.TryParse(tileStr, out type);
                        level2Tiles[tile2Row, tile2Column] = type;
                        tile2Column++;
                    }
                    tile2Row++;
                    if (tile2Row > 9) //autobreaks if the loop exceeds number of rows in array
                    {
                        break;
                    }
                    tile2Column = 0;
                }
            }
            //converts recieved int array into tile array
            for (int row = 0; row < level2Tiles.GetLength(0); row++)
            {
                for (int column = 0; column < level2Tiles.GetLength(1); column++)
                {
                    level2MapTile[row, column] = new Tile(row, column, 50, 50, level2Tiles[row, column]);
                }
            }

            //finds the start tile for the enemies
            foreach (Tile obj in level2MapTile)
            {
                if (obj.TileValue == 2)
                {
                    startTile2 = obj;
                }
            }

            #endregion
        }
Exemple #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            font = Content.Load <SpriteFont>("mainFont");

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            //GUI content----------------------------------------------------------------------------------//
            //font
            font = Content.Load <SpriteFont>("Arial"); //TEMP FONT

            //map                                                                                          //
            Texture2D mapImage = Content.Load <Texture2D>("GUI_Assets/mapassets3type.png");                 //

            mapGraph = new GUI_StatGraphics(mapImage, new Point(150, 50), 3, 1, 3, "ExampleMap1.txt");      //
            //
            //tower                                                                                        //
            Texture2D towerImage = Content.Load <Texture2D>("GUI_Assets/towerplaceholder");                 //

            //tower position vector should be tower position property from tower class                     //
            towerGraph = new GUI_Anim(towerImage, new Point(150, 50), 3, 1, 3, 1000);     //
            //
            //enemy                                                                                        //
            Texture2D enemyImage = Content.Load <Texture2D>("GUI_Assets/enemyplaceholder");                 //

            //enemy position vector should be enemy position property from enemy class                     //
            enemyGraph = new GUI_Anim(enemyImage, new Point(150, 50), 3, 1, 3, 1000);     //


            //listing                                                                                     //
            Texture2D listingImage = Content.Load <Texture2D>("GUI_Assets/storelistingplaceholder");             //

            listing1 = new GUI_StatGraphics(listingImage, new Point(150, 150), 1, 1, 1, new Vector2(450, 500));  //
            listing2 = new GUI_StatGraphics(listingImage, new Point(150, 150), 1, 1, 1, new Vector2(550, 500));  //
            listing3 = new GUI_StatGraphics(listingImage, new Point(150, 150), 1, 1, 1, new Vector2(650, 500));  //
            //store                                                                                        //
            Texture2D backStoreImage = Content.Load <Texture2D>("GUI_Assets/storebackplaceholder");              //

            storeBack = new GUI_StatGraphics(backStoreImage, new Point(750, 100), 1, 1, 1, new Vector2(0, 500)); //

            StreamReader load = new StreamReader("ExampleMap1.txt");
            string       line;
            int          tileRow    = 0;
            int          tileColumn = 0;

            tiles   = new int[10, 15];
            mapTile = new Tile[10, 15];
            while ((line = load.ReadLine()) != null)
            {
                if (line == "")//ignores the \n commands to split up rows in the array
                {
                    continue;
                }
                else
                {
                    char[] rowTiles = line.ToCharArray();
                    foreach (char tile in rowTiles)
                    {
                        int    type    = 0;
                        string tileStr = tile.ToString();
                        int.TryParse(tileStr, out type);
                        tiles[tileRow, tileColumn] = type;
                        tileColumn++;
                    }
                    tileRow++;
                    if (tileRow > 9) //autobreaks if the loop exceeds number of rows in array
                    {
                        break;
                    }
                    tileColumn = 0;
                }
            }


            //converts recieved int array into tile array
            for (int row = 0; row < tiles.GetLength(0); row++)
            {
                for (int column = 0; column < tiles.GetLength(1); column++)
                {
                    mapTile[row, column] = new Tile(row * 50, column * 50, 50, 50, tiles[row, column]);
                }
            }
        }