Exemplo n.º 1
0
 public PartPickup(Body.BodyPart part, IMap map, Rectangle rect, int id)
     : base(map, part, rect, id)
 {
     _bodyPart = part;
     offset.Y = (float)(-8 * (0.5f+0.5f*Math.Sin(_rect.X / 32.0f)));
     Move(offset);
 }
Exemplo n.º 2
0
Arquivo: Body.cs Projeto: MyEyes/Igorr
 public bool CanEquip(int slot, BodyPart part)
 {
     BodyPartType type = part.Type;
     switch (type)
     {
         case BodyPartType.Armor:
             for (int x = 0; x < Armor.Length; x++)
                 if ((Armor[x] == null && (slot < 0 || slot >= Armor.Length)) || x == slot)
                 {
                     return true;
                 }
             break;
         case BodyPartType.Attack:
             for (int x = 0; x < Attacks.Length; x++)
                 if ((Attacks[x] == null && (slot < 0 || slot >= Attacks.Length)) || x == slot)
                 {
                     return true;
                 }
             break;
         case BodyPartType.Movement:
             for (int x = 0; x < Movement.Length; x++)
                 if ((Movement[x] == null && (slot < 0 || slot >= Movement.Length)) || x == slot)
                 {
                     return true;
                 }
             break;
         case BodyPartType.Utility:
             for (int x = 0; x < Utility.Length; x++)
                 if ((Utility[x] == null && (slot < 0 || slot >= Utility.Length)) || x == slot)
                 {
                     return true;
                 }
             break;
         case BodyPartType.BaseBody:
             return true;
     }
     return false;
 }
Exemplo n.º 3
0
 /*
 public void CalculateTotalBonus()
 {
     _completeBody.Clear();
     //_completeBody.jumpBonus = 100f;
     _completeBody.speedBonus = 60f;
     for (int x = 0; x < _bodyParts.Count; x++)
         _completeBody.Add(_bodyParts[x]);
 }
  */
 public void GivePart(BodyPart part, bool autoequip)
 {
     //bool newPart = true;
     /*
     for (int x = 0; x < _bodyParts.Count; x++)
         if (_bodyParts[x].GetID() == part.GetID())
             newPart = false;
     if (newPart)
     {
      */
     if (!autoequip || !_body.TryEquip(-1, part))
         _inventory.Add(part);
     //_bodyParts.Add(part);
     //CalculateTotalBonus();
     //}
 }
Exemplo n.º 4
0
 public PartContainer(IMap map, BodyPart part, Rectangle rect, int id)
     : base(map, part.Texture, rect, id)
 {
     _part = part;
 }
Exemplo n.º 5
0
Arquivo: Body.cs Projeto: MyEyes/Igorr
        public void Unequip(BodyPart part, bool dropped = false)
        {
            changes++;
            if (owner.Map != null && dropped)
            {
                MoveItemMessage mim = (MoveItemMessage)owner.Map.ProtocolHelper.NewMessage(MessageTypes.MoveItem);
                mim.Slot = -1;
                mim.Quantity = 1;
                mim.id = part.GetID();
                mim.From = MoveTarget.Body;
                mim.Encode();
                owner.Map.SendMessage(mim, true);
            }

            for (int x = 0; x < Movement.Length; x++)
            {
                if (part.Equals(Movement[x]))
                {
                    Movement[x] = null;
                    return;
                }
            }

            for (int x = 0; x < Utility.Length; x++)
            {
                if (part.Equals(Utility[x]))
                {
                    Utility[x] = null;
                    return;
                }
            }

            for (int x = 0; x < Armor.Length; x++)
            {
                if (part.Equals(Armor[x]))
                {
                    Armor[x] = null;
                    return;
                }
            }

            for (int x = 0; x < Attacks.Length; x++)
            {
                if (part.Equals(Attacks[x]))
                {
                    Attacks[x] = null;
                    return;
                }
            }
        }
Exemplo n.º 6
0
Arquivo: Body.cs Projeto: MyEyes/Igorr
        public bool TryEquip(int slot, BodyPart part, bool dropped=false)
        {
            changes++;
            if (owner.Map != null && dropped)
            {
                MoveItemMessage mim = (MoveItemMessage)owner.Map.ProtocolHelper.NewMessage(MessageTypes.MoveItem);
                mim.Slot = slot;
                mim.Quantity = 1;
                mim.id = part.GetID();
                mim.To = MoveTarget.Body;
                mim.Encode();
                owner.Map.SendMessage(mim, true);
            }

            BodyPartType type = part.Type;
            switch (type)
            {
                case BodyPartType.Armor:
                    for (int x = 0; x < Armor.Length; x++)
                        if ((Armor[x] == null && (slot < 0 || slot >= Armor.Length)) || x == slot)
                        {
                            if (x == slot && Armor[x] != null && Armor[x] != part)
                                owner.Inventory.Add(Armor[x]);
                            Armor[x] = part as ArmorPart;
                            return true;
                        }
                    break;
                case BodyPartType.Attack:
                    for (int x = 0; x < Attacks.Length; x++)
                        if ((Attacks[x] == null && (slot < 0 || slot >= Attacks.Length)) || x == slot)
                        {
                            if (x == slot && Attacks[x] != null && Attacks[x] != part)
                                owner.Inventory.Add(Attacks[x]);
                            Attacks[x] = part as AttackPart;
                            return true;
                        }
                    break;
                case BodyPartType.Movement:
                    for (int x = 0; x < Movement.Length; x++)
                        if ((Movement[x] == null && (slot < 0 || slot >= Movement.Length)) || x == slot)
                        {
                            if (x == slot && Movement[x] != null && Movement[x] != part)
                                owner.Inventory.Add(Movement[x]);
                            Movement[x] = part as MovementPart;
                            return true;
                        }
                    break;
                case BodyPartType.Utility:
                    for (int x = 0; x < Utility.Length; x++)
                        if ((Utility[x] == null && (slot < 0 ||slot>=Utility.Length)) || x == slot)
                        {
                            if (x == slot && Utility[x]!=null && Utility[x]!=part)
                                owner.Inventory.Add(Utility[x]);
                            Utility[x] = part as UtilityPart;
                            return true;
                        }
                    break;
                case BodyPartType.BaseBody:

                    this.ChangeBaseBody(part as BaseBody);
                    return true;
            }
            return false;
        }