示例#1
0
        //Get the player Y position for walking on the Seasaw
        public float GetNewPlayerYPos(Vector2 position)
        {
            float distanceBetween = FMath.Sqrt(FMath.Pow((position.X - _sprite.Position.X), 2) + FMath.Pow((position.Y - _sprite.Position.Y), 2));

            if (distanceBetween < 0)
            {
                distanceBetween = -distanceBetween;
            }

            if (distanceBetween < (_textureInfo.TextureSizef.X / 2) + 40 && _onObstacle)
            {
                float adjacent, opposite, hypotenuse;

                adjacent   = _sprite.Position.X - position.X;
                hypotenuse = adjacent / (FMath.Sin(_angle2));
                opposite   = (FMath.Cos(_angle2)) * hypotenuse;

                _tempScale = ((_angle * 10) * _scalerValue);

                if (_tempScale < 0)
                {
                    _tempScale = -_tempScale;
                }

                float tempScale = (_scaleLimiter * _tempScale);

                return(((_sprite.Position.Y + ((_textureInfo.TextureSizef.Y * _scale) * tempScale)) - opposite) + (115 / 2));
            }
            else
            {
                _onObstacle = false;
            }

            return(position.Y);
        }
示例#2
0
        private Vector2 Normalize(Vector2 destination, Vector2 position)
        {
            Vector2 vector          = new Vector2(destination.X - position.X, destination.Y - position.Y);
            float   vectorMagnitude = FMath.Sqrt(FMath.Pow(vector.X, 2) + FMath.Pow(vector.Y, 2));

            vector = new Vector2(vector.X / vectorMagnitude, vector.Y / vectorMagnitude);

            return(vector);
        }
示例#3
0
 public void SetSpringConstant(Widget widget, SpringType type, float springConstant)
 {
     this.SetValue(widget, type, springConstant, delegate(Widget w, SpringType t, float value)
     {
         value = FMath.Clamp(value, 0f, 1f);
         this.widgetInfos[w].springConstants[(int)t]   = 4f * value + 1f;
         this.widgetInfos[w].springLimitations[(int)t] = 1f - FMath.Pow(value, 5f);
     });
 }
示例#4
0
 public static float PowEaseIn(float x, float p)
 {
     return(FMath.Pow(x, p));
 }
示例#5
0
 public static float PowerfulScurve(float x, float p1, float p2)
 {
     return(FMath.Pow(1f - FMath.Pow(1f - x, p2), p1));
 }