private void UpdateOffsets(SAMTime gameTime, InputState istate)
        {
            for (int i = 0; i < _values.Length; i++)
            {
                if (_nodes[i].HasActiveOperation("OverworldNode::Shake"))
                {
                    continue;
                }
                _values[i].Update(gameTime, istate);
            }

            _sleep = true;
            for (int i = 0; i < _values.Length; i++)
            {
                if (FloatMath.EpsilonEquals(_values[i].TargetValue, _values[i].Value, 0.01f) && FloatMath.EpsilonEquals(_values[i].Value, _nodes[i].NodePos.X, 0.01f))
                {
                    continue;
                }

                _sleep = false;

                if (_nodes[i].HasActiveOperation("OverworldNode::Shake"))
                {
                    continue;
                }

                _nodes[i].NodePos = new FPoint(_values[i].Value, POSITION_Y);

#if DEBUG
                _nodes[i].TargetNodePos = new FPoint(_values[i].TargetValue, POSITION_Y);
#endif
            }
        }
Esempio n. 2
0
 public static bool operator ==(FCircle a, FCircle b)
 {
     return
         (FloatMath.EpsilonEquals(a.X, b.X) &&
          FloatMath.EpsilonEquals(a.Y, b.Y) &&
          FloatMath.EpsilonEquals(a.Radius, b.Radius));
 }
Esempio n. 3
0
 public static bool operator ==(FRectangle a, FRectangle b)
 {
     return
         (FloatMath.EpsilonEquals(a.X, b.X) &&
          FloatMath.EpsilonEquals(a.Y, b.Y) &&
          FloatMath.EpsilonEquals(a.Width, b.Width) &&
          FloatMath.EpsilonEquals(a.Height, b.Height));
 }
Esempio n. 4
0
 public static bool operator ==(FRotatedRectangle a, FRotatedRectangle b)
 {
     return
         (FloatMath.EpsilonEquals(a.CenterX, b.CenterX) &&
          FloatMath.EpsilonEquals(a.CenterY, b.CenterY) &&
          FloatMath.EpsilonEquals(a.Width, b.Width) &&
          FloatMath.EpsilonEquals(a.Height, b.Height) &&
          FloatMath.EpsilonEquals(a.Rotation, b.Rotation));
 }
Esempio n. 5
0
 public bool Equals(Matrix3x3 other)
 {
     return
         (FloatMath.EpsilonEquals(M11, other.M11) &&
          FloatMath.EpsilonEquals(M12, other.M12) &&
          FloatMath.EpsilonEquals(M13, other.M13) &&
          FloatMath.EpsilonEquals(M21, other.M21) &&
          FloatMath.EpsilonEquals(M22, other.M22) &&
          FloatMath.EpsilonEquals(M23, other.M23) &&
          FloatMath.EpsilonEquals(M31, other.M31) &&
          FloatMath.EpsilonEquals(M32, other.M32) &&
          FloatMath.EpsilonEquals(M33, other.M33));
 }
Esempio n. 6
0
        private FlatCurve13 GetCurve(IWorldNode start, IWorldNode end, PipeBlueprint.Orientation o)
        {
            var cw     = (o == PipeBlueprint.Orientation.Clockwise);
            var ccw    = (o == PipeBlueprint.Orientation.Counterclockwise);
            var auto   = (o == PipeBlueprint.Orientation.Auto);
            var direct = (o == PipeBlueprint.Orientation.Direct);

            if (FloatMath.EpsilonEquals(start.Position.X, end.Position.X))
            {
                if (start.Position.Y < end.Position.Y)
                {
                    return(FlatCurve13.DOWN);
                }
                if (start.Position.Y > end.Position.Y)
                {
                    return(FlatCurve13.UP);
                }

                return(FlatCurve13.POINT);
            }

            if (FloatMath.EpsilonEquals(start.Position.Y, end.Position.Y))
            {
                if (start.Position.X < end.Position.X)
                {
                    return(FlatCurve13.RIGHT);
                }
                if (start.Position.X > end.Position.X)
                {
                    return(FlatCurve13.LEFT);
                }

                return(FlatCurve13.POINT);
            }

            if (start.Position.X < end.Position.X)
            {
                if (direct)
                {
                    return(FlatCurve13.DIRECT);
                }

                if (start.Position.Y < end.Position.Y)
                {
                    return((auto || cw) ? FlatCurve13.RIGHT_DOWN : FlatCurve13.DOWN_RIGHT);
                }
                else if (start.Position.Y > end.Position.Y)
                {
                    return((auto || ccw) ? FlatCurve13.RIGHT_UP : FlatCurve13.UP_RIGHT);
                }
            }

            if (start.Position.X > end.Position.X)
            {
                if (direct)
                {
                    return(FlatCurve13.DIRECT);
                }

                if (start.Position.Y < end.Position.Y)
                {
                    return((auto || ccw) ? FlatCurve13.LEFT_DOWN : FlatCurve13.DOWN_LEFT);
                }
                else if (start.Position.Y > end.Position.Y)
                {
                    return((auto || cw) ? FlatCurve13.LEFT_UP : FlatCurve13.UP_LEFT);
                }
            }

            throw new Exception("Invalid curvature found");
        }
Esempio n. 7
0
 public bool Equals(FSize other)
 {
     return(FloatMath.EpsilonEquals(Width, other.Width) && FloatMath.EpsilonEquals(Height, other.Height));
 }
Esempio n. 8
0
 public static bool operator ==(FSize a, FSize b)
 {
     return(FloatMath.EpsilonEquals(a.Width, b.Width) && FloatMath.EpsilonEquals(a.Height, b.Height));
 }
Esempio n. 9
0
        public void RegisterBlockedBlock(FRectangle ablock, float rotation)
        {
            rotation = FloatMath.NormalizeAngle(rotation);

            if (FloatMath.EpsilonEquals(rotation, FloatMath.RAD_POS_000))
            {
                RegisterAlignedBlockedBlock(ablock.AsRotated(PerpendicularRotation.DEGREE_CW_000)); return;
            }
            if (FloatMath.EpsilonEquals(rotation, FloatMath.RAD_POS_090))
            {
                RegisterAlignedBlockedBlock(ablock.AsRotated(PerpendicularRotation.DEGREE_CW_090)); return;
            }
            if (FloatMath.EpsilonEquals(rotation, FloatMath.RAD_POS_180))
            {
                RegisterAlignedBlockedBlock(ablock.AsRotated(PerpendicularRotation.DEGREE_CW_180)); return;
            }
            if (FloatMath.EpsilonEquals(rotation, FloatMath.RAD_POS_270))
            {
                RegisterAlignedBlockedBlock(ablock.AsRotated(PerpendicularRotation.DEGREE_CW_270)); return;
            }
            if (FloatMath.EpsilonEquals(rotation, FloatMath.RAD_POS_360))
            {
                RegisterAlignedBlockedBlock(ablock.AsRotated(PerpendicularRotation.DEGREE_CW_360)); return;
            }

            var block = ablock.AsRotated(rotation);

            for (int ox = (int)(block.MostLeft / GDConstants.TILE_WIDTH); ox <= (int)(block.MostRight / GDConstants.TILE_WIDTH); ox++)
            {
                for (int oy = (int)(block.MostTop / GDConstants.TILE_WIDTH); oy <= (int)(block.MostBottom / GDConstants.TILE_WIDTH); oy++)
                {
                    int x = ox + MAX_EXTENSION_X;                     // real coords -> array coords
                    int y = oy + MAX_EXTENSION_Y;

                    if (x < 0)
                    {
                        continue;
                    }
                    if (y < 0)
                    {
                        continue;
                    }
                    if (x >= tileCountX)
                    {
                        continue;
                    }
                    if (y >= tileCountY)
                    {
                        continue;
                    }

                    var rect = new FRectangle(ox * TILE_WIDTH, oy * TILE_WIDTH, TILE_WIDTH, TILE_WIDTH);

                    if (block.Contains(rect.TopLeft, 0.5f) && block.Contains(rect.TopRight, 0.5f))
                    {
                        _grid[x, y].BlockNorth = true;
                    }

                    if (block.Contains(rect.TopRight, 0.5f) && block.Contains(rect.BottomRight, 0.5f))
                    {
                        _grid[x, y].BlockEast = true;
                    }

                    if (block.Contains(rect.BottomRight, 0.5f) && block.Contains(rect.BottomLeft, 0.5f))
                    {
                        _grid[x, y].BlockSouth = true;
                    }

                    if (block.Contains(rect.BottomLeft, 0.5f) && block.Contains(rect.TopLeft, 0.5f))
                    {
                        _grid[x, y].BlockWest = true;
                    }
                }
            }
        }
Esempio n. 10
0
 public bool Equals(FPoint other)
 {
     return(FloatMath.EpsilonEquals(X, other.X) && FloatMath.EpsilonEquals(Y, other.Y));
 }
Esempio n. 11
0
        internal ParticleEmitterConfig(ParticleEmitterConfigBuilder b, TextureRegion2D[] texArray, float size, float length)
        {
            Texture       = texArray[b.TextureIndex];
            TextureBounds = Texture.Bounds;
            TextureCenter = Texture.Center();
            TextureSize   = TextureBounds.Width;

            SpawnRate = b.SpawnRate * length;

            SpawnDelay = 1f / b.SpawnRate;

            ParticleLifetimeMin      = b.ParticleLifetimeMin;
            ParticleLifetimeMax      = b.ParticleLifetimeMax;
            ParticleRespawnTime      = b.ParticleLifetimeMax;
            ParticleLifetimeIsRandom = FloatMath.FloatInequals(ParticleLifetimeMin, ParticleLifetimeMax);

            ParticleSpawnAngleMin      = b.ParticleSpawnAngleMin;
            ParticleSpawnAngleMax      = b.ParticleSpawnAngleMax;
            ParticleSpawnAngleIsRandom = FloatMath.FloatInequals(ParticleSpawnAngleMin, ParticleSpawnAngleMax);
            ParticleSpawnAngleIsTotal  = FloatMath.FloatInequals(ParticleSpawnAngleMin, ParticleSpawnAngleMax) && FloatMath.EpsilonEquals(FloatMath.NormalizeAngle(ParticleSpawnAngleMin), FloatMath.NormalizeAngle(ParticleSpawnAngleMax));
            if (!ParticleSpawnAngleIsRandom)
            {
                FixedParticleSpawnAngle = vectorOne.Rotate(ParticleSpawnAngleMin);
            }

            ParticleVelocityMin      = b.ParticleVelocityMin;
            ParticleVelocityMax      = b.ParticleVelocityMax;
            ParticleVelocityIsRandom = FloatMath.FloatInequals(ParticleVelocityMin, ParticleVelocityMax);

            ParticleAlphaInitial = b.ParticleAlphaInitial;
            ParticleAlphaFinal   = b.ParticleAlphaFinal;

            ParticleSizeInitialMin      = b.ParticleSizeInitialMin * size;
            ParticleSizeInitialMax      = b.ParticleSizeInitialMax * size;
            ParticleSizeInitialIsRandom = FloatMath.FloatInequals(ParticleSizeInitialMin, ParticleSizeInitialMax);

            ParticleSizeFinalMin      = b.ParticleSizeFinalMin * size;
            ParticleSizeFinalMax      = b.ParticleSizeFinalMax * size;
            ParticleSizeFinalIsRandom = FloatMath.FloatInequals(ParticleSizeFinalMin, ParticleSizeFinalMax);

            ColorInitial    = b.ColorInitial;
            ColorFinal      = b.ColorFinal;
            ColorIsChanging = (ColorInitial != ColorFinal);
        }
Esempio n. 12
0
        public static void Draw9Patch(IBatchRenderer sbatch, FRectangle bounds, Color colEdge, Color colCorner, Color colFill, TextureRegion2D texEdge, TextureRegion2D texCorner, TextureRegion2D texFill, float cornerSize, float rotation)
        {
            rotation = FloatMath.NormalizeAngle(rotation);

            if (FloatMath.EpsilonEquals(rotation, FloatMath.RAD_POS_000))
            {
                DrawAligned9Patch(sbatch, bounds.AsRotated(PerpendicularRotation.DEGREE_CW_000), colEdge, colCorner, colFill, texEdge, texCorner, texFill, cornerSize); return;
            }
            if (FloatMath.EpsilonEquals(rotation, FloatMath.RAD_POS_090))
            {
                DrawAligned9Patch(sbatch, bounds.AsRotated(PerpendicularRotation.DEGREE_CW_090), colEdge, colCorner, colFill, texEdge, texCorner, texFill, cornerSize); return;
            }
            if (FloatMath.EpsilonEquals(rotation, FloatMath.RAD_POS_180))
            {
                DrawAligned9Patch(sbatch, bounds.AsRotated(PerpendicularRotation.DEGREE_CW_180), colEdge, colCorner, colFill, texEdge, texCorner, texFill, cornerSize); return;
            }
            if (FloatMath.EpsilonEquals(rotation, FloatMath.RAD_POS_270))
            {
                DrawAligned9Patch(sbatch, bounds.AsRotated(PerpendicularRotation.DEGREE_CW_270), colEdge, colCorner, colFill, texEdge, texCorner, texFill, cornerSize); return;
            }
            if (FloatMath.EpsilonEquals(rotation, FloatMath.RAD_POS_360))
            {
                DrawAligned9Patch(sbatch, bounds.AsRotated(PerpendicularRotation.DEGREE_CW_360), colEdge, colCorner, colFill, texEdge, texCorner, texFill, cornerSize); return;
            }

            var ctr = bounds.Center;

            var r_tl = new FRectangle(bounds.Left - cornerSize, bounds.Top - cornerSize, 2 * cornerSize, 2 * cornerSize);
            var r_tr = new FRectangle(bounds.Right - cornerSize, bounds.Top - cornerSize, 2 * cornerSize, 2 * cornerSize);
            var r_br = new FRectangle(bounds.Right - cornerSize, bounds.Bottom - cornerSize, 2 * cornerSize, 2 * cornerSize);
            var r_bl = new FRectangle(bounds.Left - cornerSize, bounds.Bottom - cornerSize, 2 * cornerSize, 2 * cornerSize);

            var r_t = new FRectangle(bounds.Left + cornerSize, bounds.Top - cornerSize, bounds.Width - 2 * cornerSize, 2 * cornerSize);
            var r_b = new FRectangle(bounds.Left + cornerSize, bounds.Bottom - cornerSize, bounds.Width - 2 * cornerSize, 2 * cornerSize);

            var r_r = FRectangle.CreateByCenter(bounds.Right, bounds.CenterY, bounds.Height - 2 * cornerSize, 2 * cornerSize);
            var r_l = FRectangle.CreateByCenter(bounds.Left, bounds.CenterY, bounds.Height - 2 * cornerSize, 2 * cornerSize);

            var r_c = new FRectangle(bounds.Left + cornerSize, bounds.Top + cornerSize, bounds.Width - 2 * cornerSize, bounds.Height - 2 * cornerSize);

            r_tl = r_tl.AsRotateCenterAround(ctr, rotation);
            r_tr = r_tr.AsRotateCenterAround(ctr, rotation);
            r_br = r_br.AsRotateCenterAround(ctr, rotation);
            r_bl = r_bl.AsRotateCenterAround(ctr, rotation);

            r_t = r_t.AsRotateCenterAround(ctr, rotation);
            r_r = r_r.AsRotateCenterAround(ctr, rotation);
            r_b = r_b.AsRotateCenterAround(ctr, rotation);
            r_l = r_l.AsRotateCenterAround(ctr, rotation);

            sbatch.DrawStretched(texEdge, r_t, colEdge, FloatMath.RAD_POS_000 + rotation);
            sbatch.DrawStretched(texEdge, r_r, colEdge, FloatMath.RAD_POS_090 + rotation);
            sbatch.DrawStretched(texEdge, r_b, colEdge, FloatMath.RAD_POS_180 + rotation);
            sbatch.DrawStretched(texEdge, r_l, colEdge, FloatMath.RAD_POS_270 + rotation);

            sbatch.DrawStretched(texCorner, r_tl, colCorner, FloatMath.RAD_POS_000 + rotation);
            sbatch.DrawStretched(texCorner, r_tr, colCorner, FloatMath.RAD_POS_090 + rotation);
            sbatch.DrawStretched(texCorner, r_br, colCorner, FloatMath.RAD_POS_180 + rotation);
            sbatch.DrawStretched(texCorner, r_bl, colCorner, FloatMath.RAD_POS_270 + rotation);

            sbatch.DrawStretched(texFill, r_c, colFill, rotation);
        }