本文整理汇总了C#中StateMachine.ChangeState方法的典型用法代码示例。如果您正苦于以下问题:C# StateMachine.ChangeState方法的具体用法?C# StateMachine.ChangeState怎么用?C# StateMachine.ChangeState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StateMachine
的用法示例。
在下文中一共展示了StateMachine.ChangeState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start()
{
sm = StateMachine<States>.Initialize(this);
sm.ChangeState(States.Lobby);
resourceManager = this.GetComponent<ResourceManager>();
currentPlayer = playerManager.currentPlayer;
}
示例2: Start
// Use this for initialization
void Start()
{
GoToMiddleOfTile();
speed_max = 3;
state_machine = new StateMachine();
state_machine.ChangeState(new StateGelStopped(this));
}
示例3: Start
// Use this for initialization
void Start ()
{
GoToMiddleOfTile();
speed_max = 3;
state_machine = new StateMachine();
state_machine.ChangeState(new StateKeeseNormal(this, GetComponent<SpriteRenderer>(), flap));
}
示例4: InitialTransition
public void InitialTransition()
{
//This is an odd request by a user, where they wanted to use methods declared in a super class. By default we expect this to fail, but we can enable this behaivour
//by removing BindingFlags.DeclaredOnly from the reflection routine in StateMachine.cs
fsm = engine.Initialize<States>(behaviour, States.One);
fsm.ChangeState(States.Two);
//Test for when we want to include superclass methods
//Assert.AreEqual(1, behaviour.oneStats.enterCount);
//Assert.AreEqual(0, behaviour.oneStats.updateCount);
//Assert.AreEqual(0, behaviour.oneStats.lateUpdateCount);
//Assert.AreEqual(1, behaviour.oneStats.exitCount);
//Assert.AreEqual(1, behaviour.oneStats.finallyCount);
//Assert.AreEqual(1, behaviour.twoStats.enterCount);
//Assert.AreEqual(0, behaviour.twoStats.updateCount);
//Assert.AreEqual(0, behaviour.twoStats.lateUpdateCount);
//Assert.AreEqual(0, behaviour.twoStats.exitCount);
//Assert.AreEqual(0, behaviour.twoStats.finallyCount);
//Test for no superclass methods
Assert.AreEqual(0, behaviour.oneStats.enterCount);
Assert.AreEqual(0, behaviour.oneStats.updateCount);
Assert.AreEqual(0, behaviour.oneStats.lateUpdateCount);
Assert.AreEqual(0, behaviour.oneStats.exitCount);
Assert.AreEqual(0, behaviour.oneStats.finallyCount);
Assert.AreEqual(0, behaviour.twoStats.enterCount);
Assert.AreEqual(0, behaviour.twoStats.updateCount);
Assert.AreEqual(0, behaviour.twoStats.lateUpdateCount);
Assert.AreEqual(0, behaviour.twoStats.exitCount);
Assert.AreEqual(0, behaviour.twoStats.finallyCount);
}
示例5: Awake
void Awake()
{
hunger = 0;
hungerThreashold =30;
nose = (WolfScent)GetComponentInChildren<WolfScent>();
eyes = (WolfSight)GetComponentInChildren<WolfSight>();
thisWolf = new StateMachine<Wolf>(this);
thisWolf.ChangeState(WolfRest.Instance());
}
示例6: InitialTransition
public void InitialTransition()
{
fsm = engine.Initialize<States>(behaviour, States.One);
fsm.ChangeState(States.Two);
Assert.AreEqual(1, behaviour.oneStats.enterCount);
Assert.AreEqual(0, behaviour.oneStats.updateCount);
Assert.AreEqual(0, behaviour.oneStats.lateUpdateCount);
Assert.AreEqual(1, behaviour.oneStats.exitCount);
Assert.AreEqual(1, behaviour.oneStats.finallyCount);
Assert.AreEqual(1, behaviour.twoStats.enterCount);
Assert.AreEqual(0, behaviour.twoStats.updateCount);
Assert.AreEqual(0, behaviour.twoStats.lateUpdateCount);
Assert.AreEqual(0, behaviour.twoStats.exitCount);
Assert.AreEqual(0, behaviour.twoStats.finallyCount);
Assert.AreEqual(0, behaviour.threeStats.enterCount);
Assert.AreEqual(0, behaviour.threeStats.updateCount);
Assert.AreEqual(0, behaviour.threeStats.lateUpdateCount);
Assert.AreEqual(0, behaviour.threeStats.exitCount);
Assert.AreEqual(0, behaviour.threeStats.finallyCount);
behaviour.enabled = false;
fsm.ChangeState(States.Three);
Assert.AreEqual(1, behaviour.oneStats.enterCount);
Assert.AreEqual(0, behaviour.oneStats.updateCount);
Assert.AreEqual(0, behaviour.oneStats.lateUpdateCount);
Assert.AreEqual(1, behaviour.oneStats.exitCount);
Assert.AreEqual(1, behaviour.oneStats.finallyCount);
Assert.AreEqual(1, behaviour.twoStats.enterCount);
Assert.AreEqual(0, behaviour.twoStats.updateCount);
Assert.AreEqual(0, behaviour.twoStats.lateUpdateCount);
Assert.AreEqual(1, behaviour.twoStats.exitCount);
Assert.AreEqual(1, behaviour.twoStats.finallyCount);
Assert.AreEqual(1, behaviour.threeStats.enterCount);
Assert.AreEqual(0, behaviour.threeStats.updateCount);
Assert.AreEqual(0, behaviour.threeStats.lateUpdateCount);
Assert.AreEqual(0, behaviour.threeStats.exitCount);
Assert.AreEqual(0, behaviour.threeStats.finallyCount);
}
示例7: TestCallbacks
public void TestCallbacks()
{
List<string> messages = new List<string>();
StateMachine<TestNum> machine = new StateMachine<TestNum>();
machine.AddState(TestNum.Red);
machine.SubscribeToEntry(TestNum.Red, (TestNum oldState, TestNum newState) =>
{
messages.Add("Enter the red!");
});
machine.SubscribeToExit(TestNum.Red, (TestNum oldState, TestNum newState) =>
{
messages.Add("Exit the red!");
});
machine.AddState(TestNum.White);
machine.SubscribeToEntry(TestNum.White, (TestNum oldState, TestNum newState) =>
{
messages.Add("Enter the white!");
});
machine.SubscribeToExit(TestNum.White, (TestNum oldState, TestNum newState) =>
{
messages.Add("Exit the white!");
});
machine.SubscribeToExit(TestNum.White, (TestNum oldState, TestNum newState) =>
{
messages.Add("Sneaky Second Message!");
});
machine.ChangeState(TestNum.Red);
machine.ChangeState(TestNum.White);
machine.ChangeState(TestNum.Red);
Assert.AreEqual(6, messages.Count);
Assert.AreEqual("Enter the red!", messages[0]);
Assert.AreEqual("Exit the red!", messages[1]);
Assert.AreEqual("Enter the white!", messages[2]);
Assert.AreEqual("Exit the white!", messages[3]);
Assert.AreEqual("Sneaky Second Message!", messages[4]);
Assert.AreEqual("Enter the red!", messages[5]);
}
示例8: IgnoreMultipleTransitions
public void IgnoreMultipleTransitions()
{
fsm = engine.Initialize<States>(behaviour, States.One);
fsm.ChangeState(States.Two);
fsm.ChangeState(States.Two);
Assert.AreEqual(1, behaviour.oneStats.enterCount);
Assert.AreEqual(0, behaviour.oneStats.updateCount);
Assert.AreEqual(0, behaviour.oneStats.lateUpdateCount);
Assert.AreEqual(1, behaviour.oneStats.exitCount);
Assert.AreEqual(1, behaviour.oneStats.finallyCount);
Assert.AreEqual(1, behaviour.twoStats.enterCount);
Assert.AreEqual(0, behaviour.twoStats.updateCount);
Assert.AreEqual(0, behaviour.twoStats.lateUpdateCount);
Assert.AreEqual(0, behaviour.twoStats.exitCount);
Assert.AreEqual(0, behaviour.twoStats.finallyCount);
Assert.AreEqual(0, behaviour.threeStats.enterCount);
Assert.AreEqual(0, behaviour.threeStats.updateCount);
Assert.AreEqual(0, behaviour.threeStats.lateUpdateCount);
Assert.AreEqual(0, behaviour.threeStats.exitCount);
Assert.AreEqual(0, behaviour.threeStats.finallyCount);
}
示例9: Awake
// Use this for initialization
void Awake() {
if (S != null)
Debug.LogError("Multiple players!");
S = this;
start_point = transform.position;
health = maxhealth;
animation_state_machine = new StateMachine();
animation_state_machine.ChangeState(new StateIdleWithSprite(this, GetComponent<SpriteRenderer>(), link_run_down[0]));
control_state_machine = new StateMachine();
control_state_machine.ChangeState(new StateLinkNormalMovement(this));
roomPos = new Vector3(-1000000, -1000000);
enemySpawnTimer = .5f;
}
示例10: Awake
//Vector2 dirVec;
//private int angle;
//Quaternion newDirToRotate;
//public float length, yVec;
//public bool isMoving, hasRotated, enumFinished, inState, test;
// Use this for initialization
void Awake()
{
Fatigue = 0;
fuzzyFatigue = Random.Range(60,120);
//inState = false;
//test = false;
thisDuck = new StateMachine<MotherDuck>(this);
thisDuck.ChangeState(MotherDuckWandering.Instance());
//thisDuck.UpdateState();
movement = Vector3.zero;
//prevMovement = Vector3.zero;
//isMoving = true;
//hasRotated = false;
//enumFinished = false;
}
示例11: Check
protected override void Check()
{
var s1 = new StateMachine<E>(E.B);
var s2 = new StateMachine<E>(E.C);
var s3 = new StateMachine<E>(E.G);
GenerateCode(SerializationMode.Optimized, s1, s2, s3);
StateSlotCount.ShouldBe(1);
Serialize();
s1.ChangeState(E.A);
s2.ChangeState(E.A);
s3.ChangeState(E.A);
Deserialize();
s1.State.ShouldBe(E.B);
s2.State.ShouldBe(E.C);
s3.State.ShouldBe(E.G);
}
示例12: AerialPursuer
public AerialPursuer(State<AerialPursuer> startState,
Point position,
float radius,
Vector2D velocity,
float maxSpeed,
Vector2D heading,
float mass,
Vector2D scale,
float turnRate,
float maxForce,
List<Node> patrolPath,
Workspace traversabilityMap,
Workspace visibilityMap)
: base(position, radius, velocity, maxSpeed, heading, mass, scale, turnRate, maxForce, patrolPath, traversabilityMap, visibilityMap)
{
StateMachine = new StateMachine<AerialPursuer>(this);
if (startState != null)
{
StateMachine.SetCurrentState(startState);
StateMachine.ChangeState(startState);
StateMachine.SetGlobalState(GlobalAerialPursuerStates.TheInstance);
}
}
示例13: Start
// Use this for initialization
void Start()
{
health = 3.0f;
state_machine = new StateMachine();
state_machine.ChangeState(new StateAquamentusNormal(this, GetComponent<SpriteRenderer>(), walk));
}
示例14: Start
// Use this for initialization
void Start()
{
startPos = new Vector3((int)Mathf.Round(transform.position.x), (int)Mathf.Round(transform.position.y), 0);
state_machine = new StateMachine();
state_machine.ChangeState(new StateBladetrapNormal(this));
}
示例15: Start
void Start()
{
player_state_machine = new StateMachine();
player_state_machine.ChangeState(new State_Player_Normal_Movement(this));
}