public MenuState(Surface _sfcGameWindow)
     : base(_sfcGameWindow)
 {
     objs = new List<MenuObject> ();
     menuStart = new MenuText ("Start", Color.Gold, Color.Black, 42);
     menuEditor = new MenuText ("Level editor", Color.Gold, Color.Black, 42);
     menuQuit = new MenuText ("Exit", Color.Gold, Color.Red, 42);
     menuQuit.selectedHandler += EventMenuQuit;
 }
        public SelectLevelScreenState(Surface _sfcGameWindow, List<MenuObject> extraObjs)
            : base(_sfcGameWindow)
        {
            objs = new List<MenuObject> ();
            foreach (MenuObject obj in extraObjs) {
                obj.selectedHandler += EventSelected;
                objs.Add (obj);
            }

            string[] files = Directory.GetFiles (Constants.Constants.LEVEL_PATH);
            foreach (string f in files) {
                string file = Path.GetFileName (f);
                MenuObject obj = new MenuText (file.Replace (".xml", ""), Color.Gold, Color.Black, 30);
                obj.selectedHandler += EventSelected;
                objs.Add (obj);
            }
            MenuText t = new MenuText ("Exit", Color.Gold, Color.Red, 30);
            t.selectedHandler += delegate(MenuObject obj) {
                menuExitHandler (obj);
            };
            objs.Add (t);
            menu = new Menu (objs, MenuLayout.Vertical);
        }
        public LevelEditorState(Surface _sfcGameWindow, string _name="untitled")
            : base(_sfcGameWindow)
        {
            camera = new Camera ();
            name = _name;
            map = new Map ();
            map.editor = true;
            vecPlayer = new Vector (new Point (2, 3));
            player = new EditorSprite (vecPlayer, new Player (0, 0));
            enemies = new List<EditorSprite> ();
            if (name.EndsWith (".xml")) {
                XmlDocument doc = new XmlDocument ();
                doc.Load (Constants.Constants.GetResourcePath (name));
                map.FromXML (doc);
                XmlNode p = doc.SelectSingleNode ("//player");
                player.gridPos.X = Convert.ToInt16 (p.Attributes ["x"].InnerText);
                player.gridPos.Y = Convert.ToInt16 (p.Attributes ["y"].InnerText);
                name = name.Replace (".xml", "");
                foreach (XmlNode node in doc.SelectNodes("//enemy")) {
                    EnemyType typ = (EnemyType)Enum.Parse (typeof(EnemyType), node.Attributes ["type"].InnerText);
                    int x = Convert.ToInt16 (node.Attributes ["x"].InnerText);
                    int y = Convert.ToInt16 (node.Attributes ["y"].InnerText);
                    Enemy enemy = Enemy.GetEnemy (typ, x, y);
                    EditorSprite s = new EditorSprite (new Vector (new Point (x, y)), enemy);
                    Vector vec = map.GetTilePos (x, y);
                    s.x = vec.X;
                    s.y = vec.Y;
                    s.data = (object)typ;
                    enemies.Add (s);
                }
            } else {
                map.EmptyMap ();
            }

            Vector v = map.GetTilePos ((int)player.gridPos.X, (int)player.gridPos.Y);
            player.x = v.X;
            player.y = v.Y;

            grid = new EditorGrid ();

            List<MenuObject > menuObjs = new List<MenuObject> ();
            foreach (TileType typ in Enum.GetValues(typeof(TileType))) {
                MenuText t = new MenuText (typ.ToString (), Color.Gold, Color.Black, TEXT_SIZE);
                menuObjs.Add (t);
            }
            foreach (EnemyType typ in Enum.GetValues(typeof(EnemyType))) {
                MenuText t = new MenuText (typ.ToString (), Color.Gold, Color.Gray, TEXT_SIZE);
                menuObjs.Add (t);
            }
            MenuText menuNoEnemy = new MenuText ("NoEnemy", Color.Gold, Color.Gray, TEXT_SIZE);
            menuObjs.Add (menuNoEnemy);
            MenuText menuPlayer = new MenuText ("Player", Color.Gold, Color.Blue, TEXT_SIZE);
            menuObjs.Add (menuPlayer);
            MenuText menuSave = new MenuText ("Save", Color.Gold, Color.Red, TEXT_SIZE);
            menuSave.selectedHandler += EventSave;
            menuObjs.Add (menuSave);
            MenuText menuDelete = new MenuText ("Delete", Color.Gold, Color.Red, TEXT_SIZE);
            menuDelete.selectedHandler += EventDelete;
            menuObjs.Add (menuDelete);
            MenuText menuQuit = new MenuText ("Exit", Color.Gold, Color.Red, TEXT_SIZE);
            menuQuit.selectedHandler += delegate(MenuObject obj) {
                backToMenuHandler (obj);
            };
            menuObjs.Add (menuQuit);
            MenuText menuName = new MenuText (name, Color.Green, Color.Green, TEXT_SIZE);
            menuObjs.Add (menuName);
            menu = new Menu (menuObjs, MenuLayout.Horizontal, 5, 700);
            GenerateMenuBackground ();
        }