예제 #1
0
 public Powerup(Game1 game, CollisionBody collision, PowerUpType powerUpType) : base(game, collision)
 {
     Game             = game;
     Collision        = collision;
     Collision.Parent = this;
     Velocity         = new Vector2(0f);
     Acceleration     = new Vector2(0f);
     this.powerUpType = powerUpType;
 }
예제 #2
0
        public Object(Game1 game, CollisionBody collision)
        {
            Game             = game;
            Collision        = collision;
            Collision.Parent = this;

            Velocity     = new Vector2(0f);
            Acceleration = new Vector2(0f);
        }
예제 #3
0
        public Paddle(Game1 game, CollisionBody collision) : base(game, collision)
        {
            Game             = game;
            Collision        = collision;
            Collision.Parent = this;

            //Texture = null;
            //TextureColor = Color.White;
            Velocity     = new Vector2(0f);
            Acceleration = new Vector2(0f);
            //timer = new TimeSpan(0);
        }
예제 #4
0
        public Dictionary <uint, CollisionBody> GetPotentialCollisions(CollisionBody toCheck)
        {
            int xMin = 0;
            int xMax = 0;
            int yMin = 0;
            int yMax = 0;

            if (toCheck.Shape == CollisionBody.ShapeType.Circle)
            {
                CircleBody body = (CircleBody)toCheck;
                xMin = ((int)(Math.Max(body.Position.X - body.Radius / 2, 0)) / tileSize);
                xMax = (int)(Math.Min(body.Position.X + body.Radius / 2, maxWidth - 1)) / tileSize;
                yMin = ((int)(Math.Max(body.Position.Y - body.Radius / 2, 0)) / tileSize);
                yMax = (int)(Math.Min(body.Position.Y + body.Radius / 2, maxHeight - 1)) / tileSize;
            }
            else if (toCheck.Shape == CollisionBody.ShapeType.Rectangle)
            {
                RectangleBody body = (RectangleBody)toCheck;
                xMin = ((int)(Math.Max(body.Position.X, 0)) / tileSize);
                xMax = (int)(Math.Min(body.Position.X + body.Size.X, 49)) / tileSize;
                yMin = ((int)(Math.Max(body.Position.Y, 0)) / tileSize);
                yMax = (int)(Math.Min(body.Position.Y + body.Size.Y, 49)) / tileSize;
            }

            // Get every possible CollisionBody
            Dictionary <uint, CollisionBody> potentials = new Dictionary <uint, CollisionBody>();

            for (int y = yMin; y <= yMax; y++)
            {
                for (int x = xMin; x <= xMax; x++)
                {
                    foreach (CollisionBody c in Tiles[y * columns + x].Data.Values)
                    {
                        if (!potentials.ContainsKey(c.id))
                        {
                            potentials.Add(c.id, c);
                        }
                    }
                }
            }

            return(potentials);
        }
예제 #5
0
 public Brick(Game1 game, CollisionBody collision, int health, int spriteNum, int crackedNum, PowerUpType powerUpType) : base(game, collision)
 {
     Game             = game;
     Collision        = collision;
     Collision.Parent = this;
     Health           = health;
     //Texture = null;
     //CrackedTexture = null;
     //TextureColor = Color.White;
     Velocity              = new Vector2(0f);
     Acceleration          = new Vector2(0f);
     this.SpriteNum        = spriteNum;
     this.CrackedSpriteNum = crackedNum;
     if (powerUpType == PowerUpType.None)
     {
         Powerup = null;
     }
     else
     {
         CircleBody pCollision = new CircleBody(new Vector2(collision.Position.X + collision.Region().Width / 2, collision.Position.Y + collision.Region().Height / 2), Powerup.Size);
         Powerup = new Powerup(game, pCollision, powerUpType);
     }
 }
예제 #6
0
        private List <GridTile> GetCoveredTiles(CollisionBody toAdd)
        {
            int xMin = 0;
            int xMax = 0;
            int yMin = 0;
            int yMax = 0;

            if (toAdd.Shape == CollisionBody.ShapeType.Circle)
            {
                CircleBody body = (CircleBody)toAdd;
                xMin = ((int)(Math.Max(body.Position.X - body.Radius / 2, 0)) / tileSize);
                xMax = (int)(Math.Min(body.Position.X + body.Radius / 2, maxWidth - 1)) / tileSize;
                yMin = ((int)(Math.Max(body.Position.Y - body.Radius / 2, 0)) / tileSize);
                yMax = (int)(Math.Min(body.Position.Y + body.Radius / 2, maxHeight - 1)) / tileSize;
            }
            else if (toAdd.Shape == CollisionBody.ShapeType.Rectangle)
            {
                RectangleBody body = (RectangleBody)toAdd;
                xMin = ((int)(Math.Max(body.Position.X, 0)) / tileSize);
                xMax = (int)(Math.Min(body.Position.X + body.Size.X, maxWidth - 1)) / tileSize;
                yMin = ((int)(Math.Max(body.Position.Y, 0)) / tileSize);
                yMax = (int)(Math.Min(body.Position.Y + body.Size.Y, maxWidth - 1)) / tileSize;
            }

            List <GridTile> toReturn = new List <GridTile>();

            for (int y = yMin; y <= yMax; y++)
            {
                for (int x = xMin; x <= xMax; x++)
                {
                    toReturn.Add(Tiles[y * columns + x]);
                }
            }

            return(toReturn);
        }
예제 #7
0
 public void Remove(CollisionBody body)
 {
     Data.Remove(body.id);
 }
예제 #8
0
 public void Add(CollisionBody body)
 {
     Data.Add(body.id, body);
 }