// use this to initialize any game specific logic public void StartChallenge() { IsStarted = true; goalState = Instantiate(goalState); failState = Instantiate(failState); Debug.Log("chellege staert"); }
private State GetState(States state) { State result; switch (state) { case States.SPLASH: result = new SplashState(this); break; case States.GAME: result = new GameState(this); break; case States.PAUSE: result = new PauseState(this, CurrentState.StateIdentifier); break; case States.MAINMENU: result = new MainMenuState(this); break; case States.CREDIT: result = new CreditState(this); break; default: result = new FailState(this); break; } return(result); }
// use this to initialize any game specific logic public void StartChallenge() { //goalState.enabled = true; //failState.enabled = true; IsStarted = true; this.gameObject.SetActive(true); goalState = GetComponent<GoalState>(); failState = GetComponent<FailState>(); Debug.Log("chellege staert"); }
public GameController() { prepare = new PrepareState(this, new GameController.Context(this)); playing = new PlayingState(this, new GameController.Context(this)); win = new WinState(this, new GameController.Context(this)); menu = new MenuState(this, new GameController.Context(this)); remember = new RememberState(this, new GameController.Context(this)); repeat = new RepeatState(this, new GameController.Context(this)); fail = new FailState(this, new GameController.Context(this)); }
private void Start() { renderComponent = GetComponent <SpriteRenderer>(); trailComponent = GetComponent <TrailRenderer>(); anim = GetComponent <Animator>(); menuIdle = new MenuIdle(this); intoScene = new IntoScene(this); gameIdle = new GameIdle(this); sliceState = new SliceState(this, 10, 0.5f); passState = new PassState(this, 1f); failState = new FailState(this, 0.5f); actState = new ActState(this); TranslateState(null, menuIdle); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var obj = JObject.Load(reader); var type = obj["Type"].Value <string>(); State.IBuilder <State> result = null; switch (Enum.Parse(typeof(StateType), type)) { case StateType.Choice: result = ChoiceState.GetBuilder(); break; case StateType.Fail: result = FailState.GetBuilder(); break; case StateType.Parallel: result = ParallelState.GetBuilder(); break; case StateType.Pass: result = PassState.GetBuilder(); break; case StateType.Succeed: result = SucceedState.GetBuilder(); break; case StateType.Task: result = TaskState.GetBuilder(); break; case StateType.Wait: result = WaitState.GetBuilder(); break; case StateType.Map: result = MapState.GetBuilder(); break; } serializer.Populate(obj.CreateReader(), result); return(result); }
// Start is called before the first frame update private void Start() { m_gameStateMachine = new GameStateMachine(); var splash = new SplashState(this, UIController.Instance.SplashPanel); var mainMenu = new MainMenuState(this, UIController.Instance.MainMenuPanel, UIController.Instance.MainMenuPlayButton); var tutorial = new TutorialState(this, UIController.Instance.TutorialPanel, UIController.Instance.TutorialDoneButton); var gameplay = new GamePlayState(this, UIController.Instance.GamePlayPanel); var win = new WinState(this, UIController.Instance.LevelCompletePanel, UIController.Instance.WinContinueButton); var fail = new FailState(this, UIController.Instance.LevelFailPanel, UIController.Instance.FailContinueButton); //Adding Transitions At(splash, mainMenu, CanShowMainMenu()); At(mainMenu, tutorial, CanPlayTutorial()); At(mainMenu, gameplay, CanPlayGame()); At(tutorial, gameplay, () => tutorial.HasTutorialFinished); At(gameplay, win, GameToWin()); At(gameplay, fail, GameToFail()); At(win, mainMenu, WinToMainMenu()); void At(IState from, IState to, Func <bool> condition) => m_gameStateMachine.AddTransition(from, to, condition); //Adding Conditions for Transitions Func <bool> CanShowMainMenu() => () => splash.HasSplashEnded; Func <bool> CanPlayGame() => () => mainMenu.HasPressedPlay && PlayerPrefs.GetInt(GameConstants.TutorialCompleted, 0) == 1; Func <bool> CanPlayTutorial() => () => mainMenu.HasPressedPlay && PlayerPrefs.GetInt(GameConstants.TutorialCompleted, 0) == 0; Func <bool> GameToWin() => () => gameplay.HasWon; Func <bool> GameToFail() => () => gameplay.HasLost; Func <bool> WinToMainMenu() => () => win.HasPressedContinue; //SetDefaultState m_gameStateMachine.SetState(splash); }
public override int Visit(FailState failState) { _currentContext.AssertStringNotEmpty(failState.Cause, PropertyNames.CAUSE); return(0); }
public virtual T Visit(FailState failState) { return(default(T)); }