コード例 #1
0
        public void Intersect_Intersects_ReturnTrue(int x, int y)
        {
            var box = new BoundingBox2D(new Vector2(10, 10), new Size(10, 10));

            var result = box.Intersects(new Vector2(x, y));

            Assert.That(result, Is.True);
        }
コード例 #2
0
        private void CheckPlatforms(BoundingBox2D playerBox)
        {
            foreach (Platform platform in platforms)
            {
                BoundingBox2D platformBox = platform.BoundingBox;

                if (playerBox.Intersects(platformBox))
                {
                    player.RegisterPlatformCollision(platform);
                }
            }
        }
コード例 #3
0
        private void CheckHazards(BoundingBox2D playerBox)
        {
            foreach (Hazard hazard in hazards)
            {
                BoundingBox2D hazardBox = hazard.BoundingBox;

                if (hazard == lastHazard)
                {
                    if (!lastHazard.Active || !playerBox.Intersects(hazardBox))
                    {
                        lastHazard = null;
                    }
                }
                else if (hazard.Active)
                {
                    if (playerBox.Intersects(hazardBox))
                    {
                        lastHazard = hazard;
                        player.RegisterDamage(GetCollisionDirection(playerBox, hazardBox, hazard.Type));
                    }
                }
            }
        }