Exemplo n.º 1
0
 public static void Draw(SpriteBatch spriteBatch, IMenu current)
 {
     List<Buttons> currentMenuList = lesMenus.Find(bk => bk == current).buttonsList;
     foreach (var item in currentMenuList)
     {
         item.Draw(spriteBatch);
     }
 }
Exemplo n.º 2
0
 public static void Draw(SpriteBatch spriteBatch, IMenu current)
 {
     List<Buttons> currentMenuList = lesMenus.Find(bk => bk == current).buttonsList;
     foreach (var item in currentMenuList)
     {
         spriteBatch.Draw(item.texture, item.spacePos, item.couleur * item.Transparency);
     }
 }
Exemplo n.º 3
0
        public static IMenu UpdateMenu(MouseHandler mouse, IMenu current, KeyboardHandler kB)
        {
            List<Drawable> currentMenuList = lesMenus[lesMenus.IndexOf(current)].drawableList;

            if (kB.pressedKeysList.Contains(Keys.Escape))
            {
                current.EscapePressed();
                return lesMenus.Find(bk => bk.gameState == current.Escape);
            }

            foreach (var item in currentMenuList)
            {
                if (item.Update(mouse, current))
                    return lesMenus.Find(bk => bk.gameState == item.returnState);
            }
            return current;
        }
Exemplo n.º 4
0
        public override bool Update(MouseHandler mouse, IMenu sender)
        {
            if (spacePos.Contains(mouse.position))
            {
                transparency = 0.5f;
                if (mouse.LeftClickState == ClickState.Clicked)
                {
                    Clicked(sender);
                    if (returnState != GameState.None)
                        return true;
                }
            }
            else
                transparency = 1.0f;

            return false;
        }
Exemplo n.º 5
0
 public static IMenu UpdateMenu(MouseHandler mouse, IMenu current)
 {
     List<Buttons> currentMenuList = lesMenus[lesMenus.IndexOf(current)].buttonsList;
     foreach (var item in currentMenuList)
     {
         if (item.spacePos.Contains(mouse.position))
         {
             item.Transparency = 0.5f;
             if (mouse.LeftClickState == ClickState.Clicked)
             {
                 item.Clicked();
                 return lesMenus.Find(bk => bk.gameState == item.returnState);
             }
         }
         else
             item.Transparency = 1.0f;
     }
     return current;
 }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
0
 public static void Draw(SpriteBatch spriteBatch, IMenu current)
 {
     List<Drawable> currentMenuList = lesMenus.Find(bk => bk == current).drawableList;
     foreach (var item in currentMenuList)
         item.Draw(spriteBatch);
 }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
 private void UpClick(object sender, IMenu swag)
 {
     if ((Camera.speed + 200) <= 1800)
     {
         Camera.speed += 200;
         updateText();
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            //Check if the window is active
            if (IsActive)
            {
                keyboard.Update();
                mouse.Update(cam, currentMenu);

                //If the current menu = null  we are in game
                if (currentMenu == null)
                {
                    if (!gameUi.textBounds[0].Contains(mouse.position))
                    {
                        if (mouse.LeftClickState == ClickState.Clicked)
                            LeftClick();
                        else if (mouse.LeftClickState == ClickState.Released)
                            Hover();
                        if (mouse.RightClickState == ClickState.Clicked)
                            RightClick();
                    }
                    else
                    {
                        if (clippedToMouse != null)
                        {
                            clippedToMouse = null;
                        }
                    }

                    gameUi.Update(mouse, keyboard);

                    if (keyboard.pressedKeysList.Contains(Keys.Escape))
                        currentMenu = ingamemenu;
                    wave.Update(gameTime, cellsWithTower);
                    for (int i = 0; i < cellsWithTower.Count; i++)
                    {
                        cellsWithTower[i].contains.Update(gameTime);
                    }

                    cam.Update(mouse, gameTime, gameUi);
                    if (playerLife == 0)
                        currentMenu = gameOverMenu;
                }

                else
                {
                    var oldMenuState = currentMenu.gameState;
                    var newMenu = IMenu.UpdateMenu(mouse, currentMenu, keyboard);
                    if (newMenu != currentMenu)
                    {
                        currentMenu = newMenu;
                        if (currentMenu != null)
                        {
                            currentMenu.senderMenuState = oldMenuState;
                        }
                    }
                }
            }

            base.Update(gameTime);
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
 internal void Clicked(IMenu lol)
 {
     if (Clic != null)
     {
         Clic(this, lol);
     }
 }
Exemplo n.º 13
0
 public virtual bool Update(MouseHandler mouse, IMenu sender)
 {
     return false;
 }
Exemplo n.º 14
0
        public override bool Update(MouseHandler mouse, IMenu sender)
        {
            for (int i = 0; i < sliderPartsPos.Length; i++)
            {
                if (sliderPartsPos[i].spacePos.Contains(mouse.position))
                {
                    sliderPartsPos[i].transparency = 0.5f;
                    if (mouse.LeftClickState == ClickState.Clicked)
                    {
                        sliderPartsPos[i].Clicked(sender);
                        if (returnState != GameState.None)
                            return true;
                    }
                }
                else
                {
                    sliderPartsPos[i].transparency = 1.0f;
                }
            }

            return false;
        }
Exemplo n.º 15
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");
        }
Exemplo n.º 16
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (IsActive)
            {
                keyboard.Update();
                mouse.Update(cam, currentMenu);
                if(currentMenu == null)
                {
                        if (mouse.LeftClickState == ClickState.Clicked)
                            ClipTowersToCell(true);
                        if (mouse.RightClickState == ClickState.Clicked)
                            DeleteTower();
                        else
                            ClipTowersToCell(false);

                        if (keyboard.pressedKeysList.Contains(Keys.Escape))
                            currentMenu = ingamemenu;

                        cam.Update(mouse, gameTime);
                }

                else
                    currentMenu = IMenu.UpdateMenu(mouse, currentMenu, keyboard);
            }

            base.Update(gameTime);
        }
Exemplo n.º 17
0
 private void lessClick(object sender, IMenu swag)
 {
     if ((Camera.speed - 200) > 0)
     {
         Camera.speed -= 200;
         updateText();
     }
 }