public void DressOn(InventoryItem it, bool isSync = true) { it.IsDressed = true; //首先检测有没有穿上相同的类型的装备 bool isDressed = false; InventoryItem inventoryItemDressed = null; switch (it.Inventory.EquipType) { case EquipType.Bracelet: if (braceletInventoryItem != null) { isDressed = true; inventoryItemDressed = braceletInventoryItem; } braceletInventoryItem = it; break; case EquipType.Cloth: if (clothInventoryItem != null) { isDressed = true; inventoryItemDressed = clothInventoryItem; } clothInventoryItem = it; break; case EquipType.Helm: if (helmInventoryItem != null) { isDressed = true; inventoryItemDressed = helmInventoryItem; } helmInventoryItem = it; break; case EquipType.Necklace: if (necklaceInventoryItem != null) { isDressed = true; inventoryItemDressed = necklaceInventoryItem; } necklaceInventoryItem = it; break; case EquipType.Ring: if (ringInventoryItem != null) { isDressed = true; inventoryItemDressed = ringInventoryItem; } ringInventoryItem = it; break; case EquipType.Shoes: if (shoesInventoryItem != null) { isDressed = true; inventoryItemDressed = shoesInventoryItem; } shoesInventoryItem = it; break; case EquipType.Weapon: if (weaponInventoryItem != null) { isDressed = true; inventoryItemDressed = weaponInventoryItem; } weaponInventoryItem = it; break; case EquipType.Wing: if (wingInventoryItem != null) { isDressed = true; inventoryItemDressed = wingInventoryItem; } wingInventoryItem = it; break; } //有: if (isDressed) { inventoryItemDressed.IsDressed = false; InventoryUI._instance.AddInvenetoryItem(inventoryItemDressed); } if (isSync) { if (isDressed) { inventoryItemDbController.UpdateInventoryItemDBList(it.InventoryItemDB, inventoryItemDressed.InventoryItemDB); } else { inventoryItemDbController.UpdateInventoryItemDB(it.InventoryItemDB); //更新DB } } OnPlayerInfoChanged(InfoType.Equip); //把已经存在的脱掉,放到背包 //没有: //直接穿上装备 } //穿上装备
public void DressOn(InventoryItem it) { it.IsDressed = true; //检测是否穿有相同的装备 bool isDress = false;//当前格子是否穿上 InventoryItem inventoryItemDressed = null; switch (it.Inventory.EquipTYPE) { case EquipType.Helm: if (helmItem != null) { isDress = true; inventoryItemDressed = helmItem; } helmItem = it; break; case EquipType.Cloth: if (clothItem != null) { isDress = true; inventoryItemDressed = clothItem; } clothItem = it; break; case EquipType.Weapon: if (weaponItem != null) { isDress = true; inventoryItemDressed = weaponItem; } weaponItem = it; break; case EquipType.Shoes: if (shoesItem != null) { isDress = true; inventoryItemDressed = shoesItem; } shoesItem = it; break; case EquipType.Necklace: if (necklaceItem != null) { isDress = true; inventoryItemDressed = necklaceItem; } necklaceItem = it; break; case EquipType.Bracelet: if (braceletItem != null) { isDress = true; inventoryItemDressed = braceletItem; } braceletItem = it; break; case EquipType.Ring: if (ringItem != null) { isDress = true; inventoryItemDressed = ringItem; } ringItem = it; break; case EquipType.Wing: if (wingItem != null) { isDress = true; inventoryItemDressed = wingItem; } wingItem = it; break; default: break; } //有装备穿上 if (isDress) { inventoryItemDressed.IsDressed = false; inventoryItemWillDressed = inventoryItemDressed; itemDBController.UpdateInventoryItemDBList(it.InventoryItemDB, inventoryItemDressed.InventoryItemDB); } else { itemDBController.UpdateInventoryItemDB(it.InventoryItemDB); } }