コード例 #1
0
    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
    }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: lanzhuo2011/EyeSafe
        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++;
        }
コード例 #3
0
ファイル: ShredHost.cs プロジェクト: 1059444127/uDicom
        /// <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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
    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);
    }
コード例 #6
0
        // 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;
        }
コード例 #7
0
    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);
    }
コード例 #8
0
 public LiteTask(IEnumerator routine, bool startInBackground = true)
 {
     wcBackgroundMoveNextState = BackgroundMoveNextState;
     innerRoutine      = routine;
     StartInBackground = startInBackground;
     state             = routine == null ? RunningState.Done : RunningState.Init;
 }
コード例 #9
0
 /// <summary>
 /// 停止运行
 /// </summary>
 public void Stop()
 {
     State = RunningState.Stopped;
     m_process.Kill();
     m_process.Close();
     m_process.Dispose();
 }
コード例 #10
0
    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;
        }
    }
コード例 #11
0
    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);
        }
    }
コード例 #12
0
    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);
    }
コード例 #13
0
 public Machine()
 {
     _autoPauseCount   = 0;
     _runningState     = RunningState.Paused;
     _runningStateLock = new object();
     _volume           = 80;
 }
コード例 #14
0
    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);
    }
コード例 #15
0
    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);
    }
コード例 #16
0
 public void Unpublish()
 {
     RestartCount.Unpublish();
     RunningState.Unpublish();
     HealthState.Unpublish();
     StartTime.Unpublish();
 }
コード例 #17
0
 public void Dispose()
 {
     RestartCount.Remove();
     RunningState.Remove();
     HealthState.Remove();
     StartTime.Remove();
 }
コード例 #18
0
        /// <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();
        }
コード例 #19
0
    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();
        }
    }
コード例 #20
0
    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);
    }
コード例 #21
0
ファイル: ShredHost.cs プロジェクト: 1059444127/uDicom
        /// <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);
        }
コード例 #22
0
ファイル: AI_Player.cs プロジェクト: psl012/CodeBlock_GameJam
    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;
    }
コード例 #23
0
        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;
        }
コード例 #24
0
        /// <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;
            }
        }
コード例 #25
0
 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;
     }
 }
コード例 #26
0
ファイル: RetroFSM.cs プロジェクト: RetroZelda/retrolib-unity
        // 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;
        }
コード例 #27
0
 public void RecoverEnergy()
 {
     runningState = RunningState.Normal;
     moveSpeed    = normalSpeed;
     energy       = maxEnergy;
     UIManager.instance?.energyBar.SetFill(energy);
     SoundManager.instance?.StopPlay("TiredBreath", 1f);
 }
コード例 #28
0
 public void Resume()
 {
     if (_running == RunningState.Paused)
     {
         _running = RunningState.Running;
         OnResumeWorking?.Invoke();
     }
 }
コード例 #29
0
 public void Pause()
 {
     if (_running == RunningState.Running)
     {
         _running = RunningState.Paused;
         OnPauseWorking?.Invoke();
     }
 }
コード例 #30
0
 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;
 }
コード例 #31
0
        private void WLYBackupThread(string programPath)
        {
            m_programPath = programPath;
            State         = RunningState.Running;

            // 进入运行循环
            StartGame();
        }
コード例 #32
0
 public bool Resume()
 {
     bool success = RunningState == MySilmoon.RunningState.Suspended;
     RunningState = MySilmoon.RunningState.Running;
     OnResume(ref success);
     if (!success) RunningState = RunningState.Suspended;
     return success;
 }
コード例 #33
0
        public void Dispose()
        {
            semaphore?.Dispose();
            semaphore = null;

            state?.Dispose();
            state = null;
        }
コード例 #34
0
        private void StopRun()
        {
            target.Duration = DateTime.Now - state.StartTime;

            state.Dispose();
            state = null;

            target.IsRunningTests = false;
        }
コード例 #35
0
ファイル: DnaRunner.cs プロジェクト: VitalyKalinkin/ICFP
        /// <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;
        }
コード例 #36
0
 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;
     }
 }
コード例 #37
0
ファイル: DnaRunner.cs プロジェクト: VitalyKalinkin/ICFP
        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;
        }
コード例 #38
0
ファイル: DnaRunner.cs プロジェクト: VitalyKalinkin/ICFP
        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;
        }
コード例 #39
0
ファイル: DnaRunner.cs プロジェクト: VitalyKalinkin/ICFP
        /// <summary>
        /// Stop DNA processing.
        /// </summary>
        public void Stop()
        {
            lock (_runningMutex)
            {
                if (_state == RunningState.Stoped)
                    return;
                _state = RunningState.Stoped;
            }

            _runningThread.Join();
        }
コード例 #40
0
ファイル: DnaRunner.cs プロジェクト: VitalyKalinkin/ICFP
        /// <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();
        }
コード例 #41
0
ファイル: Task.cs プロジェクト: einargizz/pgworld
        // thread safely switch running state;
        private void GotoState(RunningState state)
        {
            if (_state == state) return;

            lock (this)
            {
                // maintainance the previous state;
                _previousState = _state;
                _state = state;
            }
        }
コード例 #42
0
ファイル: ShredHost.cs プロジェクト: UIKit0/ClearCanvas
 static ShredHost()
 {
     _shredInfoList = new ShredControllerList();
     _sed = null;
     _runningState = RunningState.Stopped;
 }
コード例 #43
0
ファイル: WorldManager.cs プロジェクト: fanthos/Game-Heal
 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());
         }
     }
 }
コード例 #44
0
ファイル: WorldManager.cs プロジェクト: fanthos/Game-Heal
 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;
 }
コード例 #45
0
 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();
     }
 }
コード例 #46
0
 public void Stop()
 {
     sched.Clear();
     State = RunningState.Stopped;
 }
コード例 #47
0
ファイル: Controller.cs プロジェクト: ColdMatter/EDMSuite
 public void RunStart()
 {
     runThread = new Thread(new ThreadStart(this.Run));
     runThread.Name = "MOTMaster Controller";
     runThread.Priority = ThreadPriority.Normal;
     status = RunningState.running;
     runThread.Start();
 }
コード例 #48
0
ファイル: MillipedeTests.cs プロジェクト: briandealwis/gt
 public void Stop()
 {
     State = RunningState.Stopped;
 }
コード例 #49
0
ファイル: DnaRunner.cs プロジェクト: VitalyKalinkin/ICFP
        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;
        }
コード例 #50
0
 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;
 }
コード例 #51
0
ファイル: ShredHost.cs プロジェクト: UIKit0/ClearCanvas
        /// <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);
        }
コード例 #52
0
 public bool Suspend()
 {
     bool success = RunningState == MySilmoon.RunningState.Running;
     RunningState = MySilmoon.RunningState.Suspended;
     OnSuspend(ref success);
     if (!success) RunningState = RunningState.Running;
     return success;
 }
コード例 #53
0
ファイル: ShredHost.cs プロジェクト: UIKit0/ClearCanvas
		/// <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);
        }
コード例 #54
0
ファイル: Task.cs プロジェクト: einargizz/pgworld
 public Task(IEnumerator routine)
 {
     _innerRoutine = routine;
     // runs into background first;
     _state = RunningState.Init;
 }
コード例 #55
0
ファイル: MainForm.cs プロジェクト: lanzhuo2011/EyeSafe
 private void MainForm_Click(object sender, EventArgs e)
 {
     preCount = curCount = 0;
     state = RunningState.Normal;
     ExitSleep();
 }
コード例 #56
0
ファイル: Controller.cs プロジェクト: ColdMatter/EDMSuite
        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;
        }
コード例 #57
0
ファイル: MainForm.cs プロジェクト: lanzhuo2011/EyeSafe
 private void Reset()
 {
     LoadConfig();
     state = RunningState.Normal;
     preCount = curCount = 0;
     timer.Stop();
     timer.Start();
 }
コード例 #58
0
ファイル: MillipedeTests.cs プロジェクト: briandealwis/gt
 public void Dispose()
 {
     State = RunningState.Disposed;
 }
コード例 #59
0
ファイル: MillipedeTests.cs プロジェクト: briandealwis/gt
 public override void Stop()
 {
     State = RunningState.Stopped;
 }
コード例 #60
0
ファイル: MillipedeTests.cs プロジェクト: briandealwis/gt
 public void Start()
 {
     State = RunningState.Started;
 }