Beispiel #1
0
        public void Update(GameTime gameTime, SpeedAction speedAction, TurningAction turningAction)
        {
            CurrentLapTime += gameTime.ElapsedGameTime;

            UpdateDirection(turningAction);
            UpdatePosition(speedAction);
        }
        public static void doDone(TurningAction actionObject)
        {
            ActorView entity = SceneViews.instance.getCurFBScene().getActor(actionObject.objectID);

            Quaternion end = Quaternion.LookRotation(new Vector3(actionObject.endDirection.x, 0, actionObject.endDirection.y));

            entity.setRotation(end);
        }
Beispiel #3
0
        private void UpdateDirection(TurningAction turningAction)
        {
            switch (turningAction)
            {
            case TurningAction.TurnRight:
            {
                if (currentTurningAngle < 0)
                {
                    currentTurningAngle += TurnSpeed * 10;
                }
                else
                {
                    currentTurningAngle += TurnSpeed;
                }
                break;
            }

            case TurningAction.TurnLeft:
            {
                if (currentTurningAngle > 0)
                {
                    currentTurningAngle -= TurnSpeed * 10;
                }
                else
                {
                    currentTurningAngle -= TurnSpeed;
                }
                break;
            }

            case TurningAction.None:
            {
                if (Math.Abs(Direction) > 0)
                {
                    currentTurningAngle = MathHelper.Lerp(currentTurningAngle, 0, 0.1f);
                }
                break;
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(turningAction), turningAction, null);
            }

            Direction       = MathHelper.Lerp(Direction, Direction + currentTurningAngle, CurrentSpeed);
            DirectionVector = Vector2.Transform(-Vector2.UnitY, Matrix.CreateRotationZ(Direction));
            perpendicularDirectionVector = new Vector2(-DirectionVector.Y, DirectionVector.X);
        }
        public static void doProgress(TurningAction actionObject, float progress)
        {
            if (actionObject.ignoreTimeAction)
            {
                return;
            }

            ActorView entity = SceneViews.instance.getCurFBScene().getActor(actionObject.objectID);

            Quaternion start = Quaternion.LookRotation(new Vector3(actionObject.startDirection.x, 0, actionObject.startDirection.y));
            Quaternion end   = Quaternion.LookRotation(new Vector3(actionObject.endDirection.x, 0, actionObject.endDirection.y));

            //获取本次移动位置
            Quaternion thisEndRotation = getRotatingDirection(start, end, progress);

            entity.setRotation(thisEndRotation);
        }