コード例 #1
0
 public Inventory(Texture2D invtxture, Texture2D selectedinventory)
 {
     this.invtxture = invtxture;
     this.selectedinventory = selectedinventory;
     this.armour = new Armour("", selectedinventory, 0, 0);
     this.weapon = new Weapon("", selectedinventory, 0, WeaponPower.no, 0);
     setsword();
 }
コード例 #2
0
 public void Update(GameTime gameTime)
 {
     sword.Update();
     foreach(Item i in items){
         i.Update();
     }
     if (InputManager.ks.IsKeyDown(Keys.L))
     {
         draw = true;
     }
     else
     {
         draw = false;
     }
     this.description = "";
     foreach (Item item in items)
     {
         if (item.Hitbox.Contains((int)(InputManager.mousePosition.X / Settings.Scale), (int)(InputManager.mousePosition.Y / Settings.Scale)))
         {
             this.description = item.getDescription();
             if (InputManager.ms.LeftButton == ButtonState.Pressed)
             {
                 if (!testing)
                 {
                     if (item.type == ItemType.Armour)
                     {
                         if (armour.name == "")
                         {
                             armour = (Armour) item;
                             item.togglequpited();
                             testing = true;
                         }
                         else
                         {
                             armour = (Armour)item;
                             item.togglequpited();
                             testing = true;
                             foreach (Item itemx in items)
                             {
                                 if (itemx.name == armour.name)
                                 {
                                     itemx.togglequpited();
                                 }
                             }
                         }
                     }
                     else if (item.type == ItemType.Weapon)
                     {
                         if (weapon.name == "")
                         {
                             weapon = (Weapon) item;
                             item.togglequpited();
                             testing = true;
                             setsword();
                         }
                         else
                         {
                             item.togglequpited();
                             testing = true;
                             foreach (Item itemx in items)
                             {
                                 if (itemx.name == weapon.name)
                                 {
                                     itemx.togglequpited();
                                 }
                             }
                             weapon = (Weapon)item;
                             setsword();
                         }
                     }
                 }
             }
             else
             {
                 testing = false;
             }
         }
     }
 }