コード例 #1
0
ファイル: Controls.cs プロジェクト: LordPatate/shootingame
        public static bool Collision(ref IntRect projection, Level level)
        {
            foreach (Tile tile in level.Tiles)
            {
                var rect = tile.Rect;
                if (projection.Intersects(rect))
                {
                    projection = rect;
                    return(true);
                }
            }

            IntRect bounds = level.Bounds;

            projection.Intersects(bounds, out IntRect overLap);
            if (!projection.Equals(overLap))
            {
                projection.Left   = bounds.Left + bounds.Width;
                projection.Top    = bounds.Top + bounds.Height;
                projection.Width  = -bounds.Width;
                projection.Height = -bounds.Height;
                return(true);
            }

            return(false);
        }