コード例 #1
0
 public WorldView(GraphicsDevice graphicsDevice, World world)
     : base(graphicsDevice)
 {
     assets = new Dictionary<string, Texture2D>();
     this.world = world;
 }
コード例 #2
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);
        }