public void Attack()
 {
     if (opponent == null)
     {
         opponent = fightManager.GetOpponent(); // Get the opponent
     }
     StartCoroutine(AttackPhase());
     fightManager.ButtonsActive(false);
 }
Пример #2
0
    private IEnumerator AttackPhase(int damage)
    {
        if (fakeMob != null)
        {
            // Disableing Mob main sprite
            gameObject.GetComponent <SpriteRenderer>().enabled = false;

            // Activating animated Mob for the attack animation
            fakeMob.gameObject.SetActive(true);
            fakeMob.gameObject.transform.position = new Vector3(FightSpawn.position.x, FightSpawn.position.y, FightSpawn.position.z);

            // Starting attack animation for mob
            animationRunning = true;
            fakeMob.GetComponent <Animator>().Play(fakeMob.name + "_Attacking");

            yield return(new WaitForSeconds(0.8f));

            // Damaging Player
            GameObject.Find("Player").GetComponent <PlayerFight>().HealthDamaged(damage);

            // Sound
            audioManager.PlaySound(fightManager.hitClip, true);

            yield return(new WaitForSeconds(1.5f));

            // Deactivating animated mob
            fakeMob.gameObject.SetActive(false);

            // Enableing main sprite
            gameObject.GetComponent <SpriteRenderer>().enabled = true;

            // Stopping animation
            animationRunning = false;

            //Updating turn and showing buttons for player's turn
            fightManager.currentTurn = FightManager.Turn.Player;
            fightManager.ButtonsActive(true);
        }
    }