コード例 #1
0
        void MoveToTargetPosition()
        {
            if (this._visualArc)
            {
                long progress = FixedMath.Create(this.AliveTime) / 32;
                long height   = this.arcStartHeight + this.arcStartVerticalSpeed.Mul(progress) - Gravity.Mul(progress.Mul(progress));
                this.Position.z = height;
            }
            else
            {
                this.Position.z = FixedMath.MoveTowards(this.Position.z, TargetHeight, this.linearHeightSpeed);
            }

            LSProjectile.tempDirection = TargetPosition - this.Position.ToVector2d();
            if (LSProjectile.tempDirection.Dot(this.lastDirection.x, this.lastDirection.y) < 0L || tempDirection == Vector2d.zero)
            {
                this.Hit();
            }
            else
            {
                LSProjectile.tempDirection.Normalize();
                Forward                     = tempDirection;
                this.lastDirection          = LSProjectile.tempDirection;
                LSProjectile.tempDirection *= this.speedPerFrame;
                this.Position.Add(LSProjectile.tempDirection.ToVector3d());
            }
        }
コード例 #2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            VectorRotationAttribute at    = this.attribute as VectorRotationAttribute;
            bool               timescaled = at.Timescaled;
            double             scale      = LSEditorUtility.Scale(timescaled);
            SerializedProperty x          = property.FindPropertyRelative("x");
            SerializedProperty y          = property.FindPropertyRelative("y");

            double angleInRadians = Math.Atan2(y.longValue.ToDouble(), x.longValue.ToDouble());

            double angleInDegrees = (angleInRadians * 180d / Math.PI) * scale;

            height          = 15f;
            position.height = height;
            angleInDegrees  = (EditorGUI.DoubleField(position, "Angle", angleInDegrees)) / scale;

            double newAngleInRadians = angleInDegrees * Math.PI / 180d;

            if (Math.Abs(newAngleInRadians - angleInRadians) >= .001f)
            {
                long cos = FixedMath.Create(Math.Cos(newAngleInRadians));
                long sin = FixedMath.Create(Math.Sin(newAngleInRadians));
                x.longValue = cos;
                y.longValue = sin;
            }
        }
コード例 #3
0
 /// <summary>
 /// Tries to parse string into fixed point number.
 /// </summary>
 /// <returns><c>true</c>, if parse was tried, <c>false</c> otherwise.</returns>
 /// <param name="s">S.</param>
 /// <param name="result">Result.</param>
 public static bool TryParse(string s, out long result)
 {
     string[] NewValues = s.Split('.');
     if (NewValues.Length <= 2)
     {
         long Whole;
         if (long.TryParse(NewValues[0], out Whole))
         {
             if (NewValues.Length == 1)
             {
                 result = Whole << SHIFT_AMOUNT;
                 return(true);
             }
             else
             {
                 long Numerator;
                 if (long.TryParse(NewValues[1], out Numerator))
                 {
                     int  fractionDigits = NewValues[1].Length;
                     long Denominator    = 1;
                     for (int i = 0; i < fractionDigits; i++)
                     {
                         Denominator *= 10;
                     }
                     result = (Whole << SHIFT_AMOUNT) + FixedMath.Create(Numerator, Denominator);
                     return(true);
                 }
             }
         }
     }
     result = 0;
     return(false);
 }
コード例 #4
0
        public static void FixedNumberAngle(string label, ref long Value)
        {
            double roundedDisplay = 0;

            roundedDisplay = Math.Round(Math.Asin(Value.ToDouble()) * RadToDeg, 2, MidpointRounding.AwayFromZero);
            Value          = FixedMath.Create(Math.Sin(DegToRad * EditorGUILayout.DoubleField(label, roundedDisplay)));
        }
コード例 #5
0
        public long GetHeight(int mapIndex, Vector2d position)
        {
            if (mapIndex >= Maps.Length)
            {
                return(this.HeightBounds.x);
            }
            HeightMap map        = Maps [mapIndex];
            long      normX      = (position.x - this._bottomLeft.x).Div(Interval);
            long      normY      = (position.y - this._bottomLeft.y).Div(Interval);
            int       gridX      = FixedMath.ToInt(normX);
            int       gridY      = FixedMath.ToInt(normY);
            long      fractionX  = (normX - FixedMath.Create(gridX));
            long      fractionY  = (normY - FixedMath.Create(gridY));
            long      baseHeight = map.GetHeight(gridX, gridY);

            int nextX = Mathf.Clamp(gridX + 1, 0, map.Map.Width);

            int nextY = Mathf.Clamp(gridY + 1, 0, map.Map.Height);

            //bilinear lerp
            long h1 = FixedMath.Lerp(baseHeight, map.GetHeight(nextX, gridY), fractionX);
            long h2 = FixedMath.Lerp(map.GetHeight(gridX, nextY), map.GetHeight(nextX, nextY), fractionX);

            return(FixedMath.Lerp(h1, h2, fractionY) + this.BonusHeight);
        }
コード例 #6
0
        public static int GenerateDeltaCount(int size)
        {
            long fixSize = FixedMath.Create(size);
            int  ret     = FixedMath.Mul(FixedMath.Mul(fixSize, fixSize), FixedMath.Pi).CeilToInt();

            return(ret);
        }
コード例 #7
0
        public void AwaitConstruction()
        {
            NeedsConstruction         = true;
            IsCasting                 = true;
            cachedHealth.HealthAmount = FixedMath.Create(0);

            if (cachedRally)
            {
                cachedRally.SetSpawnPoint();
            }
        }
コード例 #8
0
        public static void FixedNumberField(string label, ref long Value, long max = 0)
        {
            var value = FixedMath.Create(EditorGUILayout.DoubleField(label, Math.Round(FixedMath.ToDouble(Value), 2, MidpointRounding.AwayFromZero)));

            if (max == 0 || value <= max)
            {
                Value = value;
            }
            else
            {
                Value = max;
            }
        }
コード例 #9
0
        protected override void OnLateInitialize()
        {
            long gridWidth        = FixedMath.Create(GridManager.Width);
            long gridHeight       = FixedMath.Create(GridManager.Height);
            long widthEdgeOffset  = (gridWidth - _mapWidth) / 2;
            long heightEdgeOffset = (gridHeight - _mapHeight) / 2;
            Area gridArea         = new Area(
                GridManager.OffsetX,
                GridManager.OffsetY,
                GridManager.OffsetX + gridWidth,
                GridManager.OffsetY + gridHeight
                );
            Area noBlockArea = new Area(
                gridArea.XCorner1 + widthEdgeOffset,
                gridArea.YCorner1 + heightEdgeOffset,
                gridArea.XCorner2 - widthEdgeOffset,
                gridArea.YCorner2 - heightEdgeOffset
                );

            //block top
            ManualBlocker.BlockArea(new Area(
                                        gridArea.XMin,
                                        noBlockArea.YMax,
                                        gridArea.XMax,
                                        gridArea.YMax
                                        ));

            //block bottom
            ManualBlocker.BlockArea(new Area(
                                        gridArea.XMin,
                                        gridArea.YMin,
                                        gridArea.XMax,
                                        noBlockArea.YMin
                                        ));

            //block right
            ManualBlocker.BlockArea(new Area(
                                        noBlockArea.XMax,
                                        noBlockArea.YMin,
                                        gridArea.XMax,
                                        noBlockArea.YMax
                                        ));
            //block left
            ManualBlocker.BlockArea(new Area(
                                        gridArea.XMin,
                                        noBlockArea.YMin,
                                        noBlockArea.XMin,
                                        noBlockArea.XMax
                                        ));
        }
コード例 #10
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            double scale = ((FixedNumberAngleAttribute)this.attribute).Timescaled ? LockstepManager.FrameRate : 1;
            double angle = Math.Round(Math.Asin(property.longValue.ToDouble()) * RadToDeg, 2, MidpointRounding.AwayFromZero);

            angle = EditorGUI.DoubleField(position, label, angle * scale) / scale;
            double max = ((FixedNumberAngleAttribute)this.attribute).Max;

            if (max > 0 && angle > max)
            {
                angle = max;
            }
            property.longValue = FixedMath.Create(Math.Sin(DegToRad * angle));
        }
コード例 #11
0
        public static void SetField(string name, float value, FieldType fieldType)
        {
            SerializedProperty prop = GetProperty(name);

            switch (fieldType)
            {
            case FieldType.FixedNumber:
                prop.longValue = FixedMath.Create(value);
                break;

            case FieldType.Interval:
                prop.intValue = Mathf.RoundToInt(value * LockstepManager.FrameRate);
                break;

            case FieldType.Rate:
                prop.intValue = Mathf.RoundToInt((1 / value) * LockstepManager.FrameRate);
                break;
            }
            Apply();
        }
コード例 #12
0
        public short[,] Scan(int scanLayers)
        {
            int widthPeriods = Size.x.Div(Interval).CeilToInt();

            int heightPeriods = Size.y.Div(Interval).CeilToInt();

            short[,] heightMap = new short[widthPeriods, heightPeriods];


            Vector3 startPos = _bottomLeft.ToVector3(HeightBounds.y.ToFloat());
            Vector3 scanPos  = startPos;
            float   dist     = (HeightBounds.y - HeightBounds.x).ToFloat();

            float fRes = Interval.ToFloat();

            for (int x = 0; x < widthPeriods; x++)
            {
                scanPos.z = startPos.z;
                for (int y = 0; y < heightPeriods; y++)
                {
                    RaycastHit hit;
                    long       height;
                    if (Physics.Raycast(scanPos, Vector3.down, out hit, dist, scanLayers, QueryTriggerInteraction.UseGlobal))
                    {
                        height = FixedMath.Create(hit.point.y);
                    }
                    else
                    {
                        height = HeightBounds.x;
                    }

                    heightMap [x, y] = Compress(height);
                    scanPos.z       += fRes;
                }
                scanPos.x += fRes;
            }

            return(heightMap);
        }
コード例 #13
0
 long FixedNumberField(Rect position, GUIContent label, long value)
 {
     return(FixedMath.Create(EditorGUI.DoubleField(position, label, value.ToDouble())));
 }
コード例 #14
0
        public static void DoubleField(Rect position, GUIContent label, ref long value, bool timescaled = false)
        {
            double scale = Scale(timescaled);

            value = FixedMath.Create(EditorGUI.DoubleField(position, label, value.ToDouble() * scale) / scale);
        }
コード例 #15
0
 public GridSettings()
 {
     Init(256, 256, FixedMath.Create(-128), FixedMath.Create(-128), true);
 }
コード例 #16
0
 public Vector2d(double xDoub, double yDoub)
 {
     this.x = FixedMath.Create(xDoub);
     this.y = FixedMath.Create(yDoub);
 }
コード例 #17
0
 public Vector2d(Vector3 vec)
 {
     this.x = FixedMath.Create(vec.x);
     this.y = FixedMath.Create(vec.z);
 }
コード例 #18
0
 public Vector2d(Vector2 vec2)
 {
     this.x = FixedMath.Create(vec2.x);
     this.y = FixedMath.Create(vec2.y);
 }
コード例 #19
0
 public Vector2d(float xFloat, float yFloat)
 {
     this.x = FixedMath.Create(xFloat);
     this.y = FixedMath.Create(yFloat);
 }
コード例 #20
0
 public static long GetWorldY(int gridY)
 {
     return((FixedMath.Create(gridY + BoundY)) << AdditionalShiftSize);
 }
コード例 #21
0
 public static long GetRelativeY(long yPos)
 {
     return((yPos >> AdditionalShiftSize) - (FixedMath.Create(BoundY)));
 }
コード例 #22
0
 /// <summary>
 /// World pos to relative position on grid.
 /// </summary>
 /// <returns>The relative x.</returns>
 /// <param name="xPos">X position.</param>
 public static long GetRelativeX(long xPos)
 {
     return((xPos >> AdditionalShiftSize) - (FixedMath.Create(BoundX)));
 }
コード例 #23
0
 public static void FixedNumberField(GUIContent content, ref long Value)
 {
     Value = FixedMath.Create(EditorGUILayout.DoubleField(content, Math.Round(FixedMath.ToDouble(Value), 2, MidpointRounding.AwayFromZero)));
 }
コード例 #24
0
 public long z; //Height
 public Vector3d(Vector3 vec3)
 {
     this.x = FixedMath.Create(vec3.x);
     this.y = FixedMath.Create(vec3.z);
     this.z = FixedMath.Create(vec3.y);
 }