public virtual void Aggrevate() { if (_aiHealth.IsDead) { return; } //Move the last known location to the players position when the player shoots. _lastKnownLocation.transform.position = _player.position; _isAggrevated = true; if (stateMachine == null) { stateMachine = new AIStateMachine(this); stateMachine.RegisterState(new AIDeathState(this)); stateMachine.RegisterState(new AIIdleState(this)); stateMachine.RegisterState(new AICombatState(this)); stateMachine.RegisterState(new AISearchForPlayerState(this)); stateMachine.RegisterState(new AICheckPlayerState(this)); stateMachine.RegisterState(new AIMeleeState(this)); if (_startingWeapon) { RaycastWeapon weapon = Instantiate(_startingWeapon.Weapon); _aiWeapon = GetComponent <AIWeapons>(); _aiWeapon.EquipWeapon(weapon); } } stateMachine.ChangeState(AiStateId.CombatState); }
// Start is called before the first frame update void Start() { //Find the player if (!_player) { _player = GameObject.FindGameObjectWithTag("Player").transform; } stateMachine = new AIStateMachine(this); stateMachine.RegisterState(new AIDeathState(this)); stateMachine.RegisterState(new BrickAIIdleState(this)); stateMachine.RegisterState(new AIMeleeState(this)); if (_startingWeapon) { RaycastWeapon weapon = Instantiate(_startingWeapon.Weapon); _aiWeapon = GetComponent <AIWeapons>(); _aiWeapon.EquipWeapon(weapon); } stateMachine.ChangeState(_initialState); }
void Start() { //AI DEATH STATE ragdoll = GetComponent <Ragdoll>(); mesh = GetComponentInChildren <SkinnedMeshRenderer>(); healthBar = GetComponentInChildren <UIHealthBar>(); playerTransform = GameObject.FindGameObjectWithTag("Player").transform; navMeshAgent = GetComponent <NavMeshAgent>(); weapons = GetComponent <AIWeapons>(); stateMachine = new AIStateMachine(this); stateMachine.RegisterState(new AIChasePlayerState()); stateMachine.RegisterState(new AIDeathState()); stateMachine.RegisterState(new AIIdleState()); stateMachine.RegisterState(new AIFindWeaponState()); stateMachine.RegisterState(new AIAttackPlayerState()); stateMachine.ChangeState(initialState); rb = GetComponent <Rigidbody>(); }
// Start is called before the first frame update void Start() { //Find the player if (!_player) { _player = GameObject.FindGameObjectWithTag("Player").transform; } stateMachine = new AIStateMachine(this); stateMachine.RegisterState(new AIDeathState(this)); stateMachine.RegisterState(new AIIdleState(this)); stateMachine.RegisterState(new AICombatState(this)); stateMachine.RegisterState(new AISearchForPlayerState(this)); stateMachine.RegisterState(new AICheckPlayerState(this)); stateMachine.RegisterState(new AIMeleeState(this)); //Registers the patrol state if we have a patrol route if (_route) { stateMachine.RegisterState(new PatrolState(this, _route, _movementSpeedInPatrol, _waitAtEachPointDuration)); } //If we have a starting weapon then instantiate and equip it if (_startingWeapon) { RaycastWeapon weapon = Instantiate(_startingWeapon.Weapon); _aiWeapon = GetComponent <AIWeapons>(); _aiWeapon.EquipWeapon(weapon); } else { Debug.LogError(transform.name + " has no starting weapon"); } stateMachine.ChangeState(_initialState); if (_initialState == AiStateId.CombatState) { Aggrevate(); } }