private void Advance() { ui.SetDialogueText(toSay.dialogueText); if (!toSay.isInformation) { ui.SetDialogueTitle(toSay.dialogueName); ui.SetDialogueHeadSprite(toSay.dialogueHead); } else { ui.SetDialogueTitle(""); ui.SetDialogueHeadSprite(null); } if (toSay.animationTarget != null && toSay.animation != null) { toSay.animationTarget.GetComponent <Animator>().Play(toSay.animation); } if (toSay.addItem) { party.AddItemToInventory(toSay.itemToAdd, toSay.itemNumberToAdd); } if (toSay.removeItem) { party.RemoveItemFromInventory(toSay.itemToRemove, toSay.itemNumberToRemove); } }
private void UseItemOnTarget() { if (Databases.items[toUse].itemType == ItemType.Consumable) { ConsumableItem consumable = (ConsumableItem)Databases.items[toUse]; bool used = false; if (consumable.targetType == TargetType.One) { if (consumable.hpRestore > 0 && target.currentHealth < target.maxHealth) { target.RestoreHp(consumable.hpRestore); used = true; } if (consumable.mpRestore > 0 && target.currentMana < target.maxMana) { target.RestoreMp(consumable.mpRestore); used = true; } } else if (consumable.targetType == TargetType.AllFriendly) { foreach (GameObject member in party.playerParty) { UnitStats memberStats = member.GetComponent <UnitStats>(); if (memberStats.available == true) { if (consumable.hpRestore > 0 && memberStats.currentHealth < memberStats.maxHealth) { memberStats.RestoreHp(consumable.hpRestore); used = true; } if (consumable.mpRestore > 0 && memberStats.currentMana < memberStats.maxMana) { memberStats.RestoreMp(consumable.mpRestore); used = true; } } } } if (used) { party.RemoveItemFromInventory(toUse); sender.GetComponent <InventoryButtonController>().UpdateText(); ic.UpdateTargetPanel(); if (party.playerInventoryCount[toUse] < 1) { sender.GetComponent <InventoryButtonController>().DestroySelf(); ic.HideTargetPanel(); toUse = -1; sender = null; } target = null; } } else { //SHOW SOME KIND OF WARNING } }
private void UseItemOnTarget() { if (Databases.items[toUse].itemType == ItemType.Equipable) { string equipable = Databases.items[toUse].itemName; bool used = false; if (equipLoc == "weapon") { if (target.weapon != "") { party.AddItemToInventory(Databases.FindItem(target.weapon), 1); } target.weapon = equipable; used = true; } else if (equipLoc == "armor") { if (target.armor != "") { party.AddItemToInventory(Databases.FindItem(target.armor), 1); } target.armor = equipable; used = true; } else if (equipLoc == "acc1") { if (target.accessory1 != "") { party.AddItemToInventory(Databases.FindItem(target.accessory1), 1); } target.accessory1 = equipable; used = true; } else if (equipLoc == "acc2") { if (target.accessory2 != "") { party.AddItemToInventory(Databases.FindItem(target.accessory2), 1); } target.accessory2 = equipable; used = true; } if (used) { party.RemoveItemFromInventory(toUse); toUse = -1; equipLoc = ""; } target.CalculateModStats(); status.DisableEquipButtons(); status.UpdateStatusText(); } else { //SHOW SOME KIND OF WARNING } }
IEnumerator WaitAndThenGetHit(UnitStats target) { ui.DisableMainButtons(); ui.DisableTargetButtons(); bool used = false; if (item.itemType == ItemType.Consumable) { ConsumableItem consumable = (ConsumableItem)Databases.items[itemNum]; if (consumable.targetType == TargetType.One) { if (consumable.hpRestore > 0 && target.currentHealth < target.maxHealth) { target.RestoreHp(consumable.hpRestore); ui.ShowHealText(target, consumable.hpRestore); used = true; } if (consumable.mpRestore > 0 && target.currentMana < target.maxMana) { target.RestoreMp(consumable.mpRestore); used = true; } } else if (consumable.targetType == TargetType.AllFriendly) { foreach (UnitStats member in flow.friendlyUnits) { UnitStats memberStats = member.GetComponent <UnitStats>(); if (memberStats.available == true) { if (consumable.hpRestore > 0 && memberStats.currentHealth < memberStats.maxHealth) { memberStats.RestoreHp(consumable.hpRestore); ui.ShowHealText(memberStats, consumable.hpRestore); used = true; } if (consumable.mpRestore > 0 && memberStats.currentMana < memberStats.maxMana) { memberStats.RestoreMp(consumable.mpRestore); used = true; } } } } else if (consumable.targetType == TargetType.All) { if (consumable.hpRestore > 0 && flow.currentUnit.currentHealth < flow.currentUnit.maxHealth) { flow.currentUnit.RestoreHp(consumable.hpRestore); ui.ShowHealText(flow.currentUnit, consumable.hpRestore); used = true; } foreach (UnitStats member in flow.units) { UnitStats memberStats = member.GetComponent <UnitStats>(); if (memberStats.available == true) { if (consumable.hpRestore > 0 && memberStats.currentHealth < memberStats.maxHealth) { memberStats.RestoreHp(consumable.hpRestore); ui.ShowHealText(memberStats, consumable.hpRestore); used = true; } if (consumable.mpRestore > 0 && memberStats.currentMana < memberStats.maxMana) { memberStats.RestoreMp(consumable.mpRestore); used = true; } } } } } if (used) { party.RemoveItemFromInventory(itemNum); flow.currentUnit.battleAnimator.GetComponent <Animator>().Play("Thrust" + target.facing.ToString()); yield return(new WaitForSeconds(0.33f)); if (target.IsDead()) { target.battleAnimator.GetComponent <Animator>().Play("Die"); flow.units.Remove(target); } else { target.battleAnimator.GetComponent <Animator>().Play("Hit" + target.facing.ToString()); } yield return(new WaitForSeconds(1.0f)); } else { ui.EnableMainButtons(); } }