private void AttackOpponent(SC_BasePokemon _attackPokemon, SC_PokemonMove _attackMove, SC_BasePokemon _defensePokemon) { isAbleToPress = false; if (canExit != true) { _attackMove.moveSound.Play(); } currentMenu = GlobalEnums.BattleMenus.Message; MessageState = GlobalEnums.MessageBoxState.Attack; attackMove = _attackMove; ManageMessageBox(attackMove); isWaitingForRespond = true; _attackMove.currPP--; float _lvl = (float)_attackPokemon.level; float _power = (float)attackMove.power; float _A = (float)_attackPokemon.attack; float _D = (float)_defensePokemon.defense; float _damage = (((((((2f * _lvl) / 5f) + 2f) * _power) * (_A / _D)) + 2f) / 50f); if (currentTurn == GlobalEnums.Turns.PlayersTurn) { playerAnimator.SetTrigger("Attack"); backgroundAnimator.SetTrigger("Attack"); StartCoroutine(FlashAfterAttack(Img_foePokemon, 4, 0.1f)); } else if (currentTurn == GlobalEnums.Turns.FoesTurn) { playerBoxAnimator.SetTrigger("Attack"); foeAnimator.SetTrigger("Attack"); foeBoxAnimator.SetTrigger("Attack"); backgroundAnimator.SetTrigger("Attack"); StartCoroutine(FlashAfterAttack(Img_playerPokemon, 4, 0.1f)); } if (_defensePokemon.HpStats.curr - _damage < 1) { PlayerTimeLeft.enabled = false; FoeTimeLeft.enabled = false; float _oldHP = (_defensePokemon.HpStats.curr) / _defensePokemon.HpStats.max; StartCoroutine(handlePlayerHpDecrease(_defensePokemon, Text_PlayerHP, _defensePokemon.HpStats.curr, 0, 0.06f)); StartCoroutine(_defensePokemon.healthBar.SetHealthBarScale(_oldHP, 0)); _defensePokemon.HpStats.curr = 0; battleState = GlobalEnums.BattleStates.GameOver; } else { float _newHP = (_defensePokemon.HpStats.curr - _damage) / _defensePokemon.HpStats.max; float _oldHP = (_defensePokemon.HpStats.curr) / _defensePokemon.HpStats.max; StartCoroutine(handlePlayerHpDecrease(_defensePokemon, Text_PlayerHP, _defensePokemon.HpStats.curr, _defensePokemon.HpStats.curr - _damage, 0.06f)); StartCoroutine(_defensePokemon.healthBar.SetHealthBarScale(_oldHP, _newHP)); _defensePokemon.HpStats.curr -= _damage; } }
private void ManageMessageBox(SC_PokemonMove _move = null) { if (MessageState == GlobalEnums.MessageBoxState.EnterBattle) { ChangeMenu(GlobalEnums.BattleMenus.Message); MessageText.text = foePokemon.name + " Wants To Battle!"; } else if (MessageState == GlobalEnums.MessageBoxState.Selection) { ChangeMenu(GlobalEnums.BattleMenus.Selection); MessageText.text = "What Will " + playerPokemon.name + " Do?"; } else if (MessageState == GlobalEnums.MessageBoxState.WaitingForAttack) { ChangeMenu(GlobalEnums.BattleMenus.Message); MessageText.text = "Enemy Pokemon Is Attacking."; } else if (MessageState == GlobalEnums.MessageBoxState.EnemyRanAway) { ChangeMenu(GlobalEnums.BattleMenus.Message); MessageText.text = "Enemy " + foePokemon.name + " Ran Away... \nYou Win!"; isWaitingForRespond = true; } else if (MessageState == GlobalEnums.MessageBoxState.Attack) { ChangeMenu(GlobalEnums.BattleMenus.Message); isWaitingForRespond = true; if (_move != null) { if (currentTurn == GlobalEnums.Turns.PlayersTurn) { MessageText.text = playerPokemon.name + " Used " + _move.name + "!"; } else if (currentTurn == GlobalEnums.Turns.FoesTurn) { MessageText.text = "Oh No! \nEnemy " + foePokemon.name + " Used " + _move.name + "!"; } } } else if (MessageState == GlobalEnums.MessageBoxState.GameOver) { ChangeMenu(GlobalEnums.BattleMenus.Message); if (playerPokemon.HpStats.curr <= 0) { MessageText.text = playerPokemon.name + " Defeated! \nMaybe Next Time..."; } else if (foePokemon.HpStats.curr <= 0) { MessageText.text = "Enemy " + foePokemon.name + " Defeated! \nGood Job!"; } } }
private void RestartBattle() { isInBattle = false; isWaitingForRespond = true; isSelectionMenuEnabled = false; isMovesMenuEnabled = false; isFoeAttackingATM = false; canExit = false; MessageState = GlobalEnums.MessageBoxState.EnterBattle; battleState = GlobalEnums.BattleStates.Start; currentMenu = GlobalEnums.BattleMenus.Message; currentTurn = GlobalEnums.Turns.PlayersTurn; attackMove = null; }
private void AttackOpponent(SC_BasePokemon _attackPokemon, SC_PokemonMove _attackMove, SC_BasePokemon _defensePokemon) { currentMenu = GlobalEnums.BattleMenus.Message; MessageState = GlobalEnums.MessageBoxState.Attack; attackMove = _attackMove; ManageMessageBox(attackMove); isWaitingForRespond = true; _attackMove.currPP--; float _lvl = (float)_attackPokemon.level; float _power = (float)attackMove.power; float _A = (float)_attackPokemon.attack; float _D = (float)_defensePokemon.defense; float _modifier = (float)(UnityEngine.Random.Range(0.8f, 1f)); float _damage = (((((((2f * _lvl) / 5f) + 2f) * _power) * (_A / _D)) + 2f) / 50f) * _modifier; //float damage = (((((((2f * lvl) / 5f) + 2f) * power) * (A/D)) / 50f) + 2f) * modifier; //Debug.Log("damage: " + damage); if (currentTurn == GlobalEnums.Turns.PlayersTurn) { StartCoroutine(FlashAfterAttack(Img_foePokemon, 4, 0.1f)); } else if (currentTurn == GlobalEnums.Turns.FoesTurn) { StartCoroutine(FlashAfterAttack(Img_playerPokemon, 4, 0.1f)); } if (_defensePokemon.HpStats.curr - _damage < 0) { _defensePokemon.HpStats.curr = 0; _defensePokemon.healthBar.SetHealthBarScale(0); Text_PlayerHP.text = ((int)playerPokemon.HpStats.curr).ToString() + "/" + playerPokemon.HpStats.max.ToString(); battleState = GlobalEnums.BattleStates.GameOver; } else { float newHP = (_defensePokemon.HpStats.curr - _damage) / _defensePokemon.HpStats.max; _defensePokemon.HpStats.curr -= _damage; _defensePokemon.healthBar.SetHealthBarScale(newHP); Text_PlayerHP.text = ((int)playerPokemon.HpStats.curr).ToString() + "/" + playerPokemon.HpStats.max.ToString(); } }
private void UpdateMoveDetailBox(SC_PokemonMove move) { PPstats.GetComponent <Text>().text = move.currPP.ToString() + "/" + move.maxPP.ToString(); PPtype.text = "TYPE/" + move.type.ToString(); }
private void UpdateMoveDetailBox(SC_PokemonMove move) { GameObject.Find("Text_PPstats").GetComponent <Text>().text = move.currPP.ToString() + "/" + move.maxPP.ToString(); GameObject.Find("Text_Type").GetComponent <Text>().text = "TYPE/" + move.type.ToString(); }