예제 #1
0
        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);
        }
예제 #2
0
        public void ShowEquipment()
        {
            if (!Enabled)
            {
                Show();
            }
            EquipmentWindowComponent equipment = equipmentWindow.Component as EquipmentWindowComponent;

            equipment.SetEnabled(true);
            equipmentWindow.Show();
        }
예제 #3
0
        public void HideEquipment()
        {
            if (!inventoryWindow.Enabled)
            {
                Hide();
            }
            EquipmentWindowComponent equipment = equipmentWindow.Component as EquipmentWindowComponent;

            equipment.SetEnabled(false);
            equipmentWindow.Hide();
        }
예제 #4
0
 public void OnEquip(object sender, EventArgs args)
 {
     if (!(sender is InventoryItem))
     {
         return;
     }
     else
     {
         InventoryItem            item      = (InventoryItem)sender;
         EquipmentWindowComponent equipment = equipmentWindow.Component as EquipmentWindowComponent;
         equipment.EquipItem(item);
     }
 }
예제 #5
0
        public void EquipItem(InventoryItem item)
        {
            EquipmentWindowComponent equipment = equipmentWindow.Component as EquipmentWindowComponent;

            equipment.EquipItem(item);
        }
예제 #6
0
        public void RegisterStatChangeEvent(EventHandler evnt)
        {
            EquipmentWindowComponent equipment = (EquipmentWindowComponent)equipmentWindow.Component;

            equipment.Equipped += evnt;
        }