示例#1
0
        protected override void UnloadContent()
        {
            // unload all map components
            foreach (MapObject comp in components)
            {
                comp.UnloadContent();
            }
            components.Clear();
            components = null;

            foreach (Player p in players)
            {
                p.UnloadContent();
            }
            foreach (Being b in creatures)
            {
                b.UnloadContent();
            }
            foreach (MapObject o in toUnload)
            {
                o.UnloadContent();
            }

            // unload particle system
            explosion.UnloadContent();
            smoke.UnloadContent();

            // unload background
            base.UnloadContent();
        }
示例#2
0
        private bool createMapFromFile(string filename)
        {
            // try to open the file where map is stored
            StreamReader reader;

            try
            {
                filename = Path.Combine(Content.RootDirectory, "Maps\\" + filename);
                reader   = new StreamReader(filename);
            }
            catch (Exception)
            {   // could not read the file
                return(false);
            }

            // read the map size of
            string[] size;
            size = reader.ReadLine().Split(' ');
            int width, height;

            if (!int.TryParse(size[0], out width))
            {
                return(false);
            }
            if (!int.TryParse(size[1], out height))
            {
                return(false);
            }

            // create component colleciton acording readed map size
            components = new MapObjectCollection(width, height);

            // read map components and add them to the map component collection
            for (int i = 0; i < height; i++)
            {
                string line = reader.ReadLine();
                for (int j = 0; j < width; j++)
                {
                    createComponent(line[j], j, i);
                }
            }

            // map has been loaded
            return(true);
        }
示例#3
0
        private bool createMapFromFile(string filename)
        {
            // try to open the file where map is stored
            StreamReader reader;
            try
            {
                filename = Path.Combine(Content.RootDirectory, "Maps\\" + filename);
                reader = new StreamReader(filename);
            }
            catch (Exception)
            {   // could not read the file
                return false;
            }

            // read the map size of 
            string[] size;
            size = reader.ReadLine().Split(' ');
            int width, height;
            if (!int.TryParse(size[0], out width))
                return false;
            if (!int.TryParse(size[1], out height))
                return false;

            // create component colleciton acording readed map size
            components = new MapObjectCollection(width, height);

            // read map components and add them to the map component collection
            for (int i = 0; i < height; i++)
            {
                string line = reader.ReadLine();
                for (int j = 0; j < width; j++)
                    createComponent(line[j], j, i);
            }

            // map has been loaded
            return true;
        }
示例#4
0
        protected override void UnloadContent()
        {
            // unload all map components
            foreach (MapObject comp in components)
                comp.UnloadContent();
            components.Clear();
            components = null;

            foreach (Player p in players)
                p.UnloadContent();
            foreach (Being b in creatures)
                b.UnloadContent();
            foreach (MapObject o in toUnload)
                o.UnloadContent();

            // unload particle system
            explosion.UnloadContent();
            smoke.UnloadContent();

            // unload background
            base.UnloadContent();
        }