Exemplo n.º 1
0
        private static void Rotate(MovingEntity subject)
        {
            float velocityZ = subject.Velocity.Z;

            switch (subject.RotationDirection)
            {
                case Constants.EntityRotationDirection.Clockwise:
                    if(subject.Velocity.Z < subject.RotationSpeed)
                        velocityZ += subject.RotationAcceleration;
                    break;
                case Constants.EntityRotationDirection.Counterclockwise:
                    if(subject.Velocity.Z > -subject.RotationSpeed)
                        velocityZ -= subject.RotationAcceleration;
                    break;
                case Constants.EntityRotationDirection.None:
                    if (subject.Velocity.Z > subject.RotationAcceleration)
                        velocityZ -= subject.RotationAcceleration;
                    else if (subject.Velocity.Z < -subject.RotationAcceleration)
                        velocityZ += subject.RotationAcceleration;
                    else
                        velocityZ = 0;
                    break;
            }

            subject.Velocity = new Vector3(subject.Velocity.X, subject.Velocity.Y, velocityZ);
        }
Exemplo n.º 2
0
        private static void Walk(MovingEntity subject)
        {
            if (subject.TangentialVelocity < subject.WalkSpeed)
                subject.TangentialVelocity += subject.Acceleration;

            else
                subject.TangentialVelocity = subject.WalkSpeed;

            float velocityX = (float)Math.Cos(subject.Rotation) * subject.TangentialVelocity;
            float velocityY = (float)Math.Sin(subject.Rotation) * subject.TangentialVelocity;

            subject.Velocity = new Vector3(velocityX, velocityY, subject.Velocity.Z);
        }
Exemplo n.º 3
0
        public static void ApplyCharacterPhysics(MovingEntity subject)
        {
            Rotate(subject);

            subject.Position += new Vector2(subject.Velocity.X, subject.Velocity.Y);
            subject.Rotation += subject.Velocity.Z;

            switch (subject.CurrentState)
            {
                case Constants.CharacterState.Walking:
                    Walk(subject);
                    break;
            }
        }
Exemplo n.º 4
0
 private static void Run(MovingEntity entity)
 {
 }
Exemplo n.º 5
0
 public static void ApplyBulletPhysics(MovingEntity subject)
 {
     subject.Position += new Vector2(subject.Velocity.X, subject.Velocity.Y);
 }