Ejemplo n.º 1
0
 public BreakableBlock(int x, int y, Sprite sprite, Map map)
     : base(x,y, sprite)
 {
     //this.Kill(); // Do not draw me
     this.collisionBlock = new CollisionBlock(x, y, sprite.Width, sprite.Height);
     map.ExtraCollisionBlocks.Add(collisionBlock);
 }
Ejemplo n.º 2
0
 public Block(int x, int y, Sprite sprite)
     : base(x, y, sprite)
 {
     BlockCoordinate = new Point(x / Game1.TILE_SIZE, y / Game1.TILE_SIZE);
 }
Ejemplo n.º 3
0
 private static Block handleInteractiveTile(Game1 game, Dictionary<int, TileInfo> tileinfo, JObject obj, string name, string kind, int x, int y)
 {
     int gid = (int)obj["gid"];
     var ti = tileinfo[gid];
     Sprite sprite = new Sprite(game.ConditionalLoadSprite(ti.Loc, ti.Path), ti.Origin);
     y = y - 32;
     switch (kind)
     {
         case "door":
             return new SwitchBlock(x, y, sprite); // FIXME
         case "switch":
             return new SwitchBlock(x, y, sprite);
         case "breakable":
             var b =  new BreakableBlock(x, y, sprite, game.currentMap);
             return b;
         case "lantern":
             var lb = new LanternBlock(x, y, sprite, name);
             game.currentMap.AddSpawn(x, y, name);
             return lb;
     }
     return null;
 }
Ejemplo n.º 4
0
        private static void handleLayer(Game1 game, JObject layer, Dictionary<int, TileInfo> tileinfo, List<Block> blocks)
        {
            game.currentMap.Height = (int)layer["height"];
            int width = game.currentMap.Width = (int)layer["width"];
            JArray blockData = (JArray)layer["data"];
            for (int y = 0; y < game.currentMap.Height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    int pos = y * width + x;
                    int curItem = (int)blockData[pos];
                    if (curItem == 0) continue;
                    TileInfo ti = tileinfo[curItem];
                    Sprite sprite = new Sprite(game.ConditionalLoadSprite(ti.Loc, ti.Path), ti.Origin);

                    blocks.Add(new Block(x * Game1.TILE_SIZE, y * Game1.TILE_SIZE, sprite));
                }
            }
            game.currentMap.ReduceCollisionBlocks();
        }
Ejemplo n.º 5
0
 public MovingEntity(int x, int y, Sprite sprite)
     : base(x, y, sprite)
 {
 }