// Use this for initialization void Start() { // Self references this.dangerHitbox = this.transform.FindChild("Danger Zone").gameObject; this.targetingCone = this.transform.FindChild("Line of Sight").gameObject; _bodyBounds = CreateBodyBounds(); Fsm = new StateMachine <Enemy>(this); State <Enemy> state; switch (this.startState) { case StartState.Wander: state = new WanderState(this, Fsm, 30.0f); break; case StartState.ReachGoal: state = new ReachGoalState(this, Fsm, target); break; case StartState.Flock: state = new FlockState(this, Fsm, target, group); break; case StartState.Flee: state = new FleeState(this, Fsm, target); break; case StartState.FleeMultiple: state = new FleeMultipleState(this, Fsm, group); break; case StartState.FollowPath: Debug.Log("Setting state"); state = new FollowPathState(this, Fsm, PathFinding.spawnGameObjectsAtPathPoints(PathFinding.generatePath(gameObject, target))); Debug.Log("Done setting state"); break; case StartState.SeekTargetWithPath: state = new SeekTargetWithPathState(this, Fsm, target); break; case StartState.Patrol: state = new PatrolState(this, Fsm, patrolPath, patrolPauseTime); break; default: state = new WanderState(this, Fsm, 30.0f); break; } Fsm.InitialState(state); SetDangerous(false); }
private SeekTargetWithPathState getSeekState() { if (seekStates == null || seekStates.Length != path.Path.Count) { seekStates = new SeekTargetWithPathState[path.Path.Count]; } if (seekStates[currentTargetIndex] == null) { seekStates[currentTargetIndex] = new SeekTargetWithPathState(Owner, Fsm, path.Path[currentTargetIndex].gameObject, 0.5f); } return(seekStates[currentTargetIndex]); }
// Use this for initialization void Start() { _bodyBounds = CreateBodyBounds(); Fsm = new StateMachine <Enemy>(this); State <Enemy> state; switch (this.startState) { case StartState.Wander: state = new WanderState(this, Fsm, 30.0f); break; case StartState.ReachGoal: state = new ReachGoalState(this, Fsm, target); break; case StartState.Flock: state = new FlockState(this, Fsm, target, group); break; case StartState.Flee: state = new FleeState(this, Fsm, target); break; case StartState.FleeMultiple: state = new FleeMultipleState(this, Fsm, group); break; case StartState.FollowPath: Debug.Log("Setting state"); state = new FollowPathState(this, Fsm, PathFinding.spawnGameObjectsAtPathPoints(PathFinding.generatePath(gameObject, target))); Debug.Log("Done setting state"); break; case StartState.SeekTargetWithPath: state = new SeekTargetWithPathState(this, Fsm, target); break; default: state = new WanderState(this, Fsm, 30.0f); break; } Fsm.InitialState(state); }