ExecuteAnimation() public static method

public static ExecuteAnimation ( Animator anim, string animationName ) : void
anim Animator
animationName string
return void
Exemplo n.º 1
0
    void Update()
    {
        timer += Time.deltaTime;
        // If the enemy can attack, the player is in range and the enemy still has health, execute attack.
        if (timer >= timeBetweenAttacks && playerInRange && GetComponent <EnemyHealth>().currentHealth > 0)
        {
            // If there is a sound associated, play it
            if (attackSound != null)
            {
                SfxScript.playSound(attackSound);
            }

            // If there is an animation associated, play it
            if (anim != null)
            {
                EnemyAnimatorController.ExecuteAnimation(anim, "Attack");
            }
            else
            {
                // Exclusive animation for the spider model
                attackAnimation();
            }
            Attack(player);
        }
    }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     timer += Time.deltaTime;
     // Shoots after a certain time between attacks
     if (timer >= timeBetweenAttacks && shouldShoot)
     {
         timer = 0f;
         if (anim != null)
         {
             EnemyAnimatorController.ExecuteAnimation(anim, "Cast");
         }
         Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
     }
 }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        timer += Time.deltaTime;
        if (timer >= timeBetweenAttacks && shoot)
        {
            timer = 0f;

            // Cast animations if they exist
            if (anim != null)
            {
                EnemyAnimatorController.ExecuteAnimation(anim, "Cast");
            }
            // Instaniate the four shots
            Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
            Instantiate(shot, shotSpawn1.position, shotSpawn1.rotation);
            Instantiate(shot, shotSpawn2.position, shotSpawn2.rotation);
            Instantiate(shot, shotSpawn3.position, shotSpawn3.rotation);
        }
    }
Exemplo n.º 4
0
    public void TakeDamage(int amount)
    {
        // Reduce current health by the amount of damage taken.
        currentHealth -= amount;

        // Trigger hurt sound if it exists
        if (hurtSound != null)
        {
            SfxScript.playSound(hurtSound);
        }

        // Trigger hurt animation if it exists
        if (anim != null)
        {
            EnemyAnimatorController.ExecuteAnimation(anim, "Hit");
        }

        // Trigger flash if it exists
        EnemyFlash flash = this.gameObject.GetComponent <EnemyFlash>();

        if (flash != null)
        {
            StartCoroutine(flash.Flash());
        }

        // If the current health is less than or equal to zero
        if (currentHealth <= 0)
        {
            if (isDead == false)
            {
                isDead = true;
                Debug.Log("Enemy Destroyed!");
                if (this.tag == "Enemy" || this.tag == "Boss")
                {
                    // Increment score when destroyed.
                    Debug.Log("INCREMEMNTING!");

                    // Increment the score
                    TEMPScoreScript.Instance.IncrementScore(scoreAwarded);
                }

                // Play death sound if it exists
                if (deathSound != null)
                {
                    SfxScript.playSound(deathSound);
                }

                // Play death animation if it exists
                if (anim != null)
                {
                    EnemyAnimatorController.ExecuteAnimation(anim, "Die");
                }

                // Play spider aninimation exclusively
                SpiderAnimation temp = GetComponent <SpiderAnimation>();
                if (temp != null)
                {
                    Debug.Log("THIS IS A SPIDER!");
                    temp.spiderKilled();
                }
                else
                {
                    Destroy(gameObject, 1f);
                }
            }
        }
    }