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); }
/// <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(); }
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)); }
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(); }
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; }
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; }
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; }
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)); }
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; }
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); }
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); }
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); }
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); }
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; }
virtual public bool Update(MouseHandler mouse, IMenu sender) { return(false); }
public virtual bool Update(MouseHandler mouse, IMenu sender) { return false; }