public PartPickup(Body.BodyPart part, IMap map, Rectangle rect, int id, bool respawn) : base(map, rect, id) { _bodyPart = part; _objectType = _bodyPart.GetID(); _name = _bodyPart.GetName(); _respawn = respawn; }
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; }
public bool HasEquipped(BodyPart part) { if (part.Equals(BaseBody)) return true; for (int x = 0; x < Movement.Length; x++) { if (part.Equals(Movement[x])) { return true; } } for (int x = 0; x < Utility.Length; x++) { if (part.Equals(Utility[x])) { return true; } } for (int x = 0; x < Armor.Length; x++) { if (part.Equals(Armor[x])) { return true; } } for (int x = 0; x < Attacks.Length; x++) { if (part.Equals(Attacks[x])) { return true; } } return false; }
public void Unequip(BodyPart part) { 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; } } }
public bool TryEquip(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) { if (x == slot && Armor[x] != null && !Armor[x].Equals(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].Equals(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].Equals(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].Equals(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; }
public void RemovePart(BodyPart part) { //_bodyParts.Remove(part); //CalculateTotalBonus(); _body.Unequip(part); }
public bool HasPart(BodyPart part) { if(_inventory.Contains(part)) return true; if (_body.HasEquipped(part)) return true; return false; }
/* public void CalculateTotalBonus() { _completeBody.Clear(); //_completeBody.jumpBonus = 100f; //_completeBody.speedBonus = 60f; for (int x = 0; x < _bodyParts.Count; x++) _completeBody.Add(_bodyParts[x]); } */ public bool GivePart(BodyPart part) { /* for (int x = 0; x < _bodyParts.Count; x++) if (_bodyParts[x].GetID() == part.GetID()) return false; if (part.hasAttack) { for (int x = 0; x < _attackSlots.Length; x++) if (_attackSlots[x] == null) { EquipAttack(x, part); break; } } _bodyParts.Add(part); CalculateTotalBonus(); return true; */ if (!_body.TryEquip(-1, part)) _inventory.Add(part); return true; }