Esempio n. 1
0
        /// <summary>
        /// 更新指定执行器
        /// </summary>
        /// <param name="runnerState"></param>
        /// <returns></returns>
        public bool UpdataRunner(RunnerState runnerState)
        {
            int updataIndex = runnerState.RunnerID;

            if (this.Items.Count > updataIndex)
            {
                this.Items[updataIndex].SubItems[0].Text = runnerState.RunnerName;
                this.Items[updataIndex].SubItems[1].Text = runnerState.NowCell;
                this.Items[updataIndex].SubItems[2].Text = runnerState.RunDetails;
                this.Items[updataIndex].SubItems[3].Text = runnerState.Time;
                this.Items[updataIndex].SubItems[4].Text = runnerState.CellResult;
                ((ProgressBarList)this.Items[updataIndex].SubItems[5].Tag).UpdateListMinimal(runnerState.RunnerProgress.ToList());
                this.Items[updataIndex].SubItems[6].Text = runnerState.State;
                if (PlayStateDictionary.ContainsKey(runnerState.State))
                {
                    ((PlayButton)this.Items[updataIndex].SubItems[7].Tag).OnChangeState(PlayStateDictionary[runnerState.State]);
                }
                else
                {
                    ErrorLog.PutInLog("unkonw runnerState find in ListView_RemoteRunnerView");
                }
                return(true);
            }
            else
            {
                while (this.Items.Count < updataIndex)
                {
                    AddEmptyRunner();
                }
                AddRunner(runnerState);
            }
            return(false);
        }
Esempio n. 2
0
    void FixedUpdate()
    {
        if (_state == RunnerState.Stopped)
        {
            return;
        }

        // update current position in grid
        currentPosition2D = _tr.localPosition.To2D();

        // take the actual position as floats to compare with the destination and get there as close as is acceptable
        var currentPosition2DFloats = _tr.localPosition.To2DXZ();

        // compare with destination
        if ((destinationPosition2D - currentPosition2DFloats).sqrMagnitude > 0.05f)
        {
            _rb.MovePosition(_tr.position + currentDirection * Speed);
            _state = RunnerState.Walking;
            animator.SetTrigger("Run");
        }
        else
        {
            _state = RunnerState.Idle;
            animator.SetTrigger("Idle");
        }
    }
Esempio n. 3
0
        /// <summary>
        /// 更新指定执行器(需保证传入参数不为null)
        /// </summary>
        /// <param name="runnerState"></param>
        /// <returns>是否正常更新,如果索引不符合预期则会返回false</returns>
        public bool UpdataRunner(RunnerState runnerState)
        {
            int updataIndex = runnerState.RunnerID;

            if (this.Nodes.Count > updataIndex)
            {
                this.Nodes[updataIndex].Cells[0].Text = runnerState.RunnerName;
                this.Nodes[updataIndex].Cells[1].Text = runnerState.NowCell;
                this.Nodes[updataIndex].Cells[2].Text = runnerState.CellResult;
                this.Nodes[updataIndex].Cells[3].Text = runnerState.Time;
                this.Nodes[updataIndex].Cells[4].Text = runnerState.State;
                if (RunnerStateDictionary.ContainsKey(runnerState.State))
                {
                    this.Nodes[updataIndex].ImageIndex = RunnerStateDictionary[runnerState.State];
                }
                else
                {
                    this.Nodes[updataIndex].ImageIndex = 7;
                }
                return(true);
            }
            else
            {
                while (this.Nodes.Count < updataIndex)
                {
                    AddEmptyRunner();
                }
                AddRunner(runnerState);
            }
            return(false);
        }
 public RunnerStatsMessage(RunnerState currentState, Vector3 velocity, CollisionInfo contacts, InputState currentInput)
 {
     CurrentState = currentState;
     Velocity = velocity;
     Contacts = contacts;
     CurrentInput = currentInput;
 }
        public void SetImage(RunnerState _status)
        {
            if (Host.InvokeRequired)
            {
                Host.Invoke(new MethodInvoker(() =>
                {
                    SetImage(_status);
                }));
            }
            else
            {
                switch (_status)
                {
                case RunnerState.Init:
                    Host.pictureBox1.Image = Host.picInit.Image;
                    break;

                case RunnerState.Connecting:
                    Host.pictureBox1.Image = Host.picConnecting.Image;
                    break;

                case RunnerState.Success:
                    Host.pictureBox1.Image = Host.picSuccess.Image;
                    break;

                case RunnerState.Failed:
                    Host.pictureBox1.Image = Host.picFailure.Image;
                    break;
                }
            }
        }
Esempio n. 6
0
        public Task <bool> UpdateRunnerState(RunnerState runnerState)
        {
            _state.UpdateRunnerState(runnerState);

            _logger.Debug("{@DeviceId} updated {@RunnerState}.", _state.Id, runnerState);
            return(Task.FromResult(true));
        }
Esempio n. 7
0
    public void ChangeState(State newState)
    {
        switch (newState)
        {
        case State.run:
            state = RunnerState.running;
            anim.SetInteger("action", 0);
            break;

        case State.jump:
            state = RunnerState.jumping;
            anim.SetInteger("action", 1);
            break;

        case State.trip:
            rgb.velocity = new Vector3(0, rgb.velocity.y, 0);
            state        = RunnerState.tripping;
            anim.SetInteger("action", 2);
            fall.Play();
            break;

        case State.die:
            state = RunnerState.dying;
            anim.SetInteger("action", 3);
            break;
        }
    }
Esempio n. 8
0
        /// <summary>
        /// 添加执行器(该方法未判断索引正确性)
        /// </summary>
        /// <param name="runnerState"></param>
        public void AddRunner(RunnerState runnerState)
        {
            if (runnerState != null)
            {
                ProgressBarList runerProgressBar = new ProgressBarList();
                PlayButton      runnerButton     = new PlayButton();
                ListViewItem    myAddItem        = new ListViewItem(new string[] { runnerState.RunnerName, runnerState.NowCell, runnerState.RunDetails, runnerState.Time, runnerState.CellResult, "", runnerState.State, "" });

                if (PlayStateDictionary.ContainsKey(runnerState.State))
                {
                    runnerButton.OnChangeState(PlayStateDictionary[runnerState.State]);
                }
                else
                {
                    ErrorLog.PutInLog("unkonw runnerState find in ListView_RemoteRunnerView");
                }

                if (runnerState.RunnerProgress != null)
                {
                    runerProgressBar.UpdateList((runnerState.RunnerProgress).ToList());
                }
                else
                {
                    ErrorLog.PutInLog("no RunnerProgress find in ListView_RemoteRunnerView");
                }

                this.Controls.Add(runerProgressBar);
                this.Controls.Add(runnerButton);

                myAddItem.SubItems[5].Tag = runerProgressBar;
                myAddItem.SubItems[7].Tag = runnerButton;

                this.Items.Add(myAddItem);
            }
        }
Esempio n. 9
0
 public void OnDieing_Started()
 {
     if (_state == RunnerState.Running)
     {
         Debug.Log("Dieing");
         _state = RunnerState.Dieing;
     }
 }
Esempio n. 10
0
    void Start()
    {
        _state     = RunnerState.Idel;
        _animator  = GetComponent <Animator>();
        _direction = new Vector3(1f, 0, 0);

        Run();
    }
Esempio n. 11
0
 /// <summary>
 /// 开始跑步
 /// </summary>
 public void Start()
 {
     state      = RunnerState.Runing;
     IsRunning  = true;
     frameIndex = 0;
     view.Start();
     view.MyTrailRender.time = 0.5f;
 }
Esempio n. 12
0
 private void OnRunnerStateChnaged(RunnerState obj)
 {
     if (obj == RunnerState.Run)
     {
         lines.Clear();
         ifText.text = "";
     }
 }
Esempio n. 13
0
    public float Update()
    {
        if (IsRunning)
        {
            if (state == RunnerState.Runing)
            {
                if (frameIndex < runFrameCount)
                {
                    view.UpdatePosition(framsPositionList[frameIndex]);
                    return(frameLengthList[frameIndex++]);
                }
                else
                {
                    view.UpdatePosition(framsPositionList[frameIndex++]);
                    state = RunnerState.Gogogo;
                    SnailRun.Instance.Freezing();
                    view.ShowRankImg(myRank);
                    return(Define.RUNWAY_LENGTH);
                }
            }
            else if (state == RunnerState.Gogogo)
            {
                waitFrames = 0;
                state      = RunnerState.AfterGoGoGo;
                return(Define.RUNWAY_LENGTH);
            }
            else if (state == RunnerState.AfterGoGoGo)
            {
                waitFrames++;
                if (waitFrames < 90)
                {
                    view.UpdatePosition(framsPositionList[runFrameCount + waitFrames]);
                }
                else
                {
                    SnailRun.Instance.OnRunnerRunOver(this, runFrameCount);
                    state = RunnerState.WaitReplay;
                }
            }
            else if (state == RunnerState.Replaying)
            {
                view.UpdatePosition(framsPositionList[frameIndex++]);

                if (frameIndex > runFrameCount + 50)
                {
                    state = RunnerState.AfterReplay;
                }
            }
            else if (state == RunnerState.AfterReplay)
            {
                state     = RunnerState.None;
                IsRunning = false;
                SnailRun.Instance.OnRunnerReplayOver();
            }
            return(Define.RUNWAY_LENGTH);
        }
        return(0);
    }
Esempio n. 14
0
 public void OnRun_Started()
 {
     if (_state != RunnerState.Running)
     {
         Debug.Log("Running");
         _state     = RunnerState.Running;
         _direction = new Vector3(1f, 0f, 0f);
     }
 }
Esempio n. 15
0
 // Use this for initialization
 void Start()
 {
     endCanvas   = Resources.Load <GameObject>("Prefabs/EndCanvas");
     fall        = GetComponent <AudioSource>();
     rgb         = GetComponent <Rigidbody>();
     state       = RunnerState.running;
     anim        = GetComponent <Animator>();
     startingPos = new Vector3(transform.position.x, transform.position.y, transform.position.z);
 }
Esempio n. 16
0
        private async System.Threading.Tasks.Task Execute()
        {
            State = RunnerState.Running;

            // See https://github.com/microsoft/vs-threading/blob/master/doc/cookbook_vs.md for
            // info on VS threading.
            await System.Threading.Tasks.Task.Yield(); // Get off the caller's callstack

            try
            {
                startTime = DateTime.UtcNow;
                logger.WriteLine(Strings.JobRunner_StartingJob, jobDescription, startTime.ToLongTimeString());

                progress?.Report(new JobRunnerProgress(State, completedOperations, totalOperations));
                foreach (var op in operations)
                {
                    if (cancellationSource.Token.IsCancellationRequested)
                    {
                        break;
                    }

                    op();

                    if (cancellationSource.Token.IsCancellationRequested)
                    {
                        break;
                    }

                    completedOperations++;
                    progress?.Report(new JobRunnerProgress(State, completedOperations, totalOperations));
                }

                if (!cancellationSource.Token.IsCancellationRequested)
                {
                    State = RunnerState.Finished;
                    var elapsedTime = DateTime.UtcNow - startTime;
                    logger.WriteLine(Strings.JobRunner_FinishedJob,
                                     jobDescription, startTime.ToLongTimeString(), (long)elapsedTime.TotalMilliseconds);
                    progress?.Report(new JobRunnerProgress(State, completedOperations, totalOperations));
                }
            }
            catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex))
            {
                State = RunnerState.Faulted;
                progress?.Report(new JobRunnerProgress(State, completedOperations, totalOperations));
                logger.WriteLine(Strings.JobRunner_ExecutionError, jobDescription, startTime.ToLongTimeString(), ex.Message);
            }
            finally
            {
                // We're cancelling here purely for testing purposes: tests can wait on the token WaitHandle
                // to know that the job runner has finished. Ugly, but it means we can write reliable tests.
                cancellationSource.Cancel();
                cancellationSource?.Dispose();
                cancellationSource = null;
            }
        }
Esempio n. 17
0
 public void RunnerStan(RunnerState state)
 {
     m_state = state;
     if (m_state == RunnerState.stan)
     {
         Debug.Log("スタンしたよ");
         // RunnerStateがStanに変更されたらisStanをtrueに変更
         isStan = true;
     }
 }
Esempio n. 18
0
        public Color[] GetTypicalColors()
        {
            if (this.State != RunnerState.Finish)
            {
                return(new Color[0]);
            }

            this.State = RunnerState.Wait;
            return(this.typicalColors);
        }
Esempio n. 19
0
 public void OnDead_Started()
 {
     if (_state == RunnerState.Dieing)
     {
         Debug.Log("Dead");
         _state = RunnerState.Dead;
         if (OnRunnerDead != null)
         {
             OnRunnerDead(this.gameObject);
         }
     }
 }
Esempio n. 20
0
 /// <summary>
 /// Tries the set runner state running.
 /// </summary>
 /// <returns><c>true</c> if state could be set to running, <c>false</c> otherwise.</returns>
 private bool TrySetRunnerStateRunning()
 {
     lock (lockObj)
     {
         if (this.State != RunnerState.Idle)
         {
             return(false);
         }
         this.State = RunnerState.Running;
         return(true);
     }
 }
Esempio n. 21
0
        private CancellableJobRunner(string jobDescription, IEnumerable <Action> operations, IProgress <JobRunnerProgress> progress, ILogger logger)
        {
            this.jobDescription = jobDescription;
            this.operations     = operations;
            this.progress       = progress;
            this.logger         = logger;
            State = RunnerState.NotStarted;

            totalOperations     = operations.Count();
            completedOperations = 0;

            cancellationSource = new CancellationTokenSource();
        }
Esempio n. 22
0
    private void Start()
    {
        idleState     = GetComponent <IdleState>();
        patrolState   = GetComponent <PatrolState>();
        runnerState   = GetComponent <RunnerState>();
        summonerState = GetComponent <SummonerAttackState>();

        animator = GetComponent <Animator>();

        currentState = idleState;
        entity.EquipItem(transform.Find("Weapon").GetComponentInChildren <AbstractWeapon>());
        entity.currentWeapon.enemyWeapon = true;
    }
 public void Animate(RunnerState runnerState)
 {
     if (_animator == null)
         throw new InvalidOperationException("Animation must be initialized");
     if (_existingAnimations.Contains(runnerState.ToString()))
     {
         ChangeAnimation(runnerState.ToString());
     }
     else
     {
         Debug.LogWarning("No animation defined for " + runnerState);
     }
 }
Esempio n. 24
0
    private void SendRunnerState()
    {
        RunnerState state = new RunnerState(runnerPurple, runnerYellow);

        if (playersInfo.IsHosts[(int)myTeamRole] == true)
        {
            state.fromHost = true;
        }
        if (myTeamRole == TeamRole.PurpleRunner)
        {
            state.fromPurple = true;
        }
        nwMgr.SendPacket("state", state);
    }
 public SimpleThreadRunner(ThreadStart tsd, Form UIForm)
 {
     try
     {
         this._thrd          = new Thread(tsd);
         this._thrdKeepTrack = new Thread(new ThreadStart(this.KeepTrack));
         this._state         = RunnerState.Waiting;
         this._uifrm         = UIForm;
         this._stTime        = new DateTime();
         this._edTime        = new DateTime();
     }
     catch (Exception ex)
     {
         ProjectData.SetProjectError(ex);
         throw new SimpleThreadRunnerException("Unexpected error occurred");
     }
 }
Esempio n. 26
0
    public void Setup(Vector2Int startPosition, LevelConfig levelConfig)
    {
        currentPosition2D = _tr.localPosition.To2D();

        if (startPosition != currentPosition2D)
        {
            currentPosition2D     = startPosition;
            destinationPosition2D = startPosition;
            _tr.localPosition     = currentPosition2D.To3D();
        }

        _currentLevel       = levelConfig;
        _rb.velocity        = Vector3.zero;
        _rb.angularVelocity = Vector3.zero;
        _state           = RunnerState.Idle;
        gameObject.layer = 9;
    }
Esempio n. 27
0
    private IEnumerator startDig()
    {
        state = RunnerState.DIGGING;
        Floor floor = digTarget.GetComponent <Floor>();

        floor.dig();
        while (true)
        {
            yield return(new WaitForSeconds(0.1f));

            if (floor.digState() != 1)
            {
                state = RunnerState.NORMAL;
                break;
            }
        }
    }
Esempio n. 28
0
        public async void AsyncRun(Color[] colors)
        {
            if (this.State != RunnerState.Wait)
            {
                return;
            }
            this.State = RunnerState.Runnning;

            var clusterCount = this.clusterCount;
            var iteration    = this.iteration;
            var scaleUp      = this.scaleUp;
            var result       = await Task.Run(() =>
                                              TypicalColorsPicker.PickUp(colors, clusterCount, iteration, scaleUp).Select(e => e.Color).ToArray()
                                              );

            this.typicalColors = result;
            this.State         = RunnerState.Finish;
        }
Esempio n. 29
0
        public RunnerState GetInfo()
        {
            if (CamelService == null)
            {
                return(null);
            }

            var runner = CamelService.Runner;

            var result = new RunnerState()
            {
                Players     = runner.GetPlayers(),
                CupId       = CamelService.CupId,
                TotalGames  = CamelService.TotalGames,
                GamesPlayed = CamelService.GamesPlayed,
                Winner      = CamelService.GetWinner(),
            };

            return(result);
        }
 internal void KeepTrack()
 {
     while (this._thrd.IsAlive)
     {
         Thread.Sleep(2000);
     }
     if (this._state != RunnerState.Stopped)
     {
         this._state = RunnerState.Finished;
     }
     this._edTime = DateAndTime.Now;
     if (this._uifrm != null)
     {
         lock (this._uifrm)
             this._uifrm.BeginInvoke((Delegate) new SimpleThreadRunner.TaskDoneEventRaiseDelegate(this.TaskDoneEventRaiseMethod));
     }
     else
     {
         this.TaskDoneEventRaiseMethod();
     }
 }
Esempio n. 31
0
    public void RunnerStanTime()
    {
        //Debug.Log(m_stanTime);
        // isStanがtrueになったらスタン処理開始
        if (isStan)
        {
            --m_stanTime;
            Debug.Log("通った");

            // スタン処理
            // 現在のスピードを別の変数に保持し、スピードを0に変更
            //m_currentSpeed = m_runnerStatus.speed;
            m_runnerStatus.firstSpeed = 0f;
            m_runnerStatus.maxSpeed   = 0f;
            Debug.Log(m_playerNum + "sss" + m_runnerStatus.speed);

            if (m_stanTime < 0)
            {
                m_stanTime = 0;
            }
            if (m_stanTime == 0)
            {
                // stanTimeが0になったらisStanをfalseにする
                // RunnerStanをnormalに変更
                isStan  = false;
                m_state = RunnerState.normal;
                Debug.Log("スタン終わったよ");

                // isStanがfalseに変更されたら、スタン処理終了
                // スタン終了時に保持してたスピードをプレイヤーのステータスへ戻す
                if (!isStan)
                {
                    //m_runnerStatus.speed = m_currentSpeed;
                    m_runnerStatus.firstSpeed = 2;
                    m_runnerStatus.maxSpeed   = 3;
                }
            }
        }
        m_runnerMove.m_prevPos = m_runnerMove.m_player.transform.position;
    }
 public void Stop()
 {
     if (this._thrd == null)
     {
         throw new SimpleThreadRunnerException("Thread not initialized.");
     }
     if (this._state != RunnerState.Waiting)
     {
         return;
     }
     try
     {
         this._thrd.Abort();
         this._edTime = DateAndTime.Now;
         this._state  = RunnerState.Stopped;
     }
     catch (Exception ex)
     {
         ProjectData.SetProjectError(ex);
         throw new SimpleThreadRunnerException("Unexpected error occurred.");
     }
 }
        public RunnerState Transition(InputState action, bool touching, Vector3 currentVelocity)
        {
            touchingPlatform = touching;
            velocity = currentVelocity;
            if (_transitionCache != null)
            {
                var state = new StateTransition
                                {
                                    currentState = currentState,
                                    command = action,
                                    below = touching,
                                    above = false,
                                    behind = false,
                                    front = false,
                                };

                ToState transition;
                var foundTransition = _transitionCache.TryGetValue(state, out transition);
                var allowedTransition =  foundTransition && (currentVelocity.x > transition.minSpeedX) && (transition.maxSpeedX > currentVelocity.x);
                if (allowedTransition)
                {
                    Debug.Log("Transitioning from " + currentState + " to " + transition.nextState);
                    currentState = transition.nextState;
                }
                else
                {
                    if (!foundTransition)
                        Debug.Log("No transition found for - CurrentState: " + currentState + ", Action: " + action + ", Touching: " + touching);
                }
            }
            else
            {
                Debug.LogError("Runner State is not initialized!");
            }
            StateProcessQueue.Enqueue(currentState);
            return currentState;
        }
Esempio n. 34
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //texture = ContentPipe.LoadTexture("texture.png");

            GL.Enable(EnableCap.Texture2D);
            tileset = ContentPipe.LoadTexture("TileSet1.png");
            level = new Level("Content/labirint.tmx");
            texture = ContentPipe.LoadTexture("Waiting.png");
            hero = new AnimatedSprite(texture,1,5,4);
            texture = ContentPipe.LoadTexture("runnerLeft.png");
            runnerLeft = new AnimatedSprite(texture, 1, 4, 4);
            texture = ContentPipe.LoadTexture("runnerRight.png");
            runnerRight = new AnimatedSprite(texture, 1, 4, 4);
            texture = ContentPipe.LoadTexture("runnerClimb.png");
            runnerClimb = new AnimatedSprite(texture, 1, 2, 2);

            gameState=GameState.Menu;
            runnerState = RunnerState.Right;
            runnerPosX=50;
            runnerPosY=377;

            melodyMenu =  "Content/AKINALO.WAV";
            melodyGame = "Content/MS3ALL_F_00010.wav";

            simpleSound = new SoundPlayer(melodyMenu);
            simpleSound.PlayLooping();

            view = new View(Vector2.Zero, 2.0, 0);
            view.SetPosition(new Vector2(195,145));
            //player = new Player(new Vector2(200,150));

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
        }
Esempio n. 35
0
        public RunnerState Transition(RunnerInput input, CollisionInfo collisionInfo, Rigidbody rigidbody)
        {
            velocity = rigidbody.velocity;
            contacts = collisionInfo;
            var inputToTry = input.Try();
            Dictionary<InputState, List<TransitionInfo>> availableInputs;
            if (_availableTransitions.TryGetValue(currentState, out availableInputs))
            {
                List<TransitionInfo> inputTransitions;
                if (availableInputs.TryGetValue(inputToTry, out inputTransitions))
                {
                    var firstMatchingTransition = inputTransitions
                        .FirstOrDefault(t => (t.CollisionRequirements ?? CollisionInfo.Empty).Valid(collisionInfo) &&
                                             IsTransitionReady(t) &&
                                             IsDelayUp(t) &&
                                             t.VelocityRequirements.Equals(rigidbody.velocity));
                    if (firstMatchingTransition != null)
                    {
                        lastTransition = currentState + "To" + firstMatchingTransition.NextState;
                        currentState = firstMatchingTransition.NextState;
                        chosenTransition = firstMatchingTransition.TransitionName;
                        lastUseTime = Time.time;
                        firstMatchingTransition.Use();
                        if (firstMatchingTransition.ReuseTime > 0)
                        {
                            Debug.Log("Queuing for effect: " + firstMatchingTransition.NextState);
                            _rechargingStates.Enqueue(firstMatchingTransition);
                        }
                        if (firstMatchingTransition.HasTransitionEffect)
                            TrySendEventMessage(firstMatchingTransition.NextState.ToString());
                        input.Complete();
                    }
                }
            }

            StateProcessQueue.Enqueue(currentState);
            if (reportState)
                Messenger.Default.Send(new RunnerStatsMessage(currentState, velocity, collisionInfo, inputToTry));
            return currentState;
        }
Esempio n. 36
0
 public RunnerFSMContext AddTransition(RunnerState forState, InputState inputState, TransitionInfo transitionInfo)
 {
     if (transitionInfo.TransitionName == null)
         transitionInfo.TransitionName = forState + "To" + transitionInfo.NextState;
     _registeredTransitions.Add(transitionInfo);
     _fsm._availableTransitions[forState][inputState].Add(transitionInfo);
     return this;
 }
Esempio n. 37
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            base.OnUpdateFrame(e);
            if (Input.KeyPress(OpenTK.Input.Key.Enter))
            {
                if (gameState==GameState.Menu)
                {
                    gameState = GameState.Game;
                    simpleSound = new SoundPlayer(melodyGame);
                    simpleSound.PlayLooping();
                }
                if (gameState==GameState.Game)
                {

                }
            }
            if (Input.KeyPress(OpenTK.Input.Key.Left) && gameState==GameState.Game)
            {

                runnerState = RunnerState.Left;
                runnerLeft.Update();
                runnerPosX -= 1;
                if (Collusion.gravity(runnerPosX, runnerPosY, level))
                {
                    runnerPosY += 1;
                }
            }
            if (Input.KeyDown(OpenTK.Input.Key.Left) && gameState == GameState.Game)
            {

                runnerState = RunnerState.Left;
                runnerLeft.Update();
                runnerPosX -= 1;
                if (Collusion.gravity(runnerPosX, runnerPosY, level))
                {
                    runnerPosY += 1;
                }
            }
            if (Input.KeyPress(OpenTK.Input.Key.Right) && gameState == GameState.Game)
            {
                runnerState = RunnerState.Right;
                runnerRight.Update();
                runnerPosX += 1;
                if (Collusion.gravity(runnerPosX, runnerPosY, level))
                {
                    runnerPosY += 1;
                }
            }
            if (Input.KeyDown(OpenTK.Input.Key.Right) && gameState == GameState.Game)
            {
                runnerState = RunnerState.Right;
                runnerRight.Update();
                runnerPosX += 1;
                if (Collusion.gravity(runnerPosX, runnerPosY, level))
                {
                    runnerPosY += 1;
                }
            }
            if (Input.KeyPress(OpenTK.Input.Key.Up) && gameState == GameState.Game && Collusion.collide(runnerPosX, runnerPosY, level))
                {
                    runnerState = RunnerState.Climb;
                    runnerClimb.Update();
                    runnerPosY -= 1;
                }

                if (Input.KeyDown(OpenTK.Input.Key.Up) && gameState == GameState.Game && Collusion.collide(runnerPosX, runnerPosY, level))
                {
                    runnerState = RunnerState.Climb;
                    runnerClimb.Update();
                    runnerPosY -= 1;
                }
                if (Input.KeyPress(OpenTK.Input.Key.Down) && gameState == GameState.Game && Collusion.collide(runnerPosX, runnerPosY, level))
                {
                    runnerState = RunnerState.Climb;
                    runnerClimb.Update();
                    runnerPosY += 1;
                }
                if (Input.KeyDown(OpenTK.Input.Key.Down) && gameState == GameState.Game && Collusion.collide(runnerPosX, runnerPosY, level))
                {
                    runnerState = RunnerState.Climb;
                    runnerClimb.Update();
                    runnerPosY += 1;
                }
            //if (Input.MousePress(OpenTK.Input.MouseButton.Left))
            //{
            //    Vector2 pos = new Vector2(Mouse.X, Mouse.Y) - new Vector2(this.Width, this.Height) / 2f;
            //    pos = view.ToWorld(pos);
            //    view.SetPosition(pos, TweentType.QuadraticInOut, 15);
            //}
            //if (Input.KeyDown(OpenTK.Input.Key.Right))
            //{
            //    view.SetPosition(view.PositionGoTo + new Vector2(5, 0), TweentType.QuadraticInOut, 15);
            //}
            //if (Input.KeyDown(OpenTK.Input.Key.Left))
            //{
            //    view.SetPosition(view.PositionGoTo + new Vector2(-5, 0), TweentType.QuadraticInOut, 15);
            //}
            //if (Input.KeyDown(OpenTK.Input.Key.Up))
            //{
            //    view.SetPosition(view.PositionGoTo + new Vector2(0, -5), TweentType.QuadraticInOut, 15);
            //}
            //if (Input.KeyDown(OpenTK.Input.Key.Down))
            //{
            //    view.SetPosition(view.PositionGoTo + new Vector2(0, 5), TweentType.QuadraticInOut, 15);
            //}

            //player.Update(level);
            //view.SetPosition(player.position, TweentType.QuadraticInOut, 160);
            //view.SetPosition(new Vector2(1,1));
            if(looper==15)
            {
                hero.Update();
                looper = 0;
            }
            else
            {
                looper++;
            }
            view.Update();
            Input.Update();
        }
	private IEnumerator startDig() {
		state = RunnerState.DIGGING;
		Floor floor = digTarget.GetComponent<Floor>();
		floor.dig();
		while (true) {
			yield return new WaitForSeconds(0.1f);
			if (floor.digState() != 1) {
				state = RunnerState.NORMAL;
				break;
			}
		}
	}
Esempio n. 39
0
    public void Move(RunnerState runnerState, Rigidbody rigidbody)
    {
        if (_motorCache != null)
        {
            Motor motor;
            var found = _motorCache.TryGetValue(runnerState, out motor);
            if (found)
            {
                if (rigidbody.velocity.x < motor.maxXVelocity)
                {
                    rigidbody.AddForce(motor.acceleratingVelocity.x, 0, 0, motor.forceMode);
                }
                else if (motor.shouldDecelerate && rigidbody.velocity.y > motor.maxYVelocity)
                {
                    rigidbody.AddForce(0, -motor.deceleratingVelocity.y, 0, motor.forceMode);
                }

                if (rigidbody.velocity.y < motor.maxYVelocity)
                {
                    rigidbody.AddForce(0, motor.acceleratingVelocity.y, 0, motor.forceMode);
                }
                else if (motor.shouldDecelerate && rigidbody.velocity.x > motor.maxXVelocity)
                {
                    rigidbody.AddForce(-motor.deceleratingVelocity.x, 0, 0, motor.forceMode);
                }

            }
        }
        else
        {
            Debug.LogError("Motor is not initialized!");
        }
    }