public Valve() { mFSM = new FiniteStateMachine("Stoped", () => ValveStoped()); mFSM.addState("Opens", () => ValveOpens()); mFSM.addState("Closes", () => ValveCloses()); mFSM.addState("Esd", () => ValveEsd()); }
void Awake() { mainFSM = new FiniteStateMachine<State>(); mainFSM.AddTransition(State.Initialize, State.SetupNewGame, null, InitializeNewGame, OnSettingUpNewGame); mainFSM.AddTransition(State.SetupNewGame, State.Game, null, () => StartCoroutine(InitializeGameLogicStuff()), null); mainFSM.AddTransition(State.Game, State.GameOver, OnGameIsOver); mainFSM.AddTransition(State.GameOver, State.Restart, null); mainFSM.AddTransition(State.Restart, State.SetupNewGame, null, InitializeNewGame, null); mainFSM.AddTransition(State.Restart, State.Quit, null); mainFSM.StateChanged += (object s, EventArgs e) => { Debug.Log("state: " + mainFSM.CurrentState.ToString() + " | game state: " + gameFSM.CurrentState.ToString()); }; gameFSM = new FiniteStateMachine<GameState>(); gameFSM.AddTransition(GameState.Idle, GameState.InGameMenu, OnInGameMenuOpened); gameFSM.AddTransition(GameState.InGameMenu, GameState.Idle, OnInGameMenuClosed); gameFSM.StateChanged += (object s, EventArgs e) => { Debug.Log("state: " + mainFSM.CurrentState.ToString() + " | game state: " + gameFSM.CurrentState.ToString()); }; GameIsOver += (object s, EventArgs e) => { Debug.Log("oh no!"); }; InGameMenuOpened += (object s, EventArgs e) => { Time.timeScale = 0f; Debug.Log("PAUSED"); }; InGameMenuClosed += (object s, EventArgs e) => { Time.timeScale = 1f; Debug.Log("UNPAUSED"); }; igm = GetComponent<InGameMenu>(); mainFSM.ChangeState(State.SetupNewGame); }
/// <summary> /// Tests if the given turn is significant. /// </summary> /// <param name="test"></param> /// <param name="machine"></param> /// <returns></returns> private static bool TestNonSignificantTurnNonPoi(FiniteStateMachine<MicroPlannerMessage> machine, object test) { if (!PoiWithTurnMachine.TestPoi(machine, test)) { if (test is MicroPlannerMessagePoint) { MicroPlannerMessagePoint point = (test as MicroPlannerMessagePoint); if (point.Point.Angle != null) { if (point.Point.ArcsNotTaken == null || point.Point.ArcsNotTaken.Count == 0) { return true; } switch (point.Point.Angle.Direction) { case OsmSharp.Math.Geo.Meta.RelativeDirectionEnum.StraightOn: case RelativeDirectionEnum.SlightlyLeft: case RelativeDirectionEnum.SlightlyRight: return true; } } } return false; } return false; }
public void Input_handles_value_types() { var machine = new FiniteStateMachine<string, int>(); machine.CurrentState = "Start"; machine.Transitions.Add( new StateTransition<string, int>{InputValidator = i => i.Equals(0), FromState = "Start", ToState = "End"} ); machine.Input(0); }
public static FiniteStateMachine GenerateStateMachine(string id, int states, double transitionsPerState, double endStateProbability) { var fsm = new FiniteStateMachine(); var rand = new Random(); fsm.Id = id; for (int i = 0; i < states; i++) { var state = new State(); state.Name = "q" + i.ToString(); state.IsEndState = rand.NextDouble() < endStateProbability; fsm.States.Add(state); } var transitions = (int)Math.Floor(states * transitionsPerState + 0.5); for (int i = 0; i < transitions; i++) { State start; State end; string input; do { start = fsm.States[rand.Next(fsm.States.Count)]; end = fsm.States[rand.Next(fsm.States.Count)]; input = __inputs[rand.Next(__inputs.Length)]; } while (start.Transitions.Any(t => t.Input == input)); var transition = new Transition(); transition.StartState = start; transition.EndState = end; transition.Input = input; fsm.Transitions.Add(transition); } return fsm; }
public Generator() { mFSM = new FiniteStateMachine(Signals[0], () => Random()); mFSM.addState(Signals[1], () => Sine()); mFSM.addState(Signals[2], () => Square()); mFSM.addState(Signals[3], () => Sawtooth()); }
public RangeState(FiniteStateMachine fsm) : base(fsm) { _attack = fsm.GetComponent<KRAttack>(); _krtransform = fsm.GetComponent<KRTransform>(); _krmovement = fsm.GetComponent<KRMovement>(); }
public CooldownBehaviour(GameObject gameObject, FiniteStateMachine fsm, string variableName, float cooldown) : base(gameObject) { this.fsm = fsm; this.variableName = variableName; this.cooldown = cooldown; }
/// <summary> /// Tests if the given turn is significant. /// </summary> /// <param name="machine"></param> /// <param name="test"></param> /// <returns></returns> private static bool TestNonSignificantTurn(FiniteStateMachine<MicroPlannerMessage> machine, object test) { if (!TurnMachine.TestSignificantTurn(machine, test)) { // it is no signficant turn. return true; } return false; }
private void InitFSM() { this.FSM = new FiniteStateMachine<BossEntity>(this) .Add(new BossPatrolState()) .Add(new BossPlayerShootState()) .Add(new BossCircleShootState()) .Add(new BossSprayShootState()); }
public override void Perform(FiniteStateMachine fsm) { TransitionIndex = Math.Min(TransitionIndex, fsm.Transitions.Count - 1); var t = fsm.Transitions[TransitionIndex]; t.StartState = null; t.EndState = null; fsm.Transitions.RemoveAt(TransitionIndex); }
protected void Awake() { _fsm = new FiniteStateMachine(); _fsm.AddState(new MonsterWanderState(gameObject)); _fsm.ChangeState(new FSMTransition(MonsterState.Wander)); }
// Use this for initialization void Start() { stateMachine = GetComponent<FiniteStateMachine>(); stateMachine.InitializeStateMachine(); stateMachine.AddState(new BomberReachedScreenEdge(this.transform)); stateMachine.AddState(new BomberAttackingPlayer(this.transform, GameManager.instance.GetPlayer())); stateMachine.AddState(new BomberMovingToPosition(this.transform)); stateMachine.AddState(new BomberDead(this.transform)); }
// Use this for initialization private void Start() { State stateOne = new State("There was a dark cell. Press C to go to the corner"); State stateTwo = new State("There was a dark corner of a dark cell. Press B to go to go back"); stateOne.nextStates.Add(KeyCode.C, stateTwo); stateTwo.nextStates.Add(KeyCode.B, stateOne); stateMachine = new FiniteStateMachine(stateOne); stateMachine.states.Add(stateTwo); text.text = stateMachine.currentState.description; }
protected void Initialize() { StateBathroom = GetComponentInChildren(typeof(BathroomState)) as BathroomState; StateKitchen = GetComponentInChildren(typeof(KitchenState)) as KitchenState; StateBedroom = GetComponentInChildren(typeof(BedroomState)) as BedroomState; StateCloset = GetComponentInChildren(typeof(ClosetState)) as ClosetState; FSM = new FiniteStateMachine<MovingVoice>(this); }
/// <summary> /// Returns true if the given test object is a very short arc! /// </summary> /// <param name="test"></param> /// <param name="machine"></param> /// <returns></returns> private static bool TestVeryShortArc(FiniteStateMachine<MicroPlannerMessage> machine, object test) { if (test is MicroPlannerMessageArc) { MicroPlannerMessageArc arc = (test as MicroPlannerMessageArc); return arc.Arc.Distance.Value < 20; } return false; }
protected void Awake() { _fsm = new FiniteStateMachine(); _fsm.AddState(new HeroSeekState(gameObject)); _fsm.AddState(new HeroWalkState(gameObject)); _fsm.AddState(new HeroWaitState(gameObject)); //_fsm.ChangeState(new FSMTransition(HeroState.Seek)); }
public Monster() { random = new Random(); components.Add(timerWrapper = new TimerWrapper()); timerWrapper.AutoCreateTimers = true; components.Add(brain = new FiniteStateMachine()); components.Add(targetComponent = new TargetingComponent<Player>(this)); }
// Use this for initialization void Start() { stateMachine = GetComponent<FiniteStateMachine>(); stateMachine.InitializeStateMachine(); stateMachine.AddState(new GunnerReachedScreenEdge(this.transform)); stateMachine.AddState(new GunnerAttackingPlayer(this.transform)); stateMachine.AddState(new GunnerMovingToPosition(this.transform)); stateMachine.AddState(new GunnerInFormation(this.transform)); stateMachine.AddState(new GunnerDead(this.transform)); }
public void Init() { initialPosition = body.transform.position; accessibilityStateMachine = gameObject.AddComponent<FiniteStateMachine>(); stateMachine = gameObject.AddComponent<FiniteStateMachine>(); accessibilityStateMachine.currentState = new DoorIsLockedState(this); stateMachine.currentState = new DoorIsClosedState(this); }
public FSEvent (string name, string target, FSState state, FiniteStateMachine owner, FiniteStateMachine.EnterState e, FiniteStateMachine.PushState pu, FiniteStateMachine.PopState po) { mStateOwner = state; mEventName = name; mTargetState = target; mOwner = owner; eType = EventType.NONE; mEnterDelegate = e; mPushDelegate = pu; mPopDelegate = po; }
public override void Perform(FiniteStateMachine fsm) { var t = new Transition() { Input = Input, StartState = fsm.States[StartStateIndex], EndState = fsm.States[EndStateIndex] }; fsm.Transitions.Add(t); }
public FSEvent(string mEventName, string mTargetState, FSState mStateOwner, FiniteStateMachine mOwner, FiniteStateMachine.EnterState mEnterDelegate, FiniteStateMachine.PushState mPushDelegate, FiniteStateMachine.PopState mPopDelegate) { this.mEventName = mEventName; this.mTargetState = mTargetState; this.mStateOwner = mStateOwner; this.mOwner = mOwner; this.mEnterDelegate = mEnterDelegate; this.mPushDelegate = mPushDelegate; this.mPopDelegate = mPopDelegate; this.eType = EventType.NONE; }
void Awake() { stateBuild = new HouseStateBuild(); stateIdle = new HouseStateIdle(); stateOpen = new HouseStateOpen(); stateClose = new HouseStateClose(); stateDestroy = new HouseStateDestroy(); FSM = new FiniteStateMachine<HouseController>(); houseAnimation = this.GetComponentInChildren<HouseAnimation>(); }
protected void Awake() { _fsm = new FiniteStateMachine(); _fsm.AddState(new GameCreateState()); _fsm.AddState(new GameResetState()); _fsm.AddState(new GamePlayState()); _fsm.AddState(new GameWinState()); _fsm.AddState(new GameLoseState()); _fsm.ChangeState(new FSMTransition(GameState.GameCreate)); }
public Robot() { mJointFSM = new FiniteStateMachine[6]; mLastMS = new long[6]; for (int i = 0; i < 6; i++) { int lIndex = i; mJointFSM[i] = new FiniteStateMachine("Stable", () => StableState(lIndex)); mJointFSM[i].addState("Moving", () => MovingState(lIndex)); } }
void Awake() { squaredAttackDistance = attackDistance * attackDistance; rb2d = GetComponent<Rigidbody2D>(); boxCollider2d = GetComponent<BoxCollider2D>(); animator = GetComponent<Animator>(); wanderScript = GetComponent<Wander>(); fsm = new FiniteStateMachine<MeleeEnemyAI>(this, MeleeEnemyIdleState.Instance); meleeEnemies.Add(this); }
void ShowCooldowns(FiniteStateMachine fsm) { GUILayout.Label("Cooldowns", EditorStyles.boldLabel); Dictionary<string, float> variables = fsm.cooldowns; foreach (string variable in variables.Keys) { GUILayout.Space(2); GUILayout.BeginHorizontal(); string name = variable; EditorGUILayout.LabelField(name, variables[variable].ToString(), EditorStyles.boldLabel); GUILayout.EndHorizontal(); } }
// Use this for initialization void Start() { transform.rotation = Quaternion.LookRotation(GameManager.instance.GetPlayer().position - transform.position, new Vector3(0, 0, -1)); stateMachine = GetComponent<FiniteStateMachine>(); stateMachine.InitializeStateMachine(); stateMachine.AddState(new FighterAttackingPlayer(transform, gameMng.GetPlayer())); stateMachine.AddState(new FighterReachedScreenEdge(transform, gameMng.GetPlayer())); stateMachine.AddState(new FighterDead(transform)); partners = new FighterController[2]; }
void Start() { //Initialise the state machine FSM = new FiniteStateMachine<Main, Main.States>(this); FSM.RegisterState(stateInit); FSM.RegisterState(stateGamePlay); FSM.RegisterState(stateGameOverWinner); FSM.RegisterState(stateGameOverLoser); //Kick things off ChangeState(stateInit.StateID); }
public YellowState(Light light, FiniteStateMachine stateMachine) : base(light, stateMachine) { }
private void Start() { fsm = GetComponent <FiniteStateMachine>(); fsm.StartState("Idle"); }
/// <summary> /// Initializes a new instance of the <see cref="Midfielder"/> class. /// </summary> /// <param name="player">The football player.</param> /// <param name="footballAI">The <see cref="FsmAI" /> instance to which this player belongs.</param> public Midfielder(FootballPlayer player, FsmAI footballAI) : base(player, footballAI) { StateMachine = new FiniteStateMachine <Player>(this, new Default(this, footballAI), new MidfielderGlobalState(this, footballAI)); }
public E1_IdleState(Entity entity, FiniteStateMachine stateMachine, string animBoolName, D_IdleState stateData, Enemy1 enemy) : base(entity, stateMachine, animBoolName, stateData) { this.enemy = enemy; }
public SM1_DeadState(FiniteStateMachine stateMachine, Entity entity, string animBoolName, DeadStateData stateData, SlowMutant1 enemy) : base(stateMachine, entity, animBoolName, stateData) { this.enemy = enemy; }
public abstract bool ConditionTriggered(FiniteStateMachine stateMachine);
protected Turret() { _nullAI = new NullAI(this); _ai = new FiniteStateMachine <TurretAI>(); }
public IdleState(Entity _entity, FiniteStateMachine _stateMachine, string _animBoolName, D_IdleState _stateData) : base(_entity, _stateMachine, _animBoolName) { stateData = _stateData; }
public EWanderingHusk_LookForPlayerState(Entity entity, FiniteStateMachine stateMachine, string animBoolName, D_LookForPlayerState stateData, Enermy_WanderingHusk enermy) : base(entity, stateMachine, animBoolName, stateData) { this.enermy = enermy; }
public ESoulWarrior_TeleportState(Entity entity, FiniteStateMachine stateMachine, string animBoolName, D_TeleportOutState stateData, Enermy_SoulWarrior enermy) : base(entity, stateMachine, animBoolName, stateData) { this.enermy = enermy; }
public E4_PlayerDetectedState(Entity entity, FiniteStateMachine stateMachine, string animBoolName, D_PlayerDetected stateData, Enemy4 enemy) : base(entity, stateMachine, animBoolName, stateData) { this.enemy = enemy; }
public DialogStartState(FiniteStateMachine StateMachine) { this.StateMachine = StateMachine; }
public Blob_MeleeAttackState(Entity _entity, FiniteStateMachine _stateMachine, string _animBoolName, Transform _attackPosition, D_MeleeAttack _stateData, Blob _enemy) : base(_entity, _stateMachine, _animBoolName, _attackPosition, _stateData) { enemy = _enemy; }
public PlayerDetectedState(FiniteStateMachine finiteStateMachine, Entity entity, string animationBoolName, D_PlayerDetectedState stateData) : base(finiteStateMachine, entity, animationBoolName) { this.stateData = stateData; }
public void Setup() { fsm = new FiniteStateMachine("turkish_finite_state_machine.xml"); stateList = fsm.GetStates(); }
public DefenceState(FiniteStateMachine stateMachine, Entity entity, string animName, DefenceStateData data, State defaultNextState = null) : base(stateMachine, entity, animName, defaultNextState) { this.data = data; }
public abstract FSMState <T> CreateStateFromType(T type, FiniteStateMachine <T> owner);
public SlowDownState(FiniteStateMachine finiteStateMachine, Enemy enemy, string animationBoolName, D_SlowDownState stateData) : base(finiteStateMachine, enemy, animationBoolName) { StateData = stateData; }
private void OnPlanCompleted(IEnumerable <GOAPAction> plan) { _fsm = GoapPlanner.ConfigureFSM(plan, StartCoroutine); _fsm.Active = true; }
public StunState(Entity entity, FiniteStateMachine stateMachine, string animBoolName, D_StunState stateData) : base(entity, stateMachine, animBoolName) { this.stateData = stateData; }
private void ConfigureFsm(IEnumerable <GOAPAction> plan) { Debug.Log("Completed Plan"); _fsm = GoapPlanner.ConfigureFSM(plan, StartCoroutine); _fsm.Active = true; }
public MoveState(EntityNPC entity, FiniteStateMachine stateMachine, string animBoolName, D_MoveState stateData) : base(entity, stateMachine, animBoolName) { this.stateData = stateData; }
public Golem_PlayerDetectedState(Entity _entity, FiniteStateMachine _stateMachine, string _animBoolName, D_PlayerDetected _stateData, Golem _enemy) : base(_entity, _stateMachine, _animBoolName, _stateData) { enemy = _enemy; }
void Start() { fsm = new FiniteStateMachine <Client>(this); fsm.ChangeState <ClientStateNotConnected>(); }
public E2_DeathState(Entity etity, FiniteStateMachine stateMachine, string animBoolName, D_DeathState stateData, Enemy2 enemy) : base(etity, stateMachine, animBoolName, stateData) { this.enemy = enemy; }
public LazerIdleState(FiniteStateMachine parent, float waitTime) : base(parent, waitTime) { audioSource = parent.GetParent().GetComponent <AudioSource>(); }
public Skeleton_IdleState(FiniteStateMachine stateMachine, Entity entity, string animationName, Data_IdleState stateData, Skeleton skeleton) : base(stateMachine, entity, animationName, stateData) { this.skeleton = skeleton; }
public FSMState <T> CreateInitialState(FiniteStateMachine <T> owner) { return(CreateStateFromType(InitialState, owner)); }
public Skeleton_PlayerDetectedState(EntityNPC entity, FiniteStateMachine stateMachine, string animBoolName, D_PlayerDetectedState stateData, EnemySkeleton enemy) : base(entity, stateMachine, animBoolName, stateData) { this.enemy = enemy; }
public Samurai_AttackSword3(EntityNPC entity, FiniteStateMachine stateMachine, string animBoolName, D_MeleeAttackState stateData, EnemySamurai enemy) : base(entity, stateMachine, animBoolName, stateData) { this.enemy = enemy; }