Ejemplo n.º 1
0
    protected override void OnCantMove <T>(T component)
    {
        if (component.gameObject.tag == "Player")
        {
            Player hitPlayer = component as Player;
            hitPlayer.LoseFood(playerDamage);
            SoundManager.instance.RandomizeSFX(enemyAttack1, enemyAttack2);
        }
        else if (component.gameObject.tag == "Raider")
        {
            //attack enemy
            Raider hitEnemy = component as Raider;
            hitEnemy.LoseHealth(playerDamage / 10);
            SoundManager.instance.RandomizeSFX(enemyAttack1, enemyAttack2);
        }
        else if (component.gameObject.tag == "Enemy")
        {
            Enemy hitEnemy = component as Enemy;
            hitEnemy.LoseHealth(playerDamage / 10);
            SoundManager.instance.RandomizeSFX(enemyAttack1, enemyAttack2);
        }
        else
        {
            Wall hitWall = component as Wall;
            hitWall.DamageWall(playerDamage / 10);
            SoundManager.instance.RandomizeSFX(enemyAttack1);
        }

        raiderAnimator.SetTrigger("enemyAttack");
        if (target.gameObject.tag == "Enemy" && target.gameObject.GetComponent <Actor>().GetHealth() <= 0)
        {
            if (GameObject.FindWithTag("Enemy") == null)
            {
                target = GameObject.FindGameObjectWithTag("Player").transform;
            }
            else
            {
                target = GameObject.FindGameObjectWithTag("Enemy").transform;
            }
        }
    }