Esempio n. 1
0
        /// <summary>
        /// Loads GameObjects into the object map.
        /// Loads objects from an external Json file created from the map editor.
        /// </summary>
        public void loadMap(Dictionary <ObjectType, Texture2D> textures)
        {
            objectMap.Clear();

            StreamReader jinput    = new StreamReader("../../../../Content/level.json");
            List <Tile>  inputList = JsonConvert.DeserializeObject <List <Tile> >(jinput.ReadToEnd(), settings);

            jinput.Close();

            foreach (Tile tile in inputList)
            {
                switch (tile.type)
                {
                case ObjectType.TopBrick:
                    objectMap.Add(new Environment(tile.bounds, textures[ObjectType.TopBrick]));
                    break;

                case ObjectType.PlainBrick:
                    objectMap.Add(new Environment(tile.bounds, textures[ObjectType.PlainBrick]));
                    break;

                case ObjectType.Player:
                    objectMap.Add(new Player(tile.bounds, textures[ObjectType.Player], 5));
                    break;

                case ObjectType.Enemy:
                    objectMap.Add(new Enemy(tile.bounds, objectMap, textures[ObjectType.Enemy], 2));
                    break;

                case ObjectType.Boss:
                    objectMap.Add(new Boss(tile.bounds, objectMap, textures[ObjectType.Boss], 10, leapZoneMap));
                    break;

                case ObjectType.Rock:
                    objectMap.Add(new Environment(tile.bounds, textures[ObjectType.Rock]));
                    break;

                case ObjectType.BossLeapZone:
                    //Leap Zone tiles will be LeapZoneTile type instead of a normal tile, and a cast is needed to get extra attributes.
                    LeapZoneTile zoneTile = (LeapZoneTile)tile;
                    BossLeapZone zone     = new BossLeapZone(zoneTile.bounds, null, zoneTile.id, zoneTile.linkedZones);
                    objectMap.Add(zone);
                    leapZoneMap.Add(zone);
                    break;
                }
            }
            cam = new Camera(findPlayer());
        }
Esempio n. 2
0
 public void linkZone(LeapZoneTile tile)
 {
     linkedZones.Add(tile.id);
 }