Exemplo n.º 1
0
        /// <summary>
        /// Applies a MovementModifier to a Vector4 represented speed limit set. Vector4(Up, Down, Left, Right)
        /// </summary>
        /// <param name="modifier">The modifier to apply</param>
        /// <param name="speedLimits">The speed limits to modify</param>
        /// <returns>The new set of speed limits in the same Vector4 representation.</returns>
        private static Vector4 ApplyModifier(MovementModifier modifier, Vector4 speedLimits)
        {
            float up = speedLimits.X;

            if ((modifier.Direction & Direction.Up) != 0)
            {
                up = modifier.Function(speedLimits.X, modifier.Value);
            }

            float down = speedLimits.Y;

            if ((modifier.Direction & Direction.Down) != 0)
            {
                down = modifier.Function(speedLimits.Y, modifier.Value);
            }

            float left = speedLimits.Z;

            if ((modifier.Direction & Direction.Left) != 0)
            {
                left = modifier.Function(speedLimits.Z, modifier.Value);
            }

            float right = speedLimits.W;

            if ((modifier.Direction & Direction.Right) != 0)
            {
                right = modifier.Function(speedLimits.W, modifier.Value);
            }

            return(new Vector4(up, down, left, right));
        }
Exemplo n.º 2
0
 public ColliderWithModifier(MovementModifier modifier, bool isSolid) : base(isSolid)
 {
     Modifier = modifier;
 }