public void CloseSubMenu() { // Resets listboxes in case of a change in information (extra attacks etc) ResetListBoxes(subMenu.content); subMenu = new GameLibrary.Interface(); GameHandler.Inventory.ClearSelections(); }
private void ClickableComponent(GraphicObject component) { Rectangle TextureRectangle = new Rectangle((int)component.Position.X, (int)component.Position.Y, (int)component.Size.X, (int)component.Size.Y); if (TextureRectangle.Contains(InputHandler.MouseX, InputHandler.MouseY)&&InputHandler.LeftClickPressed) { #region Main Menu Actions if (component.Action.Equals("continue")) { currentScreen = Screens.Loading; lastScreen = Screens.Loading; temp = (Game.Content.Load<GameLibrary.Interface>("Interface/LoadingScreen")); } if (component.Action.Equals("Quit")) Game.Exit(); if (component.Action.Equals("Options")) subMenu = Game.Content.Load<GameLibrary.Interface>("Interface/SubMenuOptions"); if (component.Action.Equals("DeleteSubMenu")) CloseSubMenu(); if (component.Action.Equals("PlusRes")) { DisplayMode tmp = dm[ResID]; Configuration.Width = tmp.Width; Configuration.Height = tmp.Height; ResID++; if (ResID >= Game.GraphicsDevice.Adapter.SupportedDisplayModes.Count<DisplayMode>()) ResID = 0; } if (component.Action.Equals("MinusRes")) { DisplayMode tmp = dm[ResID]; Configuration.Width = tmp.Width; Configuration.Height = tmp.Height; if (ResID <= 0) ResID = (short)(Game.GraphicsDevice.Adapter.SupportedDisplayModes.Count<DisplayMode>()); ResID--; } if (component.Action.Equals("Fullscreen")) { Configuration.Toggle(); } if (component.Action.Equals("DeleteSaveGame")) SaveHandler.DeleteSave(); if (component.Action.Equals("openDeleteSaveBox")) subMenu = Game.Content.Load<GameLibrary.Interface>("Interface/DeleteSaveBox"); if (component.Action.Equals("OpenControls")) temp = Game.Content.Load<GameLibrary.Interface>("Interface/Help/Controls"); if (component.Action.Equals("OpenInstructions")) temp = Game.Content.Load<GameLibrary.Interface>("Interface/Help/Instructions"); if (component.Action.Equals("OpenHelpMenu")) { temp = Game.Content.Load<GameLibrary.Interface>("Interface/Help/HelpMenu"); prevScreen = currentScreen; } #endregion #region Customizer Actions // ADD BUILD IDs HERE if (component.Action.Equals("SelectStrengthBuild") || component.Action.Equals("SelectSpeedBuild") || component.Action.Equals("SelectEnduranceBuild")) { if (component.Action.Equals("SelectStrengthBuild")) GameHandler.Player = new Creature(0024, Game.Content.Load<Texture2D>("Sprites/handler"), GameHandler.TileMap.PlayerSpawn, 2f, 32, 32, 100); // Strength Build ugh i can't find the strength to continue my search if (component.Action.Equals("SelectSpeedBuild")) GameHandler.Player = new Creature(0012, Game.Content.Load<Texture2D>("Sprites/handler"), GameHandler.TileMap.PlayerSpawn, 2f, 32, 32, 100); // Speed Build if (component.Action.Equals("SelectEnduranceBuild")) GameHandler.Player = new Creature(0005, Game.Content.Load<Texture2D>("Sprites/handler"), GameHandler.TileMap.PlayerSpawn, 2f, 32, 32, 100); // Endurance Build //1024 == All traits GameHandler.Enabled = true; GameHandler.Visible = true; Interface.currentScreen = Screens.LevelMenu; SaveHandler.SaveGame(); // Save out creature details } #endregion #region Lab Menu Actions if (component.Action.Equals("Creature")) subMenu = Game.Content.Load<GameLibrary.Interface>("Interface/SubMenuCreatureInfo"); if (component.Action.Equals("OpenDNAInventory")) subMenu = Game.Content.Load<GameLibrary.Interface>("Interface/SubMenuDNAInventory"); if (component.Action.Equals("BreedCurrentSelection")) { GameHandler.Inventory.UseDNA(); ResetListBoxes(subMenu.content); subMenu = new GameLibrary.Interface(); ToggleAnimations(); } if (component.Action.Equals("exit")) Interface.currentScreen = Screens.LevelMenu; if (component.Action.Equals("ExitHelp")) { if (prevScreen == Screens.MainMenu) temp = Game.Content.Load<GameLibrary.Interface>("Interface/MainMenu"); else temp = Game.Content.Load<GameLibrary.Interface>("Interface/LevelMenu"); } #endregion #region Global Dial Actions if(component.Action.Equals("Inventory")) subMenu = Game.Content.Load<GameLibrary.Interface>("Interface/SubMenuInventory"); #endregion #region Inventory Actions if (component.Action.Equals("UseSelectedItem")) if(GameHandler.Inventory.SelectedItem != null) GameHandler.Inventory.UseItem(GameHandler.Inventory.SelectedItem.ID); if (component.Action.Equals("SelectApple")) if (GameHandler.Inventory.NumberOfApples > 0) GameHandler.Inventory.SetItem((int)Item.ItemName.Apple, Game.Content); if (component.Action.Equals("SelectGoldenApple")) if (GameHandler.Inventory.NumberOfGoldenApples > 0) GameHandler.Inventory.SetItem((int)Item.ItemName.Golden_Apple, Game.Content); if (component.Action.Equals("SelectChilli")) if (GameHandler.Inventory.NumberOfChilli > 0) GameHandler.Inventory.SetItem((int)Item.ItemName.Chilli, Game.Content); if (component.Action.Equals("SelectSpringWater")) if (GameHandler.Inventory.NumberOfSpringWater > 0) GameHandler.Inventory.SetItem((int)Item.ItemName.Spring_Water, Game.Content); if (component.Action.Equals("SelectHoney")) if (GameHandler.Inventory.NumberOfHoney > 0) GameHandler.Inventory.SetItem((int)Item.ItemName.Honey, Game.Content); #endregion #region Level Menu Actions if (component.Action.Equals("openExitBox")) subMenu = Game.Content.Load<GameLibrary.Interface>("Interface/ExitBox"); if (component.Action.Equals("exitGame")) Game.Exit(); #endregion #region Game Over Actions if (component.Action.Equals("OpenMenu")) temp = Game.Content.Load<GameLibrary.Interface>("Interface/MainMenu"); #endregion #region Battle Actions if (component.Action.Equals("Defend")) { BattleHandler.ActionSelected = true; BattleHandler.PlayerActionType = BattleHandler.ActionType.Defend; } if (component.Action.Equals("Flee")) { if (BattleHandler.CanSelectAction) { BattleHandler.ActionSelected = true; BattleHandler.PlayerActionType = BattleHandler.ActionType.Flee; } else { GameHandler.CurrentMessageBoxText = "You cannot do that right now!"; ShowMessageBox(); } } #endregion DebugLog.WriteLine(string.Format("Button Clicked Action = {0} ", component.Action)); } }
private void DrawTextComponent(TextObject component, GraphicObject parent) { component.offset.X = parent.Size.X / 100 * component.ioffset.X; component.offset.Y = parent.Size.Y / 100 * component.ioffset.Y; component.Init = true; //if (component.isCentered) string temp = ""; Vector2 off = component.offset; if (component.Text.StartsWith("@")) { if (component.Text == "@currentRes") temp = Configuration.Width.ToString() + "x" + Configuration.Height.ToString(); // Number Of Items if (component.Text == "@NumberOfApples") { if(GameHandler.Inventory.NumberOfApples > 0) temp = "x" + Convert.ToString(GameHandler.Inventory.NumberOfApples); } if (component.Text == "@NumberOfChilli") { if (GameHandler.Inventory.NumberOfChilli > 0) temp = "x" + Convert.ToString(GameHandler.Inventory.NumberOfChilli); } if (component.Text == "@NumberOfGoldenApples") { if (GameHandler.Inventory.NumberOfGoldenApples > 0) temp = "x" + Convert.ToString(GameHandler.Inventory.NumberOfGoldenApples); } if (component.Text == "@NumberOfHoney") { if (GameHandler.Inventory.NumberOfHoney > 0) temp = "x" + Convert.ToString(GameHandler.Inventory.NumberOfHoney); } if (component.Text == "@NumberOfSpringWater") { if (GameHandler.Inventory.NumberOfSpringWater > 0) temp = "x" + Convert.ToString(GameHandler.Inventory.NumberOfSpringWater); } if (component.Text == "@Fullscreen") { if (Configuration.Fullscreen) temp = "Windowed"; else temp = "Fullscreen"; } // -- HOOK UP PLAYER STATISTICS HERE -- \\ // Player Statistics if (component.Text == "@PlayerWeight") temp = "Weight: " + GameHandler.Player.Dominant.Weight.Level + "/" + GameHandler.Player.Dominant.Weight.Maximum; if (component.Text == "@PlayerStrength") temp = "Strength: " + GameHandler.Player.Dominant.Strength.Level + "/" + GameHandler.Player.Dominant.Strength.Maximum; if (component.Text == "@PlayerDexterity") temp = "Dexterity: " + GameHandler.Player.Dominant.Dexterity.Level + "/" + GameHandler.Player.Dominant.Dexterity.Maximum; if (component.Text == "@PlayerEndurance") temp = "Endurance: " + GameHandler.Player.Dominant.Endurance.Level + "/" + GameHandler.Player.Dominant.Endurance.Maximum; if (component.Text == "@PlayerHealth") temp = "Health: " + GameHandler.Player.Dominant.Health.Level + "/" + GameHandler.Player.Dominant.Health.Maximum; if (component.Text == "@PlayerSpeed") temp = "Speed: " + GameHandler.Player.Dominant.Speed.Level + "/" + GameHandler.Player.Dominant.Speed.Maximum; // Behavioural Traits if (component.Text == "@PlayerObedience") temp = "Obedience: " + GameHandler.Player.Dominant.Obedience.Level + "/" + GameHandler.Player.Dominant.Obedience.Maximum; if (component.Text == "@PlayerAggressiveness") temp = "Aggressiveness: " + GameHandler.Player.Dominant.Agressiveness.Level + "/" + GameHandler.Player.Dominant.Agressiveness.Maximum; if (component.Text == "@PlayerFocus") temp = "Focus: " + GameHandler.Player.Dominant.Focus.Level + "/" + GameHandler.Player.Dominant.Strength.Maximum; // Physical Traits if (component.Text == "@PlayerSpinalColumns") temp = "Spinal Columns: " + GameHandler.Player.Dominant.SpinalColumns.Level + "/" + GameHandler.Player.Dominant.SpinalColumns.Maximum; if (component.Text == "@PlayerTailColumns") temp = "Tail Columns: " + GameHandler.Player.Dominant.SpinalColumns.Level + "/" + GameHandler.Player.Dominant.SpinalColumns.Maximum; // -- HOOK UP SELECTED STATISTICS HERE (USING GAMEHANDLER.INVENTORY.SelectedDNA) -- \\ // Selected DNA Statistics if (GameHandler.Inventory.SelectedDNA != null) { if (component.Text == "@SelectedWeight") temp = "Weight: " + GameHandler.Inventory.SelectedDNA.Dominant.Weight.Level + "/" + GameHandler.Inventory.SelectedDNA.Dominant.Weight.Maximum; if (component.Text == "@SelectedStrength") temp = "Strength: " + GameHandler.Inventory.SelectedDNA.Dominant.Strength.Level + "/" + GameHandler.Inventory.SelectedDNA.Dominant.Strength.Maximum; if (component.Text == "@SelectedDexterity") temp = "Dexterity: " + GameHandler.Inventory.SelectedDNA.Dominant.Dexterity.Level + "/" + GameHandler.Inventory.SelectedDNA.Dominant.Dexterity.Maximum; if (component.Text == "@SelectedEndurance") temp = "Endurance: " + GameHandler.Inventory.SelectedDNA.Dominant.Endurance.Level + "/" + GameHandler.Inventory.SelectedDNA.Dominant.Endurance.Maximum; if (component.Text == "@SelectedHealth") temp = "Health: " + GameHandler.Inventory.SelectedDNA.Dominant.Health.Level + "/" + GameHandler.Inventory.SelectedDNA.Dominant.Health.Maximum; if (component.Text == "@SelectedSpeed") temp = "Speed: " + GameHandler.Inventory.SelectedDNA.Dominant.Speed.Level + "/" + GameHandler.Inventory.SelectedDNA.Dominant.Speed.Maximum; // Selected DNA Behavioural Traits if (component.Text == "@SelectedObedience") temp = "Obedience: " + GameHandler.Inventory.SelectedDNA.Dominant.Obedience.Level + "/" + GameHandler.Inventory.SelectedDNA.Dominant.Obedience.Maximum; if (component.Text == "@SelectedAggressiveness") temp = "Aggressiveness: " + GameHandler.Inventory.SelectedDNA.Dominant.Agressiveness.Level + "/" + GameHandler.Inventory.SelectedDNA.Dominant.Agressiveness.Maximum; if (component.Text == "@SelectedFocus") temp = "Focus: " + GameHandler.Inventory.SelectedDNA.Dominant.Focus.Level + "/" + GameHandler.Inventory.SelectedDNA.Dominant.Focus.Maximum; } else { if (component.Text == "@SelectedWeight") temp = "Weight: -"; if (component.Text == "@SelectedStrength") temp = "Strength: -"; if (component.Text == "@SelectedDexterity") temp = "Dexterity: -"; if (component.Text == "@SelectedEndurance") temp = "Endurance: -"; if (component.Text == "@SelectedHealth") temp = "Health: -"; if (component.Text == "@SelectedSpeed") temp = "Speed: -"; // Selected DNA Behavioural Traits if (component.Text == "@SelectedObedience") temp = "Obedience: -"; if (component.Text == "@SelectedAggressiveness") temp = "Aggressiveness: -"; if (component.Text == "@SelectedFocus") temp = "Focus: -"; } // Player CURRENT Health if (component.Text == "@PlayerCurrentHealth") temp = "Health: " + Convert.ToString(GameHandler.Player.Health) + "/" + GameHandler.Player.Dominant.Health.Level; // Enemy CURRENT Health if (component.Text == "@EnemyCurrentHealth") temp = "Health: " + Convert.ToString(BattleHandler.Enemy.Health) + "/" + BattleHandler.Enemy.Dominant.Health.Level; // Selected Creature Health if (component.Text == "@SelectedCreatureHealth") if(GameHandler.SelectedCreature != null) temp = "Health: " + Convert.ToString(GameHandler.SelectedCreature.Health) + "/" + GameHandler.SelectedCreature.Dominant.Health.Level; // Selected Item if (GameHandler.Inventory.SelectedItem != null) { if (component.Text == "@SelectedItemName") temp = GameHandler.Inventory.SelectedItem.Name; if (component.Text == "@SelectedItemDescription") temp = GameHandler.Inventory.SelectedItem.Description; } // Sign text if (component.Text == "@CurrentSignText") temp = GameHandler.CurrentMessageBoxText; // Battle text if (component.Text == "@LastPlayerMove") { if (BattleHandler.LastPlayerAction != null) temp = BattleHandler.LastPlayerAction; else temp = " "; } if (component.Text == "@LastEnemyMove") { if (BattleHandler.LastEnemyAction != null) temp = BattleHandler.LastEnemyAction; else temp = " "; } } else temp = component.Text; if (component.isCentered) off -= Game.Content.Load<SpriteFont>(component.Font).MeasureString(temp) / 2; if (parent.isClickable) { Rectangle TextureRectangle = new Rectangle((int)parent.Position.X, (int)parent.Position.Y, (int)parent.Size.X, (int)parent.Size.Y); if (TextureRectangle.Contains(new Point(InputHandler.MouseX, InputHandler.MouseY))) SpriteManager.DrawString(Game.Content.Load<SpriteFont>(component.Font), temp, parent.Position + off, new Color(component.highlightColor)); else SpriteManager.DrawString(Game.Content.Load<SpriteFont>(component.Font), temp, parent.Position + off, new Color(component.fontColor)); } else SpriteManager.DrawString(Game.Content.Load<SpriteFont>(component.Font), temp, parent.Position + off, new Color(component.fontColor)); }
public override void Update(GameTime gameTime) { if (currentScreen == Screens.Loading) { if (SaveHandler.LoadSave(GraphicsDevice, Game.Content) == false) // If no save exists, open the customizer currentScreen = Screens.CreatureCustomizer; else { currentScreen = Screens.LevelMenu; GameHandler.Enabled = true; GameHandler.Visible = true; } } if (showSign) { subMenu = Game.Content.Load<GameLibrary.Interface>("Interface/MessageBox"); showSign = false; } if (currentScreen != lastScreen) { // if screen has changed if (temp != null) ResetListBoxes(temp.content); // Reset current screen ListBoxes temp = new GameLibrary.Interface(); if (currentScreen == Screens.MainMenu) temp = (Game.Content.Load<GameLibrary.Interface>("Interface/MainMenu")); else if (currentScreen == Screens.CreatureCustomizer) temp = (Game.Content.Load<GameLibrary.Interface>("Interface/CreatureCustomization")); else if (currentScreen == Screens.LevelMenu) temp = (Game.Content.Load<GameLibrary.Interface>("Interface/LevelMenu")); else if (currentScreen == Screens.Loading) temp = (Game.Content.Load<GameLibrary.Interface>("Interface/LoadingScreen")); else if (currentScreen == Screens.Battle) temp = (Game.Content.Load<GameLibrary.Interface>("Interface/BattleScreen")); else if (currentScreen == Screens.Lab) temp = (Game.Content.Load<GameLibrary.Interface>("Interface/LabScreen")); else if (currentScreen == Screens.GameOver) temp = (Game.Content.Load<GameLibrary.Interface>("Interface/GameOverScreen")); else if (currentScreen == Screens.Victory) temp = (Game.Content.Load<GameLibrary.Interface>("Interface/VictoryScreen")); else temp = new GameLibrary.Interface(); subMenu = new GameLibrary.Interface(); } if (exitSubMenu) { subMenu = new GameLibrary.Interface(); exitSubMenu = false; } if (toggleAnimations) { ActivateAnimations(temp.content); toggleAnimations = false; } // Do any logic required for this type of screen lastScreen = currentScreen; if (subMenu.content.Count == 0) { // Check if content contains an animation foreach (Object2D obj in temp.content) if (obj is AnimatedObject) UpdateAnimation((obj as AnimatedObject), gameTime); UpdateComponent(temp.content, gameTime); } else UpdateComponent(subMenu.content, gameTime); base.Update(gameTime); }