// Use this for initialization void Start() { base.Character_Start(); // Transitions out of retreating var foundCover = new Transition(State.Tactical_Resting, (manager, character) => { return(character.InSafeSpot()); }); var retreatingTransitions = new List <Transition>(); retreatingTransitions.Add(foundCover); // Transitions out of resting var healthyAndFullAmmo = new Transition(State.Tactical_Moving, (manager, character) => { return(character.HasHighHealth() && character.HasAmmo()); }); var healthLow = new Transition(State.Tactical_Retreating, (manager, character) => { return(character.HasLowHealth()); }); var restingTransitions = new List <Transition>(); restingTransitions.Add(healthyAndFullAmmo); restingTransitions.Add(healthLow); // Transitions out of moving var hasLineOfSight = new Transition(State.Tactical_Aiming, Aim); var movingTransitions = new List <Transition>(); movingTransitions.Add(hasLineOfSight); movingTransitions.Add(healthLow); // Transitions out of aiming var noLineOfSight = new Transition(State.Tactical_Moving, (manager, character) => { return(!character.CanSeeEnemy()); }); var aimingTransitions = new List <Transition>(); aimingTransitions.Add(noLineOfSight); aimingTransitions.Add(healthLow); var transitions = new Dictionary <State, IEnumerable <Transition> >(); transitions.Add(State.Tactical_Retreating, retreatingTransitions); transitions.Add(State.Tactical_Resting, restingTransitions); transitions.Add(State.Tactical_Moving, movingTransitions); transitions.Add(State.Tactical_Aiming, aimingTransitions); fsm = new TacticalStateMachine(State.Tactical_Resting, transitions); fsm.AddStateBehavior(State.Tactical_Retreating, new RetreatingStateBehavior()); fsm.AddStateBehavior(State.Tactical_Resting, new RestingStateBehavior()); fsm.AddStateBehavior(State.Tactical_Moving, new MovingState()); fsm.AddStateBehavior(State.Tactical_Aiming, new AimingStateBehavior()); previousDestination = transform.position; commander = GameManager.instance.commander; }
// Use this for initialization public void Start() { StrategicTeam = GameManager.instance.teams[0]; Commander = GameManager.instance.commander; foreach (var strategicTeamMember in StrategicTeam.members) { strategicTeamMember.strategicOrders = new StrategicCommand( GameManager.instance.commander.strategyFSM.CurrentState, GameManager.instance.commander.teamTarget); } }
/// <summary> /// Reset everything and start a new game /// </summary> public void Reset() { activeTeams = new List <Team>(teams); foreach (Team tm in teams) { tm.ClearAll(); tm.Spawn(teamSize); tm.ConstructHierarchy(); } gameState = GameState.Running; commander = new Commander_FSM(); commander.Start(); passingManager = new CommandPassingManager(); passingManager.Start(); }