Esempio n. 1
0
 public void AttackBat_DOWN()
 {
     if (powerUpBat)
     {
         GameObject     cloneSlash          = Instantiate(slashPrefab, attackPos_Front.position, transform.rotation);
         SlashBehaviour cloneSlashBehaviour = cloneSlash.GetComponent <SlashBehaviour>();
         cloneSlashBehaviour.playerSlash = true;
         Rigidbody2D slashRB   = cloneSlash.GetComponent <Rigidbody2D>();
         Animator    slashAnim = cloneSlash.GetComponent <Animator>();
         slashAnim.SetBool("dx_front", true);
         slashRB.AddForce(-Vector2.up * slashSpeed, ForceMode2D.Impulse);
     }
 }
Esempio n. 2
0
    public void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            if (enemyClass == enemyType.Vampire && !enemyDead)
            {
                if (!attacking)
                {
                    enemyAC.SetTrigger("attack");
                    StartCoroutine(EnemyAttack());

                    enemyAI.maxSpeed = 0;
                    attackRadius     = 0;

                    if (vampireSlash != null)
                    {
                        GameObject     cloneSlash          = Instantiate(vampireSlash, transform.position, transform.rotation);
                        SlashBehaviour cloneSlashBehaviour = cloneSlash.GetComponent <SlashBehaviour>();
                        cloneSlashBehaviour.vampireSlash = true;
                        Rigidbody2D cloneRB   = cloneSlash.GetComponent <Rigidbody2D>();
                        Vector2     direction = playerPosition.position - transform.position;
                        cloneRB.AddForce(direction * slashSpeed, ForceMode2D.Impulse);
                        Animator slashAnim = cloneSlash.GetComponent <Animator>();

                        if (direction.y > 0)
                        {
                            slashAnim.SetBool("dx_front", true);
                        }
                        else if (direction.y < 0)
                        {
                            slashAnim.SetBool("sx_back", true);
                        }
                    }
                }
            }
        }
    }