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


C# Point.IsOutOfRange方法代码示例

本文整理汇总了C#中Point.IsOutOfRange方法的典型用法代码示例。如果您正苦于以下问题:C# Point.IsOutOfRange方法的具体用法?C# Point.IsOutOfRange怎么用?C# Point.IsOutOfRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Point的用法示例。


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

示例1: CollisionRight

        /// <summary>
        ///     右の当たり判定を計算します。
        /// </summary>
        public virtual ObjectHitFlag CollisionRight()
        {
            int x, y;
            var retval = ObjectHitFlag.NotHit;

            for (y = (int) (Location.Y + Collision.Top) + Size.Height / 6;
                y < (int) (Location.Y + Collision.Bottom);
                y += (int) Collision.Height / 3)
            {
                x = (int) (Location.X + Collision.X + Collision.Width);
                var pnt = new Point(x, y);
                if (pnt.IsOutOfRange())
                    continue;
                var hit = Mpts[Map[x / 16, y / 16, 0]].CheckHit(x % 16, y % 16);
                switch (hit)
                {
                    case ObjectHitFlag.NotHit:
                        break;
                    case ObjectHitFlag.Hit:
                        if (Mpts[Map[x / 16, (y - 1) / 16, 0]].CheckHit(x % 16, (y - 1) % 16) == ObjectHitFlag.NotHit)
                            Location.Y -= this is EntityPlayer && (((EntityPlayer) this).Form == PlayerForm.Big) ? 2 : 1;
                        else
                            Location.X--;
                        if (this is EntityTurcosShell && ((EntityTurcosShell) this).IsRunning)
                            if (Map[x / 16, y / 16, 0] == 9) //ブロック破壊
                            {
                                SoundUtility.PlaySound(Sounds.Destroy);
                                Map[x / 16, y / 16, 0] = 0;
                                ParticleUtility.BrokenBlock(new Point(x, y), Parent, Mpts);
                            }
                        Velocity.X = 0;
                        retval = ObjectHitFlag.Hit;
                        break;
                    case ObjectHitFlag.Damage:
                        Kill();
                        goto case ObjectHitFlag.Hit;
                    case ObjectHitFlag.Death:
                        Kill();
                        goto case ObjectHitFlag.Hit;
                }
                if (x < GameEngine.Map.Width * 16 - 1)
                    if (Mpts[Map[(x + 1) / 16, y / 16, 0]].CheckHit((x + 1) % 16, y % 16) == ObjectHitFlag.Hit)
                        retval = ObjectHitFlag.Hit;
                if (GameEngine.IsDebugMode)
                    DX.DrawPixel(GameEngine.Ks.Camera.X + x, GameEngine.Ks.Camera.Y + y, DX.GetColor(255, 255, 255));
            }
            foreach (IScaffold sc in Parent.FindEntitiesByType<IScaffold>())
            {
                if (sc == this)
                    continue;
                if (new Rectangle((int) (Location.X + Collision.Left), (int) (Location.Y + Collision.Y), 1, (int) Collision.Height)
                    .CheckCollision(
                        new Rectangle((int) (sc.Location.X + sc.Collision.Left), (int) (sc.Location.Y + sc.Collision.Y),
                            (int) sc.Collision.Width, (int) sc.Collision.Height)))
                {
                    Location.X--;
                    Velocity.X = 0;
                    retval = ObjectHitFlag.Hit;
                }
            }
            return retval;
        }
开发者ID:Citringo,项目名称:ProjectDefenderStory,代码行数:65,代码来源:AbstractEntities.cs

示例2: CollisionTop

        /// <summary>
        ///     上の当たり判定を計算します。
        /// </summary>
        public virtual ObjectHitFlag CollisionTop()
        {
            int x, y;
            var retval = ObjectHitFlag.NotHit;

            for (x = (int) (Location.X + Collision.Left) + (int) Collision.Width / 4;
                x < (int) (Location.X + Collision.Right);
                x += (int) Collision.Width / 2)
            {
                y = (int) (Location.Y + Collision.Y);
                var pnt = new Point(x, y);
                if (pnt.IsOutOfRange())
                    continue;
                var hit = Mpts[Map[x / 16, y / 16, 0]].CheckHit(x % 16, y % 16);
                switch (hit)
                {
                    case ObjectHitFlag.Hit:
                        //if (Mpts[Map[x / 16, y / 16, 0]].CheckHit(x % 16, (y + 1) % 16) == ObjectHitFlag.Hit)
                        Location.Y++;
                        Velocity.Y = 0;
                        if (this is EntityPlayer)
                            if (IsJumping && (Map[x / 16, y / 16, 0] == 9)) //ブロック破壊
                            {
                                SoundUtility.PlaySound(Sounds.Destroy);
                                Map[x / 16, y / 16, 0] = 0;
                                ParticleUtility.BrokenBlock(new Point(x, y), Parent, Mpts);
                            }
                        break;
                    case ObjectHitFlag.Damage:
                        Kill();
                        goto case ObjectHitFlag.Hit;
                    case ObjectHitFlag.Death:
                        Kill();
                        goto case ObjectHitFlag.Hit;
                }
                if (y > 0)
                    if (Mpts[Map[x / 16, (y - 1) / 16, 0]].CheckHit(x % 16, (y - 1) % 16) == ObjectHitFlag.Hit)
                        retval = ObjectHitFlag.Hit;
                if (GameEngine.IsDebugMode)
                    DX.DrawPixel(GameEngine.Ks.Camera.X + x, GameEngine.Ks.Camera.Y + y, DX.GetColor(255, 255, 255));
            }
            foreach (IScaffold sc in Parent.FindEntitiesByType<IScaffold>())
            {
                if (sc == this)
                    continue;
                if (new Rectangle((int) (Location.X + Collision.Left), (int) (Location.Y + Collision.Y), (int) Collision.Width, 1)
                    .CheckCollision(
                        new Rectangle((int) (sc.Location.X + sc.Collision.Left), (int) (sc.Location.Y + sc.Collision.Y),
                            (int) sc.Collision.Width, (int) sc.Collision.Height)))
                {
                    Location.Y++;
                    Velocity.Y = 0;
                }
            }
            return retval;
        }
开发者ID:Citringo,项目名称:ProjectDefenderStory,代码行数:59,代码来源:AbstractEntities.cs

示例3: CollisionBottom

        /// <summary>
        ///     下の当たり判定を計算します。
        /// </summary>
        public virtual ObjectHitFlag CollisionBottom()
        {
            int x, y;
            var retval = ObjectHitFlag.NotHit;
            IsOnLand = false;
            for (x = (int) (Location.X + Collision.Left) + (int) Collision.Width / 4;
                x < (int) (Location.X + Collision.Right);
                x += (int) Collision.Width / 2)
            {
                y = (int) (Location.Y + Collision.Y + Collision.Height);
                var pnt = new Point(x, y);
                if (pnt.IsOutOfRange())
                    continue;
                var hit = Mpts[Map[x / 16, y / 16, 0]].CheckHit(x % 16, y % 16);

                switch (hit)
                {
                    case ObjectHitFlag.NotHit:
                        //IsOnLand = false;
                        break;
                    case ObjectHitFlag.Hit:
                        if (Mpts[Map[x / 16, (y - 1) / 16, 0]].CheckHit(x % 16, (y - 1) % 16) == ObjectHitFlag.Hit)
                            Location.Y--;
                        IsOnLand = true;
                        IsJumping = false;
                        retval = ObjectHitFlag.Hit;
                        if (Velocity.Y > 0)
                            Velocity.Y = 0;
                        break;
                    case ObjectHitFlag.Damage:
                        Kill();
                        goto case ObjectHitFlag.Hit;
                    case ObjectHitFlag.Death:
                        Kill();
                        goto case ObjectHitFlag.Hit;
                }
                if (y < GameEngine.Map.Height * 16 - 1)
                    if (Mpts[Map[x / 16, (y + 1) / 16, 0]].CheckHit(x % 16, (y + 1) % 16) == ObjectHitFlag.Hit)
                        retval = ObjectHitFlag.Hit;
                if (GameEngine.IsDebugMode)
                    DX.DrawPixel(GameEngine.Ks.Camera.X + x, GameEngine.Ks.Camera.Y + y, DX.GetColor(255, 255, 255));
            }
            foreach (IScaffold sc in Parent.FindEntitiesByType<IScaffold>())
            {
                if (sc == this)
                    continue;
                if (new Rectangle((int) (Location.X + Collision.Left), (int) (Location.Y + Collision.Bottom), (int) Collision.Width,
                    1).CheckCollision(
                    new Rectangle((int) (sc.Location.X + sc.Collision.Left), (int) (sc.Location.Y + sc.Collision.Y),
                        (int) sc.Collision.Width, (int) sc.Collision.Height)))
                {
                    Location.Y--;
                    IsOnLand = true;
                    if (Velocity.Y > 0)
                        Velocity.Y = 0;
                    retval = ObjectHitFlag.Hit;
                }
            }
            return retval;
        }
开发者ID:Citringo,项目名称:ProjectDefenderStory,代码行数:63,代码来源:AbstractEntities.cs


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