public void Unequip(PlayerInfo playerInfo) { //Debug.Log("调用了武器卸装函数"); if (!IsEqu) { throw new System.Exception("尚未装备该物品"); } /*if (!playerInfo.equipments.IsSdEquip && type == WeaponType.Shield) * { Debug.Log("副武器为空"); return "副武器为空"; } * if (!playerInfo.equipments.IsWpEquip && type != WeaponType.Shield) * { Debug.Log("武器为空"); return "武器为空"; }*/ IsEqu = false; playerInfo.ATK -= ATK; if (weaponType == WeaponType.Knife) { playerInfo.equipments.IsSdEquip = false; playerInfo.equipments.shield = null; //Debug.Log("卸下了副武器"); SystemMessages.AddMessage("卸下了副武器"); } else { playerInfo.equipments.IsWpEquip = false; playerInfo.equipments.weapon = null; //Debug.Log("卸下了主武器"); SystemMessages.AddMessage("卸下了主武器"); } if (enchant != null) { enchant.Unenchant(playerInfo); } if (suitEffect != null) { SuitEffectInfo sinfo = playerInfo.equipments.suitEffect.Find(s => s.SuittID == suitEffect.SuittID); if (sinfo != null) { sinfo.currentNum--; if (sinfo.currentNum <= 0) { playerInfo.equipments.suitEffect.Remove(sinfo); } sinfo.TryUnEffect(playerInfo); } } ItemInfo info = new ItemInfo(this); info.Quantity++; playerInfo.bag.itemList.Add(info); playerInfo.bag.Current_Size++; }
public void Equip(PlayerInfo playerInfo) { //Debug.Log("调用了防具装备函数"); if (IsEqu) { throw new System.Exception("已经装备了该物品"); } IsEqu = true; playerInfo.DEF += DEF; switch (armorType) { case ArmorType.Clothes: if (playerInfo.equipments.IsClEquip) { //Debug.Log("已经装备了衣服,因此"); playerInfo.equipments.clothes.Unequip(playerInfo); } playerInfo.equipments.IsClEquip = true; playerInfo.equipments.clothes = this; //Debug.Log("装备了衣服"); SystemMessages.AddMessage("装备了衣服"); break; case ArmorType.Helmet: if (playerInfo.equipments.IsHmEquip) { //Debug.Log("已经装备了头饰,因此"); playerInfo.equipments.helmet.Unequip(playerInfo); } playerInfo.equipments.IsHmEquip = true; playerInfo.equipments.helmet = this; //Debug.Log("装备了头饰"); SystemMessages.AddMessage("装备了头饰"); break; case ArmorType.WristBand: if (playerInfo.equipments.IsWBEquip) { //Debug.Log("已经装备了护腕,因此"); playerInfo.equipments.wristband.Unequip(playerInfo); } playerInfo.equipments.IsWBEquip = true; playerInfo.equipments.wristband = this; //Debug.Log("装备了护腕"); SystemMessages.AddMessage("装备了护腕"); break; case ArmorType.Shoes: if (playerInfo.equipments.IsShEquip) { //Debug.Log("已经装备了鞋履,因此"); playerInfo.equipments.shoes.Unequip(playerInfo); } playerInfo.equipments.IsShEquip = true; playerInfo.equipments.shoes = this; //Debug.Log("装备了鞋履"); SystemMessages.AddMessage("装备了鞋履"); break; } if (enchant != null) { enchant.Enchanting(playerInfo); } if (suitEffect != null) { if (playerInfo.equipments.suitEffect != null) { SuitEffectInfo sinfo = playerInfo.equipments.suitEffect.Find(s => s.SuittID == suitEffect.SuittID); if (sinfo != null) { sinfo.currentNum++; sinfo.TryEffect(playerInfo); } else { suitEffect.currentNum++; playerInfo.equipments.suitEffect.Add(suitEffect); } } else { suitEffect.currentNum++; playerInfo.equipments.suitEffect = new List <SuitEffectInfo> { suitEffect }; } } ItemInfo info = playerInfo.bag.itemList.Find(i => i.Item == this); info.Quantity--; playerInfo.bag.itemList.Remove(info); playerInfo.bag.Current_Size--; }
public void Unequip(PlayerInfo playerInfo) { //Debug.Log("调用了防具卸装函数"); if (!IsEqu) { throw new System.Exception("尚未装备该物品"); } IsEqu = false; playerInfo.DEF -= DEF; switch (armorType) { case ArmorType.Clothes: playerInfo.equipments.IsClEquip = false; playerInfo.equipments.clothes = null; //Debug.Log("卸下了衣服"); SystemMessages.AddMessage("卸下了衣服"); break; case ArmorType.Helmet: playerInfo.equipments.IsHmEquip = false; playerInfo.equipments.helmet = null; //Debug.Log("卸下了头饰"); SystemMessages.AddMessage("卸下了头饰"); break; case ArmorType.WristBand: playerInfo.equipments.IsWBEquip = false; playerInfo.equipments.wristband = null; //Debug.Log("卸下了护腕"); SystemMessages.AddMessage("卸下了护腕"); break; case ArmorType.Shoes: playerInfo.equipments.IsShEquip = false; playerInfo.equipments.shoes = null; //Debug.Log("卸下了鞋履"); SystemMessages.AddMessage("卸下了鞋履"); break; } if (enchant != null) { enchant.Unenchant(playerInfo); } if (suitEffect != null) { SuitEffectInfo sinfo = playerInfo.equipments.suitEffect.Find(s => s.SuittID == suitEffect.SuittID); if (sinfo != null) { sinfo.currentNum--; if (sinfo.currentNum <= 0) { playerInfo.equipments.suitEffect.Remove(sinfo); } sinfo.TryUnEffect(playerInfo); } } ItemInfo info = new ItemInfo(this); info.Quantity++; playerInfo.bag.itemList.Add(info); playerInfo.bag.Current_Size++; }
public void Equip(PlayerInfo playerInfo) { //Debug.Log("调用了武器装备函数"); if (IsEqu) { throw new System.Exception("已经装备了该物品"); } if (!CheckEquipAble(playerInfo)) { throw new System.Exception("武器不符,无法装备"); } IsEqu = true; playerInfo.ATK += ATK; if (this.weaponType == WeaponType.Knife) { if (playerInfo.equipments.IsSdEquip) { //Debug.Log("已经装备了副武器,因此"); playerInfo.equipments.shield.Unequip(playerInfo); } playerInfo.equipments.IsSdEquip = true; playerInfo.equipments.shield = this; //Debug.Log("装备了副武器"); SystemMessages.AddMessage("装备了副武器"); } else { if (playerInfo.equipments.IsWpEquip) { //Debug.Log("已经装备了主武器,因此"); playerInfo.equipments.weapon.Unequip(playerInfo); } playerInfo.equipments.IsWpEquip = true; playerInfo.equipments.weapon = this; //Debug.Log("装备了主武器"); SystemMessages.AddMessage("装备了主武器"); } if (enchant != null) { enchant.Enchanting(playerInfo); } if (suitEffect != null) { if (playerInfo.equipments.suitEffect != null) { SuitEffectInfo sinfo = playerInfo.equipments.suitEffect.Find(s => s.SuittID == suitEffect.SuittID); if (sinfo != null) { sinfo.currentNum++; sinfo.TryEffect(playerInfo); } else { suitEffect.currentNum++; playerInfo.equipments.suitEffect.Add(suitEffect); } } else { suitEffect.currentNum++; playerInfo.equipments.suitEffect = new List <SuitEffectInfo> { suitEffect }; } } ItemInfo info = playerInfo.bag.itemList.Find(i => i.Item == this); info.Quantity--; playerInfo.bag.itemList.Remove(info); playerInfo.bag.Current_Size--; }