public void opponentAttack() { var _playerManager = GameObject.Find("Character").GetComponent <Character_manager>(); if (GameObject.Find("Game manager").GetComponent <Game_manager>().vibrationEnabled&& Application.platform == RuntimePlatform.Android) { #if UNITY_IPHONE || UNITY_ANDROID Handheld.Vibrate(); #endif } _playerManager.spell_animation.Play(enemies[id].attackAnimation); string _hitAnimation = ""; int random_crit = UnityEngine.Random.Range(0, 100); if (random_crit > 90) { _characterStats.looseHealth(enemy_damage * 2); int random_hit = UnityEngine.Random.Range(1, 3); switch (random_hit) { case 1: _hitAnimation = "crit_hit_1"; break; case 2: _hitAnimation = "crit_hit_2"; break; } _playerManager.damage_text.GetComponent <Text_animation>().startAnim("-" + enemy_damage * 2 + " CRITICAL!", 0.05f); } else { _characterStats.looseHealth(enemy_damage); int random_hit = UnityEngine.Random.Range(1, 7); switch (random_hit) { case 1: _hitAnimation = "hit_1"; break; case 2: _hitAnimation = "hit_2"; break; case 3: _hitAnimation = "hit_3"; break; case 4: _hitAnimation = "hit_4"; break; case 5: _hitAnimation = "hit_5"; break; case 6: _hitAnimation = "hit_6"; break; } _playerManager.damage_text.GetComponent <Text_animation>().startAnim("-" + enemy_damage, 0.05f); } _playerManager.damage_text.GetComponent <Animator>().Play(_hitAnimation); GameObject.Find("Battle_scene").GetComponent <Animator>().Play("Screen_shake_1"); if (_characterStats.Player_health <= 0) { _combatManager.showResults("Defeat"); } }