Exemplo n.º 1
0
 public override void Update(GameTime gameTime)
 {
     base.Update(gameTime);
     if (IsDead())
     {
         UnblockTiles();
         grid.AssignNeighbours();
     }
 }
Exemplo n.º 2
0
        public Building(GameplayManager gm, int gridX, int gridY, int faction, World world, int tileWidth, int tileHeight, int HP, float visionRange, int cost, Grid grid)
            : base(gm, new Vector2(((float)gridX + (float)tileWidth / 2.0f) * Grid.TileSize, ((float)gridY + (float)tileHeight / 2.0f) * Grid.TileSize), faction, HP, visionRange, cost, world)
        {
            body                     = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(tileWidth * Grid.TileSize), ConvertUnits.ToSimUnits(tileHeight * Grid.TileSize), 10, ConvertUnits.ToSimUnits(new Vector2(((float)gridX + (float)tileWidth / 2.0f) * Grid.TileSize, ((float)gridY + (float)tileHeight / 2.0f) * Grid.TileSize)));
            body.BodyType            = BodyType.Static;
            body.CollisionCategories = Category.All;
            body.CollidesWith        = Category.All;

            width           = tileWidth * Grid.TileSize;
            height          = tileHeight * Grid.TileSize;
            this.tileHeight = tileHeight;
            this.tileWidth  = tileWidth;
            this.gridX      = gridX;
            this.gridY      = gridY;
            this.grid       = grid;

            BlockTiles();
            grid.AssignNeighbours();

            radius = Math.Max(width / 2.0f, height / 2.0f);
            bounds = new Rectangle((int)(Position.X - width / 2.0f), (int)(Position.Y - height / 2.0f), (int)width, (int)height);
        }
Exemplo n.º 3
0
        public Building(GameplayManager gm, int gridX, int gridY, int faction, World world, int tileWidth, int tileHeight, int HP, float visionRange, Grid grid)
            : base(gm, new Vector2(((float)gridX + (float)tileWidth / 2.0f) * Grid.TileSize, ((float)gridY + (float)tileHeight / 2.0f) * Grid.TileSize), faction, HP, visionRange, world)
        {
            body = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(tileWidth * Grid.TileSize), ConvertUnits.ToSimUnits(tileHeight * Grid.TileSize), 10, ConvertUnits.ToSimUnits(new Vector2(((float)gridX + (float)tileWidth / 2.0f) * Grid.TileSize, ((float)gridY + (float)tileHeight / 2.0f) * Grid.TileSize)));
            body.BodyType = BodyType.Static;
            body.CollisionCategories = Category.All;
            body.CollidesWith = Category.All;

            width = tileWidth * Grid.TileSize;
            height = tileHeight * Grid.TileSize;
            this.tileHeight = tileHeight;
            this.tileWidth = tileWidth;
            this.gridX = gridX;
            this.gridY = gridY;
            this.grid = grid;

            BlockTiles();
            grid.AssignNeighbours();

            radius = Math.Max(width / 2.0f, height / 2.0f);
            bounds = new Rectangle((int)(Position.X - width / 2.0f), (int)(Position.Y - height / 2.0f), (int)width, (int)height);
        }