Пример #1
0
 public void OnEscape()
 {
     AudioManager.Stop("Slashy_detect");
     this.state = SlashyStates.Idle;
     this.Animator.SetBool("walking", false);
     this.target = null;
 }
Пример #2
0
    public IEnumerator Slash()
    {
        AudioManager.Play("Slashy_hit");
        this.state = SlashyStates.Hit;

        this.Animator.SetTrigger("attack");

        yield return(new WaitForSeconds(0.5f));

        Vector2 center = this.Transform.position;
        var     offset = new Vector2(this.SlashHitBoxOffset.x * this.CharacterController.Direction, this.SlashHitBoxOffset.y);

        center += offset;

        Collider2D[] collided = Physics2D.OverlapAreaAll(center - this.SlashHitboxSize / 2, center + this.SlashHitboxSize / 2);
        Debug.DrawLine(center - this.SlashHitboxSize / 2, center + this.SlashHitboxSize / 2, Color.green);
        foreach (Collider2D collider in collided)
        {
            IHitable target = collider.gameObject.GetComponent <IHitable>();
            if (collider.gameObject != this.gameObject && target != null)
            {
                target.TakeDamages(this.SlashDamages, this.Transform.position);
            }
        }

        yield return(new WaitForSeconds(0.5f));

        this.state = SlashyStates.Follow;
    }
Пример #3
0
    // use incoming events to change state and hadle atacks
    public void OnDetected(GameObject target)
    {
        if (this.state == SlashyStates.Hit)
        {
            return;
        }

        AudioManager.Play("Slashy_detect");
        this.state = SlashyStates.Follow;
        this.Animator.SetBool("walking", true);
        this.target = target.GetComponent <Transform>();
    }