コード例 #1
0
        public void initWorldConfig(ContentManager content, String actorConfigFile)
        {
            var doc = XDocument.Load(actorConfigFile);
            var worlds = doc.Element("Worlds").Elements("World");

            String worldName;
            Texture2D texture;
            int width;
            int height;
            int tileSize;

            foreach (XElement world in worlds)
            {
                worldName = world.Attribute("worldName").Value;
                texture = content.Load<Texture2D>(world.Attribute("worldTexture").Value);
                width = int.Parse(world.Attribute("width").Value);
                height = int.Parse(world.Attribute("height").Value);
                tileSize = int.Parse(world.Attribute("tileSize").Value);
                worldPrototypes[worldName] = new WorldConfig(worldName, texture, width, height, tileSize);
            }
        }
コード例 #2
0
 //Generates an World object with the given bounds using constraints outlined
 //at the top of the class.
 //Returns an array of enumerated tiles.
 public World generateWorld(WorldConfig worldConfig, int numEnemies)
 {
     World world = generateWorld(worldConfig.texture, worldConfig.enemyClasses, worldConfig.width, worldConfig.height, worldConfig.tileSize, numEnemies);
     world.themeMusic = worldConfig.music;
     return world;
 }
コード例 #3
0
        public void initWorldConfig(ContentManager content, String actorConfigFile)
        {
            XDocument doc = XDocument.Load(actorConfigFile);
            List<XElement> worlds = doc.Element("Worlds").Elements("World").ToList();
            List<XElement> enemies;

            String worldName;
            List<String> enemyClasses;
            Texture2D texture;
            int width;
            int height;
            int tileSize;

            foreach (XElement world in worlds)
            {
                worldName = world.Attribute("worldName").Value;
                enemies = world.Elements("Enemy").ToList();
                texture = content.Load<Texture2D>(world.Attribute("worldTexture").Value);
                width = int.Parse(world.Attribute("width").Value);
                height = int.Parse(world.Attribute("height").Value);
                tileSize = int.Parse(world.Attribute("tileSize").Value);
                enemyClasses = new List<String>();
                foreach (XElement enemy in enemies)
                {
                    enemyClasses.Add(enemy.Attribute("class").Value);
                }
                worldPrototypes[worldName] = new WorldConfig(worldName, enemyClasses, texture, width, height, tileSize);
                worldPrototypes[worldName].music = world.Attribute("themeMusic").Value;
            }
        }
コード例 #4
0
        //public World loadFromCustom(int[,] tileMap, bool[,] collisionMap)
        //{
        //    Point playerSpawnPos = new Point(1, 1);
        //    return this.loadFromCustom(worldPrototypes["tundra"], tileMap, collisionMap, playerSpawnPos);
        //}

        //public World loadFromCustom(WorldConfig worldConfig, int[,] tileMap, bool[,] collisionMap, Point playerSpawnPos)
        //{
        //    return this.loadFromCustom(worldConfig.texture, worldConfig.tileSize, tileMap, collisionMap, playerSpawnPos);
        //}

        //public World loadFromCustom(Texture2D tile, int tileSize, int[,] tileMap, bool[,] collisionMap, Point playerSpawnPos)
        //{
        //    List<String> enemyTypeList = new List<String>();
        //    List<Point> enemySpawnPosList = new List<Point>();
        //    return this.loadFromCustom(tile, tileSize, tileMap, collisionMap, playerSpawnPos, enemyTypeList, enemySpawnPosList);
        //}

        public World loadFromCustom(WorldConfig worldConfig, int[,] tileMap, bool[,] collisionMap, Point playerSpawnPos, List<String> enemyTypeList, List<Point> enemySpawnPosList)
        {
            return this.loadFromCustom(worldConfig.texture, worldConfig.tileSize, tileMap, collisionMap, playerSpawnPos, enemyTypeList, enemySpawnPosList);
        }
コード例 #5
0
        //Generates an World object with the given bounds using constraints outlined
        //at the top of the class.
        //Returns an array of enumerated tiles.

        public World generateWorld(WorldConfig worldConfig, int numEnemies)
        {
            return generateWorld(worldConfig.texture, worldConfig.width, worldConfig.height, worldConfig.tileSize, numEnemies);
        }
コード例 #6
0
 //Generates an World object with the given bounds using constraints outlined
 //at the top of the class.
 //Returns an array of enumerated tiles.
 public World generateWorld(WorldConfig worldConfig, int difficulty)
 {
     World world = generateWorld(worldConfig.texture, worldConfig.enemyConfigs, worldConfig.tileSize, difficulty);
     world.themeMusic = worldConfig.music;
     world.worldConfig = worldConfig;
     return world;
 }