public void HandleAttack() { Direction = GetAnimationDirection(); if (Input.GetKeyDown(KeyCode.Z)) { PlayerStateMachine.ChangeState(PlayerStateMachine.States.Attacking); CurrentEffect = PowerUpActivator.GenerateEffect(); switch (CurrentEffect) { case (PowerUpController.Effects.Fire): Renderer.material = FireMaterial; break; case (PowerUpController.Effects.Ice): Renderer.material = IceMaterial; break; case (Player.PowerUpController.Effects.Thunder): Renderer.material = ThunderMaterial; break; default: Renderer.material = StandardMaterial; break; } Attack(); } }
public void ApplyEffectsOnEnemies(GameObject enemy, PowerUpController.Effects activatedEffect) { EnemyStateMachine enemyStateMachine = enemy.GetComponent <EnemyStateMachine>(); EnemyHealthManager enemyHealthManager = enemy.GetComponent <EnemyHealthManager>(); // Even when the list is empty // ICE LV 2 doesn't needs ICE LV 1 to happen in the same attack if (PowerUpController.IceLevel > 1 && enemyStateMachine.IsFrozen) { Debug.Log("SHATTERING ENEMY"); PowerUpEffects.ShatterEnemy(enemy, PlayerStatsController.ShatterDamage); } // Choosing between all the activated effects switch (activatedEffect) { case PowerUpController.Effects.Fire: //Debug.Log("FIRE CHOSEN"); PowerUpEffects.BurnEnemy(enemy, PlayerStatsController.FireDamage); if (PowerUpController.FireLevel > 1 && enemyStateMachine.IsOnFire && enemyStateMachine.WillDieBurned) { // FIRE LV 2 Debug.Log("BURNING ENEMY TO THE DEATH"); PowerUpEffects.BurnEnemyToDeath(enemy); } break; case PowerUpController.Effects.Ice: if (!enemyStateMachine.IsParalyzed) { PowerUpEffects.FreezeEnemy(enemy, PlayerStatsController.FrostDuration); } break; case PowerUpController.Effects.Thunder: //Debug.Log("THUNDER CHOSEN"); PowerUpEffects.FindCloseEnemies(enemy, PlayerStatsController.ElectricRange, PlayerStatsController.ElectricalDamage); // AND DEALS DAMAGE TO THEM // THUNDER LV 2 if (PowerUpController.ElectricLevel >= 2) { if (enemyStateMachine.IsPrimaryTarget && Random.Range(1, 100) < PlayerStatsController.ElectricAttackRate) { if (!enemyStateMachine.IsFrozen) { PowerUpEffects.ParalyzeEnemy(enemy, PlayerStatsController.ParalyzeDuration); //Debug.Log("PARALIZADO"); } } } enemyStateMachine.IsPrimaryTarget = false; break; } }