void ResetAll() { State = OrcState.Default; pickedUp_ = false; target_ = trans_.position; Text.text = string.Empty; MeleeWeapon.gameObject.SetActive(false); }
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 }
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; } }
public void SetYoda() { State = OrcState.Yoda; }
public void SetChasePlayer(bool chase) { State = OrcState.ChasePlayer; }