Exemple #1
0
        public static IMenu UpdateMenu(MouseHandler mouse, IMenu current, KeyboardHandler kB)
        {
            List <Buttons> currentMenuList = lesMenus[lesMenus.IndexOf(current)].buttonsList;

            if (kB.pressedKeysList.Contains(Keys.Escape))
            {
                current.EscapePressed();
                return(lesMenus.Find(bk => bk.gameState == current.Escape));
            }
            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);
        }
Exemple #2
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     // TODO: Add your initialization logic here
     base.Initialize();
     mouse    = new MouseHandler();
     keyboard = new KeyboardHandler();
 }
Exemple #3
0
        public void Update(MouseHandler mouse, GameTime gametime)
        {
            if (mouse.position.X > maxX)
                position.X += (float)(speed * gametime.ElapsedGameTime.TotalSeconds);

            else if (mouse.position.X < minX)
                position.X -= (float)(speed * gametime.ElapsedGameTime.TotalSeconds);

            if (mouse.position.Y > maxY)
                position.Y += (float)(speed * gametime.ElapsedGameTime.TotalSeconds);

            else if (mouse.position.Y < minY)
                position.Y -= (float)(speed * gametime.ElapsedGameTime.TotalSeconds);

            if (position.X + GraphicsDeviceManager.DefaultBackBufferWidth >= mapWidth)
                position.X = mapWidth - GraphicsDeviceManager.DefaultBackBufferWidth;

            else if (position.X < 0)
                position.X = 0;

            if (position.Y + GraphicsDeviceManager.DefaultBackBufferHeight >= mapHeight)
                position.Y = mapHeight - GraphicsDeviceManager.DefaultBackBufferHeight;

            else if (position.Y < 0)
                position.Y = 0;

            viewMatrix = Matrix.CreateTranslation(new Vector3(-position, 0));
        }
Exemple #4
0
 public void Update(MouseHandler mouse, KeyboardHandler kB)
 {
     foreach (var item in buttonList)
     {
         if ((item.spacePos.Contains(mouse.position) && mouse.LeftClickState == ClickState.Clicked) || kB.pressedKeysList.Contains(item.Hotkey))
         {
             item.Clicked();
             Game1.inGameState = item.returnState;
         }
         else if (mouse.LeftClickState == ClickState.Releasing || kB.releasedKeysList.Contains(item.Hotkey))
         {
             item.Released();
         }
     }
     SetUIText();
 }
Exemple #5
0
 public GameState UpdateGameState(MouseHandler mouse)
 {
     foreach (var item in buttons)
     {
         if (item.spacePos.Contains(mouse.position))
         {
             item.Transparency = 0.5f;
             if (mouse.LeftClickState == ClickState.Clicked)
             {
                 return item.returnState;
             }
         }
         else
             item.Transparency = 1.0f;
     }
     return GameState.MainMenu;
 }
Exemple #6
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;
        }
Exemple #7
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;
        }
Exemple #8
0
        public void Update(MouseHandler mouse, GameTime gametime)
        {
            if (mouse.position.X > maxX)
            {
                position.X += (float)(speed * gametime.ElapsedGameTime.TotalSeconds);
            }

            else if (mouse.position.X < minX)
            {
                position.X -= (float)(speed * gametime.ElapsedGameTime.TotalSeconds);
            }

            if (mouse.position.Y > maxY)
            {
                position.Y += (float)(speed * gametime.ElapsedGameTime.TotalSeconds);
            }

            else if (mouse.position.Y < minY)
            {
                position.Y -= (float)(speed * gametime.ElapsedGameTime.TotalSeconds);
            }

            if (position.X + GraphicsDeviceManager.DefaultBackBufferWidth >= mapWidth)
            {
                position.X = mapWidth - GraphicsDeviceManager.DefaultBackBufferWidth;
            }

            else if (position.X < 0)
            {
                position.X = 0;
            }

            if (position.Y + GraphicsDeviceManager.DefaultBackBufferHeight >= mapHeight)
            {
                position.Y = mapHeight - GraphicsDeviceManager.DefaultBackBufferHeight;
            }

            else if (position.Y < 0)
            {
                position.Y = 0;
            }

            viewMatrix = Matrix.CreateTranslation(new Vector3(-position, 0));
        }
Exemple #9
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;
 }
Exemple #10
0
 public GameState UpdateGameState(MouseHandler mouse)
 {
     foreach (var item in buttons)
     {
         if (item.spacePos.Contains(mouse.position))
         {
             item.Transparency = 0.5f;
             if (mouse.LeftClickState == ClickState.Clicked)
             {
                 return(item.returnState);
             }
         }
         else
         {
             item.Transparency = 1.0f;
         }
     }
     return(GameState.MainMenu);
 }
Exemple #11
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);
        }
Exemple #12
0
        override public 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);
        }
Exemple #13
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);
        }
Exemple #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;
        }
Exemple #15
0
 virtual public bool Update(MouseHandler mouse, IMenu sender)
 {
     return(false);
 }
Exemple #16
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     // TODO: Add your initialization logic here
     base.Initialize();
     mouse = new MouseHandler();
     keyboard = new KeyboardHandler();
 }
Exemple #17
0
 public void Update(MouseHandler mouse, KeyboardHandler kB)
 {
     foreach (var item in buttonList)
     {
         if ((item.spacePos.Contains(mouse.position) && mouse.LeftClickState == ClickState.Clicked) || kB.pressedKeysList.Contains(item.Hotkey))
         {
             item.Clicked();
             Game1.inGameState = item.returnState;
         }
         else if (mouse.LeftClickState == ClickState.Releasing || kB.releasedKeysList.Contains(item.Hotkey))
         {
             item.Released();
         }
     }
     SetUIText();
 }
Exemple #18
0
 public virtual bool Update(MouseHandler mouse, IMenu sender)
 {
     return false;
 }