Exemplo n.º 1
0
    /// <summary>
    /// Desactivates the hit box.
    /// Stop the current attack if there is one.
    /// </summary>
    public void Desactivate()
    {
        CurrentAttack    = null;
        BonusDamages     = 0;
        collider.enabled = false;
        TouchedObjects.Clear();

        if (IsActive)
        {
            IsActive = false;
            OnStopAttack?.Invoke();
        }
    }
Exemplo n.º 2
0
    private void Update()
    {
        agent.destination = player.transform.position;
        if (Vector3.Distance(transform.position, player.transform.position) < attackDistance)
        {
            //if(debug) Debug.Log("Attacking");
            bool wasAttacking = isAttacking;
            isAttacking = true;
            if (!wasAttacking)
            {
                OnStartAttack?.Invoke();
            }
        }
        else
        {
            //if(debug) Debug.Log("Not attacking");
            bool wasAttacking = isAttacking;
            isAttacking = false;
            if (wasAttacking)
            {
                OnStopAttack?.Invoke();
            }
        }
        if (isAttacking)
        {
            moveState   = SpeedState.Idle;
            agent.speed = 0f;
        }
        else
        {
            if (Stunned)
            {
                moveState   = SpeedState.Walking;
                agent.speed = speed / 3f;
            }
            else
            {
                moveState   = SpeedState.Running;
                agent.speed = speed;
            }
            switch (SettingsHandler.cache.dificulty)
            {
            case Difficulty.Easy:
                agent.speed *= .8f;
                break;

            default:
                break;

            case Difficulty.Hard:
                agent.speed *= 1.1f;
                break;

            case Difficulty.Extreme:
                agent.speed *= 1.2f;
                break;
            }
        }
        stunDuration -= Time.deltaTime;
        if (stunDuration < 0f)
        {
            stunDuration = 0f;
        }
    }