Ejemplo n.º 1
0
 void ResetAll()
 {
     State     = OrcState.Default;
     pickedUp_ = false;
     target_   = trans_.position;
     Text.text = string.Empty;
     MeleeWeapon.gameObject.SetActive(false);
 }
Ejemplo n.º 2
0
    private void AIUpdate()
    {
        // Useful data for state checks
        float sqrDistToPlayer = (pController.transform.position - transform.position).sqrMagnitude;

        // Check all state changes
        switch (currentState)
        {
        case OrcState.Idle:
        {
            // Player is within alert range
            if (sqrDistToPlayer < AlertDistance * AlertDistance)
            {
                currentState = OrcState.Chase;
            }
            break;
        }

        case OrcState.Chase:
        {
            // Player is out of range
            if (sqrDistToPlayer > GiveUpChaseDistance * GiveUpChaseDistance)
            {
                currentState = OrcState.Idle;
            }

            // Health is too low, flee
            if (health.CurrentHealth < FleeHealth)
            {
                currentState = OrcState.Flee;
            }
            break;
        }

        case OrcState.Flee:
        {
            // AI has fled far enough
            if (sqrDistToPlayer > SafeDistance * SafeDistance)
            {
                currentState = OrcState.Idle;
            }
            break;
        }
        }

        // Any global state checks
    }
Ejemplo n.º 3
0
    public void HealthAction(HealthEvent hEvent)
    {
        Vector2 fromPlayer = (transform.position - pController.transform.position).normalized;

        internalRest      = false;
        internalVelocity += Vector2.up * Mathf.Sqrt(2f * InternalGravity * DamagedBounceHeight);
        velocity         += fromPlayer * 3f;

        switch (hEvent)
        {
        case HealthEvent.Death:
            currentState = OrcState.Dead;
            anim.SetBool("Dead", true);
            rb.mass = 0.1f;
            break;

        case HealthEvent.Hurt:

            break;
        }
    }
Ejemplo n.º 4
0
 public void SetYoda()
 {
     State = OrcState.Yoda;
 }
Ejemplo n.º 5
0
 public void SetChasePlayer(bool chase)
 {
     State = OrcState.ChasePlayer;
 }