Example #1
0
 public HypeGame()
 {
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     inputManager = new InputManager();
     Components.Add(inputManager);
 }
Example #2
0
        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;
        }
Example #3
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);
        }
    public void TestServiceConstructor() {
      var services = new GameServiceContainer();

      using (var manager = new InputManager(services)) {
        Assert.IsNotNull(services.GetService(typeof(IInputService)));
      }

      Assert.IsNull(services.GetService(typeof(IInputService)));
    }
Example #5
0
        public FusionGame()
        {
            Graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            Graphics.PreferredBackBufferWidth = 1024;
            Graphics.PreferredBackBufferHeight = 768;

            _gsm = new GameStateManager();

            Input = new InputManager(Services);
        }
Example #6
0
        /// <summary>
        /// Constructs a new input state.
        /// </summary>
        public InputState(Game game)
        {
            CurrentKeyboardStates = new KeyboardState[MaxInputs];
            CurrentGamePadStates = new GamePadState[MaxGamePads];

            LastKeyboardStates = new KeyboardState[MaxInputs];
            LastGamePadStates = new GamePadState[MaxGamePads];

            GamePadWasConnected = new bool[MaxGamePads];

            inputManager = new InputManager(game.Services, game.Window.Handle);
            game.Components.Add(inputManager);
        }
Example #7
0
        public ROClient()
        {
            Singleton = this;
            graphics = new GraphicsDeviceManager(this);
            graphics.SynchronizeWithVerticalRetrace = false; // REMOVE ME LATER
            Window.Title = "Ragnarok Online";

            SharedInformation.Initialize(Services, GraphicsDevice);
            Content = SharedInformation.ContentManager;

            try
            {
                Stream s = Content.Load<Stream>(@"data\fb\config\config.xml");
                SharedInformation.Config = Configuration.FromStream(s);
                s.Close();
            }
            catch
            {
                SharedInformation.Config = new Configuration();
            }

            SharedInformation.Config.ReadConfig();

            bgmManager = new BGMManager();
            effectManager = new EffectManager();
            luaManager = new LuaManager();

            inputManager = new Nuclex.Input.InputManager(Services, Window.Handle);

            guiManager = new GuiManager(this);
            guiManager.DrawOrder = 1000;

            Components.Add(inputManager);
            Components.Add(guiManager);
            Components.Add(new FPSCounter(this)); // REMOVE ME LATER

            IsFixedTimeStep = false; // REMOVE ME LATER

            Services.AddService(typeof(InputManager), inputManager);
            Services.AddService(typeof(GuiManager), guiManager);
            Services.AddService(typeof(EffectManager), effectManager);
            Services.AddService(typeof(BGMManager), bgmManager);
            Services.AddService(typeof(LuaManager), luaManager);

            graphics.PreferredBackBufferWidth = SharedInformation.Config.ScreenWidth;
            graphics.PreferredBackBufferHeight = SharedInformation.Config.ScreenHeight;
            graphics.ApplyChanges();

            netState = new NetworkState();
        }
Example #8
0
File: gxtaGame.cs Project: 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);
     }
 }
Example #9
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";
        }
Example #10
0
        public InputHandler(Game game)
            : base(game)
        {
            _inputManager = new InputManager(game.Services);

            _keyboardState = Keyboard.GetState();

            _gamePadStates = new GamePadState[Enum.GetValues(typeof(PlayerIndex)).Length];
            _diStates = new GamePadState[Enum.GetValues(typeof(ExtendedPlayerIndex)).Length];

            foreach (PlayerIndex index in Enum.GetValues(typeof(PlayerIndex)))
                _gamePadStates[(int)index] = GamePad.GetState(index);

            foreach (ExtendedPlayerIndex index in Enum.GetValues(typeof(ExtendedPlayerIndex)))
                _diStates[(int)index] = _inputManager.GetGamePad(index).GetState();

            _mouseState = Mouse.GetState();
        }
Example #11
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
        }
Example #12
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();

            // get GameStateManager up and running
            gameStateManager = new GameStateManager(Services);
            Components.Add(gameStateManager);
            gameStateManager.UpdateOrder = 200;
            gameStateManager.DrawOrder = 200;

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

            input.GetKeyboard().KeyPressed += HandleKeyPress;

            // instantiate world
            world = new World(Services, serverLink);
            world.UpdateOrder = 500;
            world.DrawOrder = 500;
            Components.Add(world);

            // 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  AudioManager 
            audioManager = new AudioManager(this);

        }
Example #13
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;
             */
        }
Example #14
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;
        }
Example #15
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);
        }
Example #16
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();
        }
Example #17
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));
            }
        }
 public void TestDefaultConstructor() {
   using (var manager = new InputManager()) {
     Assert.IsNotNull(manager); // nonsense, avoids compiler warning
   }
 }
 public void TestUpdateViaIUpdateable() {
   using (var manager = new InputManager()) {
     ((IUpdateable)manager).Update(new GameTime());
   }
 }
 public void TestEnabledProperty() {
   using (var manager = new InputManager()) {
     Assert.IsTrue(((IUpdateable)manager).Enabled);
   }
 }
 public void TestInitializeGameComponent() {
   using (var manager = new InputManager()) {
     ((IGameComponent)manager).Initialize();
   }
 }
    public void TestChangeUpdateOrder() {
      using (Mockery mockery = new Mockery()) {
        using (var manager = new InputManager()) {
          IUpdateableSubscriber updateable = mockery.NewMock<IUpdateableSubscriber>();
          manager.EnabledChanged += updateable.EnabledChanged;
          manager.UpdateOrderChanged += updateable.UpdateOrderChanged;

          Expect.Once.On(updateable).Method("UpdateOrderChanged").WithAnyArguments();
          manager.UpdateOrder = 123;
          Assert.AreEqual(123, manager.UpdateOrder);

          manager.UpdateOrderChanged -= updateable.UpdateOrderChanged;
          manager.EnabledChanged -= updateable.EnabledChanged;
        }

        mockery.VerifyAllExpectationsHaveBeenMet();
      }
    }
 public void TestGetDirectInputGamePad() {
   using (var manager = new InputManager()) {
     Assert.IsNotNull(manager.GetGamePad(ExtendedPlayerIndex.Five));
   }
 }
 public void TestGetXinputGamePad() {
   using (var manager = new InputManager()) {
     Assert.IsNotNull(manager.GetGamePad(PlayerIndex.One));
   }
 }
 public void TestGetChatPad() {
   using (var manager = new InputManager()) {
     Assert.IsNotNull(manager.GetKeyboard(PlayerIndex.One));
   }
 }
 public void TestGetKeyboard() {
   using (var manager = new InputManager()) {
     Assert.IsNotNull(manager.GetKeyboard());
   }
 }
Example #27
0
        /// <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()
        {
            // load settings file
            LoadSettings();

            InitializeGraphics();

            GameStates = new GameStateManager(Services);
            Input = new InputManager(Services);
            Services.AddService(typeof(ContentManager), Content);

            GameStates.Initialize();

            base.Initialize();
        }
 public void TestMiceCollection() {
   using (var manager = new InputManager()) {
     Assert.Greater(manager.Mice.Count, 0);
   }
 }
 public void TestGamePadsCollection() {
   using (var manager = new InputManager()) {
     Assert.Greater(manager.GamePads.Count, 0);
   }
 }
 public void TestSnapshots() {
   using (var manager = new InputManager()) {
     Assert.AreEqual(0, manager.SnapshotCount);
     manager.TakeSnapshot();
     Assert.AreEqual(1, manager.SnapshotCount);
     manager.Update();
     Assert.AreEqual(0, manager.SnapshotCount);
   }
 }