public void SetPlayerData() { playerHP.text = PlayerStat.health.ToString(); playerMP.text = PlayerStat.mana.ToString(); maxPlayerHP.text = PlayerStat.maxHealth.ToString(); maxPlayerMP.text = PlayerStat.maxMana.ToString(); for (int i = 0; i < moves.Count; i++) { moves[i].transform.GetChild(0).GetComponent <TMP_Text>().text = moveSet.getCurrentMoves()[i].getMoveBase().getMoveName().ToString(); moves[i].transform.GetChild(1).GetChild(1).GetComponent <TMP_Text>().text = moveSet.getCurrentMoves()[i].getMoveBase().GetMoveType().ToString(); if (moveSet.getCurrentMoves()[i].getMoveBase().getCostType() == costType.Hp) { var cost = Mathf.Round(moveSet.getCurrentMoves()[i].getMoveBase().getCost() + 1 * PlayerStat.health / 100); moves[i].transform.GetChild(1).GetChild(3).GetComponent <TMP_Text>().text = cost.ToString() + " Hp"; } else { moves[i].transform.GetChild(1).GetChild(3).GetComponent <TMP_Text>().text = moveSet.getCurrentMoves()[i].getMoveBase().getCost().ToString() + " Mana"; } } }
//-----------------------------Battle------------------------------------------ IEnumerator PerformPlayerMove(int moveNumber) { state = BattleState.Busy; var move = moveSet.getCurrentMoves()[moveNumber]; audioSource.PlayOneShot(move.getMoveBase().getAudio()); dialogueBox.ActivateDialogue(); //------------------------Player Move------------------------------- targetType moveType = move.getMoveBase().getTargetType(); if (moveType == targetType.Enemy) { player.PlayZoomInAnimation(ghostTarget[currentChooseTarget].GetPosition()); ghostTarget[currentChooseTarget].PlayHitAnimation(); int dmg = ghostTarget[currentChooseTarget].Ghost.TakeDmg(move.getMoveBase()); ghostTarget[currentChooseTarget].GetComponent <BattleHud>().UpdateUI(ghostTarget[currentChooseTarget].Ghost); if (move.getMoveBase().getMoveName() != "Attack") { yield return(dialogueBox.TypeDialogue($"Dara menggunakan {move.getMoveBase().getMoveName()} sebanyak {dmg.ToString()} Damage")); } else { yield return(dialogueBox.TypeDialogue($"Dara menyerang musuh sebanyak {dmg.ToString()} Damage")); } player.PlayZoomOutAnimation(); } if (moveType == targetType.Aoe) { int dmg = 0; for (int i = 0; i < ghostTarget.Count; i++) { ghostTarget[i].PlayHitAnimation(); dmg = ghostTarget[i].Ghost.TakeDmg(move.getMoveBase()); ghostTarget[i].GetComponent <BattleHud>().UpdateUI(ghostTarget[i].Ghost); } yield return(dialogueBox.TypeDialogue("Dara menyerang semua musuh")); } if (moveType == targetType.Self) { //heal persen var heal = (move.getMoveBase().getBaseDmg() * PlayerStat.maxHealth) / 100; PlayerStat.health += (int)heal; if (PlayerStat.health >= PlayerStat.maxHealth) { PlayerStat.health = PlayerStat.maxHealth; } yield return(dialogueBox.TypeDialogue($"Dara memulihkan {heal.ToString()} HP")); } //------------------------Player Move------------------------------- var moveBase = moveSet.getCurrentMoves()[moveNumber].getMoveBase(); player.MinusCost(moveBase); List <bool> deadGhostIndex = new List <bool>(); for (int i = 0; i < ghostTarget.Count; i++) { bool status = false; if (ghostTarget[i].Ghost.HP <= 0) { status = true; } deadGhostIndex.Add(status); } for (int i = 0; i < deadGhostIndex.Count; i++) { if (deadGhostIndex[i] == true) { dialogueBox.ActivateDialogue(); yield return(dialogueBox.TypeDialogue($"{ghostTarget[i].Ghost.Base.getName()} berhasil ditaklukan")); yield return(DeadEnemies(i)); deadGhostIndex.RemoveAt(i); i = 0; } } yield return(new WaitForSeconds(waitDialogue)); StartCoroutine(EnemyMove()); }