public void Run()
 {
     objs.Add (menuStart);
     objs.Add (menuEditor);
     objs.Add (menuQuit);
     menu = new Menu (objs, MenuLayout.Vertical);
 }
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            intro = new Intro(this);

            Components.Add(intro);
            menu = new Menu(this);
            menu.Enabled = false;
            menu.Visible = false;
            Components.Add(menu);
            menu.Visible = false;
            map = new Map(this);
            Components.Add(map);
            map.Visible = false;
        }
        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);
        }
Exemple #4
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            credits = Content.Load<Texture2D>("credits");
            splash = Content.Load<Texture2D>("splash");
            splashSpace = Content.Load<Texture2D>("splashspace");
            disclaimerTexture = Content.Load<Texture2D>("disclaimer");
            soundChoice = Content.Load<SoundEffect>("choice");
            soundSelected = Content.Load<SoundEffect>("select");

               // new TeamsParser("Teams.txt").Parse(this, teams /*, scenario2DPainter */);

            mainMenu = new GameMenu.Menu(this);
            mainMenu.textColor = Color.White;
            mainMenu.selectColor = Color.Orange;
            mainMenu.visible = true;

            MenuChoice choice = mainMenu.AddChoice("Play");
            choice.AddChoice("Player vs Player");
            choice.AddChoice("Player vs Computer");

            // match settings
            choice = choice.AddChoice("Settings");
            MenuChoice dur = choice.AddChoice("Full duration (minutes) ");
            dur.AddLeftRightChoices(new string[] { "2", "5", "10", "20" });
            MenuChoice cam = choice.AddChoice("Camera ");
            cam.AddLeftRightChoices(new string[] { "Top" });
            MenuChoice wea = choice.AddChoice("Weather ");
            wea.AddLeftRightChoices(new string[] { "Sunny", "Rainy" });
            MenuChoice dif = choice.AddChoice("Difficulty ");
            dif.AddLeftRightChoices(new string[] { "Normal" });

            // game settings
            choice = mainMenu.AddChoice("Settings");
            MenuChoice scr = choice.AddChoice("Screen ");
            scr.AddChoice("640x480");
            scr.AddChoice("800x600");
            scr.AddChoice("1024x768");
            choice.AddChoice("Toggle Fullscreen");
            MenuChoice sou = choice.AddChoice("Sound ");
            sou.AddLeftRightChoices(new string[] { "On", "Off" });
            MenuChoice cmds = choice.AddChoice("Controls");
            //cmds.AddLeftRightChoices(new string[] { "Player 1", "Player 2" });

            MenuChoice pl1 = cmds.AddChoice("Player 1");
            pl1.AddChoice("Buy the full version!");
            MenuChoice pl2 = cmds.AddChoice("Player 2");
            pl2.AddChoice("Buy the full version!");

            choice = mainMenu.AddChoice("Credits");

            mainMenu.ChoiceExecuted += new Menu.ChoiceExecutedHandler(ChoiceExecuted);
            mainMenu.ChoiceSelected += new Menu.ChoiceSelectedHandler(ChoiceSelected);
        }
Exemple #5
0
        public void ChoiceSelected(object source, Menu.MenuEvent e)
        {
            soundChoice.Play();

            switch (e.choiceString)
            {
                // game settings
                case "Sunny":
                    matchWeather = Weather.sunny; break;
                case "Rainy":
                    matchWeather = Weather.rainy; break;
                case "Top":
                    matchCamera = CameraType.top; break;
                case "Normal":
                    matchDifficulty = Difficulty.normal; break;
                case "2":
                case "5":
                case "10":
                case "20":
                    matchDuration = Convert.ToInt32(e.choiceString) * 60;
                   ; break;
                // sound settings
                case "On":
                    SetSound(1.0f, 0.3f); break;
                case "Off":
                    SetSound(0.0f, 0.0f); break;
            }
        }
Exemple #6
0
        public void ChoiceExecuted(object source, Menu.MenuEvent e)
        {
            soundSelected.Play();

            switch (e.choiceString)
            {
                case "Return":
                    mainMenu.visible = false; break;

                // game type
                case "Player vs Player":
                    matchDifficulty = Difficulty.none;
                    gameStarted = true;

                    Match = new Match(this, (Team)teams[0], (Team)teams[1], matchCamera, matchDifficulty, matchWeather, matchDuration, false /*, scenario, scenario2DPainter, field */);

                    Match.Initialize();
                    Match.LoadContent();

                    break;
                case "Player vs Computer":
                    gameStarted = true;

                    Match = new Match(this, (Team)teams[0], (Team)teams[1], matchCamera, matchDifficulty, matchWeather, matchDuration, true /*, scenario, scenario2DPainter, field */);

                    Match.Initialize();
                    Match.LoadContent();

                    break;

                case "Credits":
                    showCredits = true; break;

                // screen resolution
                case "Toggle Fullscreen":
                    screenFull = !screenFull;
                    InitGraphicsMode(screenWidth, screenHeight, screenFull); break;
                case "640x480":
                    screenWidth = 640;
                    screenHeight = 480;
                    InitGraphicsMode(screenWidth, screenHeight, screenFull); break;
                case "800x600":
                    screenWidth = 800;
                    screenHeight = 600;
                    InitGraphicsMode(screenWidth, screenHeight, screenFull); break;
                case "1024x768":
                    screenWidth = 1024;
                    screenHeight = 768;
                    InitGraphicsMode(screenWidth, screenHeight, screenFull); break;
                }
        }
 void EventSave(MenuObject obj)
 {
     List<MenuObject > objs = new List<MenuObject> ();
     MenuTextEntry nameMenuTextEntry = new MenuTextEntry (42, Color.Black, name);
     nameMenuTextEntry.escapeHandler += EventNameEscape;
     nameMenuTextEntry.selectedHandler += EventNameSave;
     objs.Add (nameMenuTextEntry);
     nameMenu = new Menu (objs, MenuLayout.Vertical, 10,
         Constants.Constants.HEIGHT / 2);
     //nameMenu.selectChangeTime = 0.5f;
 }
 void EventNameSave(MenuObject obj)
 {
     MenuTextEntry tE = (MenuTextEntry)obj;
     name = tE.text;
     MenuText t = (MenuText)menu.objects [menu.objects.Count - 1];
     t.text = name;
     t.colourSelected = Color.Green;
     t.colourNotSelected = Color.Green;
     t.RenderText ();
     menu.GenerateWidth ();
     GenerateMenuBackground ();
     menu.lastSelectChange = -0.2f;
     nameMenu = null;
     map.ToXML (name, vecPlayer, enemies);
 }
 void EventNameEscape(MenuObject obj)
 {
     nameMenu = null;
 }
        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 ();
        }