private void TestDialogueSystem() { foreach (NPC npc in npcs) { if (npc.canInteract()) { ContentManager content = gameRef.Content; Texture2D tooltipBackground = content.Load <Texture2D>(@"GUI\Inventory\Tooltip\background-v2"); Texture2D tooltipBorder = content.Load <Texture2D>(@"GUI\Inventory\Tooltip\border-v6"); SpriteFont font = content.Load <SpriteFont>(@"Fonts\ItemDataFont"); Rectangle screenRectangle = gameRef.ScreenRectangle; SimpleHUDWindow dialogueWindow = new SimpleHUDWindow(font); DialogueComponent dialogueComponent = new DialogueComponent(font, gameRef.Content, npc); dialogueComponent.RegisterCommand(Keys.Escape, CloseDialogueWindow, ClickState.RELEASED); dialogueComponent.RegisterCommand(Keys.E, CloseDialogueWindow, ClickState.RELEASED); dialogueWindow.Size = new Vector2(screenRectangle.Width * (2f / 3f), (screenRectangle.Height / 2f) - 100); dialogueWindow.Position = new Vector2( (screenRectangle.Width - dialogueWindow.Size.X) / 2f, screenRectangle.Height / 2f + (screenRectangle.Height / 2f - dialogueWindow.Size.Y) / 2f); dialogueWindow.Title = npc.Name; dialogueWindow.BorderTexture = tooltipBorder; dialogueWindow.Component = dialogueComponent; dialogueWindow.Show(); dialogueComponent.DialogueSelected += dialogueManager.OnSelected; hudManager.Put(Window.DIALOGUE, dialogueWindow); isPaused = true; break; } } }
private SimpleHUDWindow CreateEquipmentWindow(SpriteFont font, ContentManager content, Texture2D border, Rectangle screenRectangle, InventoryManager inventoryManager) { SimpleHUDWindow equipmentWindow = new SimpleHUDWindow(font); //TODO: hardcoded title equipmentWindow.Title = "Equipment"; EquipmentWindowComponent equipmentComponent = new EquipmentWindowComponent(font, content, inventoryManager); equipmentComponent.RegisterUnequip(OnUnequip); equipmentComponent.RegisterReplace(OnUnequip); equipmentWindow.BorderTexture = border; //TODO: hardcoded size equipmentWindow.Size = new Vector2(400, 600); float positionOffset = (screenRectangle.Width / 2 >= equipmentWindow.Size.X) ? (screenRectangle.Width / 2 - equipmentWindow.Size.X) / 2 : 0; Vector2 position = new Vector2(positionOffset, (screenRectangle.Height - equipmentWindow.Size.Y) / 2); equipmentWindow.Position = position; equipmentWindow.Component = equipmentComponent; equipmentComponent.RepositionHolders(); return(equipmentWindow); }
public void Initialize() { foreach (IHUDWindow window in windows) { if (window is SimpleHUDWindow) { SimpleHUDWindow tempWindow = (SimpleHUDWindow)window; AInventoryComponent component = tempWindow.Component as AInventoryComponent; if (component != null) { component.InventoryManager = inventoryManager; } } } }
public void OnDisposeItem(object sender, EventArgs args) { //TODO: Kai bus sukurtas alert boxas, paklausti zaidejo, ar tikrai nori ismest daikta if (!IsMouseInside() && inventoryManager.DraggedItem != null) { // Null is passed into PopUpManager.CreateInstance method because it is // a singleton class and should be initialized somewhere else //TODO: hardcoded PopUp message SimpleHUDWindow window = WindowFactory.CreatePopup("Drop item?", OnPopupYes, OnPopupNo); this.enabled = false; window.Enabled = true; window.Visible = true; PopUpManager.CreateInstance(null).Push(window); } }
public static SimpleHUDWindow CreatePopup(string text, EventHandler onYesPressed, EventHandler onNoPressed) { SpriteFont font = content.Load <SpriteFont>(windowFontResource); SimpleHUDWindow popupWindow = new SimpleHUDWindow(font); PopupComponent popupComponent = new PopupComponent(font, content, text); popupComponent.RegisterYesEvent(onYesPressed); popupComponent.RegisterNoEvent(onNoPressed); //TODO: hardcoded popup size popupWindow.Size = new Vector2(330, 150); popupWindow.Position = new Vector2( (GameSettings.ScreenRectangle.Width - popupWindow.Size.X) / 2, (GameSettings.ScreenRectangle.Height - popupWindow.Size.Y) / 2); popupWindow.Component = popupComponent; popupWindow.BorderTexture = content.Load <Texture2D>(borderResource); return(popupWindow); }
public InventoryHUDWindow(GamePlayScreen parent, SpriteFont font, ContentManager content, Texture2D border, Rectangle screenRectangle) : base() { this.windows = new IHUDWindow[2]; this.inventoryManager = new InventoryManager(); this.inventoryManager.DisposeItem += OnDisposeItem; this.equipmentWindow = CreateEquipmentWindow(font, content, border, screenRectangle, inventoryManager); this.inventoryWindow = CreateInventoryWindow(font, content, border, screenRectangle, inventoryManager); this.windows[EQUIPMENT_INDEX] = equipmentWindow; this.windows[INVENTORY_INDEX] = inventoryWindow; this.commandManager = new CommandManager(); this.enabled = false; this.visible = false; this.parent = parent; //Initialize(); }
private SimpleHUDWindow CreateInventoryWindow(SpriteFont font, ContentManager content, Texture2D border, Rectangle screenRectangle, InventoryManager inventoryManager) { SimpleHUDWindow inventoryWindow = new SimpleHUDWindow(font); //TODO: hardcoded title inventoryWindow.Title = "Inventory"; InventoryWindowComponent inventoryComponent = new InventoryWindowComponent(font, content, inventoryManager); inventoryComponent.RegisterEquip(OnEquip); inventoryWindow.BorderTexture = border; //TODO: hardcoded size inventoryWindow.Size = new Vector2(400, 600); float positionOffset = (screenRectangle.Width / 2 >= inventoryWindow.Size.X) ? (screenRectangle.Width / 2 - inventoryWindow.Size.X) / 2 : 0; Vector2 position = new Vector2(screenRectangle.Width / 2 + positionOffset, (screenRectangle.Height - inventoryWindow.Size.Y) / 2); inventoryWindow.Position = position; inventoryWindow.Component = inventoryComponent; return(inventoryWindow); }
private void LoadWindows() { Rectangle screenRectangle = gameRef.ScreenRectangle; ContentManager content = Game.Content; SpriteFont font = content.Load <SpriteFont>(@"Fonts\ItemDataFont"); notifications = NotificationPopup.GetInstance(); notifications.Font = font; notifications.Size = new Vector2(300, 0); notifications.Position = new Vector2((screenRectangle.Width - notifications.Size.X) / 2, screenRectangle.Height * (3f / 4f)); Texture2D tooltipBackground = content.Load <Texture2D>(@"GUI\Inventory\Tooltip\background-v2"); Texture2D tooltipBorder = content.Load <Texture2D>(@"GUI\Inventory\Tooltip\border-v6"); SimpleHUDWindow pauseWindow = new SimpleHUDWindow(font); PauseGameComponent pauseMenu = new PauseGameComponent(font, gameRef.Content); pauseMenu.RegisterExitButtonEvent(new EventHandler(CloseWindow)); pauseMenu.RegisterResumeButtonEvent(new EventHandler(ClosePauseMenuWindow)); pauseMenu.RegisterCommand(Keys.Escape, ClosePauseMenuWindow, ClickState.RELEASED); //pauseMenu.BackgroundTexture = tooltipBackground; //TODO: hardcoded offset pauseMenu.ButtonOffset = new Vector2(100, 50); pauseWindow.BorderTexture = tooltipBorder; //TODO: hardcoded size pauseWindow.Size = new Vector2(400, 400); Vector2 position = new Vector2((screenRectangle.Width - pauseWindow.Size.X) / 2, (screenRectangle.Height - pauseWindow.Size.Y) / 2); pauseWindow.Position = position; pauseWindow.Component = pauseMenu; hudManager.Put(Window.PAUSE, pauseWindow); InventoryHUDWindow inventoryEquipmentWindow = new InventoryHUDWindow(this, font, gameRef.Content, tooltipBorder, screenRectangle); ItemPickedUp += inventoryEquipmentWindow.OnItemPickup; hudManager.Put(Window.INVENTORY, inventoryEquipmentWindow); commandManager.RegisterCommand(Keys.I, inventoryEquipmentWindow.ShowEquipment); commandManager.RegisterCommand(Keys.U, inventoryEquipmentWindow.ShowInventory); inventoryEquipmentWindow.RegisterCommand(Keys.I, inventoryEquipmentWindow.ToggleEquipment); inventoryEquipmentWindow.RegisterCommand(Keys.U, inventoryEquipmentWindow.ToggleInventory); inventoryEquipmentWindow.RegisterCommand(Keys.Escape, inventoryEquipmentWindow.Close); inventoryEquipmentWindow.RegisterStatChangeEvent(ChangePlayerStats); SimpleHUDWindow missionLogWindow = new SimpleHUDWindow(font); MissionLogComponent missionLogComponent = new MissionLogComponent(font, gameRef.Content); //TODO: hardcoded position and size missionLogWindow.Size = new Vector2(800, 600); position = new Vector2((screenRectangle.Width - missionLogWindow.Size.X) / 2, (screenRectangle.Height - missionLogWindow.Size.Y) / 2); missionLogWindow.Position = position; missionLogWindow.Component = missionLogComponent; missionLogWindow.BorderTexture = tooltipBorder; //TODO: hardcoded title missionLogWindow.Title = "Mission Log"; missionLogComponent.RegisterCommand(Keys.L, CloseMissionLogWindow, ClickState.RELEASED); missionLogComponent.RegisterCommand(Keys.Escape, CloseMissionLogWindow, ClickState.RELEASED); hudManager.Put(Window.MISSION_LOG, missionLogWindow); SimpleHUDWindow playerInfoWindow = new SimpleHUDWindow(font); PlayerInfoComponent playerInfoComponent = new PlayerInfoComponent(font, content, player); //TODO: hardcoded size and test position playerInfoWindow.Size = new Vector2(400, 300); position = new Vector2((screenRectangle.Width - playerInfoWindow.Size.X) / 2, (screenRectangle.Height - playerInfoWindow.Size.Y) / 2); playerInfoWindow.Position = position; playerInfoWindow.Component = playerInfoComponent; playerInfoWindow.BorderTexture = tooltipBorder; //TODO: hardcoded title playerInfoWindow.Title = "Player Stats"; playerInfoComponent.RegisterCommand(Keys.C, ClosePlayerInfoWindow, ClickState.RELEASED); playerInfoComponent.RegisterCommand(Keys.Escape, ClosePlayerInfoWindow, ClickState.RELEASED); hudManager.Put(Window.PLAYER_INFO, playerInfoWindow); gameInterface = new GameInterface(player, font); //TODO: hardcoded position gameInterface.Position = new Vector2(screenRectangle.Width - 200, screenRectangle.Height - 60); }