Ejemplo n.º 1
0
        public Menu(Game game)
            : base(game)
        {
            Console.WriteLine("Menu Constructor");
            this.game            = (Game1)game;
            this.cursorAnimation = new Texture2D[10];
            //if (Game.Services.GetService(typeof(IMenuService)) != null)
            //    Console.WriteLine("IMenuService already exist...BUG");
            Game.Services.AddService(typeof(IMenuService), this);
            //   this.gameLogic = new GameLogic(game);
            //   this.gameLogic.running = true;
            //   Game.Components.Add(this.gameLogic);
            // game.Services.AddService(typeof(GameLogic), this.gameLogic);

            this.font = game.Content.Load <SpriteFont>("SimpleFont");
            //this.menuBackground = game.Content.Load<Texture2D>("bugamove");
            this.menuListBackground = game.Content.Load <Texture2D>("rootmenu");//game.Content.Load<Texture2D>("background");//
            this.scoreBackground    = game.Content.Load <Texture2D>("scorelistbg");

            this.root = new RootMenuItem(this.game.graphics.PreferredBackBufferHeight, this.game.graphics.PreferredBackBufferWidth, null);
            VerticalListMenuContainer list    = new VerticalListMenuContainer("rootmenu", this.menuListBackground, this.font, Color.White, Color.Yellow);
            VerticalListMenuContainer sublist = new VerticalListMenuContainer("Info", this.menuListBackground, this.font, Color.White, Color.Yellow);

            ScoreBoard board = new ScoreBoard(this, this.scoreBackground, this.font, Color.White, Color.Yellow);

            sublist.addChildComponent(board);
            sublist.addChildComponent((new MenuEntryChoice("Credits", null, this.font, Color.White, Color.Yellow)));

            this.root.addChildComponent(list);
            MenuEntryChoice quickPlay = new MenuEntryChoice("New Game", null, this.font, Color.White, Color.Yellow);

            quickPlay.actionPerformed += this.StartLevel;
            this.root.getChild(0).addChildComponent(quickPlay);
            MenuEntryChoice loadGame = new MenuEntryChoice("Load Game", null, this.font, Color.White, Color.Yellow);

            loadGame.actionPerformed += this.LoadGame;
            list.addChildComponent(loadGame);

            MenuEntryChoice exitGame = new MenuEntryChoice("Exit Game", null, this.font, Color.White, Color.Yellow);

            exitGame.actionPerformed += this.ExitGame;
            this.root.getChild(0).addChildComponent(exitGame);

            this.root.getChild(0).addChildComponent(sublist);

            this.soundManager = new MenuSoundManager(game);
            Game.Components.Add(this.soundManager);
            Game.Services.AddService(typeof(MenuSoundManager), this.soundManager);
        }
Ejemplo n.º 2
0
 public void forward()
 {
     //   MenuComponentComposite t = this.currentSelectedComponent;
     try
     {
         goForward();
     }
     catch (NoChildException e)
     {
         if (Menu.soundEnabled)
         {
             MenuSoundManager.playError();
         }
     }
 }
Ejemplo n.º 3
0
        public void down()
        {
            MenuComponentComposite f = this.currentSelectedComponent.getFather();

            if (f != null)
            {
                this.currentSelectedComponent.setFocus(false);
                IList <MenuComponentComposite> sibling = f.getAllChildren();
                this.currentComponentIndex    = (this.currentComponentIndex + 1) % (sibling.Count);
                this.currentSelectedComponent = sibling[this.currentComponentIndex];
                this.currentSelectedComponent.setFocus(true);

                if (Menu.soundEnabled)
                {
                    MenuSoundManager.playMoveDown();
                }
            }
        }
Ejemplo n.º 4
0
 void InitSoundManager()
 {
     _menuSoundManager = gameObject.GetComponent <MenuSoundManager> ();
 }
 void Awake ()
 {
     Instance = this;
 }
 void Awake()
 {
     instance = this;
 }