public void calculateDamage(skillData skill, GameObject attacker) { int damage = skill.damage; characterStatusController atkrStatus = attacker.GetComponent <characterStatusController>(); damageText.color = healColor; // Debug.Log("chara: " + charaName + ", skill: " + skill.skillName + // ", base skill dmg: " + damage); if (damage > 0) { damage += atkrStatus.currentAtk - currentDef; damageText.color = damageColor; } // Debug.Log("skill dmg: " + damage + ", currHP: " + currentHP + // ", newHP: " + (currentHP - damage)); currentHP -= damage; damageText.text = Mathf.Abs(damage).ToString(); damageTextTimer = damageTextTimeout; // Debug.Log("dmgText: " + damageText + ", damageTextTimer: " // + damageTextTimer); if (currentHP > maxHP) { currentHP = maxHP; } if (currentHP < 0) { currentHP = 0; GameObject.Find("gameController").GetComponent <battleController>().killCharacter(this.gameObject); } HPSlider.value = currentHP; }
public void useItem() { // GameObject[] playerItems // int itemIndex = selectedItem; itemData item = inventoryController.partyInventory[selectedItem].GetComponent <itemData>(); GameObject target = targets[selectedTarget]; characterStatusController targetStatus = target.GetComponent <characterStatusController>(); inventoryController.useItem(selectedItem); itemBattleController itemController = playerItems[selectedItemNum].GetComponent <itemBattleController>(); itemController.itemCount--; if (itemController.itemCount > 0) { itemController.itemCountText.text = itemController.itemCount.ToString(); } else { foreach (GameObject playerItem in playerItems) { Destroy(playerItem); } numItems = 0; loadItems(); } targetStatus.calculateDamage(item); targetMenu.SetActive(false); itemsMenu.SetActive(false); selectedItem = -1; selectedTarget = -1; }
public void loadEquipStats() { charaStatus = gameController.availCharas[selectedChara].GetComponent <characterStatusController>(); charaEquipManager = gameController.availCharas[selectedChara].GetComponent <equipManager>(); charaEquipManager.charaMenuController = this; currentChara = charaEquipManager.character; nameText.text = charaStatus.charaName; levelText.text = "Level: " + charaStatus.level; hpText.text = "HP: " + charaStatus.currentHP + "/" + charaStatus.maxHP; mpText.text = "MP: " + charaStatus.currentMP + "/" + charaStatus.maxMP; expText.text = "Exp: " + charaStatus.currentExp + "/" + charaStatus.expToNextLvl; skillPointText.text = "Skill Points: " + charaStatus.skillPoints; strText.text = "Strength: " + charaStatus.strength; intText.text = "Intelligence: " + charaStatus.intelligence + ""; dexText.text = "Dexterity: " + charaStatus.dexterity + ""; agiText.text = "Agility: " + charaStatus.agility + ""; endurText.text = "Endurance: " + charaStatus.endurance + ""; luckText.text = "Luck: " + charaStatus.luck + ""; clarityText.text = "Clarity: " + charaStatus.clarity + ""; zenText.text = "Zen: " + charaStatus.zen + ""; atkText.text = "Attack: " + charaStatus.currentAtk + ""; defText.text = "Defense: " + charaStatus.currentDef + ""; magAtkText.text = "Magic Attack: " + charaStatus.magicAtk + ""; magDefText.text = "Magic Defense: " + charaStatus.magicDef + ""; evaText.text = "Evasion: " + charaStatus.evasion + ""; }
public void useSkill() { skillData skill = charaSkills[selectedSkill + 2]; GameObject target = targets[selectedTarget]; characterStatusController targetStatus = target.GetComponent <characterStatusController>(); battleSkillController skillController = skillItems[selectedSkill].GetComponent <battleSkillController>(); skillController.skillTimer = skillController.rechargeTime + skillController.castingTime; playerCharaStatuses[selectedCharacter].currentMP -= skill.MPCost; targetStatus.calculateDamage(skill, playerParty[selectedCharacter]); targetMenu.SetActive(false); skillsMenu.SetActive(false); selectedSkill = -1; selectedTarget = -1; }
public void createPreview() { charaPreview = Instantiate(charaPreviews[selectedChara], charaPreviewPos.position, charaPreviewPos.rotation) as GameObject; charaPreview.GetComponent <playerController>().enabled = false; charaPreview.GetComponent <Collider>().enabled = false; charaPreview.transform.parent = transform; if (!equipList.activeInHierarchy) { charaPreview.layer = 5; for (int i = 0; i < charaPreview.transform.childCount; i++) { Transform child = charaPreview.transform.GetChild(i); child.gameObject.layer = 5; } } charaStatus = gameController.availCharas[selectedChara].GetComponent <characterStatusController>(); nameText.text = charaStatus.charaName; levelText.text = "Level: " + charaStatus.level; hpText.text = "HP: " + charaStatus.currentHP + "/" + charaStatus.maxHP; mpText.text = "MP: " + charaStatus.currentMP + "/" + charaStatus.maxMP; expText.text = "Exp: " + charaStatus.currentExp + "/" + charaStatus.expToNextLvl; skillPointText.text = "Skill Points: " + charaStatus.skillPoints; strText.text = "Strength: " + charaStatus.strength; intText.text = "Intelligence: " + charaStatus.intelligence + ""; dexText.text = "Dexterity: " + charaStatus.dexterity + ""; agiText.text = "Agility: " + charaStatus.agility + ""; endurText.text = "Endurance: " + charaStatus.endurance + ""; luckText.text = "Luck: " + charaStatus.luck + ""; clarityText.text = "Clarity: " + charaStatus.clarity + ""; zenText.text = "Zen: " + charaStatus.zen + ""; atkText.text = "Attack: " + charaStatus.currentAtk + ""; defText.text = "Defense: " + charaStatus.currentDef + ""; magAtkText.text = "Magic Attack: " + charaStatus.magicAtk + ""; magDefText.text = "Magic Defense: " + charaStatus.magicDef + ""; evaText.text = "Evasion: " + charaStatus.evasion + ""; bonusText.text = "Bonus: "; }