// Use this for initialization void Start() { player = GameObject.FindGameObjectWithTag("Player"); monsterNavAgent = GetComponent <NavMeshAgent>(); CurrentState = new MonsterRelocationState(this, true); CurrentState.Start(); }
void Awake() { monsterPatrolState = new MonsterPatrolState(this); monsterSearchState = new MonsterSearchState(this); monsterChaseState = new MonsterChaseState(this); monsterDistractionState = new MonsterDistractionState(this); anim = GetComponentInChildren <Animator>(); soundManager = GameObject.FindGameObjectWithTag("SoundManager").GetComponent <SoundManager>(); //This is just so we don't have to write GetComponent a lot later. proxyLocation = proxy.GetComponent <Transform>(); agent = proxy.GetComponent <NavMeshAgent>(); targetLocation = targetActual.GetComponent <Transform>(); mainCamera = GameObject.FindGameObjectWithTag("MainCamera"); currentState = monsterPatrolState; player = targetActual.GetComponent <Player>(); //We need this if we ever have to reset the monster. initialPos = new Vector3(proxyLocation.position.x, proxyLocation.position.y, proxyLocation.position.z); }
public void SwitchState(IMonsterState newState) { CurrentState.End(); CurrentState = newState; CurrentState.Start(); }
public void SetState(IMonsterState state) { State = state; }