示例#1
0
        private void Update()
        {
            if (ErrorManager.HasError)
            {
                return;
            }

            DisposeDistance      = SetDisposeDistance;
            MinDisposeMultiply   = SetMinDisposeMultiply;
            GenerateDistance     = SetGenerateDistance;
            MaxGeneratePlatforms = SetMaxGeneratePlatforms;

            Runner.PlayerController player = Player.Current;
            if (player == null)
            {
                ErrorManager.Show("ERROR", "player == null");
                return;
            }
            float moveSpeed = Player.Speed * Time.deltaTime;

            Player.Move(moveSpeed);
            Generator.Generate(moveSpeed, player);
            Platforms.Move(moveSpeed, player);
            DisposedManager.Update(player);
            Missions.Dispatch("run", player.Distance);
        }
示例#2
0
        void Update()
        {
            if (States.Current == State.LOSE || States.Current == State.LOAD)
            {
                return;
            }
            //ARROWS
            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                if (!Player.currentList[0].bInAir && !Player.isJumpPowerUp)
                {
                    jumpCount++;
                    Missions.Dispatch("jump", jumpCount);

                    for (int i = 0; i < Player.currentList.Count; i++)
                    {
                        Player.currentList[i].doJump();
                    }
                }
            }
            if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                if (!Player.currentList[0].bInDuck && !Player.isJumpPowerUp)
                {
                    slideCount++;
                    Missions.Dispatch("slide", slideCount);

                    for (int i = 0; i < Player.currentList.Count; i++)
                    {
                        Player.currentList[i].doSlide();
                    }
                }
            }
            if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                Waypoint.changeWP(false);
            }
            if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                Waypoint.changeWP(true);
            }
            //TOUCH
            if (iTouchStateFlag == 0 && Input.GetMouseButtonDown(0))
            {
                fInitialX = Input.mousePosition.x;
                fInitialY = Input.mousePosition.y;

                sSwipeDirection = SwipeDirection.Null;
                iTouchStateFlag = 1;
            }
            if (iTouchStateFlag == 1)
            {
                fFinalX = Input.mousePosition.x;
                fFinalY = Input.mousePosition.y;

                sSwipeDirection = swipeDirection();
                if (sSwipeDirection != SwipeDirection.Null)
                {
                    iTouchStateFlag = 2;

                    switch (sSwipeDirection)
                    {
                    case SwipeDirection.Jump:
                        if (!Player.currentList[0].bInAir && !Player.isJumpPowerUp)
                        {
                            jumpCount++;
                            Missions.Dispatch("jump", jumpCount);
                            for (int i = 0; i < Player.currentList.Count; i++)
                            {
                                Player.currentList[i].doJump();
                            }
                        }
                        break;

                    case SwipeDirection.Duck:
                        if (!Player.currentList[0].bInDuck && !Player.isJumpPowerUp)
                        {
                            slideCount++;
                            Missions.Dispatch("slide", slideCount);
                            for (int i = 0; i < Player.currentList.Count; i++)
                            {
                                Player.currentList[i].doSlide();
                            }
                        }
                        break;

                    case SwipeDirection.Left:
                        Waypoint.changeWP(false);
                        break;

                    case SwipeDirection.Right:
                        Waypoint.changeWP(true);
                        break;
                    }
                }
            }
            if (iTouchStateFlag == 2 || Input.GetMouseButtonUp(0))
            {
                iTouchStateFlag = 0;
            }
        }