Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (GetComponent <HealthEnemy>().health <= .0f)
        {
            followTarget.enabled = false;
            GetComponent <Collider2D>().enabled = false;
            return;
        }

        if (followTarget.GetDistance() < 2.0f && attackTimeout < .0f)
        {
            punch.PerformAttack();
            attackTimeout = attackRate;
        }

        if (knives && followTarget.GetDistance() < rangeAttackRange && rangeAttackTimeout < .0f)
        {
            knives.PerformAttack();
            rangeAttackTimeout = rangeAttackRate;
        }

        rangeAttackTimeout -= Time.deltaTime;
        attackTimeout      -= Time.deltaTime;
    }