private void Initiallize() { defaultGameMode = new DefaultGameMode(); defaultGameState1 = new DefaultGameState1(); defaultGameState2 = new DefaultGameState2(); defaultGameMode.InitailizeGameState(defaultGameState1); defaultGameMode.InitailizeGameState(defaultGameState2); TestRunnerHelper.Reset(); }
private void InitiallizeFSM() { root = new TestFSMRoot(); state1 = new TestFSMState1(); state2 = new TestFSMState2(); state3 = new TestFSMState3(); root.AddState(state1); root.AddState(state2); root.AddState(state3); TestRunnerHelper.Reset(); }
public IEnumerator NotOverrideTest() { FSMRoot <ETestRunenrEnum> fSMRoot = new FSMRoot <ETestRunenrEnum>(); fSMRoot.AddState(new FSMState <ETestRunenrEnum>(ETestRunenrEnum.Test1)); fSMRoot.AddState(new FSMState <ETestRunenrEnum>(ETestRunenrEnum.Test2)); fSMRoot.AddState(new FSMState <ETestRunenrEnum>(ETestRunenrEnum.Test3)); TestRunnerHelper.Reset(); TestRunnerHelper.testBoolean = false; fSMRoot.OnRunAction = () => { TestRunnerHelper.testBoolean = true; }; fSMRoot.OnUpdateAction = () => { TestRunnerHelper.testFloat += 1.0f; }; fSMRoot.OnStopAction = () => { TestRunnerHelper.testBoolean = false; }; FSMState <ETestRunenrEnum> fsmState = fSMRoot.GetState(ETestRunenrEnum.Test1); fsmState.OnEnterAction = () => { TestRunnerHelper.testInt = 1; }; fsmState.OnStayAction = () => { TestRunnerHelper.testInt += 1; }; fsmState.OnExitAction = () => { TestRunnerHelper.testFloat = 0.1f; }; fsmState = fSMRoot.GetState(ETestRunenrEnum.Test2); fsmState.OnEnterAction = () => { TestRunnerHelper.testInt = 2; }; fsmState.OnStayAction = () => { TestRunnerHelper.testInt -= 2; }; fsmState.OnExitAction = () => { TestRunnerHelper.testFloat = 0.2f; }; fsmState = fSMRoot.GetState(ETestRunenrEnum.Test3); fsmState.OnEnterAction = () => { TestRunnerHelper.testInt = 3; }; fsmState.OnStayAction = () => { TestRunnerHelper.testInt += 3; }; fsmState.OnExitAction = () => { TestRunnerHelper.testFloat = 0.3f; }; fSMRoot.Run(ETestRunenrEnum.Test1); Assert.AreEqual(true, TestRunnerHelper.testBoolean); Assert.AreEqual(1, TestRunnerHelper.testInt); while (fSMRoot.Update()) { if (TestRunnerHelper.testInt > 30) { Assert.AreEqual(true, TestRunnerHelper.testFloat >= 30.0f); fSMRoot.Transition(ETestRunenrEnum.Test2); break; } yield return(null); } Assert.AreEqual(2, TestRunnerHelper.testInt); Assert.AreEqual(0.1f, TestRunnerHelper.testFloat); while (fSMRoot.Update()) { if (TestRunnerHelper.testInt < -60) { Assert.AreEqual(true, TestRunnerHelper.testFloat >= 30.0f); fSMRoot.Transition(ETestRunenrEnum.Test3); break; } yield return(null); } Assert.AreEqual(3, TestRunnerHelper.testInt); Assert.AreEqual(0.2f, TestRunnerHelper.testFloat); while (fSMRoot.Update()) { if (TestRunnerHelper.testInt > 90) { Assert.AreEqual(true, TestRunnerHelper.testFloat >= 30.0f); fSMRoot.Stop(); break; } yield return(null); } Assert.AreEqual(0.3f, TestRunnerHelper.testFloat); Assert.AreEqual(false, TestRunnerHelper.testBoolean); yield return(null); }