public DraggableItem(Level a_Level, int newSlot) { m_Input = a_Level.Input; currState = State.Static; m_bButtonPressedOnMe = false; slot = newSlot; }
public TaskDescription(Level level, Vector2 a_Position) { Task.OnCreate += NewTask; m_level = level; m_Position = a_Position; m_CurrState = State.DISPLAY; LoadContent(); }
public CardOrganizer(Level a_Level) { m_Level = a_Level; Element.OnCast += Element_OnCast; Task.OnCreate += NewTask; m_State = State.Static; m_arrNewCards = new List<Card>(); m_arrCards = new List<Card>(); }
public Timer(Level level, int totalTime, int xPos, int yPos) { this.level = level; this.totalTime = totalTime; timeRemaining = this.totalTime; this.xPos = xPos; this.yPos = yPos; LoadContent(); }
public void Dispose() { m_Level = null; Element.OnCast -= Element_OnCast; Task.OnCreate -= NewTask; foreach (Card card in m_arrCards) { card.Dispose(); } m_arrCards = null; }
/// <summary> /// This is a private constructor in order to force you to create Elements by using /// the Element.ElementBuilder static class. /// </summary> /// <param name="a_Type"></param> /// <param name="a_Level"></param> private Element(Type a_Type, Level a_Level, int newSlot) : base(a_Level, newSlot) { m_Type = a_Type; Draggable = (m_Type != Type.Fizzle); LoadContent(a_Level); m_Level = a_Level; m_nHeight = 90; m_nWidth = 90; floatOffset = rand.NextDouble()*2*Math.PI; UserInput.OnDoubleClick += Mouse_OnDoubleClick; }
public Scorebar(Level l) { level = l; updated = false; UpdatePrestige(); for (int i = 0; i < saves.Length; i++) saves[i] = false; score = 10000; LoadContent(); }
public WorkSpace(Vector2 a_Position, Level a_Level, int slot) { m_Level = a_Level; m_Position = a_Position; LoadContent(a_Level, slot); m_nWidth = m_tBackground.Width; m_nHeight = m_tBackground.Height; m_center = m_Position; m_center.X = this.m_Position.X + (m_nWidth / 4); m_center.Y = this.m_Position.Y + (m_nHeight / 4); Element.ElementBuilder.OnBuild += ElementBuilt; Element.OnSpamDrop += Element_OnSpamDrop; }
public SaveSlot(Vector2 a_Position, Level a_Level, int slot) { active = false; m_Level = a_Level; m_Position = a_Position; LoadContent(a_Level, slot); m_nWidth = m_tBackground.Width; m_nHeight = m_tBackground.Height; m_center = m_Position; m_center.X = this.m_Position.X + (m_nWidth / 4); m_center.Y = this.m_Position.Y + (m_nHeight / 4); Element.ElementBuilder.OnBuild += ElementBuilt; }
public Card(Element.Type a_Type, Vector2 a_Position, Level a_Level, State a_State) { m_Type = a_Type; m_Position = a_Position; m_State = a_State; m_Level = a_Level; LoadContent(a_Level); m_nFadeInTimer = 0; if (a_Type <= Element.Type.Earth) value = 25; else if (a_Type <= Element.Type.Stone) value = 50; else if (a_Type <= Element.Type.Death) value = 75; else if (a_Type <= Element.Type.Tree) value = 100; else if (a_Type <= Element.Type.Hurricane) value = 125; else value = 150; }
public void Dispose() { Element.ElementBuilder.OnBuild -= ElementBuilt; m_btnClear.OnClick -= Button_OnClick; //if nobody else is connected, clean them up m_btnClear.Dispose(); currElement = null; m_Level = null; }
public void LoadContent(Level a_Level, int slot) { if (m_tBackground == null) { m_tBackground = a_Level.Content.Load<Texture2D>("UI/SaveSlot"); } m_btnClear = new UIButton(m_Position + new Vector2(70, -5), m_Level.Content, UIButton.Button.clearButton, true, slot); }
public void Dispose() { Element.ElementBuilder.OnBuild -= ElementBuilt; m_btnCast.OnClick -= Button_OnClick; m_btnClear.OnClick -= Button_OnClick; Element.OnSpamDrop -= Element_OnSpamDrop; m_btnCastAll.OnClick -= Button_OnClick; m_btnClearAll.OnClick -= Button_OnClick; //if nobody else is connected, clean them up if (m_btnClearAll.OnClick == null) { m_btnClearAll = null; m_btnCastAll = null; } m_btnClear.Dispose(); m_btnCast.Dispose(); currElement = null; m_Level = null; }
/// <summary> /// This will only return Fire, Water, Wind, and Earth elements, everything else /// needs to go through GetElement(...) to ensure that proper combining is adhered to /// </summary> /// <param name="a_Type"></param> /// <param name="a_Level"></param> /// <returns></returns> public static Element GetBaseElement(Element.Type a_Type, Level a_Level, int slot) { switch (a_Type) { case Element.Type.Water: case Element.Type.Wind: case Element.Type.Fire: case Element.Type.Earth: Element element = new Element(a_Type, a_Level, slot); if (OnBuild != null) OnBuild(element); return element; default: return null; } }
public void LoadContent(Level a_Level) { if (m_tBackground == null) { m_tBackground = a_Level.Content.Load<Texture2D>("Elements/element-token-backdrop"); m_tShine = a_Level.Content.Load<Texture2D>("Elements/element-token-shine"); m_Font = a_Level.Content.Load<SpriteFont>("UI/Lithos Pro Regular Element"); } if (ElementType != Type.Fizzle) { m_tIcon = a_Level.Content.Load<Texture2D>("Elements/symbols-token/" + ElementType.ToString().ToLower()); } }
/// <summary> /// Returns the appropriate Element object based on the two Elements provided to combine. /// the Elements provided will turn to Fizzle types since they should be discarded after /// they are used to create another Element. /// </summary> /// <param name="a_ElementOne"></param> /// <param name="a_ElementTwo"></param> /// <param name="a_level"></param> /// <returns>The resulting element. Fizzle if there is no valid combination.</returns> public static Element GetElement(Element a_ElementOne, Element a_ElementTwo, Level a_level, int slot) { Element.Type TypeA = a_ElementOne.m_Type; Element.Type TypeB = a_ElementTwo.m_Type; if (TypeA > TypeB) { Element.Type temp = TypeB; TypeB = TypeA; TypeA = temp; } a_ElementOne.Destroy(true); a_ElementTwo.Destroy(true); Element element = new Element(Map[(int)TypeA, (int)TypeB], a_level, slot); element.currHolder = Holder.Board; if (GetElementPermission(a_level.Score.Prestige) < element.GetElementTier()) element.Destroy(); if (OnBuild != null) OnBuild(element); return element; }
public void ManageMainMenu() { //Find out where the mouse currently is at, change selection accordingly #if !WINDOWS if (currentMainMenuIndex == -1) currentMainMenuIndex = 0; if (ButtonJustPressed(Buttons.DPadDown) || GamePad.GetState(selectedIndex).ThumbSticks.Left.Y < -0.3f && ThumbstickJustTilted(false) || GamePad.GetState(selectedIndex).ThumbSticks.Right.Y < -0.3f && ThumbstickJustTilted(true)) { currentMainMenuIndex = (currentMainMenuIndex + 1) % mainMenuItems.Length; } if (ButtonJustPressed(Buttons.DPadUp) || GamePad.GetState(selectedIndex).ThumbSticks.Left.Y > 0.3f && ThumbstickJustTilted(false) || GamePad.GetState(selectedIndex).ThumbSticks.Right.Y > 0.3f && ThumbstickJustTilted(true)) { currentMainMenuIndex = (currentMainMenuIndex + mainMenuItems.Length - 1) % mainMenuItems.Length; } #else bool hitMenu = false; for (int i = 0; i < mainMenuItems.Length; i++) { MenuSelection z = mainMenuItems[i]; MouseState currentMouseState = Mouse.GetState(); if (currentMouseState.Y < z.GetMouseSelectionArea().Bottom && currentMouseState.Y > z.GetMouseSelectionArea().Top && currentMouseState.X < z.GetMouseSelectionArea().Right && currentMouseState.X > z.GetMouseSelectionArea().Left) { currentMainMenuIndex = i; hitMenu = true; break; } } if (!hitMenu) currentMainMenuIndex = -1; #endif //When the mouse clicks, pick the selection. if (input.ButtonJustPressed(UserInput.MouseButton.Left) || ButtonJustPressed(Buttons.A) && currentMainMenuIndex != -1) { sfx_menuSelection.Play(); string selection = mainMenuItems[currentMainMenuIndex].GetTitle(); if (selection == "Play") { mainMenuCue.Stop(AudioStopOptions.Immediate); mainMenuSongStart = false; level = new Level(Services, graphics); if (!playedIntroduction) playedIntroduction = true; currentGameState = GameState.InGame; } else if (selection == "Instructions") { currentGameState = GameState.Instructions; } else if (selection == "Exit") { this.Exit(); } else { mainMenuCue.Stop(AudioStopOptions.Immediate); mainMenuSongStart = false; currentGameState = GameState.Credits; } } }
public void Dispose() { level = null; }
/// <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) { // TODO: Add your update logic here if (input.KeyJustPressed(Keys.F11)) graphics.ToggleFullScreen(); if (PlayerIndexChosen && !GamePad.GetState((PlayerIndex)selectedIndex).IsConnected) { PlayerIndexChosen = false; } if (!PlayerIndexChosen) { for (int i = (int)PlayerIndex.One; i < (int)PlayerIndex.Four; i++) { if (GamePad.GetState((PlayerIndex)i).Buttons.A == ButtonState.Pressed || GamePad.GetState((PlayerIndex)i).Buttons.B == ButtonState.Pressed || GamePad.GetState((PlayerIndex)i).Buttons.Back == ButtonState.Pressed || GamePad.GetState((PlayerIndex)i).Buttons.BigButton == ButtonState.Pressed || GamePad.GetState((PlayerIndex)i).Buttons.LeftShoulder == ButtonState.Pressed || GamePad.GetState((PlayerIndex)i).Buttons.LeftStick == ButtonState.Pressed || GamePad.GetState((PlayerIndex)i).Buttons.RightShoulder == ButtonState.Pressed || GamePad.GetState((PlayerIndex)i).Buttons.RightStick == ButtonState.Pressed || GamePad.GetState((PlayerIndex)i).Buttons.Start == ButtonState.Pressed || GamePad.GetState((PlayerIndex)i).Buttons.X == ButtonState.Pressed || GamePad.GetState((PlayerIndex)i).Buttons.Y == ButtonState.Pressed) { selectedIndex = (PlayerIndex)i; PlayerIndexChosen = true; break; } } } switch (currentGameState) { case GameState.MainMenu: if (input.KeyJustPressed(Keys.Escape) || ButtonJustPressed(Buttons.Back)) this.Exit(); if(!mainMenuSongStart) { try { gameSongStart = false; creditsSongStart = false; mainMenuCue = soundBank.GetCue("KnowThyself"); mainMenuCue.Play(); mainMenuSongStart = true; } catch (InvalidOperationException e) { } } ManageMainMenu(); break; case GameState.Instructions: if (input.KeyJustPressed(Keys.Escape) || instructionsScreen.IsMouseSelectedAndClicked || PressedAnything()) { sfx_menuSelection.Play(); if (isPaused) { currentGameState = GameState.InGame; instructionsScreen.ResetPosition(); } else { currentGameState = GameState.MainMenu; instructionsScreen.ResetPosition(); } } instructionsScreen.Update(gameTime); break; case GameState.Credits: if (input.KeyJustPressed(Keys.Escape) || creditsScreen.IsMouseSelectedAndClicked || PressedAnything()) { sfx_menuSelection.Play(); currentGameState = GameState.MainMenu; creditsScreen.ResetPosition(); creditsCue.Stop(AudioStopOptions.Immediate); creditsCue = soundBank.GetCue("Credits"); } creditsScreen.Update(gameTime); if (!creditsSongStart) { mainMenuSongStart = false; gameSongStart = false; creditsCue.Play(); creditsSongStart = true; } break; case GameState.InGame: UpdateGame(gameTime); if (level != null && level.GameEnded != 0) { MediaPlayer.Stop(); byte endGame = level.GameEnded; level.Dispose(); level = null; if (endGame == 1) { sfx_gameWin.Play(); currentGameState = GameState.GameClear; } else if (endGame == 2) { sfx_endGame.Play(); currentGameState = GameState.GameOver; } } if (!gameSongStart) { mainMenuSongStart = false; creditsSongStart = false; inGameCue = soundBank.GetCue("InGameMusic"); inGameCue.Play(); gameSongStart = true; } break; case GameState.GameClear: if (input.KeyJustPressed(Keys.Escape) || gameCompleteScreen.IsMouseSelectedAndClicked2 || PressedAnything()) { sfx_menuSelection.Play(); currentGameState = GameState.MainMenu; gameCompleteScreen = new NotificationScroll(Content, input, "UI/dialog-backdrop", "You Have Won!"); } else if (gameCompleteScreen.IsMouseSelectedAndClicked1) { sfx_menuSelection.Play(); level = new Level(Services, graphics); currentGameState = GameState.InGame; gameCompleteScreen = new NotificationScroll(Content, input, "UI/dialog-backdrop", "You Have Won!"); } gameCompleteScreen.Update(gameTime); break; case GameState.GameOver: if (input.KeyJustPressed(Keys.Escape) || gameOverScreen.IsMouseSelectedAndClicked2 || PressedAnything()) { sfx_menuSelection.Play(); currentGameState = GameState.MainMenu; gameOverScreen = new NotificationScroll(Content, input, "UI/dialog-backdrop", "Game Over"); } else if (gameOverScreen.IsMouseSelectedAndClicked1) { sfx_menuSelection.Play(); level = new Level(Services, graphics); currentGameState = GameState.InGame; gameOverScreen = new NotificationScroll(Content, input, "UI/dialog-backdrop", "Game Over"); } gameOverScreen.Update(gameTime); break; case GameState.Introduction: if (input.KeyJustPressed(Keys.Escape) || input.KeyJustPressed(Keys.Space) || input.ButtonJustPressed(UserInput.MouseButton.Left) || PressedAnything()) { logoPosition = new Vector2(95, 39); introTime = -1; } if (introTime <= 0) currentGameState = GameState.MainMenu; else { introTime -= gameTime.ElapsedGameTime.TotalSeconds; //System.Diagnostics.Debug.WriteLine("Current Time Remaining: " + introTime); //Increase visibility of buttons. fadeTimer -= gameTime.ElapsedGameTime.TotalSeconds; if (fadeTimer < 0) { alphaValue += fadeIncrement; } //Scroll up sky background if (skyPosition.Y >= 0) skyPosition -= new Vector2(0, 10); //Move ground position. if (groundPosition.Y >= -768) groundPosition -= new Vector2(0, 5); if(groundPosition.Y < 300) groundPosition -= new Vector2(0, 1); //Move mountains. if (mountainsPosition.Y >= -768) mountainsPosition -= new Vector2(0, 5); //Sea position. if (seaPosition.Y >= -768) seaPosition -= new Vector2(0, 5); //Move volcano. if (volcanoPosition.Y >= -768) volcanoPosition -= new Vector2(0, 5); //Move forest into position. if (forest1Position.Y < 768) forest1Position += new Vector2(0, 5); if (forest2Position.Y < 768) forest2Position += new Vector2(0, 5); if (forest3Position.Y < 768) forest3Position += new Vector2(0, 5); if (forest4Position.Y < 768) forest4Position += new Vector2(0, 5); //Move clouds into position. if (cloud1Position.Y < 768) cloud1Position += new Vector2(0, 4); if (cloud2Position.Y < 768) cloud2Position += new Vector2(0, 4); if (cloud3Position.Y < 768) cloud3Position += new Vector2(0, 4); if (cloud4Position.Y < 768) cloud4Position += new Vector2(0, 4); //Logo position. if (logoPosition.Y < 39) logoPosition += new Vector2(0, 1); else logoPosition = new Vector2(95, 39); } if (!mainMenuSongStart) { try { gameSongStart = false; creditsSongStart = false; mainMenuCue.Play(); mainMenuSongStart = true; } catch (InvalidOperationException e) { } } break; } input.Update(gameTime); base.Update(gameTime); prevGamePadState = GamePad.GetState(selectedIndex); }
public static Element GetElement(Element.Type type, Level level, int slot) { Element element = new Element(type, level, slot); element.currHolder = Holder.Board; if (GetElementPermission(level.Score.Prestige) < element.GetElementTier()) element.Destroy(); if (OnBuild != null) OnBuild(element); return element; }
public void Dispose() { m_Level = null; }
public ElementGenerator(Vector2 a_Position, Level a_Level, Element.Type a_Type) { m_Level = a_Level; m_Position = a_Position; m_Type = a_Type; }
public void Dispose() { Task.OnCreate -= NewTask; m_level = null; }
public void Dispose() { m_Level = null; currElement.OnDrop -= Element_OnDrop; currElement = null; }
public void LoadContent(Level a_Level, int slot) { if (m_tBackground == null) { m_tBackground = a_Level.Content.Load<Texture2D>("UI/mat"); } m_btnCast = new UIButton(m_Position + new Vector2(220, 24), m_Level.Content, UIButton.Button.castButton, true, slot); m_btnCast.OnClick += Button_OnClick; m_btnClear = new UIButton(m_Position + new Vector2(220, 72), m_Level.Content, UIButton.Button.clearButton, true, slot); m_btnClear.OnClick += Button_OnClick; a_Level.Add(m_btnCast); a_Level.Add(m_btnClear); if (m_btnCastAll == null) { m_btnCastAll = new UIButton(new Vector2(516, 695), m_Level.Content, UIButton.Button.castallButton, true, -1); m_btnClearAll = new UIButton(new Vector2(280, 695), m_Level.Content, UIButton.Button.clearallButton, true, -1); a_Level.Add(m_btnCastAll); a_Level.Add(m_btnClearAll); } m_btnCastAll.OnClick += Button_OnClick; m_btnClearAll.OnClick += Button_OnClick; }
private void UpdateGame(GameTime gameTime) { if (input.KeyJustPressed(Keys.Escape) || ButtonJustPressed(Buttons.Back) || ButtonJustPressed(Buttons.Start)) IsPaused = !IsPaused; if (isPaused) { //Find out where the mouse currently is at, change selection accordingly #if !WINDOWS if (currentPauseMenuIndex == -1) currentPauseMenuIndex = 0; if (ButtonJustPressed(Buttons.DPadDown) || GamePad.GetState(selectedIndex).ThumbSticks.Left.Y < -0.3f && ThumbstickJustTilted(false) || GamePad.GetState(selectedIndex).ThumbSticks.Right.Y < -0.3f && ThumbstickJustTilted(true)) { currentPauseMenuIndex = (currentPauseMenuIndex + 1) % pauseMenuItems.Length; } if (ButtonJustPressed(Buttons.DPadUp) || GamePad.GetState(selectedIndex).ThumbSticks.Left.Y > 0.3f && ThumbstickJustTilted(false) || GamePad.GetState(selectedIndex).ThumbSticks.Right.Y > 0.3f && ThumbstickJustTilted(true)) { currentPauseMenuIndex = (currentPauseMenuIndex + pauseMenuItems.Length - 1) % pauseMenuItems.Length; } #else bool hitMenu = false; for (int i = 0; i < pauseMenuItems.Length; i++) { MenuSelection z = pauseMenuItems[i]; MouseState currentMouseState = Mouse.GetState(); if (currentMouseState.Y < z.GetMouseSelectionArea().Bottom && currentMouseState.Y > z.GetMouseSelectionArea().Top && currentMouseState.X < z.GetMouseSelectionArea().Right && currentMouseState.X > z.GetMouseSelectionArea().Left) { currentPauseMenuIndex = i; hitMenu = true; } } if (!hitMenu) currentPauseMenuIndex = -1; #endif //When the mouse clicks, pick the selection. if ((input.ButtonJustPressed(UserInput.MouseButton.Left) || ButtonJustPressed(Buttons.A)) && currentPauseMenuIndex != -1) { sfx_menuSelection.Play(); string selection = pauseMenuItems[currentPauseMenuIndex].GetTitle(); if (selection == "Resume Game") { IsPaused = false; } else if (selection == "Help") { currentGameState = GameState.Instructions; } else if (selection == "Return to Title") { level.Dispose(); level = null; currentGameState = GameState.MainMenu; IsPaused = false; inGameCue.Stop(AudioStopOptions.Immediate); } else { this.Exit(); } } } else if (level.Score.NeedsAdvancedNotification) { if (input.ButtonJustPressed(UserInput.MouseButton.Left) || SageGame.PressedAnything()) { level.Score.SawAdvancedNotification = true; level.Score.NeedsAdvancedNotification = false; //System.Diagnostics.Debug.WriteLine("Stuff should now be not drawn"); } } else { ManageUI(gameTime); if (level != null) { level.Update(gameTime); } } }
public void LoadContent(Level a_Level) { if (m_tarrBackgrounds == null) { m_tarrBackgrounds = new Texture2D[5]; m_tarrBackgrounds[(int)State.ReallyDisabled] = a_Level.Content.Load<Texture2D>("Elements/element-card-dim2"); m_tarrBackgrounds[(int)State.Activated] = a_Level.Content.Load<Texture2D>("Elements/element-card-lit"); m_tarrBackgrounds[(int)State.Available] = a_Level.Content.Load<Texture2D>("Elements/element-card-normal"); m_tarrBackgrounds[(int)State.Disabled] = a_Level.Content.Load<Texture2D>("Elements/element-card-dim1"); m_tarrBackgrounds[(int)State.Disappear] = m_tarrBackgrounds[(int)State.Activated]; m_Font = a_Level.Content.Load<SpriteFont>("UI/Lithos Pro Regular Element"); } if (m_Type != Element.Type.Fizzle) { try { m_tIcon = a_Level.Content.Load<Texture2D>("Elements/symbols-card/" + m_Type.ToString().ToLower()); } catch (ContentLoadException e) { m_tIcon = null; } } }
public static void MoveGameLoc(bool horiz, bool down, bool right, Level level) { if (!horiz) { if (down) { gameSelectedIndex = (gameSelectedIndex + 4) % 12; } else { gameSelectedIndex = (gameSelectedIndex + 8) % 12; } } else { if (right) { gameSelectedIndex = (gameSelectedIndex + 1) % 4 + gameSelectedIndex / 4*4; } else { gameSelectedIndex = (gameSelectedIndex + 3) % 4 + gameSelectedIndex / 4*4; } } if (gameSelectedIndex >= 8) { int index = gameSelectedIndex - 8; bool miss = false; if (index == 0 && !level.saveOne.active) { miss = true; } else if (index == 1 && !level.saveTwo.active) { miss = true; } else if (index == 2 && !level.saveFour.active) { miss = true; } else if (index == 3 && !level.saveThree.active) { miss = true; } while (miss) { if (!horiz) { if (down) { gameSelectedIndex = (gameSelectedIndex + 4) % 12; } else { gameSelectedIndex = (gameSelectedIndex + 8) % 12; } } else { if (right) { gameSelectedIndex = (gameSelectedIndex + 1) % 4 + gameSelectedIndex / 4 * 4; } else { gameSelectedIndex = (gameSelectedIndex + 3) % 4 + gameSelectedIndex / 4 * 4; } } if (gameSelectedIndex < 8) { miss = false; } else { index = gameSelectedIndex - 8; miss = false; if (index == 0 && !level.saveOne.active) { miss = true; } else if (index == 1 && !level.saveTwo.active) { miss = true; } else if (index == 2 && !level.saveFour.active) { miss = true; } else if (index == 3 && !level.saveThree.active) { miss = true; } } } } }
public override void Dispose() { m_Level = null; UserInput.OnDoubleClick -= Mouse_OnDoubleClick; DropAreas = null; base.Dispose(); }