public static bool drinkPotion (PotionItem potionItem) { switch (potionItem.getPotionType()) { case PotionType.HEALTH: if (getHealth() < getMaxHealth()) { healHero(100); Util.disposeItem(potionItem); return true; } else return false; case PotionType.AGILITY: if (!isPotionAlreadyDrinked(potionItem.getPotionType())) { potionAgility = 10; drinkedPotions[potionItem.getPotionType()] = true; Util.disposeItem(potionItem); return true; } else return false; case PotionType.STRENGTH: if (!isPotionAlreadyDrinked(potionItem.getPotionType())) { potionStrength = 10; drinkedPotions[potionItem.getPotionType()] = true; Util.disposeItem(potionItem); return true; } else return false; case PotionType.ARMOR: if (!isPotionAlreadyDrinked(potionItem.getPotionType())) { potionArmor = 20; drinkedPotions[potionItem.getPotionType()] = true; Util.disposeItem(potionItem); return true; } else return false; default: Debug.Log("Unknown Potion"); return false; } }
private void setActionMsg (ItemHolder holder) { if (shopDescriptor && holder == null) {//Подразумевает, что мы находимся в магазине, и смотрим на полки (у них нет холдера) if (item.getCost() <= Vars.gold) { adjustFooter("Купить", false); } else { adjustFooter("Не хватает монет", true); } } else if (shopDescriptor) { adjustFooter("Продать", false); } else if (workbenchDescriptor) { hideActionMsg(); } else { switch (holder.getHolderType()) { case ItemHolderType.INVENTORY: case ItemHolderType.POTION_BAG: if (holder.getItem().getItemType() == ItemType.POTION) { tempPotion = (PotionItem)holder.getItem(); if ((tempPotion.getPotionType() == PotionType.HEALTH && Hero.getHealth() == Hero.getMaxHealth())) { adjustFooter("Здоровье макс.", true); } else if (Hero.isPotionAlreadyDrinked(tempPotion.getPotionType())) { adjustFooter("Нельзя выпить", true); } else { adjustFooter("Выпить", false); } } else if (holder.getItem().getItemType() == ItemType.MATERIAL) { hideActionMsg(); } else if (holder.getItem().getItemType() == ItemType.WEAPON) { adjustFooter("Взять", false); } else { adjustFooter("Надеть", false); } break; case ItemHolderType.EQUIPMENT: adjustFooter("Снять", false); break; } } }