本文整理汇总了C#中StateMachine.Transition方法的典型用法代码示例。如果您正苦于以下问题:C# StateMachine.Transition方法的具体用法?C# StateMachine.Transition怎么用?C# StateMachine.Transition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StateMachine
的用法示例。
在下文中一共展示了StateMachine.Transition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Check
protected override void Check()
{
var sm = new StateMachine<S>(S.A);
sm.Transition(
from: S.A,
to: S.B);
(sm == S.B).ShouldBe(true);
sm.Transition(
from: S.B,
to: S.A,
guard: false);
(sm == S.B).ShouldBe(true);
sm.Transition(
from: S.A,
to: S.A);
(sm == S.B).ShouldBe(true);
var x = 0;
sm.Transition(
from: S.B,
to: S.C,
guard: x == 0,
action: () => x = 17);
(sm == S.C).ShouldBe(true);
x.ShouldBe(17);
}
示例2: Ponder
public void Ponder(StateMachine machine, float delta)
{
foreach(Transition transition in transitions)
{
State next = transition.TryNextState(machine);
if (next != null)
{
machine.Transition(next);
}
}
}
示例3: Setup
// Here we initialize our app.
public override void Setup()
{
//Init Hashtables
cHash = new Hashtable();
pHash = new Hashtable();
eHash = new Hashtable();
int i = 0;
// Load up the list of images.
mImageNames = LoadImageIndex();
mDripNames = LoadDripIndex("r");
mPdripNames = LoadPdripIndex("r");
mYDripNames = LoadDripIndex("y");
mYPdripNames = LoadPdripIndex("y");
mBDripNames = LoadDripIndex("b");
mBPdripNames = LoadPdripIndex("b");
mBEcoliNames = LoadEColiIndex("b");
mREcoliNames = LoadEColiIndex("r");
mYEcoliNames = LoadEColiIndex("y");
mEcoliNames = LoadEColiIndex("w");
mEcoliTravelNames = LoadSameEColiTravelIndex("w");
mBEcoliTravelNames = LoadSameEColiTravelIndex("b");
mREcoliTravelNames = LoadSameEColiTravelIndex("r");
mYEcoliTravelNames = LoadSameEColiTravelIndex("y");
mBYEcoliTravelNamesC1 = LoadMixC1EcoliTravelIndex("b", "y");
mBYEcoliTravelNamesC2 = LoadMixC2EcoliTravelIndex("b", "y");
mRBEcoliTravelNamesC1 = LoadMixC1EcoliTravelIndex("r", "b");
mRBEcoliTravelNamesC2 = LoadMixC2EcoliTravelIndex("r", "b");
mRYEcoliTravelNamesC1 = LoadMixC1EcoliTravelIndex("r", "y");
mRYEcoliTravelNamesC2 = LoadMixC2EcoliTravelIndex("r", "y");
mWBEcoliTravelNamesC1 = LoadMixC1EcoliTravelIndex("w", "b");
mWBEcoliTravelNamesC2 = LoadMixC2EcoliTravelIndex("w", "b");
mWREcoliTravelNamesC1 = LoadMixC1EcoliTravelIndex("w", "r");
mWREcoliTravelNamesC2 = LoadMixC2EcoliTravelIndex("w", "r");
mWYEcoliTravelNamesC1 = LoadMixC1EcoliTravelIndex("w", "y");
mWYEcoliTravelNamesC2 = LoadMixC2EcoliTravelIndex("w", "y");
Array.Sort(mDripNames);
Array.Sort(mPdripNames);
Array.Sort(mYDripNames);
Array.Sort(mYPdripNames);
Array.Sort(mBDripNames);
Array.Sort(mBPdripNames);
Array.Sort(mBEcoliNames);
Array.Sort(mREcoliNames);
Array.Sort(mYEcoliNames);
Array.Sort(mEcoliNames);
Array.Sort(mEcoliTravelNames);
Array.Sort(mBEcoliTravelNames);
Array.Sort(mREcoliTravelNames);
Array.Sort(mYEcoliTravelNames);
Array.Sort(mBYEcoliTravelNamesC1);
Array.Sort(mBYEcoliTravelNamesC2);
Array.Sort(mRBEcoliTravelNamesC1);
Array.Sort(mRBEcoliTravelNamesC2);
Array.Sort(mRYEcoliTravelNamesC1);
Array.Sort(mRYEcoliTravelNamesC2);
Array.Sort(mWBEcoliTravelNamesC1);
Array.Sort(mWBEcoliTravelNamesC2);
Array.Sort(mWREcoliTravelNamesC1);
Array.Sort(mWREcoliTravelNamesC2);
Array.Sort(mWYEcoliTravelNamesC1);
Array.Sort(mWYEcoliTravelNamesC2);
//Init the StateMachine
sm = new StateMachine();
//Init the Controllers
whitePlasmidController = new PlasmidController(this);
yellowPlasmidController = new YellowPlasmidController(this);
redPlasmidController = new RedPlasmidController (this);
bluePlasmidController = new BluePlasmidController(this);
sm.State("White", whitePlasmidController);
sm.State("Yellow", yellowPlasmidController);
sm.State("Red", redPlasmidController);
sm.State("Blue", bluePlasmidController);
sm.Transition("White", tWhiteToYellow, "Yellow");
sm.Transition("White", tWhiteToRed, "Red");
sm.Transition("White", tWhiteToBlue, "Blue");
sm.SetState("White", tWhiteToYellow);
//Log.Debug("mImageNames Length: " + mImageNames.Length);
//Log.Debug("mDripNames Length: " + mDripNames.Length);
//Log.Debug("mPdripNames Length: " + mPdripNames.Length);
//Log.Debug("mYDripNames Length: " + mYDripNames.Length);
//Log.Debug("mYPdripNames Length: " + mYPdripNames.Length);
//.........这里部分代码省略.........
示例4: Setup
// called during intitialization, before the game has started to run
public override void Setup()
{
Log.Debug ("Setup()");
mNeedCheck = true;
// Load up the list of images.
mImageNames = LoadImageIndex ();
System.Version myVersion = System.Reflection.Assembly.GetExecutingAssembly ().GetName ().Version;
Log.Debug (myVersion.ToString ());
//Init the State Machine
sm = new StateMachine ();
//Init the Controllers
titleController = new TitleController ();
menuController = new MenuController (this, CubeSet);
gameController = new GameController ();
gameBeginController = new GameBeginController (this, CubeSet);
gameShuffleController = new GameShuffleController (this, CubeSet);
gameEndController = new GameEndController (this, CubeSet);
sm.State ("Title", titleController);
sm.State ("Menu", menuController);
sm.State ("Game", gameController);
sm.State ("GameBegin", gameBeginController);
sm.State ("GameShuffle", gameShuffleController);
sm.State ("GameEnd", gameEndController);
sm.Transition ("Title", "TitleToMenu", "Menu");
sm.Transition ("Menu", tMenuToGameBegin, "GameBegin");
sm.Transition ("GameBegin", tGameBeginToMenu, "Menu");
sm.Transition ("GameBegin", tGameBeginToGameShuffle, "GameShuffle");
sm.Transition ("GameShuffle", tGameShuffleToGameEnd, "GameEnd");
sm.Transition ("GameEnd", tGameEndToMenu, "Menu");
sm.SetState ("Menu", "MenuToGameBegin");
// Loop through all the cubes and set them up.
lastIndex = 1;
foreach (Cube cube in CubeSet) {
CubeWrapper wrapper = new CubeWrapper (this, cube, lastIndex);
lastIndex += 1;
mWrappers.Add (wrapper);
}
this.PauseEvent += OnPause;
this.UnpauseEvent += OnUnpause;
CubeSet.NewCubeEvent += OnNewCube;
CubeSet.LostCubeEvent += OnLostCube;
CubeSet.NeighborAddEvent += OnNeighborAdd;
CubeSet.NeighborRemoveEvent += OnNeighborRemove;
}
示例5: SetupStateMachine
/*
* StateMachine Initialization
*/
private StateMachine SetupStateMachine()
{
//Init the State Machine
StateMachine sm = new StateMachine ();
//Init the Controllers
titleController = new TitleController ();
menuController = new MenuController ();
gameController = new GameController ();
gameBeginController = new GameBeginController ();
gameEndController = new GameEndController ();
sm.State (Constants.TitleState, titleController);
sm.State (Constants.MenuState, menuController);
sm.State (Constants.GameState, gameController);
sm.State (Constants.GameBegin, gameBeginController);
sm.State (Constants.GameEndState, gameEndController);
sm.Transition ("Title", "TitleToMenu", "Menu");
sm.Transition (Constants.MenuState, Constants.tMenuToGameBegin, Constants.GameBegin);
sm.Transition (Constants.GameBegin, Constants.tGameBeginToMenu, Constants.MenuState);
sm.Transition (Constants.GameBegin, Constants.tGameBeginToGame, Constants.GameState);
sm.Transition (Constants.GameState, Constants.tGameToGameEnd, Constants.GameEndState);
sm.Transition (Constants.GameEndState, Constants.tGameEndToMenu, Constants.MenuState);
//Set the Current State
sm.SetState (Constants.MenuState, Constants.tMenuToGameBegin);
return sm;
}
示例6: InitStateMachine
//Setup Operand Cube
private void InitStateMachine()
{
mCubeStateMachine = new StateMachine ();
operandController = new OperandController (mCube);
operatorController = new OperatorController (mCube);
hintController = new HintController (mCube);
resultController = new ResultController (mCube);
mCubeStateMachine.State (Constants.HintState, hintController);
mCubeStateMachine.State (Constants.OperandState, operandController);
mCubeStateMachine.State (Constants.OperatorState, operatorController);
mCubeStateMachine.State (Constants.ResultState, resultController);
mCubeStateMachine.Transition (Constants.OperandState, Constants.tOperandToOperatorState, Constants.OperatorState);
mCubeStateMachine.Transition (Constants.OperatorState, Constants.tOperatorToOperandState, Constants.OperandState);
mCubeStateMachine.SetState (mRole.stateName, mRole.stateTransition);
/*
if (mIndex == 6) { //Must have 6 cubes to play
//Set hint cube as last cube in set
mCubeStateMachine.SetState (Constants.HintState, Constants.tTitleToHintState);
//Value is negative for Hint Cube
mValue = -1;
} else if (mIndex % 2 == 0) {
//Number is Even - Make that cube an Operator Cube
SetupOperandCube ();
}
mCubeStateMachine.SetState (Constants.OperandState, Constants.tTitleToOperandState);
//Randome for OperandCube
mValue = RandomNumber (0, 9);
*/
}