private static PauseAction GetPauseAction(MultipleRecords multipleRecords) { var action = new PauseAction(); action.Time = SerializerHelper.GetTime(multipleRecords); return(action); }
public GameStateController() { gameFsm = new FSM("GameFSM"); preStartState = gameFsm.AddState((byte)GameState.PreStart); idleState = gameFsm.AddState((byte)GameState.Idle); playState = gameFsm.AddState((byte)GameState.Play); pauseState = gameFsm.AddState((byte)GameState.Pause); gameOverState = gameFsm.AddState((byte)GameState.GameOver); preStartAction = new PreStartAction(preStartState); playingAction = new PlayAction(playState); pauseAction = new PauseAction(pauseState); gameOverAction = new GameOverAction(gameOverState); idleAction = new IdleAction(idleState); preStartState.AddTransition((byte)FSMTransition.ToIdle, idleState); idleState.AddTransition((byte)FSMTransition.ToPlay, playState); playState.AddTransition((byte)FSMTransition.ToPause, pauseState); playState.AddTransition((byte)FSMTransition.ToGameOver, gameOverState); gameOverState.AddTransition((byte)FSMTransition.ToIdle, idleState); preStartAction.Init(); idleAction.Init(); playingAction.Init(); pauseAction.Init(); gameOverAction.Init(); }
private void OnStop(object sender, StoppedEventArgs args) { if (args.Exception != null) { // Notify program of stop caused by exception _renderFix?.Stop(); OnFailure?.Invoke(args.Exception); return; } if (_action == PauseAction.Clip) { // Write circular buffer to output stream using (_dest) { if (_fullBuffer) { _dest.Write(_buffer, _index, _buffer.Length - _index); } if (_index > 0) { _dest.Write(_buffer, 0, _index); } _dest.Flush(); } _dest = null; } _action = PauseAction.None; _task.SetResult(true); }
// Write buffer to output public Task Clip(Stream dest) { _dest = dest; _action = PauseAction.Clip; _task = new TaskCompletionSource <bool>(); _capture.StopRecording(); _renderFix?.Pause(); return(_task.Task); }
public void Play(AnimationStateForZMJ[] states) { //BracketAniControlManager.singleton.Play(new Vector2(20, 30), 4f, new List<float>(new float[] { 0.51f, 0.55f, 0.6f, 0.65f, 0.7f, 0.75f, 0.8f, 0.85f, 0.9f, 0.95f, 1f })); //BracketAniControlManager.singleton.Play(new Vector2(20, 30), 4f, new List<float>(new float[] { 0.51f, 0.55f, 0.6f, 0.65f, 0.7f, 0.75f, 0.8f, 0.85f, 0.9f, 0.95f, 1f }), "UpArm"); // AddParticle(); DestroyWall.singleton.control1 = false; DestroyWall.singleton.control2 = false; DestroyWall.singleton.height = 0.9f; CutMineAnimation.singleton.speed = 0.52f; playin = true; firstplay = true; firstplaytime = 20; firstplaysatrttime = Time.time; firstcutterplay = true; firstcutterplaytime = 5; firstcutterplaystarttime = Time.time; rember = states; identification = 0; SlanimationFirst = true; allAnimationOvew = false; zmjZhijiaend = false; result = false; allstop1 = false; pauseAction = null; call1 = false; call2 = false; animationQueue = new Queue <AnimationStateForZMJ>(); for (int i = 0; i < states.Length; i++) { animationQueue.Enqueue(states[i]); } float[] sketor = new float[54]; float[] bracket = new float[54]; float[] uparm = new float[54]; for (int i = 0; i < sketor.Length; i++) { sketor[i] = 0.5f; bracket[i] = 0.5f; uparm[i] = 1; } ZhengScripts.InitilizeBracketAll(new Vector2(0, 53), bracket); ZhengScripts.InitilizeUpArm(new Vector2(0, 53), uparm); ZhengScripts.InitilizeSketator(new Vector2(0, 53), sketor); ZhengScripts.InitilizeBracketAll(new Vector2(0, 11), new float[] { 0, 0, 0, 0, 0, 0, 0, 0, 0.1f, 0.2f, 0.3f, 0.4f }); ZhengScripts.InitilizeUpArm(new Vector2(0, 11), new float[] { 0, 0, 0, 0, 0, 0, 0, 0, 0.2f, 0.4f, 0.6f, 0.8f }); ZhengScripts.InitilizeSketator(new Vector2(0, 16), new float[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.5f, 0.5f }); ZhuAnimation.PlayAnimation(new Vector2(0, 16), 0.1f, new float[] { 0, 0, 0, 0, 0, 0, 0, 0, 0.05f, 0.1f, 0.15f, 0.2f, 0.3f, 0.4f, 0.5f, 0.5f, 0.5f }, ZhuAnimation.ZhuAnimationMode.Mode3); // if (identification == 1) // { // } }
private void ProcessTurnChange(int playerTurn, short senderId, PauseAction pauseAction) { if (playerTurn < _gameServer.Simulation.GetMinTurn() + _gameServer.Simulation.Delta - 1) { IncreaseTurn(senderId, pauseAction); } else { WaitPlayer(senderId); } }
public Task Stop() { if (_capture.CaptureState != CaptureState.Capturing) { return(Task.CompletedTask); } _action = PauseAction.Stop; _task = new TaskCompletionSource <bool>(); _capture.StopRecording(); _renderFix?.Stop(); return(_task.Task); }
public void Resume() { ResetTime(); IsPaused = false; if (executeEvents) { resumeEvent.Invoke(); } if (executeDelegateActions && PauseAction != null) { PauseAction.Invoke(IsPaused); } }
public void Pause() { if (useTimeScale) { StopTime(); } IsPaused = true; if (executeEvents) { pauseEvent.Invoke(); } if (executeDelegateActions && PauseAction != null) { PauseAction.Invoke(IsPaused); } }
private void insert_Click(object sender, System.EventArgs e) { MacroAction a = null; if (radioPause.Checked) { a = new PauseAction(TimeSpan.FromMilliseconds(Utility.ToInt32(pause.Text, 1000))); } else if (radioGump.Checked) { a = new WaitForGumpAction(0); } else if (radioMenu.Checked) { a = new WaitForMenuAction(0); } else if (radioTarg.Checked) { a = new WaitForTargetAction(); } else if (radioStat.Checked && statList.SelectedIndex >= 0 && statList.SelectedIndex < 3 && statOpList.SelectedIndex >= 0 && statOpList.SelectedIndex < statOpList.Items.Count) { a = new WaitForStatAction((IfAction.IfVarType)statList.SelectedIndex, (byte)statOpList.SelectedIndex, Utility.ToInt32(statAmount.Text, 0)); } if (a != null) { if (m_Action == null) { m_Macro.Insert(m_Idx + 1, a); } else { m_Action.Parent.Convert(m_Action, a); } this.DialogResult = DialogResult.OK; this.Close(); } }
public bool PlayMec(Vector2 playindex) { TestAnimation t = GetAnimation((int)playindex.x); if (t != null) { t.isPositive = true; t.Play(this.time, this.step, this.distance); t.SetAction(this.actiontime * t.GetAlltime(), delegate { call1 = true; }); } else { return(false); } //can add animation before play inverse animation pauseStartTime = Time.time; pauseAction = delegate { pauseAction = null; TestAnimation tt = GetAnimation((int)playindex.y); if (tt != null) { tt.isPositive = false; Vector3 newTime = new Vector3(this.time.z, this.time.y, this.time.x); Vector3 newStep = new Vector3(this.step.z, this.step.y, this.step.x); Vector2 newDistance = new Vector2(this.distance.y, this.distance.x); tt.Play(newTime, -newStep, newDistance); tt.SetAction(this.actiontime * tt.GetAlltime(), delegate { call2 = true; }); } }; return(true); }
private void IncreaseTurn(short id, PauseAction pauseAction) { InfoLog.WriteInfo("Increasing turn for player: " + id, EPrefix.GameMessageProccesing); int minTurnBefore = _gameServer.Simulation.GetMinTurn(); int maxTurn = _gameServer.Simulation.GetMaxTurn(); int actualTurn = _gameServer.Simulation.GetPlayerTurn(id); int delta = 1; if (actualTurn < maxTurn) { delta = maxTurn - actualTurn; } _gameServer.Simulation.IncPlayerTurn(id, delta); int minTurnAfter = _gameServer.Simulation.GetMinTurn(); // if this is slowest player then tell him to speed up DoTurnMessage dtm = (DoTurnMessage)MessageFactory.Create(MessageType.DoTurn); dtm.Pause = (byte)pauseAction; dtm.TurnsToGo = (short)delta; if (minTurnBefore != minTurnAfter) { dtm.SpeedUp = true; } // SendMessage(dtm, id); if (minTurnAfter != minTurnBefore) { InfoLog.WriteInfo("Waking waiting players", EPrefix.GameMessageProccesing); short[] stoppedWaiting = _gameServer.Simulation.StopWaiting(); InfoLog.WriteInfo("Players to wake: " + stoppedWaiting.ToString(), EPrefix.GameMessageProccesing); for (int i = 0; i < stoppedWaiting.Length; ++i) { _gameServer.Simulation.IncPlayerTurn(stoppedWaiting[i]); SendMessage(MessageFactory.Create(MessageType.DoTurn), stoppedWaiting[i]); } } }
void Instance_DoTurnPermission(object sender, DoTurnMessage dtm) { //InfoLog.WriteInfo("Turn permitted", EPrefix.SimulationInfo); PauseAction paction = (PauseAction)dtm.Pause; switch (paction) { case PauseAction.Resume: //_isPaused = false; if (dtm.SpeedUp) { _sim.SpeedUp = true; InfoLog.WriteInfo("Speeding Up", EPrefix.GameLogic); } if (PauseResume != null) { PauseResume(false); } _sim.DoTurn(dtm.TurnsToGo); break; case PauseAction.None: if (dtm.SpeedUp) { _sim.SpeedUp = true; InfoLog.WriteInfo("Speeding Up", EPrefix.GameLogic); } _sim.DoTurn(dtm.TurnsToGo); break; case PauseAction.Pause: //this._isPaused = true; if (PauseResume != null) { PauseResume(true); } break; } }
public void RaisePause(bool pause) { PauseAction?.Invoke(pause); }
/// <summary> /// Lets the game respond to player input. Unlike the Update method, /// this will only be called when the gameplay screen is active. /// </summary> public override void HandleInput(GameTime gameTime, InputState input) { if (input == null) { throw new ArgumentNullException("input"); } // Look up inputs for the active player int activePlayerIndex = (int)ControllingPlayer.Value; KeyboardState keyboardState = input.CurrentKeyboardStates[activePlayerIndex]; PlayerIndex playerIndex; // Pause the game if user presses the pause key if (PauseAction.Evaluate(input, ControllingPlayer, out playerIndex)) { ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer); } if (Player.HasShape) { PlayerRotated = false; // Move left if (MoveLeftAction.Evaluate(input, ControllingPlayer, out playerIndex)) { Player.Shape.Move(Direction.Left); } // Move right if (MoveRightAction.Evaluate(input, ControllingPlayer, out playerIndex)) { Player.Shape.Move(Direction.Right); } // Rotate left if (RotateLeftAction.Evaluate(input, ControllingPlayer, out playerIndex)) { Player.Shape.Rotate(Direction.Left); PlayerRotated = true; } // Rotate right if (RotateRightAction.Evaluate(input, ControllingPlayer, out playerIndex)) { Player.Shape.Rotate(Direction.Right); PlayerRotated = true; } // Soft drop if (SoftDropAction.Evaluate(input, ControllingPlayer, out playerIndex)) { Player.Shape.Move(Direction.Down); } // Hard drop if (HardDropAction.Evaluate(input, ControllingPlayer, out playerIndex)) { int distance = Player.Drop(); } // Hold shape if (HoldAction.Evaluate(input, ControllingPlayer, out playerIndex)) { Player.Hold(); } } }
public PauseParameters(int[] objectIds, PauseAction action = PauseAction.Pause) : base(objectIds) { PauseAction = action; }
internal void RaisePause(bool pause) { PauseAction?.Invoke(pause); }
private void Awake() { action = new PauseAction(); }
public void OnTransitionPause(Transition p0) { PauseAction?.Invoke(); }