void OnEnable() { if (!GameStateMachine.GetInstance().isFirstGame) { SetReferencesAndStartValues(); } }
public MainMenuState( GameStateMachine <JamStateType> gameStateMachine, GuiManager gui) { _gameStateMachine = gameStateMachine; _gui = gui; }
public PlayState(GameStateMachine gameStateMachine_Ref, bool showMessage) { gameStateMachine = gameStateMachine_Ref; debugMode = gameStateMachine.debugMode; if (debugMode) { Debug.Log("------------Running PlayState Constructor-------------"); } if (!gameStateMachine.IntroIsDone) { gameStateMachine_Ref.introTauntScreen_Ref.SetActive(true); } canvas_ref = gameStateMachine.Canvas_Ref; isDisplayingMessage = showMessage; if (!showMessage) { gameStateMachine.BubbleManager_Ref.TurnOn(); gameStateMachine.ToggleSpawners(true); } if (debugMode) { Debug.Log("------------PlayState Constructor Done-------------"); } }
private void Awake() { // Make sure there's only ever one instance of GameStateMachine if (_instance != null) { Destroy(this.gameObject); return; } _instance = this; DontDestroyOnLoad(this.gameObject); // Create a base StateMachine and hook into it's OnStateChanged _stateMachine = new StateMachine(); _stateMachine.OnStateChanged += state => OnGameStateChanged?.Invoke(state); // Create our states and default to the Menu state var menu = new Menu(); var loading = new LoadLevel(); var play = new Play(); var pause = new Pause(); _stateMachine.SetState(menu); // Create all of our game state transitions _stateMachine.AddTransition(menu, loading, () => PlayButton.LevelToLoad != null); _stateMachine.AddTransition(loading, play, loading.Finished); _stateMachine.AddTransition(play, pause, () => PlayerInput.Instance.PausePressed); _stateMachine.AddTransition(pause, play, () => PlayerInput.Instance.PausePressed); _stateMachine.AddTransition(pause, menu, () => RestartButton.Pressed); }
public void Load() { this.stateMachine = GameStateMachine.GetInstance(); // if(SceneManager.GetActiveScene().ToString() != scene.name) stateMachine.LoadState(this); }
void Start() { var roomStatus = new RoomStatus(); roomStatus.SetFloatValue(FloatRequirementType.Temperature, 0); roomStatus.SetBoolValue(BooleanRequirementType.Water, false); roomStatus.SetBoolValue(BooleanRequirementType.Light, true); StateData.Add("room", roomStatus); var stateList = new Dictionary <EGameState, IGameState> { { EGameState.Splash, new SplashScreenState(GameCanvasTransform, SplashUI) }, { EGameState.Running, new RunningScreenState( GameCanvasTransform, RunningUI, UICanvasTransform, GameSettings, Characters ) }, { EGameState.Review, new ReviewScreenState(GameCanvasTransform, ReviewUI) }, }; Instantiate(PersistentObjects, GameObject.Find("PersistentObjects").transform); GameStateMachine = new GameStateMachine(stateList, EGameState.Splash); }
// Use this for initialization void Start() { InputHandler = GameObject.Find("Camera").GetComponent <InputHandler>(); stateMachine = new GameStateMachine(); stateMachine.ChangeState(new GameStateBlackTurn()); }
public override void InitializeStates(out BaseState default_state) { default_state = off; root.DoNothing(); off.PlayAnim("off").EventTransition(GameHashes.OperationalChanged, on, (AutoMiner.Instance smi) => smi.GetComponent <Operational>().IsOperational); on.DefaultState(on.idle).EventTransition(GameHashes.OperationalChanged, off, (AutoMiner.Instance smi) => !smi.GetComponent <Operational>().IsOperational); on.idle.PlayAnim("on").EventTransition(GameHashes.ActiveChanged, on.moving, (AutoMiner.Instance smi) => smi.GetComponent <Operational>().IsActive); on.moving.Exit(delegate(AutoMiner.Instance smi) { smi.master.StopRotateSound(); }).PlayAnim("working").EventTransition(GameHashes.ActiveChanged, on.idle, (AutoMiner.Instance smi) => !smi.GetComponent <Operational>().IsActive) .Update(delegate(AutoMiner.Instance smi, float dt) { smi.master.UpdateRotation(dt); }, UpdateRate.SIM_33ms, false) .Transition(on.digging, RotationComplete, UpdateRate.SIM_200ms); on.digging.Enter(delegate(AutoMiner.Instance smi) { smi.master.StartDig(); }).Exit(delegate(AutoMiner.Instance smi) { smi.master.StopDig(); }).PlayAnim("working") .EventTransition(GameHashes.ActiveChanged, on.idle, (AutoMiner.Instance smi) => !smi.GetComponent <Operational>().IsActive) .Update(delegate(AutoMiner.Instance smi, float dt) { smi.master.UpdateDig(dt); }, UpdateRate.SIM_200ms, false) .Transition(on.moving, GameStateMachine <States, AutoMiner.Instance, AutoMiner, object> .Not(RotationComplete), UpdateRate.SIM_200ms); }
public TutorialDisplay(GraphicsDevice graphics, ContentManager content) : base(graphics, content, "Tutorial") { GameStateMachine.getInstance().LevelContext = null; float xBuffer = 256; float yBuffer = 128; float leftSideX = Constants.RESOLUTION_X - xBuffer; float y = Constants.RESOLUTION_Y - yBuffer; VisualCallback setPrevipousState = delegate() { GameStateMachine.getInstance().goToPreviousState(); }; VisualCallback resetState = delegate() { init(this.scenario); }; string[] buttonNames = { "Menu", "Reset" }; TexturedEffectButton menu = ModelGenerationUtil.createButton(content, new Vector2(xBuffer, y), buttonNames[0]); TexturedEffectButton restart = ModelGenerationUtil.createButton(content, new Vector2(leftSideX, y), buttonNames[1]); this.buttons = new List <Button>(); this.buttons.Add(new Button(content, menu, setPrevipousState)); this.buttons.Add(new Button(content, restart, resetState)); init(0); }
private void Awake() { if (!alreadyLoaded) { instance = this; #region Instantiate State Machine & Level States gameSM = new GameStateMachine(); introState = new GameIntroMenuState(this, gameSM); hangarState = new HangarState(this, gameSM); asteroidLevelState = new AsteroidLevelState(this, gameSM); nebulaLevelState = new NebulaLevelState(this, gameSM); blackHoleLevelState = new BlackHoleLevelState(this, gameSM); deathState = new DeathState(this, gameSM); highScoresState = new HighScoresState(this, gameSM); #endregion #region Create Events SceneManager.sceneLoaded += OnSceneLoaded; AddEvents(); #endregion } }
void Start() { if (movementSpeed == 0) { movementSpeed = 5; } if (elevationSpeed == 0) { elevationSpeed = 3; } if (spriteSwitchTimeInterval == 0) { spriteSwitchTimeInterval = 0.3f; } if (gameStateMachine_Ref == null) { gameStateMachine_Ref = GameStateMachine.GetInstance(); } mySpriteRenderer = GetComponent <SpriteRenderer>(); mySpriteRenderer.sprite = movingBubbleSprite01_Ref; FlipSpriteRenderer(); }
void Awake() { if (gameStateMachine_Ref == null) gameStateMachine_Ref = this; else Destroy(this); gameboard_Ref = Gameboard.GetInstance(); isFirstGame = true; if (devMode) { portrait_Refs = Resources.LoadAll("Portraits", typeof(Sprite)); if (disclaimerText != null) disclaimerText.SetActive(true); } else { portrait_Refs = Resources.LoadAll("WitchPortraits", typeof(Sprite)); if (enableDevModeText != null) enableDevModeText.SetActive(true); } gamerTag_Refs = Resources.LoadAll("GamerTags", typeof(TextAsset)); introPhrases = Resources.LoadAll("IntroPhrases", typeof(TextAsset)); victoryPhrases = Resources.LoadAll("VictoryPhrases", typeof(TextAsset)); playerOneCharacter = new PlayerCharacter(portrait_Refs, introPhrases, victoryPhrases, gamerTag_Refs); playerTwoCharacter = new PlayerCharacter(portrait_Refs, introPhrases, victoryPhrases, gamerTag_Refs); playerCharacterArray = new PlayerCharacter[] { playerOneCharacter, playerTwoCharacter}; }
public void Awake() { DontDestroyOnLoad(gameObject); gameStateMachine = new GameStateMachine(this, new MenuState()); players[0] = new Player(new Vector3(-17, 0, 0)); players[1] = new Player(new Vector3(17, 0, 0)); }
void Awake() { gameStateMachine = GetComponent <GameStateMachine>(); selectedHabitat = new Habitat(); selectedHabitats = new List <Habitat>(); curPhase = Phase.start; }
public TutorialComplete(ContentManager content) : base(content, "GeneralBackground") { VisualCallback setPrevipousState = delegate() { GameStateMachine.getInstance().goToPreviousState(); }; VisualCallback setNextState = delegate() { GameStateMachine.getInstance().LevelContext = null; GameStateMachine.getInstance().goToNextState(); }; List <ButtonRequest> requests = new List <ButtonRequest>(); requests.Add(new ButtonRequest("Menu", setPrevipousState)); requests.Add(new ButtonRequest("Torment", setNextState)); base.createButtons(requests.ToArray()); Texture2D texture = LoadingUtils.load <Texture2D>(content, "Tut_Finish"); StaticDrawable2DParams parms = new StaticDrawable2DParams { Texture = texture, Origin = new Vector2(texture.Width / 2, texture.Height / 2), Position = new Vector2(Constants.RESOLUTION_X / 2, Constants.RESOLUTION_Y / 2) }; this.image = new StaticDrawable2D(parms); }
// Start is called before the first frame update void Start() { gsm = GameObject.FindGameObjectWithTag("GameStateMachine").GetComponent <GameStateMachine>(); monsterMov = GetComponent <MonsterMovement>(); mb = GetComponent <MonsterBrain>(); ma = GetComponent <MonsterAttack>(); }
/// <summary> /// Initializes a new instance of the <see cref="GameApplication"/> class. /// </summary> public GameApplication() { StateMachine = new GameStateMachine(this); Variables = new ExpandoObject(); Configurators = new List<ICustomConfigurator>(); Timer = new ElapsedTime(); }
public DealingState( GameStateMachine stateMachine, ICardDealerService dealer) { _stateMachine = stateMachine; _dealer = dealer; }
// Update is called once per frame void Update() { if (stateMachine == GameStateMachine.Prepare) { Time.timeScale = 0f; ResetGame(); stateMachine = GameStateMachine.Running; gameController.ResetGameLevel(); } else if (stateMachine == GameStateMachine.Running) { Time.timeScale = 1f; tmpPos = selectedTank == null ? transform.position : selectedTank.transform.position; gameController.UpdateHeroPosition(tmpPos); camController.SetUpCam(tmpPos); } else if (stateMachine == GameStateMachine.Hold) { Time.timeScale = 0f; } else if (stateMachine == GameStateMachine.HeroDied) { Time.timeScale = 0f; NCenter.OnNotify(new OnEndGameNotification { totalKills = 123 }); stateMachine = GameStateMachine.Hold; } }
public LoadGameplayState( GameStateMachine <JamStateType> gameStateMachine, GuiManager gui) { _gameStateMachine = gameStateMachine; _gui = gui; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { Constants.FONT = LoadingUtils.load <SpriteFont>(Content, "SpriteFont1"); GameStateMachine.getInstance().init(GraphicsDevice, Content); SoundManager.getInstance().init(Content); this.fadeParams = new FadeEffectParams { OriginalColour = Color.Black, State = FadeEffect.FadeState.Out, TotalTransitionTime = TRANSITION_TIME }; this.fadeEffect = new FadeEffect(fadeParams); StaticDrawable2DParams transitionParms = new StaticDrawable2DParams { Texture = LoadingUtils.load <Texture2D>(Content, "Chip"), Scale = new Vector2(Constants.RESOLUTION_X, Constants.RESOLUTION_Y), LightColour = Color.Black }; this.transitionItem = new StaticDrawable2D(transitionParms); this.transitionItem.addEffect(this.fadeEffect); #if WINDOWS #if DEBUG ScriptManager.getInstance().LogFile = "Log.log"; ScriptManager.getInstance().registerObject(MapEditor.getInstance(), "editor"); Debug.debugChip = LoadingUtils.load <Texture2D>(Content, "Chip"); Debug.debugRing = TextureUtils.create2DRingTexture(GraphicsDevice, (int)Constants.BOUNDING_SPHERE_SIZE, Color.White); #endif #endif }
/// <summary> /// Configure the state in the given state machine. /// </summary> /// <param name="stateMachine">The state machine.</param> public override void Configure(GameStateMachine stateMachine) { stateMachine.StateMachine.Configure("StateIdle") .OnEntry(OnEntry) .OnExit(OnExit) .Permit("TriggerStatePlay", "StatePlay"); }
public StartGameCommandHandler(GameStateMachine gameStateMachine, GameplayState gameplayState, MainMenuState mainMenuState) { _gameStateMachine = gameStateMachine; _gameplayState = gameplayState; _mainMenuState = mainMenuState; }
static public void addScore(int pointsGot) { GameStateMachine gsm = safeGet(); gsm.score += pointsGot; updateScore(); }
public IntroState( GameStateMachine <JamStateType> gameStateMachine, GuiManager gui) { _gameStateMachine = gameStateMachine; _gui = gui; }
public Singleton( DiContainer container, GameStateMachine <JamStateType> gsMachine, SessionFlags pSessionFlags, [Inject(Id = GameInstaller.GLOBAL_DISPATCHER)] IEventDispatcher eventDispatcher, GameConfig pGameConfig, NetworkManager pNetworkManager, GuiManager guiManager, ParticleGOD pparticleGod, AudioSystem pAudioSystem) { diContainer = container; sessionFlags = pSessionFlags; gameConfig = pGameConfig; gameStateMachine = gsMachine; notificationDispatcher = eventDispatcher; networkManager = pNetworkManager; gui = guiManager; particleGod = pparticleGod; audioSystem = pAudioSystem; _initialize(); _instance = this; }
/// <summary> /// Configure the state in the given state machine. /// </summary> /// <param name="stateMachine">The state machine.</param> public override void Configure(GameStateMachine stateMachine) { stateMachine.StateMachine.Configure("StatePayWin") .OnEntry(OnEntry) .OnExit(OnExit) .Permit("TriggerStateGameOver", "StateGameOver"); }
public MainMenuState(GameStateMachine gameStateMachine_Ref) { gameStateMachine = gameStateMachine_Ref; debugMode = gameStateMachine.debugMode; if (debugMode) { Debug.Log("------------Running MainMenuState Constructor-------------"); } if (gameStateMachine.Canvas_Ref != null) { canvas_ref = gameStateMachine.Canvas_Ref; } else { Debug.Log("MainMenuState cannot get a reference to the canvas"); } timeBeingActive = 0; if (debugMode) { Debug.Log("------------MainMenuState Constructor Done-------------"); } }
public void SetMessageTest() { var gsm = new GameStateMachine(new Table(new Deck(), 4)); gsm.SetMessage("Message"); Assert.AreEqual("Message", gsm.MessageObs.Element); }
public BeginState(GameStateMachine gameStateMachine_Ref) { this.gameStateMachine = gameStateMachine_Ref; debugMode = gameStateMachine.debugMode; if (debugMode) { Debug.Log("------------Running BeginState Constructor-------------"); } if (gameStateMachine.Canvas_Ref != null) { canvas_ref = gameStateMachine.Canvas_Ref; } else { Debug.Log("BeginState cannot get a reference to the canvas"); } if (gameStateMachine.GameOver) { gameStateMachine.Reset(); } timeBeingActive = 0; lifeTime = 3; if (debugMode) { Debug.Log("------------BeginState Constructor Done-------------"); } }
public LoadingProceedCommandHandler(GameStateMachine gameStateMachine, LoadingState loadingState, MainMenuState mainMenuState) { _gameStateMachine = gameStateMachine; _mainMenuState = mainMenuState; _loadingState = loadingState; }
public EndPlayGameState( GameStateMachine stateMachine ) : base(stateMachine) { foreach( UIView v in UIManager.Instance.Views ) { if( v is EndGameView ) { view = v as EndGameView; } } }
public PlayGameState( GameStateMachine stateMachine ) : base(stateMachine) { foreach( UIView v in UIManager.Instance.Views ) { if( v is GameView ) { view = v as GameView; } } playerStateMachine = GameObject.FindObjectOfType<PlayerStateMachine>() as PlayerStateMachine; environmentStateMachine = GameObject.FindObjectOfType<EnvironmentStateMachine>() as EnvironmentStateMachine; }
public MainMenuGameState( GameStateMachine stateMachine ) : base(stateMachine) { foreach( UIView v in UIManager.Instance.Views ) { if( v is MainMenu ) { view = v as MainMenu; } } playerController = GameObject.FindObjectOfType<PlayerController>() as PlayerController; playerStateMachine = GameObject.FindObjectOfType<PlayerStateMachine>() as PlayerStateMachine; environmentStateMachine = GameObject.FindObjectOfType<EnvironmentStateMachine>() as EnvironmentStateMachine; initialPlayerPosition = playerController.transform.position; initialPlayerRotation = playerController.transform.rotation; }
public GameState( GameStateMachine stateMachine ) : base() { this.stateMachine = stateMachine; }
public WaitingForSolution(GameStateMachine gsm) { gameStateMachine = gsm; }
void Initialize() { // Prevents duplicate GameManagers, but allows for easier testing if (Instance != FindObjectOfType<GameManager>()) { gameObject.SetActive(false); return; } // Don't destroy this; other GameManagers in other scenes should be disabled before build and for testing should use GameStateInit DontDestroyOnLoad(this); // Create new inventory if (m_inventory == null) { m_inventory = new Inventory(slots); } /////////////////////// // Create new CharacterManager if (m_characters == null) { // No auto; let game states search by their own m_characters = new CharacterManager(false); } /////////////////////// // Create new CameraController if (m_camera == null) { // Add targets after scene load m_camera = new CameraController(/*Human.Link.gameObject, Dog.Link.gameObject*/); // Add states, but change on GameStatePlay m_camera.AddState(new CameraStateFollow(movementSmooth, rotationSmooth, minY, maxY)); //Camera.ChangeState("CameraStateFollow"); } /////////////////////// // Create a new UI Manager if (m_ui == null) { //BUG: this seems to be null'd after first scene load? m_ui = new UIManager(false); } /////////////////////// // Create new GameStateMachine if (GameState == null) { GameState = new GameStateMachine(); // Add some states GameState.AddStatesRange(new GameStatePlay(), new GameStateStart(), new GameStateEnd(), new GameStateLoad(), new GameStateInit()); GameState.ChangeState(startState); // Set starting statea GameState.UpdateState(); // Update to that state immidiately } /////////////////////// // Refresh GameManager once after all systems are initialized Refresh(); }
void Start() { if (GameObject.Find("Game Manager")) gameStateMachine = GameObject.Find("Game Manager").GetComponent<GameStateMachine>(); Vector3 pos; pos.x = Screen.width - 75; pos.y = Screen.height - 75; pos.z = 0; deployButton.transform.position = pos; pos.x -= 100; if (musicButton) { musicButton.transform.position = pos; } if (musicButton2) { musicButton2.transform.position = pos; pos.x -= 100; } if (replayButton) { replayButton.transform.position = pos; pos.x -= 100; } if (backButton) { backButton.transform.position = pos; } /* if (AudioListener.volume == 1) { musicButton2.SetActive (false); musicButton.SetActive (true); } else if (AudioListener.volume == 0) { musicButton2.SetActive (true); musicButton.SetActive (false); } */ }
public GamePlayingState(GameStateMachine gameStateMachine) { this.gameStateMachine = gameStateMachine; }
void Awake() { _stateMachine = new GameStateMachine(); _stateMachine.SetState(new StateGameStart()); }
public void setStateMachine(GameStateMachine newMachine) { this.gameStateMachine = newMachine; }
public PauseMenuGameState( GameStateMachine stateMachine ) : base(stateMachine) { }
public GameIsRunning(GameStateMachine gsm) { gameStateMachine = gsm; }
/// <summary> /// Configures the specified app. /// </summary> /// <param name="app">The app.</param> /// <param name="states">The states.</param> public void Configure(GameApplication app, GameStateMachine states) { }
public PlayerDeadState( PlayerStateMachine stateMachine ) : base(stateMachine) { environmentStateMachine = GameObject.FindObjectOfType<EnvironmentStateMachine>() as EnvironmentStateMachine; gameStateMachine = GameObject.FindObjectOfType<GameStateMachine>() as GameStateMachine; }
public GameRedoState(GameStateMachine gameStateMachine) { this.gameStateMachine = gameStateMachine; }
public EvaluatingSolution(GameStateMachine gsm) { gameStateMachine = gsm; }
public GameEndedState(GameStateMachine gameStateMachine) { this.gameStateMachine = gameStateMachine; }
// Use this for initialization void Start() { gameStateMachine = new GameStateMachine(this); }
public GameInitializingState(GameStateMachine gameStateMachine) { this.gameStateMachine = gameStateMachine; }
public GameUndoingState(GameStateMachine gameStateMachine) { this.gameStateMachine = gameStateMachine; }
public GeneratingExercise(GameStateMachine gsm) { gameStateMachine = gsm; }