Example #1
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);
            mainMenuButtons = new Texture2D[3];
            Map.map = Map.Parse("1.txt");
            debugFont = Content.Load<SpriteFont>("SpriteFont1");
            cam = new Camera();
            mainMenuButtons[0] = Content.Load<Texture2D>("PlayButton");
            mainMenuButtons[1] = Content.Load<Texture2D>("OptsButton");

            cellT = Content.Load<Texture2D>("Cell");

            font = Content.Load<SpriteFont>("SpriteFont1");

            towersText = new Texture2D[10];
            towersText[0] = Content.Load<Texture2D>("Tower");

            uiTextures = new Texture2D[10];
            uiTextures[0] = Content.Load<Texture2D>("planUI");

            clippedToMouse = new Tower(Point.Zero, Tower.Types.type1, towersText[0]);

            currentMenu = new Menus.MainMenu();
            gameUi = new InGameUI(uiTextures);
            ingamemenu = new Menus.InGameMenu(ref cam, "1.txt");
        }
Example #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);
            mainMenuButtons = new Texture2D[3];
            map = Cell.Parse("1.txt");
            cam = new Camera(map);
            mainMenuButtons[0] = Content.Load<Texture2D>("PlayButton");
            mainMenuButtons[1] = Content.Load<Texture2D>("OptsButton");

            cellT = Content.Load<Texture2D>("Cell");

            font = Content.Load<SpriteFont>("SpriteFont1");

            towersText = new Texture2D[10];
            towersText[0] = Content.Load<Texture2D>("Tower");

            uiTextures = new Texture2D[10];
            uiTextures[0] = Content.Load<Texture2D>("planUI");
            mainMenu = new IMenu(GameState.MainMenu);
            mainMenu.AddButton("Play", font, mainMenuButtons[0], GameState.LoadingMenu);
            mainMenu.AddButton("Options", font, mainMenuButtons[1], GameState.Options);
            mainMenu.AddButton("Quit", font, mainMenuButtons[0], GameState.Quit, Color.Yellow);

            inGameMenu = new IMenu(GameState.InGameMenu);
            inGameMenu.AddButton("Play", font, mainMenuButtons[0], GameState.InGame);
            inGameMenu.AddButton("Main Menu", font, mainMenuButtons[1], GameState.MainMenu);

            clippedToMouse = new Tower(Point.Zero, Tower.Types.type1, towersText[0]);

            currentMenu = mainMenu;
            gameUi = new InGameUI(uiTextures);
        }
Example #3
0
 public void Update(Camera cam, IMenu menu)
 {
     MouseState currentMouseState = Mouse.GetState();
     if (menu == null)
     {
         if (currentMouseState.X >= GraphicsDeviceManager.DefaultBackBufferWidth)
         {
             Mouse.SetPosition(GraphicsDeviceManager.DefaultBackBufferWidth, currentMouseState.Y);
         }
         else if (currentMouseState.X <= 0)
         {
             Mouse.SetPosition(0, currentMouseState.Y);
         }
         else if (currentMouseState.Y >= GraphicsDeviceManager.DefaultBackBufferHeight)
         {
             Mouse.SetPosition(currentMouseState.X, GraphicsDeviceManager.DefaultBackBufferHeight);
         }
         else if (currentMouseState.Y <= 0)
         {
             Mouse.SetPosition(currentMouseState.X, 0);
         }
         fakePos = new Point((int)cam.position.X + currentMouseState.X, (int)cam.position.Y + currentMouseState.Y);
     }
     position = new Point(currentMouseState.X, currentMouseState.Y);
     if (currentMouseState.LeftButton == ButtonState.Pressed)
     {
         if (oldMouseState.LeftButton == ButtonState.Released)
         {
             LeftClickState = ClickState.Clicked;
         }
         else
         {
             LeftClickState = ClickState.Held;
         }
     }
     else
     {
         if (oldMouseState.LeftButton == ButtonState.Released)
         {
             LeftClickState = ClickState.Released;
         }
         else
         {
             LeftClickState = ClickState.Releasing;
         }
     }
     if (currentMouseState.RightButton == ButtonState.Pressed)
     {
         if (oldMouseState.RightButton == ButtonState.Released)
         {
             RightClickState = ClickState.Clicked;
         }
         else
         {
             RightClickState = ClickState.Held;
         }
     }
     else
     {
         if (oldMouseState.RightButton == ButtonState.Released)
         {
             RightClickState = ClickState.Released;
         }
         else
         {
             RightClickState = ClickState.Releasing;
         }
     }
     oldMouseState = currentMouseState;
 }
Example #4
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.
            Map.map = Map.Parse(currentMap);
            cellsWithTower = new List<Cell>();
            spriteBatch = new SpriteBatch(GraphicsDevice);
            mainMenuButtons = new Texture2D[3];
            towersText = new Texture2D[10];
            uiTextures = new Texture2D[10];

            cam = new Camera();
            cam.position = new Vector2(0, Map.initialPathLocation.Y - GraphicsDeviceManager.DefaultBackBufferHeight / 2);

            debugFont = Content.Load<SpriteFont>("SpriteFont1");
            font = Content.Load<SpriteFont>("SpriteFont1");

            creepText = Content.Load<Texture2D>("Creep");

            wave = new CreepWave(30);

            towerRange = Content.Load<Texture2D>("range");

            missileText = Content.Load<Texture2D>("Missile");

            mainMenuButtons[0] = Content.Load<Texture2D>("PlayButton");
            mainMenuButtons[1] = Content.Load<Texture2D>("OptsButton");

            cellT = Content.Load<Texture2D>("Cell");

            towersText[0] = Content.Load<Texture2D>("Tower");

            uiTextures[0] = Content.Load<Texture2D>("UIParts/UI_Bottom");
            uiTextures[1] = Content.Load<Texture2D>("Icons/deleteIcon");
            uiTextures[2] = Content.Load<Texture2D>("Icons/addIcon");
            uiTextures[3] = Content.Load<Texture2D>("Icons/upgradeIcon");

            currentMenu = new Menus.MainMenu();
            options = new Menus.Options(graphics);
            gameUi = new InGameUI(uiTextures, ref cellsWithTower);
            ingamemenu = new Menus.InGameMenu(ref cam, ref cellsWithTower, currentMap);
            gameOverMenu = new Menus.GameOverMenu(ref cam, ref cellsWithTower, currentMap);

            clippedToMouse = new Tower(Point.Zero, Tower.Types.type1, towersText[0], 100, false);
        }