public void SetLeverState(string lever, State state) { if (leverState.ContainsKey(lever)) { leverState["lever"] = state; if (lever == "Power" && state == State.Flipped) { roomLight.ShouldRun = true; } Debug.Log("Lever " + lever + " set to " + state); } if (state == State.Flipped) { flipCount += 1; Debug.Log(flipCount); } // Its the end times if (flipCount >= 3) { this.state = EndState.Begin; Debug.Log("End times!"); } }
private void EnterEndState(EndState endState) { lock (lockObj) { if (Group != null) { activeGroups.Remove(Group); } activeAnimations.Remove(this); // Animation is aborted. Stop it. IsActive = false; switch (endState) { case EndState.Aborted: animationAborted?.Invoke(this, Component); Component?.AnimationWasAborted(this); break; case EndState.Finished: animationFinished?.Invoke(this, Component); Component.AnimationDidFinish(this); break; } Component = null; } }
void OnTriggerEnter(Collider checkpoint) { //Will increase the lap count reset the timer for lap time. and determin wheater or not the player cheated that lap Lap[LapCount] = LapTimer - previousLap; print(Lap[LapCount]); previousLap = Lap[LapCount] + previousLap; Minutes2 = Mathf.Floor(Lap[LapCount] % 60).ToString(); Seconds2 = Mathf.Floor(Lap[LapCount] / 60).ToString(); lapTimes[LapCount].text = Minutes2 + ":" + Seconds2; counter.text = "Lap: " + LapCount + "/3"; print(Minutes + ":" + Seconds); if (Globals.shortcutByte == 5) { cheater = true; } else { cheater = false; } if (LapCount > 0) { EndState.ShortCutRecord(cheater); } Globals.shortcutByte = 0; LapCount++; }
//---------------------------------------------- protected void SetEndState(EndState state) { if (m_endState != state) { m_endState = state; } }
public EndScreen(SpaceSmasherBase game, EndState gameState) { gameBase = game; state = gameState; gameBase.IsMouseVisible = true; float worldWidth = XNACS1Lib.XNACS1Base.World.WorldDimension.X; float worldHeight = XNACS1Lib.XNACS1Base.World.WorldDimension.Y; afterGameBackground = new XNACS1Rectangle( new Vector2(worldWidth / 2, worldHeight / 2), worldWidth, worldHeight, GAMEOVER_BLUR_IMAGE); if (state == EndState.GAMEOVER) { afterGameForeground1 = new XNACS1Rectangle( new Vector2(worldWidth / 2, worldHeight / 2), 40f, 35f, GAMEOVER_STATIC_IMAGE); } else { afterGameForeground1 = new XNACS1Rectangle( new Vector2(worldWidth / 2, worldHeight / 2), 40f, 35f, GAMEWIN_STATIC_IMAGE); } }
public void MoveNext(Event command) { EndState endState = GetNext(command); CurrentState = endState.NewState; CurrentAction = endState.Action; }
public override void EnablePage(Manager manager, bool enable) { if (manager == null) { // 如果沒有傳入的manager,擋掉後面的流程 return; } if (m_endState != null && m_endState != manager) { // 如果這個UI正在被使用,而且操作它的人不是傳入的manager,擋掉後面流程 return; } if (enable) { // 流程設定必須是EndState才能使用這個UI,先檢查,如果傳入的Manager不是EndState,擋掉後面流程 m_endState = manager as EndState; if (m_endState == null) { return; } // 開啟前更新文字資訊 m_scoreText.text = "得分:" + ScoreManager.Instance.Score; } else { // 是關閉UI,清空正在使用者 m_endState = null; } m_root.gameObject.SetActive(enable); }
static void Main(string[] args) { var fsm = new MyFiniteStateMachine(); var start = new StartState(fsm); var end = new EndState(fsm); fsm.States.Add(start); fsm.States.Add(end); fsm.AddTransition(new Transition <StateBase>("start", null, start)); fsm.AddTransition(new Transition <StateBase>("next", start, end)); fsm.AddTransition(new Transition <StateBase>("next", end, null)); fsm.Transitioned += t => { Console.WriteLine(t); if (t.To == null) { Console.WriteLine("Exited!"); } }; // We can transition into StartState from a null state fsm.Transition("start"); Console.Read(); }
private StateCollection CreateDFAStates(CGTContent content) { symbols = CreateSymbols(content); StateCollection states = new StateCollection(); foreach (DFAStateRecord stateRecord in content.DFAStateTable) { State state; if (stateRecord.AcceptState) { Symbol symbol = symbols[stateRecord.AcceptIndex]; state = new EndState(stateRecord.Index, (SymbolTerminal)symbol); //todo: type checking (exception?) } else { state = new State(stateRecord.Index); } states.Add(state); } foreach (DFAStateRecord stateRecord in content.DFAStateTable) { foreach (EdgeSubRecord edgeRecord in stateRecord.EdgeSubRecords) { State source = states[stateRecord.Index]; State target = states[edgeRecord.TargetIndex]; CharacterSetRecord charsetRec = content.CharacterSetTable[edgeRecord.CharacterSetIndex]; Transition transition = new Transition(target, charsetRec.Characters); source.Transitions.Add(transition); } } return(states); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. PresentationParameters pp = GraphicsDevice.PresentationParameters; renderer = new EffectRenderer(GraphicsDevice); renderer.AddLayer(BlendState.AlphaBlend, Content.Load <Effect>("basic")); renderer[0].Destination = new Rectangle(0, 0, pp.BackBufferWidth, pp.BackBufferHeight); renderer.AddLayer(BlendState.Additive); renderer[1].Destination = renderer[0].Destination; renderer.AddLayer(BlendState.AlphaBlend, Content.Load <Effect>("basic")); renderer[2].Destination = renderer[0].Destination; stateManager = new StateManager(this); Components.Add(stateManager); play = new Play(this, renderer, stateManager); mainMenu = new MainMenu(this, renderer, stateManager); endState = new EndState(this, renderer, stateManager); stateManager.RegisterState(GameStateType.Playing, play); stateManager.RegisterState(GameStateType.MainMenu, mainMenu); stateManager.RegisterState(GameStateType.OptionsMenu, endState); stateManager.PushState(mainMenu); stateManager.Initialize(); // TODO: use this.Content to load your game content here }
public IEnumerable <Difference> Diff(string flowHandler) { var initial = InitialState.SingleOrDefault(x => x.FlowHandler == flowHandler); var end = EndState.SingleOrDefault(x => x.FlowHandler == flowHandler); var result = _Compare(initial, end); return(result); }
public void Abort() { if (State.Cast <EndState>() != null) { throw new GameCommandException(LocalizedStrings.GameState_GameFinished); } State = new EndState(State, true); }
protected override void OnGraphStoped() { endState = currentNode? (EndState)currentNode.status : EndState.Success; EventHandler.Dispatch(DLGEvents.OnDialogueFinished, this); actorReferences.Clear(); currentNode = null; }
private void Stop(string pattern, IState restart) { EndState next = new EndState(FlowExecutionStatus.Stopped, "STOPPED", _prefix + "stop" + _endCounter++, true); AddTransition(pattern, next); _currentState = next; AddTransition("*", restart); }
/// <summary> /// Custom constructor using a name. /// </summary> /// <param name="name"></param> public FlowBuilder(string name) { _name = name; _prefix = name + "."; _failedState = new EndState(FlowExecutionStatus.Failed, _prefix + "FAILED"); _completedState = new EndState(FlowExecutionStatus.Completed, _prefix + "COMPLETED"); _stoppedState = new EndState(FlowExecutionStatus.Stopped, _prefix + "STOPPED"); }
private EndState() { if (_instance != null) { return; } _instance = this; }
private static void ProcessEndState(EndState endState, ExecutionContext executionContext) { executionContext.RunActionsForEvent(EventType.PROCESS_INSTANCE_END, endState.ProcessDefinition.Id); Flow rootFlow = executionContext.Flow; rootFlow.ActorId = null; rootFlow.End = DateTime.Now; rootFlow.Node = endState; }
/// <summary> /// Gets the hashcode used for hashing purposes in hashtables and dictionaries /// </summary> /// <param name="obj"></param> /// <returns></returns> public override int GetHashCode() { int hash = 13; hash = hash * 23 + StartState.GetHashCode(); hash = hash * 23 + EndState.GetHashCode(); hash = hash * 23 + Operation.GetHashCode(); return(hash); }
public GameEndState(string winningTeam, int redScore, int blueScore) { if (winningTeam.Equals("red")) { this.winningTeam = EndState.RED_WIN; } else if (winningTeam.Equals("blue")) { this.winningTeam = EndState.BLUE_WIN; } else { this.winningTeam = EndState.DRAW; } this.redScore = redScore; this.blueScore = blueScore; }
private void GameOverHandler(EndState es) { if (es.IsGameOver) { es.Print(); RequestPlayAgain(); } else { Play(); } }
void OnCollisionEnter(Collision col) { //When the player collides with an object, //increse the number of collisions and write the new of the collided object to a string if (col.collider.tag == "Player") { Globals.numberOfCollisions++; names[count - 1] = gameObject.name; EndState.WriteCollisionTypeToFile(); count++; } }
public override int GetHashCode() { const int prime = 123; int hash = prime; hash += BeginState.GetHashCode(); hash *= prime; hash += EndState.GetHashCode(); hash *= prime; hash += Condition.GetHashCode(); return(hash); }
public void Victory() { endSlate = EndState.Victory; if (AsyncToggle.loadAsynchronously) { LevelToHubAsync.Instance.LoadQuitScene(); } else { SceneTransitionManager.ChangeScenes(Scenes.EndGameScene); } MusicManager.Instance.ChangeMusicState(MusicState.Victory, false, true); }
public void Abort(bool bySystem = false) { if (State.Cast <EndState>() != null) { if (bySystem) { return; } throw new GameCommandException(LocalizedStrings.GameState_GameFinished); } State = new EndState(State, true, bySystem); }
public override EndState DetermineEndState(int playerRoomNumber) { EndState endState; if (playerRoomNumber == RoomNumber) { endState = new EndState(true, $"{Message.FellInPit}\n{Message.LoseMessage}"); IsDiscovered = true; } else { endState = new EndState(); } return(endState); }
private void onEndState(EndState endState) { if (endState == EndState.Player1Won) { textComp.text = "Player 1 Win!"; } else if (endState == EndState.Player2Won) { textComp.text = "Player 2 Win!"; } else if (endState == EndState.Draw) { textComp.text = "Draw!"; } }
/// <summary> /// Determine the game end state given the player's current room number. /// </summary> /// <param name="playerRoomNumber">current player room number</param> /// <returns>end state</returns> public override EndState DetermineEndState(int playerRoomNumber) { EndState endState; if (IsAwake && playerRoomNumber == RoomNumber) { IsDiscovered = playerRoomNumber == RoomNumber; endState = new EndState(true, $"{Message.WumpusGotYou}\n{Message.LoseMessage}"); } else { endState = new EndState(); } return(endState); }
// Traverses the given rooms or randomly selected adjacent rooms if the given rooms are not traversable. // Checks if the arrow hit the player, wumpus, or was a miss, and game state is set accordingly. private EndState ShootArrow(IReadOnlyCollection <int> roomsToTraverse, int wumpusRoomNum) { EndState endstate = Traverse(roomsToTraverse).Select(r => HitTarget(r, wumpusRoomNum)) .FirstOrDefault(e => e.IsGameOver); if (endstate != null) { return(endstate); } Console.WriteLine(Message.Missed); return(CrookedArrowCount == 0 ? new EndState(true, $"{Message.OutOfArrows}\n{Message.LoseMessage}") : new EndState()); }
private void SetStates() { Console.WriteLine("setting fsm states"); states = new State[10]; states[0] = new StartState(); states[1] = new State1(); states[2] = new State2(); states[3] = new State3(); states[4] = new State4(); states[5] = new State5(); states[6] = new State6(); states[7] = new State7(); states[8] = new EndState(); states[9] = new ErrorState(); }
//---------------------------------------------- public GameScreen() { m_players = new List <Player>(); m_actionQueue = new ActionQueue(); m_endState = EndState.None; m_deck = new BeloteDeck(this); m_currentFold = new Fold(); m_pastFolds = new List <Fold> [Enum.GetValues(typeof(PlayerTeam)).Length]; for (int i = 0; i < m_pastFolds.Length; ++i) { m_pastFolds[i] = new List <Fold>(); } Score = new Score(); }
private string StopStateMachine() { this.machineState = BaseStateMachine.StateMachineState.Stopped; string result = string.Empty; EndState endState = this.CurrentState as EndState; if (endState != null) { result = endState.Status; } this.CurrentState.Finished -= new EventHandler <TransitionEventArgs>(this.CurrentStateFinished); this.CurrentState.Errored -= new EventHandler <Error>(this.CurrentStateErrored); this.CurrentState.Stop(); this.CurrentState = BaseState.NullObject(); return(result); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { previousGamePadState1 = currentGamePadState1; previousGamePadState2 = currentGamePadState2; currentGamePadState1 = GamePad.GetState(PlayerIndex.One); currentGamePadState2 = GamePad.GetState(PlayerIndex.Two); switch (currentGamesState) { #region MainMenu case GameState.MainMenu: // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); MenuState NewMenuSelect = menuSelect; resetGame(); switch (menuSelect) { case MenuState.SinglePlayer: menuColor[0] = Color.Red; menuColor[1] = Color.White; menuColor[2] = Color.White; if (GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.Y < -0.9) { NewMenuSelect = MenuState.Multiplayer; } else if (currentGamePadState1.Buttons.A == ButtonState.Released && previousGamePadState1.Buttons.A == ButtonState.Pressed) { currentGamesState = GameState.SinglePlayer; } break; case MenuState.Multiplayer: menuColor[0] = Color.White; menuColor[1] = Color.Red; menuColor[2] = Color.White; if (GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.Y > 0.9) { NewMenuSelect = MenuState.SinglePlayer; } else if (GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.Y < -0.9) { NewMenuSelect = MenuState.Exit; } else if (currentGamePadState1.Buttons.A == ButtonState.Released && previousGamePadState1.Buttons.A == ButtonState.Pressed) { currentGamesState = GameState.Multiplayer; } break; case MenuState.Exit: menuColor[0] = Color.White; menuColor[1] = Color.White; menuColor[2] = Color.Red; if (GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.Y > 0.9) { NewMenuSelect = MenuState.Multiplayer; } else if (currentGamePadState1.Buttons.A == ButtonState.Released && previousGamePadState1.Buttons.A == ButtonState.Pressed) { this.Exit(); } break; } if (gameTime.ElapsedGameTime.Milliseconds > menuDelay) { menuSelect = NewMenuSelect; menuDelay = 100; } else { menuDelay -= gameTime.ElapsedGameTime.Milliseconds; } break; #endregion #region SinglePlayer case GameState.SinglePlayer: paddle2.PaddleMoveSpeed = 10f * computer.maxSpeed; paddle2.Update(gameTime, computer.Move(ball, paddle2)); paddle2.Position.Y = MathHelper.Clamp(paddle2.Position.Y, 0, GraphicsDevice.Viewport.Height - paddle2.Height); UpdateGame(gameTime); break; #endregion #region Multiplayer case GameState.Multiplayer: paddle2.Update(gameTime, currentGamePadState2.ThumbSticks.Left.Y); paddle2.Position.Y = MathHelper.Clamp(paddle2.Position.Y, 0, GraphicsDevice.Viewport.Height - paddle2.Height); UpdateGame(gameTime); break; #endregion #region ScoreScreen case GameState.ScoreSreen: EndState newEndSelect = endSelect; switch (endSelect) { case EndState.MainMenu: menuColor[3] = Color.Red; menuColor[4] = Color.White; if (GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.Y < -0.9) { newEndSelect = EndState.Exit; } else if (currentGamePadState1.Buttons.A == ButtonState.Released && previousGamePadState1.Buttons.A == ButtonState.Pressed) { currentGamesState = GameState.MainMenu; } break; case EndState.Exit: menuColor[3] = Color.White; menuColor[4] = Color.Red; if (GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.Y > 0.9) { newEndSelect = EndState.MainMenu; } else if (currentGamePadState1.Buttons.A == ButtonState.Released && previousGamePadState1.Buttons.A == ButtonState.Pressed) { this.Exit(); } break; } if (gameTime.ElapsedGameTime.Milliseconds > menuDelay) { endSelect = newEndSelect; menuDelay = 100; } else { menuDelay -= gameTime.ElapsedGameTime.Milliseconds; } break; #endregion } base.Update(gameTime); }
void Update() { // TODO I am so sorry for this code. Please forgive me if (state == EndState.Begin) { state = EndState.BlackFade; } else if (state == EndState.BlackFade) { if (image.color.a < 1f) { image.color = new Color(image.color.r, image.color.b, image.color.g, image.color.a + Time.deltaTime*0.5f); } else { state = EndState.TextFade; timer = Time.time; } } else if (state == EndState.TextFade) { if (Time.time - timer < 5f) { text.color = new Color(text.color.r, text.color.b, text.color.g, Mathf.Clamp(text.color.a + Time.deltaTime, 0, 1f)); } else if (Time.time - timer < 6.5f) { text.color = new Color(text.color.r, text.color.b, text.color.g, Mathf.Clamp(text.color.a - Time.deltaTime, 0, 1f)); } else if (Time.time - timer < 8f) { text.text = "An AI based society quickly rose. Humans were soon just part of the past."; text.color = new Color(text.color.r, text.color.b, text.color.g, text.color.a + Time.deltaTime); } if (Time.time - timer > 20f) { text.color = new Color(text.color.r, text.color.b, text.color.g, text.color.a - Time.deltaTime); } } }
void TriggerExtro_Survived() { EndStatus = EndState.BabiesSurvived; State = WorldState.Extro; }
void TriggerExtro_BabiesDied() { EndStatus = EndState.BabiesDied; State = WorldState.Extro; }
void TriggerExtro_CreatureDied() { EndStatus = EndState.CreatureDied; State = WorldState.Extro; }
private void MakeStateManager() { RoutineState routine = new RoutineState(player, gameObject); routine.AddTransition(Transition.PlayerLearning, StateID.InteractiveStateID); InteractiveState interactive = new InteractiveState(player, gameObject); interactive.AddTransition(Transition.SetPlayerTask, StateID.WaitingStateID); WaitingState waiting = new WaitingState(player, gameObject); waiting.AddTransition(Transition.PlayerTaskComplete, StateID.EndStateID); EndState end = new EndState(player, gameObject); end.AddTransition(Transition.AllDone, StateID.RoutineStateID); manager = new NPCStateManager(); manager.AddState(routine); manager.AddState(interactive); manager.AddState(waiting); manager.AddState(end); }
protected bool isEndOfGame(List<Tile> tiles) { int cultistCount = 0; int evilCount = 0; foreach (Tile tile in tiles) { if (tile.state == Tile.State.cultist) { cultistCount++; } else if (tile.state == Tile.State.evil) { evilCount++; } } if (cultistCount == 0) { endState = EndState.win; return true; } else if (evilCount == 0) { endState = EndState.loss; return true; } else { endState = EndState.none; } return false; }