コード例 #1
0
        /// <summary>
        /// 物理演算を行います。
        /// </summary>
        public virtual void UpdatePhysics(ColliderType top, ColliderType bottom, ColliderType left, ColliderType right)
        {
            if (Location.X < 0)
            {
                Location.X = 0;
            }

            if (Core.I.CurrentMap != null && Location.X > Core.I.CurrentMap.Size.X * 16)
            {
                Location.X = Core.I.CurrentMap.Size.X * 16;
            }

            if (top.IsLandLike() && Velocity.Y < 0)
            {
                // 天井で反発する
                Velocity.Y = 0;
            }

            IsOnLand = bottom.IsLandLike();
            if (IsOnLand && Velocity.Y > 0)
            {
                Velocity.Y = 0;
            }

            // 滞空時間を更新
            FlightingTime = IsOnLand ? 0 : FlightingTime + 1;

            if (left.IsLandLike() && Velocity.X < 0)
            {
                if (CollisionTopLeft().IsLandLike() || FlightingTime > 10)
                {
                    Velocity.X = 0;
                }
                else
                {
                    while (Misc.CheckHit((int)(Location.X), (int)(Location.Y + Collision.Bottom)).IsLandLike())
                    {
                        Location.Y--;
                    }
                }
            }

            if (right.IsLandLike() && Velocity.X > 0)
            {
                if (CollisionTopRight().IsLandLike() || FlightingTime > 10)
                {
                    Velocity.X = 0;
                }
                else
                {
                    while (Misc.CheckHit((int)(Location.X + Collision.Right), (int)(Location.Y + Collision.Bottom)).IsLandLike())
                    {
                        Location.Y--;
                    }
                }
            }
        }
コード例 #2
0
 public override void UpdatePhysics(ColliderType top, ColliderType bottom, ColliderType left, ColliderType right)
 {
     base.UpdatePhysics(top, bottom, left, right);
     var(x, y) = (VectorInt)Location;
     for (var i = (int)Collision.Left; i < Collision.Right; i++)
     {
         if (top.IsLandLike() && Map[(x + i) / 16, (y - 1) / 16, 0] == 9)
         {
             Map[(x + i) / 16, (y - 1) / 16, 0] = 0;
             DESound.Play(Sounds.Destroy);
             Particle.BrokenBlock(new Point(x, y), Parent, Mpts);
         }
     }
     if (IsOnLand)
     {
         IsJumping = false;
     }
 }