Ejemplo n.º 1
0
        /// <summary>
        /// Called when it is time to setup the next frame.
        /// </summary>
        /// <param name="e">Contains timing information for framerate independent logic.</param>
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            base.OnUpdateFrame(e);
            //GameLogic gameplay = new GameLogic();
            //gameplay.AddPlayer(player);

            if (Keyboard[Key.Q]){
                map = mapGenerator.generateCLASSIC_Map();
                mapp = new Map(map);
                mode = new GameMode(GameMode.Mode.CLASSIC);
                save = new MapSave(mapp, mode);
                save.createXMLDoc("C:\\inputXML.xml");

                loader = new MapLoader();
                mapp2 = loader.loadMap("C:\\inputXML.xml");
                mode2 = loader.getMode();
                save2 = new MapSave(mapp2, mode2);
                save2.createXMLDoc("C:\\outputXML.xml");
            }
            if (Keyboard[Key.W])
                map = mapGenerator.generateDM_Map();
            if (Keyboard[Key.E])
                map = mapGenerator.generateTDMB_Map();
            if (Keyboard[Key.R])
                map = mapGenerator.generateTDM_Map();
            if (Keyboard[Key.Escape])
                Exit();
        }
Ejemplo n.º 2
0
        public Map LoadMap(String filePath)
        {
            int x,y;
            mapObjects  = new MapObject[20][];
            for (int i = 0; i < mapObjects.Length; i++)
                mapObjects[i] = new MapObject[19];
            MapObject obj;
            String tempStr;
            reader = new XmlTextReader(filePath);
            reader.WhitespaceHandling = WhitespaceHandling.None;    //skipping empty nodes
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == "mode")
                    {
                        tempStr = reader.GetAttribute("name");
                        switch (tempStr)
                        {
                            case "CLASSIC":
                                mode = new GameMode(GameMode.Mode.CLASSIC);
                                break;
                            case "TDM":
                                mode = new GameMode(GameMode.Mode.TDM);
                                break;
                            case "TDMB":
                                mode = new GameMode(GameMode.Mode.TDMB);
                                break;
                            case "DM":
                                mode = new GameMode(GameMode.Mode.DM);
                                break;
                        }
                    }
                    if (reader.Name == "element")
                    {
                        x = int.Parse(reader.GetAttribute("x"));
                        y = int.Parse(reader.GetAttribute("y"));
                        tempStr = reader.GetAttribute("type");
                        switch (tempStr)
                        {
                            case "EMPTY":
                                obj = new MapObject(x, y, MapObject.Types.EMPTY);
                                mapObjects[x][y] = obj;
                                break;

                            case "BRICK":
                                obj = new MapObject(x, y, MapObject.Types.BRICK);
                                mapObjects[x][y] = obj;
                                break;
                            case "CONCRETE":
                                obj = new MapObject(x, y, MapObject.Types.CONCRETE);
                                mapObjects[x][y] = obj;
                                break;
                            case "WATER":
                                obj = new MapObject(x, y, MapObject.Types.WATER);
                                mapObjects[x][y] = obj;
                                break;
                            case "FOREST":
                                obj = new MapObject(x, y, MapObject.Types.FOREST);
                                mapObjects[x][y] = obj;
                                break;
                            case "BASE":
                                obj = new MapObject(x, y, MapObject.Types.BASE);
                                mapObjects[x][y] = obj;
                                break;
                        }

                    }

                }
            }
            reader.Close();
            map = new Map(mapObjects);
            return map;
        }
Ejemplo n.º 3
0
 public MapSaver(Map map, GameMode mode)
 {
     this.map = map;
     this.mode = mode;
 }
Ejemplo n.º 4
0
 public Round(GameMode mode, Map map, List<Player> playerList)
 {
     Mode = mode;
     Map = map;
     PlayerList = playerList;
 }