예제 #1
0
        private ButtonControl joinButton, helpButton, quitButton; // the buttons

        public MainMenu(Game game, GameStateManager gameStateManager, GuiManager gui, InputManager input)
            : base(gameStateManager)
        {
            // load textures
            // this can probably go in OnEntered()
            bg = game.Content.Load<Texture2D>("textures/menu/greentank");

            // stays in constructor
            this.gameStateManager = gameStateManager;
            this.game = game;
            this.gui = gui;
            this.input = input;

            // the following code can probably go in OnEntered() as well
            graphicsDevice = game.GraphicsDevice;
            spriteBatch = new SpriteBatch(graphicsDevice);
            
            Viewport viewport = game.GraphicsDevice.Viewport;
            mainMenuScreen = new Screen(viewport.Width, viewport.Height);

            gui.Screen = mainMenuScreen;
            mainMenuScreen.Desktop.Bounds = new UniRectangle(new UniScalar(0.0f, 0.0f), new UniScalar(0.0f, 0.0f),
                                                        new UniScalar(1.0f, 0.0f), new UniScalar(1.0f, 0.0f));
            InitializeComponents();

            joinButton.Pressed += new EventHandler(joinButton_Pressed);
            helpButton.Pressed += new EventHandler(helpButton_Pressed);
            quitButton.Pressed += new EventHandler(quitButton_Pressed);
        }
예제 #2
0
파일: Game.cs 프로젝트: apeape/GameClient
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            input = new InputManager(Services, Window.Handle);
            gui = new GuiManager(Services);
            Content.RootDirectory = "Content";

            var capturer = new Nuclex.UserInterface.Input.DefaultInputCapturer(input);
            capturer.ChangePlayerIndex(ExtendedPlayerIndex.Five);
            gui.InputCapturer = capturer;

            // Automatically query the input devices once per update
            Components.Add(input);

            // You can either add the GUI to the Components collection to have it render
            // automatically, or you can call the GuiManager's Draw() method yourself
            // at the appropriate place if you need more control.
            Components.Add(gui);

            IsMouseVisible = true;
            Window.AllowUserResizing = true;

            graphics.PreferredBackBufferWidth = 1024;
            graphics.PreferredBackBufferHeight = 768;
        }
예제 #3
0
        protected FusionGameState(FusionGame game)
        {
            Game = game;

            _spriteBatch = (SpriteBatch) game.Services.GetService(typeof (SpriteBatch));

            Gui = new GuiManager(Game.Graphics, Game.Input)
            {
                Screen = new Screen(game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height)
            };

            Gui.Screen.Desktop.Bounds = new UniRectangle(
              new UniScalar(0.0F, 25.0F), new UniScalar(0.0F, 25.0F),
              new UniScalar(1.0f, -50.0F), new UniScalar(1.0f, -50.0F)
            );

            Gui.Initialize();

            Gui.Visualizer = FlatGuiVisualizer.FromFile(game.Services, "Content/menu_gui.xml");
            ((FlatGuiVisualizer)Gui.Visualizer).RendererRepository.AddAssembly(typeof(FlatImageButtonControlRenderer).Assembly);
            ((FlatGuiVisualizer)Gui.Visualizer).RendererRepository.AddAssembly(typeof(FlatTiledIconControlRenderer).Assembly);

            Gui.UpdateOrder = 1000;

            Components = new GameComponentCollection { Gui };
        }
예제 #4
0
파일: gxtaGame.cs 프로젝트: Loko/GXT
 public gxtaGame()
 {
     try
     {
         this.gdm = new GraphicsDeviceManager(this);
         this.input = new InputManager(Services, Window.Handle);
         this.gui = new GuiManager(Services);
         Content.RootDirectory = "Content";
         IsMouseVisible = true;
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
예제 #5
0
        public GuiManager(QSGame game)
            : base(game)
        {
            this.game = game;

            // Add this to the game service list
            this.game.Services.AddService(typeof(GuiManager), this);

            this.gui   = new Nuclex.UserInterface.GuiManager(this.game.Services);
            this.input = new Nuclex.Input.InputManager(this.game.Services, game.Window.Handle);

            // The Nuclex UserInterface requires its own input handling setup. For now
            // this engine will use Nuclex's input handling for GUI, but it may be replaced
            // in the future if needed.
            this.game.Services.AddService(typeof(Nuclex.Input.InputManager), this.input);
        }
예제 #6
0
        public BattleBoardLayer(Torch.Scene scene, Torch.Object parent)
            : base(scene, parent)
        {
            _gui = new GuiManager(
                (GraphicsDeviceManager)Game.Services.GetService(typeof(IGraphicsDeviceManager)),
                (IInputService)Game.Services.GetService(typeof(IInputService))
            );
            _gui.DrawOrder = 0;
            _gui.Initialize();

            _gui.Visualizer = FlatGuiVisualizer.FromFile(Game.Services, "Content/Gui/main_gui.xml");
            ((FlatGuiVisualizer)_gui.Visualizer).RendererRepository.AddAssembly(typeof(FlatGridCellControlRenderer).Assembly);

            Components.Add(_gui);

            ((IInputService)Game.Services.GetService(typeof(IInputService))).GetMouse().MouseButtonPressed += OnMouseButtonPressed;
        }
예제 #7
0
        public PandaPanic()
        {
            this.graphics = new GraphicsDeviceManager(this);
            this.input = new InputManager(Services, Window.Handle);
            this.gui = new Nuclex.UserInterface.GuiManager(Services);

            Components.Add(input);
            // You can either add the GUI to the Components collection to have it render
            // automatically, or you can call the GuiManager's Draw() method yourself
            // at the appropriate place if you need more control.
            Components.Add(this.gui);
            
            // It's a good idea to show the mouse if the user is supposed to click on
            // the buttons in the GUI :)
            IsMouseVisible = true;

            Content.RootDirectory = "Content";
        }
예제 #8
0
        /// <summary>
        /// Creates a new Director instance using the specified Game.
        /// </summary>
        /// <param name="game">Game instance for the Director to use.</param>
        /// <param name="preferredResolution">Preferred resolution for game graphics.</param>
        /// <remarks>Protected to prevent instantiating Director instances outside of the static SharedDirector property.</remarks>
        protected Director(Game game, Vector2 preferredResolution)
            : base(game)
        {
            if (preferredResolution == null)
            {
                throw new ArgumentNullException("defaultResolution");
            }

            PreferredResolution = preferredResolution;
            DisplaySize = preferredResolution;
            DisplayCenter = new Vector2(DisplaySize.X / 2.0f, DisplaySize.Y / 2.0f);
            ResolutionIndependent = false;
            TransformationMatrix = new Matrix();

            EntityWorld = new EntityWorld(game);
            RenderSystem renderSystem = EntityWorld.SystemManager.SetSystem<RenderSystem>(new RenderSystem(), SystemExecutionType.Draw);
            AnimationSystem animationSystem = EntityWorld.SystemManager.SetSystem<AnimationSystem>(new AnimationSystem(), SystemExecutionType.Update);
            MovementSystem movementSystem = EntityWorld.SystemManager.SetSystem<MovementSystem>(new MovementSystem(), SystemExecutionType.Update);
            ControlSystem controlSystem = EntityWorld.SystemManager.SetSystem<ControlSystem>(new ControlSystem(), SystemExecutionType.Update);

            MessageBoard = new MessageBoard(game);
            GameStateManager = new GameStateManager(game.Services);
            InputManager = new InputManager(game.Services);
            InputBindingManager = new InputBindingManager(game);
            TextureManager = new TextureManager(game.Content);
            FontManager = new FontManager(game.Content);
            GuiManager = new GuiManager(game.Services);

            game.Components.Add(EntityWorld);
            game.Components.Add(MessageBoard);
            game.Components.Add(InputManager);
            game.Components.Add(InputBindingManager);

            game.Services.AddService(typeof(IEntityWorld), EntityWorld);
            game.Services.AddService(typeof(IMessageBoard), MessageBoard);
            game.Services.AddService(typeof(IInputBindingManager), InputBindingManager);
            game.Services.AddService(typeof(ITextureManager), TextureManager);
            game.Services.AddService(typeof(IFontManager), FontManager);
            #if DEBUG
            DebugDisplay = new DebugDisplay(game);
            game.Components.Add(DebugDisplay);
            game.Services.AddService(typeof(IDebugDisplay), DebugDisplay);
            #endif
        }
예제 #9
0
        public Game1()
        {
            this.graphics = new GraphicsDeviceManager(this);
            this.input = new InputManager(Services, Window.Handle);
            this.gui = new GuiManager(Services);
            this.manager = new GameStateManager(Services);

            Components.Add(this.input);
            Components.Add(this.gui);
            this.gui.DrawOrder = 1000;
            Components.Add(this.manager);

            IsMouseVisible = true;
            quit = false;
            music = null;
            cursorTrigger = false;

            Content.RootDirectory = "Content";
            Window.Title = "GunBond";
            MediaPlayer.IsRepeating = true;
        }
예제 #10
0
        public JoinMenu(Game game, GameStateManager gameStateManager, GuiManager gui, InputManager input)
            : base(gameStateManager)
        {
            this.game = game;
            this.gameStateManager = gameStateManager;
            this.gameService = new GameServiceContainer();
            this.gui = gui;
            this.input = input;

            spriteBatch = new SpriteBatch(game.GraphicsDevice);
            bg = game.Content.Load<Texture2D>("textures/menu/ScoutTank");
            
            Viewport viewport = game.GraphicsDevice.Viewport;
            joinScreen = new Screen(viewport.Width, viewport.Height);
            gui.Screen = joinScreen;

            joinScreen.Desktop.Bounds = new UniRectangle(new UniScalar(0.0f, 0.0f), new UniScalar(0.0f, 0.0f),
                                                        new UniScalar(1.0f, 0.0f), new UniScalar(1.0f, 0.0f));
            InitializeComponents();

            joinButton.Pressed += new EventHandler(joinButton_Pressed);
            backButton.Pressed += new EventHandler(backButton_Pressed);
        }
예제 #11
0
파일: Scene.cs 프로젝트: HaKDMoDz/armadillo
        // new
        protected Scene(Game game)
        {
            Game = game;

            _spriteBatch = (SpriteBatch) game.Services.GetService(typeof (SpriteBatch));

            IsInitialized = false;
            IsRunning = true;

            Gui = new GuiManager(
                (GraphicsDeviceManager)Game.Services.GetService(typeof(IGraphicsDeviceManager)),
                (IInputService)Game.Services.GetService(typeof(IInputService)))
            {
                Screen = new Screen(game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height)
            };

            Gui.Screen.Desktop.Bounds = new UniRectangle(
              new UniScalar(0.01F, 0.0F), new UniScalar(0.01F, 0.0F),
              new UniScalar(0.98F, 0.0F), new UniScalar(0.98F, 0.0F)
            );

            Gui.DrawOrder = 100;
        }
예제 #12
0
        public User(Game game, Ecosystem ecosystem)
        {
            this.ecosystem = ecosystem;
            this.game = game;
            this.baseGame = (CircleOfLifeGame)game;

            //Initialize Nuclex Managers
            state = new Nuclex.Game.States.GameStateManager(game.Services);
            input = new InputManager(game.Services);
            gui = new GuiManager(game.Services);

            //Add nuclex managers to game components
            game.Components.Add(state);
            game.Components.Add(input);
            game.Components.Add(gui);

            //initialize input device objects
            keyboard = input.GetKeyboard();
            mouse = input.GetMouse();

            hudDestination = new Rectangle(0, (int)(baseGame.graphics.PreferredBackBufferHeight * 0.9f), baseGame.graphics.PreferredBackBufferWidth, (int)(baseGame.graphics.PreferredBackBufferHeight * 0.1f));
            //meh
            Initialize();
        }
예제 #13
0
        public Game1()
        {
            handler =
                new UnhandledExceptionEventHandler(Target);
            try
            {
                outWriter.WriteLine(DateTime.Now.ToLongDateString() + ", " + DateTime.Now.ToLongTimeString());
                PrintToOutput("Starting Program");
                graphics = new GraphicsDeviceManager(this);
                Content.RootDirectory = "Content";
                guiManager = new GuiManager(Services);
                inputManager = new InputManager(Services, Window.Handle);
                Components.Add(this.inputManager);
                Components.Add(this.guiManager);
                this.guiManager.DrawOrder = 1000;
                IsMouseVisible = true;

                PrintToOutput("Finished Starting Program");
            }
            catch (Exception e)
            {
                handler.Invoke(e, new UnhandledExceptionEventArgs(e, true));
            }
        }
예제 #14
0
        public AngryTanks()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // increase update rate to 120 Hz
            IsFixedTimeStep = true;
            TargetElapsedTime = new TimeSpan(0, 0, 0, 0, (int)(1000 / 120));

            // instantiate server link
            serverLink = new ServerLink();

            // down with xna's input!
            Input = new InputManager(Services, Window.Handle);
            Services.AddService(typeof(InputManager), Input);
            Components.Add(Input);
            Input.UpdateOrder = 100;

            gameServices = new GameServiceContainer();
            gui = new GuiManager(gameServices, graphics, Input);
            Services.AddService(typeof(GuiManager), gui);
            Components.Add(gui);

            IsMouseVisible = true;
            //Input.GetKeyboard().KeyPressed += HandleKeyPress;

            // instantiate game console
            //gameConsole = new GameConsole(this, new Vector2(0, 400), new Vector2(800, 200),
            //                              new Vector2(10, 10), new Vector2(10, 10), new Color(255, 255, 255, 100));
            //Components.Add(gameConsole);
            //gameConsole.UpdateOrder = 1000;
            //gameConsole.DrawOrder = 1000;

            //gameConsole.PromptReceivedInput += HandlePromptInput;

            // instantiate the world
            /* disabling for testing
            world = new World(this, serverLink);
            Components.Add(world);
            world.UpdateOrder = 100;
            world.DrawOrder = 100;
             */
        }
예제 #15
0
        public ChimeraGame(string firstLevel)
        {
            mFirstLevelName = firstLevel;

            this.Window.AllowUserResizing = true;
            this.Window.ClientSizeChanged += ResizedWindow;

            Game = this;
            Graphics = new GraphicsDeviceManager(this);
            Graphics.PreferredBackBufferWidth = 1280;
            Graphics.PreferredBackBufferHeight = 720;
            Graphics.PreferMultiSampling = true;
            //Graphics.ToggleFullScreen();

            Content.RootDirectory = "Content";

            forward = new KeyInputAction(PlayerIndex.One, InputAction.ButtonAction.Down, Microsoft.Xna.Framework.Input.Keys.W);
            celShading = new KeyInputAction(PlayerIndex.One, InputAction.ButtonAction.Pressed, Microsoft.Xna.Framework.Input.Keys.F2);

            // DEBUG
            mDebugScreen = new Nuclex.UserInterface.Screen(Graphics.PreferredBackBufferWidth, Graphics.PreferredBackBufferHeight);
            mDebugGUI = new GuiManager(Services);
            mDebugGUI.Screen = mDebugScreen;
            DebugConsole debugConsole = new DebugConsole();
            mDebugScreen.Desktop.Children.Add(debugConsole);
            mDebugInput = new InputManager(Services, Window.Handle);

            Components.Add(mDebugInput);
            Components.Add(mDebugGUI);
            mDebugGUI.DrawOrder = 1000;

            mDebugScreen.FocusedControl = DebugConsole.ConsoleInput;
            DebugConsole.AddCommand("exit", new DebugConsole.ConsoleCommand(ExitConsoleCommand));
            DebugConsole.AddCommand("enableAllParts", new DebugConsole.ConsoleCommand(EnableParts));
            DebugConsole.AddCommand("partMenu", new DebugConsole.ConsoleCommand(PartMenuCommand));
            DebugConsole.AddCommand("resizeShadowCascade", new DebugConsole.ConsoleCommand(ResizeShadowCascadesCommand));
            DebugConsole.AddCommand("collisions", new DebugConsole.ConsoleCommand(CollisionMeshCommand));
            DebugConsole.AddCommand("debug", new DebugConsole.ConsoleCommand(DebugConsoleCommand));
            DebugConsole.AddCommand("visualizeCascades", new DebugConsole.ConsoleCommand(VisualizeCascadesCommand));
            DebugConsole.AddCommand("celShading", new DebugConsole.ConsoleCommand(CelShadingCommand));
            DebugConsole.AddCommand("outlining", new DebugConsole.ConsoleCommand(OutliningCommand));
            DebugConsole.AddCommand("drawBoundingBoxes", new DebugConsole.ConsoleCommand(BoundingBoxCommand));
            DebugConsole.AddCommand("BirdsEyeView", new DebugConsole.ConsoleCommand(BirdsEyeViewCommand));
            DebugConsole.AddCommand("BEV", new DebugConsole.ConsoleCommand(BirdsEyeViewCommand));
            DebugConsole.AddCommand("level", new DebugConsole.ConsoleCommand(LoadLevel));
            DebugConsole.AddCommand("toggleShadows", new DebugConsole.ConsoleCommand(ToggleShadows));
            DebugConsole.AddCommand("wireframe", new DebugConsole.ConsoleCommand(WireframeCommand));
            DebugConsole.Hide();
            // END

            CollisionRules.CollisionGroupRules.Add(new CollisionGroupPair(Sensor.SensorGroup, CollisionRules.DefaultDynamicCollisionGroup), CollisionRule.NoSolver);
            CollisionRules.CollisionGroupRules.Add(new CollisionGroupPair(Sensor.SensorGroup, CollisionRules.DefaultKinematicCollisionGroup), CollisionRule.NoSolver);
            CollisionRules.CollisionGroupRules.Add(new CollisionGroupPair(Sensor.SensorGroup, Projectile.ProjectileGroup), CollisionRule.NoBroadPhase);
            CollisionRules.CollisionGroupRules.Add(new CollisionGroupPair(Sensor.SensorGroup, Sensor.SensorGroup), CollisionRule.NoBroadPhase);
            CollisionRules.CollisionGroupRules.Add(new CollisionGroupPair(Sensor.SensorGroup, TerrainPhysics.TerrainPhysicsGroup), CollisionRule.NoBroadPhase);
            CollisionRules.CollisionGroupRules.Add(new CollisionGroupPair(Sensor.SensorGroup, InvisibleWall.InvisibleWallGroup), CollisionRule.NoBroadPhase);

            CollisionRules.CollisionGroupRules.Add(new CollisionGroupPair(Projectile.SensorProjectileGroup, CollisionRules.DefaultDynamicCollisionGroup), CollisionRule.NoSolver);
            CollisionRules.CollisionGroupRules.Add(new CollisionGroupPair(Projectile.SensorProjectileGroup, CollisionRules.DefaultKinematicCollisionGroup), CollisionRule.NoSolver);
            CollisionRules.CollisionGroupRules.Add(new CollisionGroupPair(Projectile.SensorProjectileGroup, Projectile.ProjectileGroup), CollisionRule.NoBroadPhase);
            CollisionRules.CollisionGroupRules.Add(new CollisionGroupPair(Projectile.SensorProjectileGroup, Sensor.SensorGroup), CollisionRule.NoBroadPhase);
            CollisionRules.CollisionGroupRules.Add(new CollisionGroupPair(Projectile.SensorProjectileGroup, Projectile.SensorProjectileGroup), CollisionRule.NoBroadPhase);
            CollisionRules.CollisionGroupRules.Add(new CollisionGroupPair(Projectile.SensorProjectileGroup, InvisibleWall.InvisibleWallGroup), CollisionRule.NoBroadPhase);

            CollisionRules.CollisionGroupRules.Add(new CollisionGroupPair(Wormhole.WormholeGroup, CollisionRules.DefaultDynamicCollisionGroup), CollisionRule.NoSolver);
            CollisionRules.CollisionGroupRules.Add(new CollisionGroupPair(Wormhole.WormholeGroup, CollisionRules.DefaultKinematicCollisionGroup), CollisionRule.NoSolver);
            CollisionRules.CollisionGroupRules.Add(new CollisionGroupPair(Wormhole.WormholeGroup, Projectile.ProjectileGroup), CollisionRule.NoBroadPhase);
            CollisionRules.CollisionGroupRules.Add(new CollisionGroupPair(Wormhole.WormholeGroup, Wormhole.WormholeGroup), CollisionRule.NoBroadPhase);
            CollisionRules.CollisionGroupRules.Add(new CollisionGroupPair(Wormhole.WormholeGroup, TerrainPhysics.TerrainPhysicsGroup), CollisionRule.NoBroadPhase);
            CollisionRules.CollisionGroupRules.Add(new CollisionGroupPair(Wormhole.WormholeGroup, InvisibleWall.InvisibleWallGroup), CollisionRule.NoBroadPhase);
        }