当前位置: 首页>>代码示例>>C#>>正文


C# IntPoint类代码示例

本文整理汇总了C#中IntPoint的典型用法代码示例。如果您正苦于以下问题:C# IntPoint类的具体用法?C# IntPoint怎么用?C# IntPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IntPoint类属于命名空间,在下文中一共展示了IntPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplySetPieces

        public static void ApplySetPieces(World world)
        {
            var map = world.Map;
            int w = map.Width, h = map.Height;

            Random rand = new Random();
            HashSet<Rect> rects = new HashSet<Rect>();
            foreach (var dat in setPieces)
            {
                int size = dat.Item1.Size;
                int count = rand.Next(dat.Item2, dat.Item3);
                for (int i = 0; i < count; i++)
                {
                    IntPoint pt = new IntPoint();
                    Rect rect;

                    int max = 50;
                    do
                    {
                        pt.X = rand.Next(0, w);
                        pt.Y = rand.Next(0, h);
                        rect = new Rect() { x = pt.X, y = pt.Y, w = size, h = size };
                        max--;
                    } while ((Array.IndexOf(dat.Item4, map[pt.X, pt.Y].Terrain) == -1 ||
                             rects.Any(_ => Rect.Intersects(rect, _))) &&
                             max > 0);
                    if (max <= 0) continue;
                    dat.Item1.RenderSetPiece(world, pt);
                    rects.Add(rect);
                }
            }
        }
开发者ID:BlackRayquaza,项目名称:MMOE,代码行数:32,代码来源:SetPieces.cs

示例2: Resolve

 protected internal override void Resolve(State parent)
 {
     parent.Death += (sender, e) =>
     {
         var dat = e.Host.Manager.GameData;
         var w = e.Host.Owner;
         var pos = new IntPoint((int) e.Host.X - (dist/2), (int) e.Host.Y - (dist/2));
         if (w == null) return;
         for (int x = 0; x < dist; x++)
         {
             for (int y = 0; y < dist; y++)
             {
                 WmapTile tile = w.Map[x + pos.X, y + pos.Y].Clone();
                 if (groundToChange != null)
                 {
                     foreach (string type in groundToChange)
                     {
                         int r = Random.Next(targetType.Length);
                         if (tile.TileId == dat.IdToTileType[type])
                         {
                             tile.TileId = dat.IdToTileType[targetType[r]];
                             w.Map[x + pos.X, y + pos.Y] = tile;
                         }
                     }
                 }
                 else
                 {
                     int r = Random.Next(targetType.Length);
                     tile.TileId = dat.IdToTileType[targetType[r]];
                     w.Map[x + pos.X, y + pos.Y] = tile;
                 }
             }
         }
     };
 }
开发者ID:SirAnuse,项目名称:fabiano-swagger-of-doom,代码行数:35,代码来源:ChangeGroundOnDeath.cs

示例3: InequalityOperatorTest

        public void InequalityOperatorTest( int x1, int y1, int x2, int y2, bool areNotEqual )
        {
            IntPoint point1 = new IntPoint( x1, y1 );
            IntPoint point2 = new IntPoint( x2, y2 );

            Assert.AreEqual( point1 != point2, areNotEqual );
        }
开发者ID:hungdluit,项目名称:aforge,代码行数:7,代码来源:IntPointTest.cs

示例4: UpdateTile

        // called for each visible tile
        protected override void UpdateTile(UIElement _tile, IntPoint ml)
        {
            MapControlTile tile = (MapControlTile)_tile;

            BitmapSource bmp;

            if (m_map.Bounds.Contains(ml))
            {
                byte b = m_map.MapArray[ml.Y, ml.X];

                if (b < 100)
                    bmp = m_symbolBitmapCache.GetBitmap(SymbolID.Wall, Colors.Black, false);
                else
                    bmp = m_symbolBitmapCache.GetBitmap(SymbolID.Floor, Colors.Black, false);
            }
            else
            {
                bmp = null;
            }

            if (bmp != tile.Bitmap)
            {
                tile.Bitmap = bmp;
            }
        }
开发者ID:tomba,项目名称:dwarrowdelf,代码行数:26,代码来源:MapControl1.cs

示例5: Shift

 /// <summary>
 /// Shift cloud by adding specified value to all points in the collection.
 /// </summary>
 /// 
 /// <param name="cloud">Collection of points to shift their coordinates.</param>
 /// <param name="shift">Point to shift by.</param>
 /// 
 public static void Shift( List<IntPoint> cloud, IntPoint shift )
 {
     for ( int i = 0, n = cloud.Count; i < n; i++ )
     {
         cloud[i] = cloud[i] + shift;
     }
 }
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:14,代码来源:PointsCloud.cs

示例6: RenderSetPiece

        public void RenderSetPiece(World world, IntPoint pos)
        {
            int[,] t = new int[5, 5];

            t[0, 2] = 1;
            t[1, 2] = 1;
            t[2, 2] = 1;
            t[3, 2] = 1;
            t[4, 2] = 1;
            t[2, 0] = 1;
            t[2, 1] = 1;
            t[2, 3] = 1;
            t[2, 4] = 1;
            t[1, 1] = 1;
            t[1, 3] = 1;
            t[3, 3] = 1;
            t[3, 1] = 1;

            for (int x = 0; x < 5; x++)                    //Rendering
                for (int y = 0; y < 5; y++)
                {
                    if (t[x, y] == 1)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId = Lava; tile.ObjType = 0;
                        if (world.Obstacles[x + pos.X, y + pos.Y] == 0)
                        world.Map[x + pos.X, y + pos.Y] = tile;
                    }
                }
        }
开发者ID:RoxyLalonde,项目名称:Phoenix-Realms,代码行数:30,代码来源:TempLava3.cs

示例7: RenderSetPiece

        public void RenderSetPiece(World world, IntPoint pos)
        {
            var deepWaterRadius = 1f;

            var border = new List<IntPoint>();

            var t = new int[Size, Size];

            for (var y = 0; y < Size; y++) //Replace Deep Water With NWater
                for (var x = 0; x < Size; x++)
                {
                    var dx = x - (Size/2.0);
                    var dy = y - (Size/2.0);
                    var r = Math.Sqrt(dx*dx + dy*dy);
                    if (r <= deepWaterRadius)
                    {
                        t[x, y] = 1;
                    }
                }
            for (var x = 0; x < Size; x++)
                for (var y = 0; y < Size; y++)
                {
                    if (t[x, y] == 1)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId = Water;
                        tile.ObjType = 0;
                        world.Obstacles[x + pos.X, y + pos.Y] = 0;
                        world.Map[x + pos.X, y + pos.Y] = tile;
                    }
                }
        }
开发者ID:RiiggedMPGH,项目名称:Owl-Realms-Source,代码行数:32,代码来源:HermitOnDeath.cs

示例8: RenderSetPiece

        public void RenderSetPiece(World world, IntPoint pos)
        {
            Entity boss = Entity.Resolve(world.Manager, "shtrs Bridge Sentinel");
            boss.Move(pos.X, pos.Y);

            Entity chestSpawner = Entity.Resolve(world.Manager, "shtrs encounterchestspawner");
            chestSpawner.Move(pos.X, pos.Y + 5f);

            Entity blobombSpawner1 = Entity.Resolve(world.Manager, "shtrs blobomb maker");
            blobombSpawner1.Move(pos.X, pos.Y + 5f);

            Entity blobombSpawner2 = Entity.Resolve(world.Manager, "shtrs blobomb maker");
            blobombSpawner2.Move(pos.X + 5f, pos.Y + 5f);

            Entity blobombSpawner3 = Entity.Resolve(world.Manager, "shtrs blobomb maker");
            blobombSpawner3.Move(pos.X - 5f, pos.Y + 5f);

            world.EnterWorld(boss);

            world.EnterWorld(chestSpawner);

            world.EnterWorld(blobombSpawner1);
            world.EnterWorld(blobombSpawner2);
            world.EnterWorld(blobombSpawner3);
        }
开发者ID:OryxAwakening,项目名称:Fabiano_Swagger_of_Doom,代码行数:25,代码来源:BridgeSentinel.cs

示例9: RenderSetPiece

        public void RenderSetPiece(World world, IntPoint pos)
        {
            var cooledRadius = 15;

            var t = new int[Size, Size];

            for (var y = 0; y < Size; y++)
                for (var x = 0; x < Size; x++)
                {
                    var dx = x - Size / 2.0;
                    var dy = y - Size / 2.0;
                    var r = Math.Sqrt(dx * dx + dy * dy);
                    if (r <= cooledRadius)
                        t[x, y] = 1;
                }

            for (var x = 0; x < Size; x++)
                for (var y = 0; y < Size; y++)
                {
                    if (t[x, y] == 1)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();

                        tile.TileId = Cooled; tile.ObjType = 0;

                        if (world.Obstacles[x + pos.X, y + pos.Y] == 0)
                            world.Map[x + pos.X, y + pos.Y] = tile;
                    }
                }
        }
开发者ID:BlackRayquaza,项目名称:PhoenixRealms,代码行数:30,代码来源:EternalCrucible.cs

示例10: RenderSetPiece

        public void RenderSetPiece(World world, IntPoint pos)
        {
            var dat = world.Manager.GameData;
            for (int x = 0; x < Size; x++)
                for (int y = 0; y < Size; y++)
                {
                    double dx = x - (Size / 2.0);
                    double dy = y - (Size / 2.0);
                    double r = Math.Sqrt(dx * dx + dy * dy) + rand.NextDouble() * 4 - 2;
                    if (r <= 10)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = 0;
                        world.Map[x + pos.X, y + pos.Y] = tile;
                    }
                }

            Entity lord = Entity.Resolve(world.Manager, "Phoenix Lord");
            lord.Move(pos.X + 15.5f, pos.Y + 15.5f);
            world.EnterWorld(lord);

            Container container = new Container(world.Manager, 0x0501, null, false);
            Item[] items = chest.GetLoots(world.Manager, 5, 8).ToArray();
            for (int i = 0; i < items.Length; i++)
                container.Inventory[i] = items[i];
            container.Move(pos.X + 15.5f, pos.Y + 15.5f);
            world.EnterWorld(container);
        }
开发者ID:Topnenyie,项目名称:rotmg_svr,代码行数:28,代码来源:Pyre.cs

示例11: RenderSetPiece

        public void RenderSetPiece(World world, IntPoint pos)
        {
            for (int x = 0; x < Size; x++)
                for (int y = 0; y < Size; y++)
                {
                    double dx = x - (Size / 2.0);
                    double dy = y - (Size / 2.0);
                    double r = Math.Sqrt(dx * dx + dy * dy) + rand.NextDouble() * 4 - 2;
                    if (r <= 10)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId = Floor; tile.ObjType = 0;
                        world.Obstacles[x + pos.X, y + pos.Y] = 0;
                        world.Map[x + pos.X, y + pos.Y] = tile;
                    }
                }

            Entity lord = Entity.Resolve(0x675);
            lord.Move(pos.X + 15.5f, pos.Y + 15.5f);
            world.EnterWorld(lord);

            Container container = new Container(0x0501, null, false);
            int count = rand.Next(5, 8);
            List<Item> items = new List<Item>();
            while (items.Count < count)
            {
                Item item = chest.GetRandomLoot(rand);
                if (item != null) items.Add(item);
            }
            for (int i = 0; i < items.Count; i++)
                container.Inventory[i] = items[i];
            container.Move(pos.X + 15.5f, pos.Y + 15.5f);
            world.EnterWorld(container);
        }
开发者ID:rotmgkillroyx,项目名称:rotmg_svr_OLD,代码行数:34,代码来源:Pyre.cs

示例12: RenderSetPiece

        public void RenderSetPiece(World world, IntPoint pos)
        {
            int heatedRadius = 15;

            int[,] t = new int[Size, Size];

            for (int y = 0; y < Size; y++)
                for (int x = 0; x < Size; x++)
                {
                    double dx = x - (Size / 2.0);
                    double dy = y - (Size / 2.0);
                    double r = Math.Sqrt(dx * dx + dy * dy);
                    if (r <= heatedRadius)
                        t[x, y] = 1;
                }

            for (int x = 0; x < Size; x++)
                for (int y = 0; y < Size; y++)
                {
                    if (t[x, y] == 1)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();

                        tile.TileId = Heated; tile.ObjType = 0;

                        if (world.Obstacles[x + pos.X, y + pos.Y] == 0)
                            world.Map[x + pos.X, y + pos.Y] = tile;

                    }
                }
        }
开发者ID:RoxyLalonde,项目名称:Phoenix-Realms,代码行数:31,代码来源:EternalCrucible.cs

示例13: GetBoundingRectangle

        /// <summary>
        /// Get bounding rectangle of the specified list of points.
        /// </summary>
        /// 
        /// <param name="cloud">Collection of points to get bounding rectangle for.</param>
        /// <param name="minXY">Point comprised of smallest X and Y coordinates.</param>
        /// <param name="maxXY">Point comprised of biggest X and Y coordinates.</param>
        /// 
        public static void GetBoundingRectangle( List<IntPoint> cloud, out IntPoint minXY, out IntPoint maxXY )
        {
            if ( cloud.Count == 0 )
                throw new ArgumentException( "List of points can not be empty." );

            // take first point as min and max
            int minX = cloud[0].X;
            int maxX = cloud[0].X;
            int minY = cloud[0].Y;
            int maxY = cloud[0].Y;

            for ( int i = 1, n = cloud.Count; i < n; i++ )
            {
                int x = cloud[i].X;
                int y = cloud[i].Y;

                // check X coordinate
                if ( x < minX )
                    minX = x;
                if ( x > maxX )
                    maxX = x;

                // check Y coordinate
                if ( y < minY )
                    minY = y;
                if ( y > maxY )
                    maxY = y;
            }

            minXY = new IntPoint( minX, minY );
            maxXY = new IntPoint( maxX, maxY );
        }
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:40,代码来源:PointsCloud.cs

示例14: RoundTest

        public void RoundTest( float x, float y, int expectedX, int expectedY )
        {
            Point point = new Point( x, y );
            IntPoint iPoint = new IntPoint( expectedX, expectedY );

            Assert.AreEqual( iPoint, point.Round( ) );
        }
开发者ID:accord-net,项目名称:framework,代码行数:7,代码来源:PointTest.cs

示例15: GetAngleBetweenLines

        /// <summary>
        /// Calculate minimum angle between two lines measured in [0, 90] degrees range.
        /// </summary>
        /// 
        /// <param name="line1start">Starting point of the first line.</param>
        /// <param name="line1end">Ending point of the first line.</param>
        /// <param name="line2start">Starting point of the second line.</param>
        /// <param name="line2end">Ending point of the second line.</param>
        /// 
        /// <returns>Returns minimum angle between two lines.</returns>
        /// 
        public static double GetAngleBetweenLines( IntPoint line1start, IntPoint line1end, IntPoint line2start, IntPoint line2end )
        {
            double k1, k2;

            if ( line1start.X != line1end.X )
            {
                k1 = (double) ( line1end.Y - line1start.Y ) / ( line1end.X - line1start.X );
            }
            else
            {
                k1 = double.PositiveInfinity;
            }

            if ( line2start.X != line2end.X )
            {
                k2 = (double) ( line2end.Y - line2start.Y ) / ( line2end.X - line2start.X );
            }
            else
            {
                k2 = double.PositiveInfinity;
            }

            // check if lines are parallel
            if ( k1 == k2 )
                return 0;

            double angle = 0;

            if ( ( k1 != double.PositiveInfinity ) && ( k2 != double.PositiveInfinity ) )
            {
                double tanPhi = ( ( k2 > k1 ) ? ( k2 - k1 ) : ( k1 - k2 ) ) / ( 1 + k1 * k2 );
                angle = Math.Atan( tanPhi );
            }
            else
            {
                // one of the lines is parallel to Y axis

                if ( k1 == double.PositiveInfinity )
                {
                    angle = Math.PI / 2 - Math.Atan( k2 ) * Math.Sign( k2 );
                }
                else
                {
                    angle = Math.PI / 2 - Math.Atan( k1 ) * Math.Sign( k1 );
                }
            }

            // convert radians to degrees
            angle *= ( 180.0 / Math.PI );

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

            return angle;
        }
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:68,代码来源:GeometryTools.cs


注:本文中的IntPoint类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。