Пример #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 hurt(int damage)
 {
     health -= damage;
     isAngry = true;
     if (health <= 0 && speedoffset != Vector2.Zero)
     {
         deadparticles.position = pos;
         Game1.levellist[Game1.level - 1].deadenemyparticle(deadparticles, 100);
         speedoffset = Vector2.Zero;
         draw = false;
         Item add = new Weapon("", GameContent.fourpixels, 0, WeaponPower.no, 0);
         for (int i = 0; i < itemdrops.Count; i++)
         {
             if (Game1.rand.Next((int)itemdrops[itemdrops.Keys.ToList()[i]].X, (int)itemdrops[itemdrops.Keys.ToList()[i]].Y) == 0)
             {
                 add = itemdrops.Keys.ToList()[i];
                 break;
             }
         }
         if(add.name != ""){
             Game1.levellist[Game1.level - 1].mobdropsonfloor.Add(new ItemOnFloor(add, pos, .2f, .001f, 0.08f, 6.25f));
         }
     }
 }
Пример #3
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;
             }
         }
     }
 }