Beispiel #1
0
 private void changeState(SkeletonEnemyState newState)
 {
     if (currentState != newState)
     {
         currentState = newState;
     }
 }
Beispiel #2
0
    private IEnumerator KnockWithoutDamage(Rigidbody2D hit)
    {
        if (hit != null)
        {
            CancelInvoke("ShootArrow");
            rb2d.bodyType = RigidbodyType2D.Dynamic;

            yield return(new WaitForSeconds(0.2f));

            hit.velocity = Vector2.zero;

            yield return(new WaitForSeconds(1f));

            currentState = SkeletonEnemyState.patrol;
        }
    }
Beispiel #3
0
    private IEnumerator Knock(Rigidbody2D hit, int attackPower, Vector2 difference)
    {
        if (hit != null)
        {
            CancelInvoke("ShootArrow");
            rb2d.bodyType = RigidbodyType2D.Dynamic;
            hit.AddForce(difference, ForceMode2D.Impulse);
            decreaseHealth(attackPower);

            yield return(new WaitForSeconds(0.2f));

            hit.velocity = Vector2.zero;

            yield return(new WaitForSeconds(1f));

            currentState = SkeletonEnemyState.patrol;
        }
    }
Beispiel #4
0
    void Start()
    {
        deadSkeleton = false;
        if (points.Length != 0)
        {
            transform.position = points[0].position;
        }
        else
        {
            attackRadious = 15;
        }

        currentPoint = 0;

        currentState = SkeletonEnemyState.patrol;
        animator     = GetComponent <Animator>();
        target       = GameObject.FindGameObjectWithTag("Player").transform;
        health       = 5;
        speed        = 1f;

        rb2d = GetComponent <Rigidbody2D>();

        attackRadious = 8;
    }