Example #1
0
        public void Update(GameTime gameTime)
        {
            switch (tabState)
            {
            case (TabState.CharacterTab):
                charTab.Update(gameTime);
                if (KeyMouseReader.LeftClick())
                {
                    if (inventoryButton.Contains(new Vector2(KeyMouseReader.mouseState.X, KeyMouseReader.mouseState.Y)))
                    {
                        tabState = TabState.InventoryTab;
                    }
                    if (questLogButton.Contains(new Vector2(KeyMouseReader.mouseState.X, KeyMouseReader.mouseState.Y)))
                    {
                        tabState = TabState.QuestLogTab;
                    }
                }
                break;

            case (TabState.InventoryTab):
                invTab.Update(gameTime);
                if (KeyMouseReader.LeftClick())
                {
                    if (questLogButton.Contains(new Vector2(KeyMouseReader.mouseState.X, KeyMouseReader.mouseState.Y)))
                    {
                        tabState = TabState.QuestLogTab;
                    }
                    if (characterButton.Contains(new Vector2(KeyMouseReader.mouseState.X, KeyMouseReader.mouseState.Y)))
                    {
                        tabState = TabState.CharacterTab;
                    }
                }
                break;

            case (TabState.QuestLogTab):
                qlogTab.Update(gameTime);
                if (KeyMouseReader.LeftClick())
                {
                    if (inventoryButton.Contains(new Vector2(KeyMouseReader.mouseState.X, KeyMouseReader.mouseState.Y)))
                    {
                        tabState = TabState.InventoryTab;
                    }
                    if (characterButton.Contains(new Vector2(KeyMouseReader.mouseState.X, KeyMouseReader.mouseState.Y)))
                    {
                        tabState = TabState.CharacterTab;
                    }
                }
                break;
            }
        }
Example #2
0
 public void Update()
 {
     if (KeyMouseReader.KeyPressed(Keys.Space))
     {
         Item redItem  = (ItemDatabase.items[1]);;
         bool breakOut = false;
         for (int i = 0; i < xNumberOfSlots; i++)
         {
             for (int j = 0; j < yNumberOfSlots; j++)
             {
                 if (invSlot[i, j].InventoryFull == false)
                 {
                     invSlot[i, j].Item          = redItem;
                     invSlot[i, j].InventoryFull = true;
                     breakOut = true;
                     break;
                 }
             }
             if (breakOut == true)
             {
                 break;
             }
         }
     }
     if (KeyMouseReader.LeftClick())
     {
         if (ItemInHand != true)
         {
             for (int i = 0; i < xNumberOfSlots; i++)
             {
                 for (int j = 0; j < yNumberOfSlots; j++)
                 {
                     if (new Rectangle(invSlot[i, j].GraphicLocationX, invSlot[i, j].GraphicLocationY, 64, 64).Contains(KeyMouseReader.mouseState.Position))
                     {
                         if (invSlot[i, j].Item == null)
                         {
                             break;
                         }
                         itemInHand         = inPlayerHand.Item;
                         inPlayerHand.Item  = invSlot[i, j].Item;
                         invSlot[i, j].Item = itemInHand;
                         ItemInHand         = true;
                         if (invSlot[i, j].Item == null)
                         {
                             invSlot[i, j].InventoryFull = false;
                         }
                         else
                         {
                             invSlot[i, j].InventoryFull = true;
                         }
                         break;
                     }
                 }
             }
         }
         else
         {
             for (int i = 0; i < xNumberOfSlots; i++)
             {
                 for (int j = 0; j < yNumberOfSlots; j++)
                 {
                     if (new Rectangle(invSlot[i, j].GraphicLocationX, invSlot[i, j].GraphicLocationY, 64, 64).Contains(KeyMouseReader.mouseState.Position))
                     {
                         itemInHand         = inPlayerHand.Item;
                         inPlayerHand.Item  = invSlot[i, j].Item;
                         invSlot[i, j].Item = itemInHand;
                         if (inPlayerHand.Item == null)
                         {
                             ItemInHand = false;
                         }
                         if (invSlot[i, j].Item == null)
                         {
                             invSlot[i, j].InventoryFull = false;
                         }
                         else
                         {
                             invSlot[i, j].InventoryFull = true;
                         }
                     }
                 }
             }
         }
     }
 }