public void useSupply(SupplySlot slot) { if (slot.item != null) { SupplyData data = (SupplyData)slot.item.itemData; if (fightProcessor.canUseSupply(data.type)) { bool toPlayer = data.type != SupplyType.GRENADE_FLASH && data.type != SupplyType.GRENADE_PARALIZE; StatusEffect statusEffect = getStatusEffectByType(data.type.toStatusEffectType(), toPlayer); FightEffectType fightEffectType = data.type.toFightEffectType(); if (data.type.isMedkit()) { fightEffectPlayer.playEffect(fightEffectType, Player.heal(data.value)); } else if (data.type.isGrenade()) { fightEffectPlayer.playEffectOnEnemy(fightEffectType, 0); statusEffect.addStatus(data.value, data.duration); } else if (data.type.isInjection()) { fightEffectPlayer.playEffect(fightEffectType, data.value); statusEffect.addStatus(data.value, data.duration); } else { Debug.Log("Unknown status effect type"); } Vector3 effectPos = toPlayer? playerStatusStartPosition: enemyStatusStartPosition; int activeEffects = -1; //вычитаем добавляемый эффект effList = toPlayer? playerStatusEffects: enemyStatusEffects; for (int i = 0; i < effList.Count; i++) { if (effList[i].isFired) { activeEffects++; } } if (toPlayer) { effectPos.x += activeEffects * playerStatusStep; } else { effectPos.y += activeEffects * enemyStatusStep; } statusEffect.transform.localPosition = effectPos; fightProcessor.skipMove(); FightProcessor.FIGHT_ANIM_PLAYER_DONE = false; slot.takeItem().destroy(); } } }
override protected void checkItemDrop() { if (Utils.hit != null && Utils.hit.name.Equals("Cell")) { InventoryCell cell = Utils.hit.GetComponent <InventoryCell>(); Inventory targetInv = cell.inventory; if (draggedItem.cell == null) { switch (draggedItem.kind) { case ItemKind.SHIP_EQUIPMENT: shipData.updateHullInfo(); break; case ItemKind.EQUIPMENT: playerData.updatePlayerInfo(); break; } } targetInv.addItemToCell(draggedItem, cell); } else if (Utils.hit != null && Utils.hit.name.StartsWith("HullSlot")) { HullSlot slot = Utils.hit.GetComponent <HullSlot> (); if (slot.slotType != getItemToHullSlotType(draggedItem.type)) { if (draggedItem.cell == null && draggedItem.slot == null) { if (inventory.gameObject.activeInHierarchy) { inventory.addItemToCell(draggedItem, draggedItem.cell); } shipData.updateHullInfo(); } else { draggedItem.returnToParent(); } } else if (slot.item == null) { setItemToSlot(slot); } else if (slot.item != null) { Item currItem = slot.takeItem(); if (draggedItem.slot != null && draggedItem.slot.slotType == slot.slotType) { draggedItem.slot.setItem(currItem); } else if (draggedItem.slot != null) { draggedItem.returnToParent(); } else if (inventory.gameObject.activeInHierarchy) { inventory.addItemToCell(currItem, draggedItem.cell); } shipData.updateHullInfo(); setItemToSlot(slot); } } else if (Utils.hit != null && Utils.hit.name.StartsWith("EquipmentSlot")) { EquipmentSlot slot = Utils.hit.GetComponent <EquipmentSlot> (); if (slot.slotType != getItemToEquipmentSlotType(draggedItem.type)) { if (draggedItem.cell == null && draggedItem.slot == null) { if (inventory.gameObject.activeInHierarchy) { inventory.addItemToCell(draggedItem, draggedItem.cell); } playerData.updatePlayerInfo(); } else { draggedItem.returnToParent(); } } else if (slot.item == null) { setItemToSlot(slot); } else if (slot.item != null) { Item currItem = slot.takeItem(); if (draggedItem.slot != null && draggedItem.slot.slotType == slot.slotType) { draggedItem.slot.setItem(currItem); } else if (draggedItem.slot != null) { draggedItem.returnToParent(); } else if (inventory.gameObject.activeInHierarchy) { inventory.addItemToCell(currItem, draggedItem.cell); } setItemToSlot(slot); playerData.updatePlayerInfo(); } } else if (Utils.hit != null && Utils.hit.name.StartsWith("Supply")) { SupplySlot slot = Utils.hit.GetComponent <SupplySlot>(); if (slot.item == null) { setItemToSlot(slot); } else { Item currItem = slot.takeItem(); if (draggedItem.slot != null) { draggedItem.slot.setItem(currItem); } else if (inventory.gameObject.activeInHierarchy) { inventory.addItemToCell(currItem, draggedItem.cell); } setItemToSlot(slot); } } else if (draggedItem.cell == null && draggedItem.slot == null) { if (inventory.gameObject.activeInHierarchy) { inventory.addItemToCell(draggedItem, null); } switch (draggedItem.kind) { case ItemKind.SHIP_EQUIPMENT: shipData.updateHullInfo(); break; case ItemKind.EQUIPMENT: playerData.updatePlayerInfo(); break; } } else { draggedItem.returnToParent(); } }