コード例 #1
0
ファイル: Game.cs プロジェクト: calebthompson/pest-control
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            eventQueue = new EventQueue();

            player = new Player(1,this,eventQueue);

            menu = new Menu(eventQueue);
            menuView = new MenuView(GraphicsDevice,menu);

            currentView = menuView;
            currentController = menu;

            base.Initialize();
        }
コード例 #2
0
 public void setChildView(View view)
 {
     childView = view;
 }
コード例 #3
0
ファイル: Game.cs プロジェクト: calebthompson/pest-control
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            player.Update();
            currentController.Update();

            while (!eventQueue.IsQueueEmpty("SYSTEM"))
            {
                Event e = eventQueue.DequeueEvent("SYSTEM");
                switch(e.getName())
                {
                    case "NEW_GAME":
                        world = new World(30, 5000, 5000, 1, eventQueue);
                        worldView = new WorldView(GraphicsDevice,world);
                        worldView.LoadContent(Content);
                        currentController = world;
                        currentView = worldView;
                        break;
                    case "TERMINATE":
                        Exit();
                        break;
                    case "MENU":
                        if (currentController == menu)
                        {
                            if (world == null) break;

                            currentController = world;
                            currentView = worldView;
                        }
                        else
                        {
                            currentController = menu;
                            menuView.setChildView(worldView);
                            currentView = menuView;
                        }
                        break;
                }
            }

            base.Update(gameTime);
        }