public ScreenSelect() { RunningState.set_state(1); //Set to 1 for title do { switch (RunningState.get_state()) { case (1): //1 for title screen using (var game = new TitleScreen()) game.Run(); break; case (2): //2 for game screen using (var game = new GameScreen()) game.Run(); break; case (3): //3 for death screen using (var game = new DeathScreen()) game.Run(); break; } } while (RunningState.get_state() != 0); //Run the game until the running state is at 0, where the game will exit }
private void Timer_Tick(object sender, EventArgs e) { if (RunningState.Normal == state) { if (curCount >= preCount + spanTimeValue) { // 进入 sleep 模式 state = RunningState.Sleep; curCount = preCount = 0; EnterSleep(); } if ((curCount - preCount) == (spanTimeValue - 10)) // 提前 10s 提示进入sleep模式 { notifyIcon.BalloonTipText = "10s 后进入sleep"; notifyIcon.ShowBalloonTip(2); } } else { if (curCount >= preCount + sleepValue) { // 退出 sleep 模式 state = RunningState.Normal; curCount = preCount = 0; ExitSleep(); } // 在 sleep 模式 Countdown(preCount + sleepValue - curCount); } curCount++; }
/// <summary> /// Stops the running ShredHost. /// </summary> /// <returns>true - if the ShredHost is running, false - if the ShredHost is stopped.</returns> public static bool Stop() { lock (_lockObject) { if (RunningState.Stopped == _runningState || RunningState.Transition == _runningState) { return(RunningState.Running == _runningState); } _runningState = RunningState.Transition; } // correct sequence should be to stop the WCF host so that we don't // receive any more incoming requests Platform.Log(LogLevel.Info, "ShredHost stop request received"); StopShreds(); Platform.Log(LogLevel.Info, "Completing ShredHost stop."); lock (_lockObject) { _runningState = RunningState.Stopped; } return(RunningState.Running == _runningState); }
protected override void Update(GameTime gameTime) { // Allows the game to exit ------------------ if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } RunningState.set_state(0); input.Update(); // Update the inputs MouseState myMouseState = Mouse.GetState(); // Updates the mouse state //Go through each button currently on screen and change their status ------ int limit = ButtonList.Count; for (int i = 0; i < limit; i++) { ButtonList[i].UpdateState(myMouseState); //Update the button state based on where the mouse is pointing if (ButtonList[i].isPressed()) //Check if the button is pressed or not, if it is then the program needs to go onto the function list { TitleFunctions(ButtonList[i].Get_Name()); } } base.Update(gameTime); }
protected override void Start() { base.Start(); RecalculateHiddenValues(); // States var falling = new FallingState("Falling", velocity, gravity, () => speed * input.Horizontal); var running = new RunningState("Running", velocity, () => speed * input.Horizontal); var jumping = new FallingState("Jumping", velocity, gravity, () => speed * input.Horizontal); // OnExit/Enter falling.OnExit += () => SetVelocityY(); running.OnExit += () => SetVelocityY(); running.OnExit += () => coyoteTimer = coyoteTime; jumping.OnEnter += () => SetVelocityY(jumpVelocity); // States falling.AddTransition(() => SurfaceClose(downHit), running); falling.AddTransition(() => input.Jump && !jumpLastPressed && coyoteTimer > 0, jumping, () => { Debug.Log("COYOTE TIME!!!"); jumpLastPressed = true; }); running.AddTransition(() => !SurfaceClose(downHit), falling); running.AddTransition(() => input.Jump && !jumpLastPressed, jumping, () => jumpLastPressed = true); jumping.AddTransition(() => velocity.Value.y <= 0, falling); jumping.AddTransition(() => SurfaceClose(upHit), falling, () => SetVelocityY(gravity * 0.06f)); // Initialization _controllerBrain = new StateMachine(falling, DebugBlock); }
// public processing functions public void StartChapter(object[] initObjects) { // ensure we have a start if (_NewPush == null) { throw new StartingChapterNotSetException("Default state not set for chapter " + _ID); } if (_RunningState == RunningState.Running) { throw new ChapterAlreadyRunningException("Chapter is already running!"); } // create all states foreach (IState state in _States.Values) { state.OnCreate(initObjects); } _RunningState = RunningState.Running; }
virtual protected void StartStepping() { switch (playerState) { case RunningState.Inactive: Reset(); SetCodingModeActive(false); playerState = RunningState.Step; break; case RunningState.Pause: playerState = RunningState.Step; break; case RunningState.NotReady: playerState = RunningState.Pause; return; case RunningState.Ready: //ignore return; default: //should not be in Step state. The button should be disactivated. throw new System.Exception("An unexpected player state: " + playerState); } debugPan.SetDebugButtonActive(ButtonCode.Stop, true); debugPan.SetDebugButtonActive(ButtonCode.Run, false); debugPan.SetDebugButtonActive(ButtonCode.Back, false); debugPan.SetDebugButtonActive(ButtonCode.Step, false); playerCMDNo += 1; Invoke("RunPlayerCommand", delaySec); }
public LiteTask(IEnumerator routine, bool startInBackground = true) { wcBackgroundMoveNextState = BackgroundMoveNextState; innerRoutine = routine; StartInBackground = startInBackground; state = routine == null ? RunningState.Done : RunningState.Init; }
/// <summary> /// 停止运行 /// </summary> public void Stop() { State = RunningState.Stopped; m_process.Kill(); m_process.Close(); m_process.Dispose(); }
private void controllerMovement() { Vector3 forwardVector; Vector3 leftVector; forwardVector = (forwardTransform.position - theTransform.position).normalized; leftVector = (leftTransform.position - theTransform.position).normalized; float forwardChange = -(Input.GetAxis("LeftJoystickY") * speed * Time.deltaTime); float leftChange = -(Input.GetAxis("LeftJoystickX") * speed * Time.deltaTime); if (Input.GetButton("LeftStickClick")) { running = RunningState.running; forwardChange *= 2.0f; leftChange *= 2.0f; } else if (Input.GetAxis("BackTriggers") >= 0.5f) { running = RunningState.silent; forwardChange *= 0.5f; leftChange *= 0.5f; } theTransform.position += forwardVector * forwardChange; theTransform.position += leftVector * leftChange; if (leftChange > 0.0f || forwardChange > 0.0f) { giveSound(); } else { walking = false; } }
virtual protected bool ExecuteNextIfNotPaused() { if (playerState == RunningState.Pause) { debugPan.SetDebugButtonActive(ButtonCode.Run, true); debugPan.SetDebugButtonActive(ButtonCode.Stop, true); debugPan.SetDebugButtonActive(ButtonCode.Back, (playerCMDNo > -1)); debugPan.SetDebugButtonActive(ButtonCode.Step, true); return(false); } else if (playerState == RunningState.NotReady) { playerState = RunningState.Ready; debugPan.SetDebugButtonActive(ButtonCode.Step, true); debugPan.SetDebugButtonActive(ButtonCode.Run, false); debugPan.SetDebugButtonActive(ButtonCode.Step, true); debugPan.SetDebugButtonActive(ButtonCode.Back, (playerCMDNo > -1)); playerCMDNo += 1; Invoke("RunPlayerCommand", delaySec); return(true); } else { throw new System.Exception("An unexpected player state: " + playerState); } }
virtual protected void Reset() { hasSolved = 0; playerState = RunningState.Inactive; playerCMDNo = -1; playerOldCounter = player.counter; player.ResetAnimator(); playerInbox.ResetInbox(InitialInboxGenerator()); playerOutbox.EmptyAllData(); playerFeedback.SetActive(false); enumPan.ResetRunningState(); memoryBar.EmptyMemoryBar(); distrustCMDNo = -1; distrustPlayerState = RunningState.Inactive; distrustOldCounter = distrust.counter; distrust.ResetAnimator(); distrustOutbox.EmptyAllData(); distrustFeedback.SetActive(false); SetCodingModeActive(true); debugPan.SetDebugButtonActive(ButtonCode.Run, true); debugPan.SetDebugButtonActive(ButtonCode.Stop, false); //TODO Implement step back and step forward debugPan.debugButtons[(int)ButtonCode.Back].gameObject.SetActive(false); debugPan.debugButtons[(int)ButtonCode.Step].gameObject.SetActive(false); }
public Machine() { _autoPauseCount = 0; _runningState = RunningState.Paused; _runningStateLock = new object(); _volume = 80; }
virtual protected bool DistrustMoves() { if (distrustPlayerState != RunningState.Inactive) { if (distrustCMDNo == enumPan.transform.childCount) { enumPan.ResetRunningState(); distrustPlayerState = RunningState.Inactive; return(false); } enumPan.SetRunningState(distrustCMDNo, EnumPanel.Status.Executing); distrustPlayerState = RunningState.NotReady; distrustOldCounter = distrust.counter; TopCommand.Code topCodeToRun = distrustTopCode[distrustCMDNo]; if (topCodeToRun == TopCommand.Code.Inbox) { distrust.SetEndPosition(distrustInboxPos); } else if (distrustSubCode[distrustCMDNo] != SubCommand.Code.NoAction) { SetEndPositionBySubCMD(distrust, distrustSubCode[distrustCMDNo]); } } return(true); }
virtual protected bool RunPlayerCommand() { if (!CheckPlayerReady()) { return(false); } if (FinishWithoutSucceed()) { return(false); } if (!DistrustMoves()) { return(false); } if (playerState != RunningState.Inactive) { playerState = RunningState.NotReady; playerOldCounter = player.counter; TopCommand topCommandToRun = instructionPan.GetTopCommandAt(playerCMDNo); if (topCommandToRun.myCode == TopCommand.Code.Inbox) { player.SetEndPosition(playerInbox.playerPos); } else if (topCommandToRun.myCode == TopCommand.Code.NoAction) { player.counter += 1; } else if (topCommandToRun.subCommandRef) { SetEndPositionBySubCMD(player, topCommandToRun.subCommandRef.myCode); } } return(true); }
public void Unpublish() { RestartCount.Unpublish(); RunningState.Unpublish(); HealthState.Unpublish(); StartTime.Unpublish(); }
public void Dispose() { RestartCount.Remove(); RunningState.Remove(); HealthState.Remove(); StartTime.Remove(); }
/// <summary> /// Creates a deep copy of the passed object. /// </summary> /// <param name="old">An entity object to create the deep copy from.</param> private void CopyMembers(Entity old) { this.guid = old.guid; this.concurrencyVersion = old.concurrencyVersion; this.parentReference = new ParentEntityReference <Entity>(old.parentReference); this.EntityType = old.EntityType; // always use property! this.number = old.number; this.name = old.name; this.version = old.version; this.system = old.system; this.hidden = old.hidden; this.readOnly = old.readOnly; this.primary = old.primary; this.deleted = old.deleted; this.lockOwner = old.lockOwner; this.runningState = old.runningState; this.alertState = old.alertState; this.deploymentState = old.deploymentState; this.userGuidOwner = old.userGuidOwner; this.dateCreated = old.dateCreated; this.userGuidCreated = old.userGuidCreated; this.dateModified = old.dateModified; this.userGuidModified = old.userGuidModified; this.dateDeleted = old.dateDeleted; this.userGuidDeleted = old.userGuidDeleted; this.settings = new ParameterCollection(old.settings); this.comments = old.comments; CopyEntityReferences(old); InitializeChildTypes(); }
void OnNotifyGameObjectRunState(RunningState pMsg) { UInt64 sGUID; sGUID = pMsg.objguid; Vector3 mvPos = this.ConvertPosToVector3(pMsg.pos); Vector3 mvDir = this.ConvertDirToVector3(pMsg.dir); float mvSp = pMsg.movespeed / 100.0f; Player entity = null; entity = PlayersManager.Instance.PlayerDic[sGUID]; if (entity != null) { mvPos.y = entity.RealEntity.transform.position.y; entity.GOSSI.sServerBeginPos = mvPos; entity.GOSSI.sServerSyncPos = mvPos; entity.GOSSI.sServerDir = mvDir; entity.GOSSI.fServerSpeed = mvSp; entity.GOSSI.fBeginTime = Time.realtimeSinceStartup; entity.GOSSI.fLastSyncSecond = Time.realtimeSinceStartup; //数据改变 entity.EntityChangedata(mvPos, mvDir); entity.isRuning = true; //调用子类执行状态 //entity.OnRuntate(); } }
virtual protected void Reset() { hasSolved = 0; playerCMDNo = -1; playerOldCounter = player.counter; playerState = RunningState.Inactive; enumPan.ResetRunningState(); player.ResetAnimator(); playerInbox.ResetInbox(InitialInboxGenerator()); playerOutbox.EmptyAllData(); playerFeedback.SetActive(false); SetCodingModeActive(true); playerInboxLog.Clear(); playerOutboxLog.Clear(); hasSolvedLog.Clear(); playerHoldingLog.Clear(); playerPosLog.Clear(); debugPan.SetDebugButtonActive(ButtonCode.Run, true); debugPan.SetDebugButtonActive(ButtonCode.Step, true); debugPan.SetDebugButtonActive(ButtonCode.Stop, false); debugPan.SetDebugButtonActive(ButtonCode.Back, false); }
/// <summary> /// Starts the ShredHost routine. /// </summary> /// <returns>true - if the ShredHost is currently running, false - if ShredHost is stopped.</returns> public static bool Start() { // install the unhandled exception event handler AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += MyUnhandledExceptionEventHandler; lock (_lockObject) { if (RunningState.Running == _runningState || RunningState.Transition == _runningState) { return(RunningState.Running == _runningState); } _runningState = RunningState.Transition; } Platform.Log(LogLevel.Info, "Starting up in AppDomain [" + AppDomain.CurrentDomain.FriendlyName + "]"); // Startup WorkItem Shred StartShreds(); lock (_lockObject) { _runningState = RunningState.Running; } return(RunningState.Running == _runningState); }
protected override void Awake() { base.Awake(); Initialize(); HandleInitialze(); var runningState = new RunningState(this); var deathState = new DeathState(this); var runAndGunState = new RunAndGunState(this); At(runningState, deathState, PlayerDead()); At(runningState, runAndGunState, isEquipWeapon()); At(runAndGunState, runningState, isWeaponDestroyed()); At(runAndGunState, deathState, PlayerDead()); _stateMachine.SetState(runningState); void At(IState from, IState to, Func <bool> condition) => _stateMachine.AddTransition(from, to, condition); // Func<bool> StageStart() => () => true; Func <bool> PlayerDead() => () => _health.currentHealth <= 0; Func <bool> isEquipWeapon() => () => _characterHandleWeapon._weaponAttachments.isWeaponCreated; Func <bool> isWeaponDestroyed() => () => !_characterHandleWeapon._weaponAttachments.isWeaponCreated; }
public void StopChapter() { if (_RunningState == RunningState.Suspended) { throw new ChapterNotRunningException("Chapter isnt running!"); } // exit all current states FlushStates(); // destroy all states foreach (IState state in _States.Values) { state.OnDestroy(); } _RunningState = RunningState.Suspended; }
/// <summary> /// 复位线程 /// </summary> private void ResettingLoopTask() { try { RunningState = RunningState.Resetting; Log($"{Name} ResetLoop Start...", LogLevel.Info); ResetLoop(); Log($"{Name} ResetLoop Finish", LogLevel.Info); RunningState = RunningState.WaitRun; } catch (Exception ex) { if (ex is TaskCancelException) { Log($"复位取消:[{Station.Name}-{Station.Id}]:[{Name}-{Id}]:{ex.Message}", LogLevel.Warning); } else { Log($"复位异常:[{Station.Name}-{Station.Id}]:[{Name}-{Id}]:{ex.Message}", LogLevel.Error); } RunningState = RunningState.WaitReset; Station.Machine.PostEvent(UserEventType.STOP, Station); } finally { _task = null; } }
private void controllerMovement() { Vector3 forwardVector; Vector3 leftVector; forwardVector = (forwardTransform.position - theTransform.position).normalized; leftVector = (leftTransform.position - theTransform.position).normalized; float forwardChange = -(Input.GetAxis("LeftJoystickY") * speed * Time.deltaTime); float leftChange = -(Input.GetAxis("LeftJoystickX") * speed * Time.deltaTime); if (Input.GetButton("LeftStickClick")) { running = RunningState.running; forwardChange *= 2.0f; leftChange *= 2.0f; } else if (Input.GetAxis("BackTriggers") >= 0.5f) { running = RunningState.silent; forwardChange *= 0.5f; leftChange *= 0.5f; } theTransform.position += forwardVector * forwardChange; theTransform.position += leftVector * leftChange; if (leftChange > 0.0f || forwardChange > 0.0f) { giveSound(); } else { walking = false; } }
// private processing functions private void StartLibrary_Internal() { if (_RunningState == RunningState.Running) { throw new FSMLibraryAlreadyRunningException("FSM Library is already running!"); } if (_RunningState == RunningState.Paused) { throw new FSMLibraryNotRunningException("FSM Library is paused!"); } foreach (FSMChapter chapter in _FSMChapters.Values) { chapter.StartChapter(new object[] { chapter }); } _RunningState = RunningState.Running; }
public void RecoverEnergy() { runningState = RunningState.Normal; moveSpeed = normalSpeed; energy = maxEnergy; UIManager.instance?.energyBar.SetFill(energy); SoundManager.instance?.StopPlay("TiredBreath", 1f); }
public void Resume() { if (_running == RunningState.Paused) { _running = RunningState.Running; OnResumeWorking?.Invoke(); } }
public void Pause() { if (_running == RunningState.Running) { _running = RunningState.Paused; OnPauseWorking?.Invoke(); } }
public bool Start() { bool success = RunningState == MySilmoon.RunningState.Stopped; RunningState = MySilmoon.RunningState.Running; if (OnStart != null) OnStart(ref success); if (!success) RunningState = RunningState.Stopped; return success; }
private void WLYBackupThread(string programPath) { m_programPath = programPath; State = RunningState.Running; // 进入运行循环 StartGame(); }
public bool Resume() { bool success = RunningState == MySilmoon.RunningState.Suspended; RunningState = MySilmoon.RunningState.Running; OnResume(ref success); if (!success) RunningState = RunningState.Suspended; return success; }
public void Dispose() { semaphore?.Dispose(); semaphore = null; state?.Dispose(); state = null; }
private void StopRun() { target.Duration = DateTime.Now - state.StartTime; state.Dispose(); state = null; target.IsRunningTests = false; }
/// <summary> /// Constructor of DNA processor. /// </summary> /// <param name="inputStream">Input stream with source DNA.</param> /// <param name="outputStream">Output stream for produced RNA.</param> public DnaRunner(Stream inputStream, Stream outputStream) { if (inputStream.CanSeek) inputStream.Seek(0, SeekOrigin.Begin); _sourceDna = new StringManager(new StreamReader(inputStream).ReadToEnd()); RnaStream = outputStream; _state = RunningState.Stoped; }
public void StartUpdating() { if (State == RunningState.Waiting || State == RunningState.Stopped) { trigger = new SimpleTriggerImpl("Feed parsing", null, DateTime.Now, null, SimpleTriggerImpl.RepeatIndefinitely, RepeatInterval); jobDetail = new JobDetailImpl("job", typeof(UpdateJob)); jobDetail.JobDataMap["service"] = service; sched.ScheduleJob(jobDetail, trigger); State = RunningState.Runing; } }
private PatternInfo DecodePattern() { var result = new PatternInfo(); int level = 0; bool flag = true; while (flag) { if (_currentIndex >= _runningDna.Length) { lock (_runningMutex) { _state = RunningState.Stoped; return null; } } if (_runningDna.HasPatternAtPosition( new[] { "C" }, _currentIndex)) { ++_currentIndex; result.AppendBack('I'); continue; } if (_runningDna.HasPatternAtPosition( new[] { "F" }, _currentIndex)) { ++_currentIndex; result.AppendBack('C'); continue; } if (_runningDna.HasPatternAtPosition( new[] { "P" }, _currentIndex)) { ++_currentIndex; result.AppendBack('F'); continue; } if (_runningDna.HasPatternAtPosition( new[] { "IC" }, _currentIndex)) { _currentIndex += 2; result.AppendBack('P'); continue; } if (_runningDna.HasPatternAtPosition( new[] { "IP" }, _currentIndex)) { _currentIndex += 2; int number = DecodeNumber(); result.AppendSkip(number); continue; } if (_runningDna.HasPatternAtPosition( new[] { "IF" }, _currentIndex)) { _currentIndex += 3; string consts = DecodeConsts(); result.AppendSearch(consts); continue; } if (_runningDna.HasPatternAtPosition( new[] { "IIP" }, _currentIndex)) { _currentIndex += 3; ++level; result.IncreaseLevel(); continue; } if (_runningDna.HasPatternAtPosition( new[] { "IIC", "IIF" }, _currentIndex)) { _currentIndex += 3; if (level == 0) { flag = false; continue; } --level; result.DecreaseLevel(); continue; } if (_runningDna.HasPatternAtPosition( new[] { "III" }, _currentIndex)) { string toRna = _runningDna.Substring(_currentIndex + 3, 7).ToString(); OutputToRna(toRna); _currentIndex += 10; continue; } // Else stop. lock (_runningMutex) { _state = RunningState.Stoped; return null; } } return result; }
private int DecodeNumber() { int result = 0; int firstPIndex = _runningDna.IndexOf("P", _currentIndex); if (firstPIndex == -1) { lock (_runningMutex) { _state = RunningState.Stoped; } } for (int index = firstPIndex - 1; index >= _currentIndex; --index) { if (_runningDna.HasPatternAtPosition( new[] { "I", "F" }, index)) result *= 2; else if (_runningDna.HasPatternAtPosition( new[] { "C" }, index)) result = result * 2 + 1; } _currentIndex = firstPIndex + 1; return result; }
/// <summary> /// Stop DNA processing. /// </summary> public void Stop() { lock (_runningMutex) { if (_state == RunningState.Stoped) return; _state = RunningState.Stoped; } _runningThread.Join(); }
/// <summary> /// Start DNA processing. /// </summary> public void Start() { lock (_runningMutex) { if (_state == RunningState.Running) return; _state = RunningState.Running; } _rnaWriter = new StreamWriter(RnaStream); _runningDna = new StringManager(Prefix); _runningDna.AppendToBack(_sourceDna, 0); _totalCharsOfRna = 0; _totalCommandProcessed = 0; _lastRaisedCharsCountOverEvent = 0; _lastRaisedCommandsCountOverEvent = 0; _currentIndex = 0; _runningThread = new Thread(ProcessDna); _runningThread.Start(); }
// thread safely switch running state; private void GotoState(RunningState state) { if (_state == state) return; lock (this) { // maintainance the previous state; _previousState = _state; _state = state; } }
static ShredHost() { _shredInfoList = new ShredControllerList(); _sed = null; _runningState = RunningState.Stopped; }
public void Update(GameTime gameTime) { m_lastState = State; switch (this.State) { case RunningState.Running: { Destination = Player.Locate; this.UpdateDraw(gameTime); AIControler.Update(gameTime, m_units, m_item, Player); foreach (var mRegion in m_regions) { mRegion.Update(gameTime); } } break; case RunningState.Loading: { if (m_loadingTimer > 0.1f && m_data.LoadingLeft == 0) { SwitchTo(RunningState.Running, null); } m_loadingTimer += (float)gameTime.ElapsedGameTime.TotalSeconds; } break; case RunningState.Speaking: m_dialog.Update(gameTime); break; case RunningState.Viewing: m_camera.Update(gameTime); this.UpdateDraw(gameTime); break; case RunningState.Splash: m_splash.Update( gameTime ); break; case RunningState.Handbook: m_handbook.Update( gameTime ); break; } string cmd; string[] cmds; while (GameCommands.Count() > 0) { cmd = GameCommands.Dequeue(); if(cmd == null)continue; cmds = cmd.Split(';'); foreach (string s in cmds) { CommandResolver(s.Trim()); } } }
private void SwitchTo(RunningState runningState, object param) { if (runningState == RunningState.Running && State == RunningState.Loading) { InternalLoad(m_data); } else if (runningState == RunningState.Loading) { m_data = (MapManager.MapLoadingData)param; m_loadingTimer = 0; } else if (runningState == RunningState.Speaking) { this.UpdateDraw(new GameTime()); AIControler.Update(new GameTime(), m_units, m_item, Player); DrawRunning(new GameTime(), SpriteManager.SpriteBatch); m_dialog.Load(param.ToString(), m_resolveTexture); } else if (runningState == RunningState.Viewing) { m_camera.Load((string)param); } else if(runningState == RunningState.Splash) { } State = runningState; }
private void mouseMovement() { Vector3 forwardVector; Vector3 leftVector; float theSpeed = speed; if (Input.GetKey(KeyCode.LeftShift)) { theSpeed *= 1.5f; running = RunningState.running; } else if (Input.GetKey(KeyCode.Space)) { theSpeed *= 0.5f; running = RunningState.silent; } else { running = RunningState.normal; } theSpeed *= Time.deltaTime; forwardVector = (forwardTransform.position - theTransform.position).normalized * theSpeed; leftVector = (leftTransform.position - theTransform.position).normalized * theSpeed; walking = false; if (Input.GetKey(KeyCode.W)) { theTransform.position += forwardVector; giveSound(); } if (Input.GetKey(KeyCode.A)) { theTransform.position += leftVector; giveSound(); } if (Input.GetKey(KeyCode.S)) { theTransform.position += -forwardVector; giveSound(); } if (Input.GetKey(KeyCode.D)) { theTransform.position += -leftVector; giveSound(); } }
public void Stop() { sched.Clear(); State = RunningState.Stopped; }
public void RunStart() { runThread = new Thread(new ThreadStart(this.Run)); runThread.Name = "MOTMaster Controller"; runThread.Priority = ThreadPriority.Normal; status = RunningState.running; runThread.Start(); }
public void Stop() { State = RunningState.Stopped; }
private TemplateInfo DecodeTemplate() { var template = new TemplateInfo(); bool flag = true; while (flag) { if (_currentIndex >= _runningDna.Length) { lock (_runningMutex) { _state = RunningState.Stoped; return null; } } if (_runningDna.HasPatternAtPosition( new[] { "C" }, _currentIndex)) { ++_currentIndex; template.AppendBack('I'); continue; } if (_runningDna.HasPatternAtPosition( new[] { "F" }, _currentIndex)) { ++_currentIndex; template.AppendBack('C'); continue; } if (_runningDna.HasPatternAtPosition( new[] { "P" }, _currentIndex)) { ++_currentIndex; template.AppendBack('F'); continue; } if (_runningDna.HasPatternAtPosition( new[] { "IC" }, _currentIndex)) { _currentIndex += 2; template.AppendBack('P'); continue; } if (_runningDna.HasPatternAtPosition( new[] { "IF", "IP" }, _currentIndex)) { _currentIndex += 2; int level = DecodeNumber(); int reference = DecodeNumber(); template.AddReference(reference, level); continue; } if (_runningDna.HasPatternAtPosition( new[] { "IIC", "IIF" }, _currentIndex)) { _currentIndex += 3; flag = false; continue; } if (_runningDna.HasPatternAtPosition( new[] { "IIP" }, _currentIndex)) { _currentIndex += 3; int reference = DecodeNumber(); template.AddLengthOfReference(reference); continue; } if (_runningDna.HasPatternAtPosition( new[] { "III" }, _currentIndex)) { string toRna = _runningDna.Substring(_currentIndex + 3, 7).ToString(); OutputToRna(toRna); _currentIndex += 10; continue; } // Else stop. lock (_runningMutex) { _state = RunningState.Stoped; return null; } } return template; }
public bool Stop() { MySilmoon.RunningState runstate = RunningState; bool success = RunningState != MySilmoon.RunningState.Stopped; RunningState = MySilmoon.RunningState.Stopped; if (OnStop != null) OnStop(ref success); if (!success) RunningState = runstate; return success; }
/// <summary> /// Stops the running ShredHost. /// </summary> /// <returns>true - if the ShredHost is running, false - if the ShredHost is stopped.</returns> public static bool Stop() { lock (_lockObject) { if (RunningState.Stopped == _runningState || RunningState.Transition == _runningState) return (RunningState.Running == _runningState); _runningState = RunningState.Transition; } // correct sequence should be to stop the WCF host so that we don't // receive any more incoming requests Platform.Log(LogLevel.Info, "ShredHost stop request received"); if (_shredHostWCFInitialized) { try { WcfHelper.StopHost(_sed); Platform.Log(LogLevel.Info, "The ShredHost WCF service has stopped."); } catch(Exception e) { Platform.Log(LogLevel.Error, e); } } StopShreds(); Platform.Log(LogLevel.Info, "Completing ShredHost stop."); _shredInfoList.Clear(); lock (_lockObject) { _runningState = RunningState.Stopped; } return (RunningState.Running == _runningState); }
public bool Suspend() { bool success = RunningState == MySilmoon.RunningState.Running; RunningState = MySilmoon.RunningState.Suspended; OnSuspend(ref success); if (!success) RunningState = RunningState.Running; return success; }
/// <summary> /// Starts the ShredHost routine. /// </summary> /// <returns>true - if the ShredHost is currently running, false - if ShredHost is stopped.</returns> public static bool Start() { // install the unhandled exception event handler AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += MyUnhandledExceptionEventHandler; lock (_lockObject) { if (RunningState.Running == _runningState || RunningState.Transition == _runningState) return (RunningState.Running == _runningState); _runningState = RunningState.Transition; } Platform.Log(LogLevel.Info, "Starting up in AppDomain [" + AppDomain.CurrentDomain.FriendlyName + "]"); // the ShredList and shreds objects are proxy objects that actually exist // in the secondary AppDomain //AppDomain stagingDomain = AppDomain.CreateDomain("StagingDomain"); ExtensionScanner scanner = (ExtensionScanner)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap(Assembly.GetExecutingAssembly().Location, "ClearCanvas.Server.ShredHost.ExtensionScanner"); ShredStartupInfoList shredStartupInfoList = null; try { shredStartupInfoList = scanner.ScanExtensions(); } catch (PluginException pluginException) { // There was a problem loading the plugins, including if there were no plugins found // This is an innocuous problem, and just means that there are no shreds to run Platform.Log(LogLevel.Warn, pluginException); } StartShreds(shredStartupInfoList); // all the shreds have been created, so we can dismantle the secondary domain that was used // for scanning for all Extensions that are shreds //AppDomain.Unload(stagingDomain); //try //{ // _sed = WcfHelper.StartHttpHost<ShredHostServiceType, IShredHost>( // "ShredHost", "Host program of multiple independent service-like sub-programs", ShredHostServiceSettings.Instance.ShredHostHttpPort); // _shredHostWCFInitialized = true; // string message = String.Format("The ShredHost WCF service has started on port {0}.", ShredHostServiceSettings.Instance.ShredHostHttpPort); // Platform.Log(LogLevel.Info, message); // Console.WriteLine(message); //} //catch(Exception e) //{ // Platform.Log(LogLevel.Error, e); // Console.WriteLine("The ShredHost WCF service has failed to start. Please check the log for more details."); //} lock (_lockObject) { _runningState = RunningState.Running; } return (RunningState.Running == _runningState); }
public Task(IEnumerator routine) { _innerRoutine = routine; // runs into background first; _state = RunningState.Init; }
private void MainForm_Click(object sender, EventArgs e) { preCount = curCount = 0; state = RunningState.Normal; ExitSleep(); }
public void Run(Dictionary<String, Object> dict) { Stopwatch watch = new Stopwatch(); MOTMasterScript script = prepareScript(scriptPath, dict); if (script != null) { MOTMasterSequence sequence = getSequenceFromScript(script); try { if (config.CameraUsed) prepareCameraControl(); if (config.TranslationStageUsed) armTranslationStageForTimedMotion(script); if (config.CameraUsed) GrabImage((int)script.Parameters["NumberOfFrames"]); buildPattern(sequence, (int)script.Parameters["PatternLength"]); if (config.CameraUsed) waitUntilCameraIsReadyForAcquisition(); watch.Start(); for (int i = 0; i < controllerWindow.GetIterations() && status == RunningState.running; i++) { if(!config.Debug) runPattern(sequence); } if (!config.Debug) clearDigitalPattern(sequence); watch.Stop(); //MessageBox.Show(watch.ElapsedMilliseconds.ToString()); if (saveEnable) { if (config.CameraUsed) { waitUntilCameraAquisitionIsDone(); try { checkDataArrived(); } catch (DataNotArrivedFromHardwareControllerException) { return; } Dictionary<String, Object> report = null; if (config.ReporterUsed) { report = GetExperimentReport(); } save(script, scriptPath, imageData, report); } else { Dictionary<String, Object> report = null; if (config.ReporterUsed) { report = GetExperimentReport(); } save(script, scriptPath, report); } } if (config.CameraUsed) finishCameraControl(); if (config.TranslationStageUsed) disarmAndReturnTranslationStage(); } catch (System.Net.Sockets.SocketException e) { MessageBox.Show("CameraControllable not found. \n Is there a hardware controller running? \n \n" + e.Message, "Remoting Error"); } } else { MessageBox.Show("Unable to load pattern. \n Check that the script file exists and that it compiled successfully"); } status = RunningState.stopped; }
private void Reset() { LoadConfig(); state = RunningState.Normal; preCount = curCount = 0; timer.Stop(); timer.Start(); }
public void Dispose() { State = RunningState.Disposed; }
public override void Stop() { State = RunningState.Stopped; }
public void Start() { State = RunningState.Started; }