Inheritance: IServiceProvider
Exemple #1
0
        public Game()
        {
            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            _gameComponentCollection.ComponentAdded += Handle_gameComponentCollectionComponentAdded;

            // The default for Windows is 480 x 800
            //RectangleF frame = NSScreen.MainScreen.Frame;
            RectangleF frame = new RectangleF(0, 0, Microsoft.Xna.Framework.Graphics.PresentationParameters._defaultBackBufferWidth,
                                              Microsoft.Xna.Framework.Graphics.PresentationParameters._defaultBackBufferHeight);

            //Create a window
            _mainWindow = new NSWindow(frame, NSWindowStyle.Titled | NSWindowStyle.Closable, NSBackingStore.Buffered, true);

            // Perform any other window configuration you desire
            _mainWindow.IsOpaque = true;

            _view      = new GameWindow(frame);
            _view.game = this;

            _mainWindow.ContentView.AddSubview(_view);
            _mainWindow.AcceptsMouseMovedEvents = false;

            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime   = new GameTime();

            //Set the current directory.
            // We set the current directory to the ResourcePath on Mac
            Directory.SetCurrentDirectory(NSBundle.MainBundle.ResourcePath);
        }
Exemple #2
0
        public Game()
        {
            inRun = false;

            isFixedTimeStep = true;

            visibleDrawable   = new List <IDrawable>();
            enabledUpdateable = new List <IUpdateable>();

            components = new GameComponentCollection();
            components.ComponentAdded   += new EventHandler <GameComponentCollectionEventArgs>(GameComponentAdded);
            components.ComponentRemoved += new EventHandler <GameComponentCollectionEventArgs>(GameComponentRemoved);

            services = new GameServiceContainer();

            content = new ContentManager(services);

            gameUpdateTime = new GameTime(TimeSpan.Zero, TimeSpan.Zero, TimeSpan.Zero, TimeSpan.Zero);

            inactiveSleepTime = TimeSpan.FromTicks(0);
            targetElapsedTime = TimeSpan.FromTicks(DefaultTargetElapsedTicks);

            gameHost = new SdlGameHost(this);
            gameHost.EnsureHost();

            isActive = true;
        }
Exemple #3
0
        public Game()
        {
            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            _gameComponentCollection.ComponentAdded += Handle_gameComponentCollectionComponentAdded;
            RectangleF frame = NSScreen.MainScreen.Frame;

            //Create a full-screen window
            _mainWindow = new NSWindow(frame, NSWindowStyle.Titled | NSWindowStyle.Closable, NSBackingStore.Buffered, true);

            // Perform any other window configuration you desire
            _mainWindow.IsOpaque          = true;
            _mainWindow.HidesOnDeactivate = true;

            _view      = new GameWindow(frame);
            _view.game = this;

            _mainWindow.ContentView.AddSubview(_view);
            _mainWindow.AcceptsMouseMovedEvents = true;

            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime   = new GameTime();
        }
Exemple #4
0
        public Game()
        {
            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            _gameComponentCollection.ComponentAdded += Handle_gameComponentCollectionComponentAdded;

            // The default for Windows is 480 x 800
            //RectangleF frame = NSScreen.MainScreen.Frame;
            RectangleF frame = new RectangleF(0, 0, Microsoft.Xna.Framework.Graphics.PresentationParameters._defaultBackBufferWidth,
                                              Microsoft.Xna.Framework.Graphics.PresentationParameters._defaultBackBufferHeight);

            //Create a window
            _mainWindow = new MacGameNSWindow(frame, NSWindowStyle.Titled | NSWindowStyle.Closable, NSBackingStore.Buffered, true);

            // Perform any other window configuration you desire
            _mainWindow.IsOpaque = true;
            _mainWindow.EnableCursorRects();
            _gameWindow      = new GameWindow(frame);
            _gameWindow.game = this;

            _mainWindow.ContentView.AddSubview(_gameWindow);
            _mainWindow.AcceptsMouseMovedEvents = false;
            _mainWindow.Center();
            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime   = new GameTime();

            //Set the current directory.
            // We set the current directory to the ResourcePath on Mac
            Directory.SetCurrentDirectory(NSBundle.MainBundle.ResourcePath);

            //Tao.Sdl.Sdl.SDL_Init(Tao.Sdl.Sdl.SDL_INIT_JOYSTICK);

            // Leave these here for when we implement the Activate and Deactivated
            _mainWindow.DidBecomeKey += delegate(object sender, EventArgs e) {
                //if (!IsMouseVisible)
                //	_gameWindow.HideCursor();
                //Console.WriteLine("BecomeKey");
            };

            _mainWindow.DidResignKey += delegate(object sender, EventArgs e) {
                //if (!IsMouseVisible)
                //	_gameWindow.UnHideCursor();
                //Console.WriteLine("ResignKey");
            };

            _mainWindow.DidBecomeMain += delegate(object sender, EventArgs e) {
                //if (!IsMouseVisible)
                //_gameWindow.HideCursor();
                ////Console.WriteLine("BecomeMain");
            };

            _mainWindow.DidResignMain += delegate(object sender, EventArgs e) {
                //if (!IsMouseVisible)
                //	_gameWindow.UnHideCursor();
                //Console.WriteLine("ResignMain");
            };
        }
Exemple #5
0
        public Game(UIViewController viewController = null)
        {
            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();
            _gameComponentCollection.ComponentAdded += Handle_gameComponentCollectionComponentAdded;

            _mainWindow = new UIWindow(UIScreen.MainScreen.Bounds);

            if (viewController != null)
            {
                _mainWindow.RootViewController = viewController;
            }

            FixupRotationIos7();  // important to get proper _mainWindow bounds right now.

            _view           = new GameWindow(_mainWindow.Bounds, UIScreen.MainScreen.Scale);
            GameWindow.game = this;
            _mainWindow.Add(_view);


            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime   = new GameTime();
        }
Exemple #6
0
        public Game()
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            LaunchParameters = new LaunchParameters();
            Components       = new GameComponentCollection();
            Services         = new GameServiceContainer();
            Content          = new ContentManager(Services);

            updateableComponents        = new List <IUpdateable>();
            currentlyUpdatingComponents = new List <IUpdateable>();
            drawableComponents          = new List <IDrawable>();
            currentlyDrawingComponents  = new List <IDrawable>();

            IsMouseVisible    = false;
            IsFixedTimeStep   = true;
            TargetElapsedTime = TimeSpan.FromTicks(166667);             // 60fps
            InactiveSleepTime = TimeSpan.FromSeconds(0.02);

            hasInitialized = false;
            suppressDraw   = false;
            isDisposed     = false;

            gameTime = new GameTime();

            Window                  = FNAPlatform.CreateWindow();
            Mouse.WindowHandle      = Window.Handle;
            TouchPanel.WindowHandle = Window.Handle;

            FrameworkDispatcher.Update();

            // Ready to run the loop!
            RunApplication = true;
        }
Exemple #7
0
        public Game()
        {
            Game._instance             = this;
            this.LaunchParameters      = new LaunchParameters();
            this._services             = new GameServiceContainer();
            this._components           = new GameComponentCollection();
            this.Content               = new ContentManager((IServiceProvider)this._services);
            this.Platform              = GamePlatform.Create(this);
            this.Platform.Activated   += new EventHandler <EventArgs>(this.OnActivated);
            this.Platform.Deactivated += new EventHandler <EventArgs>(this.OnDeactivated);
            this._services.AddService(typeof(GamePlatform), (object)this.Platform);
            string   str           = string.Empty;
            Assembly entryAssembly = Assembly.GetEntryAssembly();
            AssemblyTitleAttribute assemblyTitleAttribute = (AssemblyTitleAttribute)System.Attribute.GetCustomAttribute(entryAssembly, typeof(AssemblyTitleAttribute));

            if (assemblyTitleAttribute != null)
            {
                str = assemblyTitleAttribute.Title;
            }
            if (string.IsNullOrEmpty(str))
            {
                str = entryAssembly.GetName().Name;
            }
            this.Window.Title = str;
        }
        /// <summary>
        /// Initialisation de XNA et du SharedGraphicsManager
        /// </summary>
        private void InitializeXNA()
        {
            Services = new GameServiceContainer();
            Services.AddService(typeof(IGraphicsDeviceService), new SharedGraphicsDeviceManager());

            Content = new ContentManager(Services);
            Content.RootDirectory = "Content";
        }
    public void Setup() {
      this.mockedGraphicsDeviceService = new MockedGraphicsDeviceService();

      GameServiceContainer services = new GameServiceContainer();
      services.AddService(
        typeof(IGraphicsDeviceService), this.mockedGraphicsDeviceService
      );
      this.testComponent = new GraphicsDeviceDrawableComponent(services);
    }
    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)));
    }
        public Game1()
        {
            Services = new GameServiceContainer();

            _graphicsManager = new SharedGraphicsDeviceManager();
            Services.AddService(typeof(IGraphicsDeviceService), _graphicsManager);
            Content = new ContentManager(Services, "Content");
            Instance = this;
        }
 public SpriteController(SpriteBatch SB, GameController gameController, GameServiceContainer gameServiceContainer, GraphicsDevice graphicsDevice)
 {
     this.gameController = gameController;
     _graphicsDevice = graphicsDevice;
     spriteBatch = SB;
     if (content == null) content = new ContentManager(gameServiceContainer, "Content");
     LoadSprites();
     LoadFonts();
 }
    /// <summary>Initializes a new game state manager</summary>
    /// <param name="gameServices">
    ///   Services container the game state manager will add itself to
    /// </param>
    public GameStateManager(GameServiceContainer gameServices) :
      base(gameServices) {

      this.gameServices = gameServices;
      this.activeGameStates = new Stack<GameState>();

      // Register ourselves as a service
      gameServices.AddService(typeof(IGameStateService), this);
    }
Exemple #14
0
        /// <summary>
        ///     Creates a new instance of the <see cref="Manager" /> class.
        /// </summary>
        internal Manager()
        {
            windows = true;
            services = new GameServiceContainer();

            arguments = new string[0];

            Bootstrap = null;
            Instance = this;
        }
Exemple #15
0
    /// <summary>
    ///   Initializes a new GUI manager using the XNA service container
    /// </summary>
    /// <param name="gameServices">
    ///   Game service container the GuiManager will register itself in and
    ///   to take the services it consumes from.
    /// </param>
    public GuiManager(GameServiceContainer gameServices) {
      this.gameServices = gameServices;

      gameServices.AddService(typeof(IGuiService), this);

      // Do not look for the consumed services yet. XNA uses a two-stage
      // initialization where in the first stage all managers register themselves
      // before seeking out the services they use in the second stage, marked
      // by a call to the Initialize() method.
    }
    /// <summary>Initializs a new mock input manager</summary>
    /// <param name="services">Game service container the manager registers to</param>
    public MockInputManager(GameServiceContainer services) {
      if (services != null) {
        this.gameServices = services;
        this.gameServices.AddService(typeof(IInputService), this);
      }

      setupGamePads();
      setupMouse();
      setupKeyboards();
    }
Exemple #17
0
 public AWGame(GraphicsDeviceService graphicsDeviceService)
 {
     GraphicsDeviceService = graphicsDeviceService;
     Services = new GameServiceContainer();
     if (graphicsDeviceService != null) Services.AddService(typeof(IGraphicsDeviceService), graphicsDeviceService);
     Components = new AWGameComponentCollection();
     GameTime = new AWGameTime();
     _framerateTimer = new AWTimer(() => GameTime.TotalRealTime, TimeSpan.FromSeconds(1)) { SkipPastIntervals = true };
     _frameDrawTimes = new RunningSequenceTimeSpan(TimeSpan.FromSeconds(1));
     _frameDrawStopwatch = new Stopwatch();
 }
Exemple #18
0
        public XnaForms(IntPtr handle, int width, int height)
        {
            deviceManager = new DeviceManager(handle, width, height);

            services = new GameServiceContainer();
            services.AddService(typeof (IGraphicsDeviceService), deviceManager);

            contentManager = new ContentManager(services);

            gameTime = new GameTime();
        }
Exemple #19
0
        public Game()
        {
            _instance        = this;
            LaunchParameters = new LaunchParameters();
            _services        = new GameServiceContainer();
            _components      = new GameComponentCollection();
            Content          = new ContentManager(_services);

            Platform              = GamePlatform.Create(this);
            Platform.Activated   += Platform_Activated;
            Platform.Deactivated += Platform_Deactivated;
            _services.AddService(typeof(GamePlatform), Platform);
        }
Exemple #20
0
        public Game()
        {
            IsTabStop    = true;
            Services     = new GameServiceContainer();
            Components   = new GameComponentCollection();
            Content      = new ContentManager(Services);
            base.Content = (Surface = new DrawingSurface());

            Window = new GameWindow(this);

            Loaded       += new RoutedEventHandler(Game_Loaded);
            Surface.Draw += new EventHandler <DrawEventArgs>(Surface_Draw);
        }
Exemple #21
0
        public Game()
        {
            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            _view      = new WindowsGameWindow();
            _view.Game = this;

            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime   = new GameTime();
        }
Exemple #22
0
        public Game(Activity context)
        {
            contextInstance = context;

            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            view      = new AndroidGameWindow(context);
            view.game = this;
            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime   = new GameTime();
        }
Exemple #23
0
		public Game()
		{

			// Initialize collections
			_services = new GameServiceContainer();
			_gameComponentCollection = new GameComponentCollection();

            _view = new WindowsGameWindow();
			_view.Game = this;
					
			// Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime = new GameTime();
		}
Exemple #24
0
        /****************************************************************************************/
        public static void Initialize(GameServiceContainer Services)
        {
            CoreContainer = new ContentManager(Services);
            CoreContainer.RootDirectory = "Content";
            GameContainer = new ContentManager(Services);
            GameContainer.RootDirectory = "Content";
            PersistantContainer = new ContentManager(Services);
            PersistantContainer.RootDirectory = "Content";
            NULLED_TEXTURE = CoreContainer.Load<Texture2D>(Assets.NULL_TEXTURE);
            mDebug.Initialize(mGraphics.Peek.Device(), CoreContainer, Assets.DEBUG_FONT, Vector2.Zero);

            SunColor = DebugMessage.Initialize(true, Color.White, true, "Sun Color: Calculating...");
            SunIntensity = DebugMessage.Initialize(true, Color.White, true, "Sun Intensity: Calculating...");
            SunPosition = DebugMessage.Initialize(true, Color.White, true, "Sun Position: Calculating...");
        }
Exemple #25
0
        public Game()
        {
            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            //Create a full-screen window
            // TODO _mainWindow = new NSWindow(NSScreen.MainScreen.Frame, NSWindowStyle.Titled, NSBackingStore.Buffered, false);
            _view      = new GameWindow();
            _view.game = this;
            // TODO _mainWindow.Add(_view);

            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime   = new GameTime();
        }
Exemple #26
0
        public Game()
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            LaunchParameters = new LaunchParameters();
            _services        = new GameServiceContainer();
            _components      = new GameComponentCollection();
            _content         = new ContentManager(_services);

            Window = FNAPlatform.CreateWindow();

            AudioDevice.Initialize();

            // Ready to run the loop!
            RunApplication = true;
        }
Exemple #27
0
        public Game()
        {
            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            //Create a full-screen window
            _mainWindow = new UIWindow(UIScreen.MainScreen.Bounds);
            _view       = new GameWindow();
            _view.game  = this;
            _mainWindow.Add(_view);

            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime   = new GameTime();
        }
Exemple #28
0
        public Game()
        {
            _instance = this;

            TitleContainer.Initialize();

            LaunchParameters = new LaunchParameters();
            _services        = new GameServiceContainer();
            _components      = new GameComponentCollection();
            Content          = new ContentManager(_services);

            Platform              = GamePlatform.Create(this);
            Platform.Activated   += OnActivated;
            Platform.Deactivated += OnDeactivated;
            _services.AddService(typeof(GamePlatform), Platform);

            /* Set the window title
             * TODO: Get the title from the WindowsPhoneManifest.xml for WP7 projects
             */
            string windowTitle = string.Empty;

            // When running unit tests this can return null
            Assembly assembly = Assembly.GetEntryAssembly();

            if (assembly != null)
            {
                // Use the Title attribute of the Assembly if possible
                AssemblyTitleAttribute assemblyTitleAtt = (AssemblyTitleAttribute)
                                                          AssemblyTitleAttribute.GetCustomAttribute(
                    assembly,
                    typeof(AssemblyTitleAttribute)
                    );

                if (assemblyTitleAtt != null)
                {
                    windowTitle = assemblyTitleAtt.Title;
                }

                // Otherwise, fallback to the Name of the assembly
                if (string.IsNullOrEmpty(windowTitle))
                {
                    windowTitle = assembly.GetName().Name;
                }
            }

            Window.Title = windowTitle;
        }
Exemple #29
0
        public Game()
        {
            System.Diagnostics.Debug.Assert(contextInstance != null, "Must set Game.Activity before creating the Game instance");
            contextInstance.Game = this;

            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            _content = new ContentManager(_services);

            view      = new AndroidGameWindow(contextInstance);
            view.game = this;
            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime   = new GameTime();
        }
Exemple #30
0
        public static Grid FromBitmap(GameServiceContainer services, string bitmapName)
        {
            var texture = ((ContentManager)services.GetService(typeof(ContentManager))).Load<Texture2D>(bitmapName);
            var grid = new Grid(texture.Width, texture.Height);

            for (var i = 0; i < grid.Size.Width; i++)
            {
                for (var j = 0; j < grid.Size.Height; j++)
                {
                    var c = new Color[1];
                    texture.GetData(0, new Rectangle(i, j, 1, 1), c, 0, 1);
                    grid.Weight[i, j] = (byte)((c[0].R + c[0].G + c[0].B)/3);
                }
            }

            return grid;
        }
Exemple #31
0
        public Game()
        {
            Instance = this;

            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            LaunchParameters = new LaunchParameters();
            _services        = new GameServiceContainer();
            _components      = new GameComponentCollection();
            _content         = new ContentManager(_services);

            Platform              = GamePlatform.Create(this);
            Platform.Activated   += OnActivated;
            Platform.Deactivated += OnDeactivated;
            _services.AddService(typeof(GamePlatform), Platform);

            AudioDevice.Initialize();
        }
Exemple #32
0
        public Game()
        {
            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            _gameComponentCollection.ComponentAdded += Handle_gameComponentCollectionComponentAdded;

            _view      = new GameWindow();
            _view.Game = this;

            // default update rate
            _targetElapsedTime = TimeSpan.FromSeconds(1.0D / FramesPerSecond);

            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime   = new GameTime();
        }
Exemple #33
0
        public Game()
        {
            _instance = this;

            LaunchParameters = new LaunchParameters();
            _services        = new GameServiceContainer();
            _components      = new GameComponentCollection();
            _content         = new ContentManager(_services);

            Platform              = GamePlatform.Create(this);
            Platform.Activated   += OnActivated;
            Platform.Deactivated += OnDeactivated;
            _services.AddService(typeof(GamePlatform), Platform);

#if WINDOWS_STOREAPP && !WINDOWS_PHONE81
            Platform.ViewStateChanged += Platform_ApplicationViewChanged;
#endif
        }
        internal void Initialize(D3D11Host host)
        {
            Services = new GameServiceContainer();

            ServiceLocator.Initialize(Services);

            Artemis.System.EntitySystem.BlackBoard.SetEntry("GraphicsDevice", host.GraphicsDevice);
            Artemis.System.EntitySystem.BlackBoard.SetEntry("ServiceProvider", Services);

            Services.AddService<IGraphicsDeviceService>(host);
            Services.AddService(host.GraphicsDevice);

            _mouse = new MouseService(host);
            Services.AddService<IMouseService>(_mouse);
            _mouse.ButtonDown += OnMouseButtonDown;
            _keyboard = new KeyboardService(host);
            Services.AddService<IKeyboardService>(_keyboard);
            _timer = new TimerService();
            Services.AddService<ITimerService>(_timer);
            Services.AddService(new FastSpriteBatch(host.GraphicsDevice));

            _timer.LastFrameUpdateTime = _gameTime;
            _timer.LastFrameRenderTime = _gameTime;

            SpriteBatch = new SpriteBatch(host.GraphicsDevice);
            Services.AddService(SpriteBatch);

            Content = new ContentManager(Services);
            Content.RootDirectory = Environment.CurrentDirectory;

            SpriteManager = new SpriteManagerService(Content);
            Services.AddService<ISpriteManagerService>(SpriteManager);

            SpriteManager.LoadSpriteSheet("Textures/Hulls.json");

            Host = host;
            World = new EntityWorld(false, false, false);
            int drawDepth = 0;
            World.CreateComponentPool<Transform>(200, 200);
            World.SystemManager.SetSystem(new GridRendererSystem(), Artemis.Manager.GameLoopType.Draw, drawDepth++);
            World.InitializeAll();
            World.CreateCamera(Constants.ActiveCameraTag, Host.GraphicsDevice);
            Emitter = new ParticleEmitterComponent();
        }
Exemple #35
0
        public Game()
        {
            _instance        = this;
            LaunchParameters = new LaunchParameters();
            _services        = new GameServiceContainer();
            _components      = new GameComponentCollection();
            Content          = new ContentManager(_services);

            Platform              = GamePlatform.Create(this);
            Platform.Activated   += OnActivated;
            Platform.Deactivated += OnDeactivated;
            _services.AddService(typeof(GamePlatform), Platform);

#if WINDOWS_STOREAPP
            Platform.ViewStateChanged += Platform_ApplicationViewChanged;
#endif

#if MONOMAC || WINDOWS || LINUX
            // Set the window title.
            // TODO: Get the title from the WindowsPhoneManifest.xml for WP7 projects.
            string windowTitle = string.Empty;

            // When running unit tests this can return null.
            var assembly = Assembly.GetEntryAssembly();
            if (assembly != null)
            {
                //Use the Title attribute of the Assembly if possible.
                var assemblyTitleAtt = ((AssemblyTitleAttribute)AssemblyTitleAttribute.GetCustomAttribute(assembly, typeof(AssemblyTitleAttribute)));
                if (assemblyTitleAtt != null)
                {
                    windowTitle = assemblyTitleAtt.Title;
                }

                // Otherwise, fallback to the Name of the assembly.
                if (string.IsNullOrEmpty(windowTitle))
                {
                    windowTitle = assembly.GetName().Name;
                }
            }

            Window.Title = windowTitle;
#endif
        }
Exemple #36
0
        public Game()
        {
            _instance = this;

            LaunchParameters = new LaunchParameters();
            _services        = new GameServiceContainer();
            _components      = new GameComponentCollection();
            _content         = new ContentManager(_services);

            Platform              = GamePlatform.PlatformCreate(this);
            Platform.Activated   += OnActivated;
            Platform.Deactivated += OnDeactivated;
            _services.AddService(typeof(GamePlatform), Platform);

            // Calling Update() for first time initializes some systems
            FrameworkDispatcher.Update();

            // Allow some optional per-platform construction to occur too.
            PlatformConstruct();
        }
    /// <summary>Initializs a new input manager</summary>
    /// <param name="services">Game service container the manager registers to</param>
    /// <param name="windowHandle">Handle of the game's main window</param>
    public InputManager(GameServiceContainer services, IntPtr windowHandle) {
#if !(XBOX360 || WINDOWS_PHONE)
      this.windowMessageInterceptor = new WindowMessageInterceptor(windowHandle);
#endif

#if !NO_DIRECTINPUT
      if (DirectInputManager.IsDirectInputAvailable) {
        this.directInputManager = new DirectInputManager(windowHandle);
      }
#endif

      setupGamePads();
      setupMouse();
      setupKeyboards();

      if (services != null) {
        this.gameServices = services;
        this.gameServices.AddService(typeof(IInputService), this);
      }
    }
Exemple #38
0
        public Game()
        {
            _instance = this;

            LaunchParameters = new LaunchParameters();
            _services        = new GameServiceContainer();
            _components      = new GameComponentCollection();
            _content         = new ContentManager(_services);

            Platform              = GamePlatform.PlatformCreate(this);
            Platform.Activated   += OnActivated;
            Platform.Deactivated += OnDeactivated;
            _services.AddService(typeof(GamePlatform), Platform);

            // Calling Update() for first time initializes some systems
            FrameworkDispatcher.Update();

#if WINDOWS_STOREAPP && !WINDOWS_PHONE81
            Platform.ViewStateChanged += Platform_ApplicationViewChanged;
#endif
        }
        public void Initialize(GraphicsDeviceManager graphics)
        {
            //Start the log
            Log.Initialize();
            Log.Write("Initializing the engine");
            GraphicsDevice = graphics.GraphicsDevice;
            Blackboard.Set("GraphicsDevice", GraphicsDevice);
            Blackboard.Set("BasicEffect", new BasicEffect(GraphicsDevice));

            Services = new GameServiceContainer();
            Services.AddService(typeof(IGraphicsDeviceManager), graphics);
            Services.AddService(typeof(IGraphicsDeviceService), graphics);

            //Add content manager
            ContentManager = new WaffleCatContentManager(Services);
            ContentManager.RootDirectory = "Content";
            Blackboard.Set("ContentManager", ContentManager);

            if (World == null)
                World = new World();
            World.Initialize();
        }
Exemple #40
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);
        }
Exemple #41
0
        public Game()
        {
            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            //Create a full-screen window
            _mainWindow = new UIWindow (UIScreen.MainScreen.Bounds);
            _view = new GameWindow();
            _view.game = this;
            _mainWindow.Add(_view);

            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime = new GameTime();
        }
Exemple #42
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;
             */
        }
Exemple #43
0
        public Game()
        {
            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            //Create a full-screen window
            // TODO _mainWindow = new NSWindow(NSScreen.MainScreen.Frame, NSWindowStyle.Titled, NSBackingStore.Buffered, false);
            _view = new GameWindow();
            _view.game = this;
            // TODO _mainWindow.Add(_view);

            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime = new GameTime();
        }
        public Engine(DrawingSurface drawingSurface)
        {
            RootControl = (Control)App.Current.RootVisual;

            Asserter.AssertIsNotNull(RootControl, "RootControl");
            Asserter.AssertIsNotNull(drawingSurface, "drawingSurface");

            _drawingSurface = drawingSurface;
            _content = new ContentManager(_gameServices);
            _content.RootDirectory = "Content";
            _totalGameTime = TimeSpan.Zero;
            _accumulatedElapsedGameTime = TimeSpan.Zero;
            _lastFrameElapsedGameTime = TimeSpan.Zero;
            _targetElapsedTime = TimeSpan.FromTicks(166667L);
            _drawState = new DrawState();
            _updateState = new UpdateState();
            _gameServices = new GameServiceContainer();
        }
Exemple #45
0
        public Game()
        {
            // Initialize collections
            _services = new GameServiceContainer ();
            _gameComponentCollection = new GameComponentCollection ();

            _gameComponentCollection.ComponentAdded += Handle_gameComponentCollectionComponentAdded;

            // The default for Windows is 480 x 800
            //RectangleF frame = NSScreen.MainScreen.Frame;
            RectangleF frame = new RectangleF(0,0,Microsoft.Xna.Framework.Graphics.PresentationParameters._defaultBackBufferWidth,
                Microsoft.Xna.Framework.Graphics.PresentationParameters._defaultBackBufferHeight);

            //Create a window
            _mainWindow = new MacGameNSWindow (frame, NSWindowStyle.Titled | NSWindowStyle.Closable, NSBackingStore.Buffered, true);

            // Perform any other window configuration you desire
            _mainWindow.IsOpaque = true;
            _mainWindow.EnableCursorRects();
            _gameWindow = new GameWindow (frame);
            _gameWindow.game = this;

            _mainWindow.ContentView.AddSubview (_gameWindow);
            _mainWindow.AcceptsMouseMovedEvents = false;
            _mainWindow.Center();
            // Initialize GameTime
            _updateGameTime = new GameTime ();
            _drawGameTime = new GameTime ();

            //Set the current directory.
            // We set the current directory to the ResourcePath on Mac
            Directory.SetCurrentDirectory(NSBundle.MainBundle.ResourcePath);

            //Tao.Sdl.Sdl.SDL_Init(Tao.Sdl.Sdl.SDL_INIT_JOYSTICK);

            // Leave these here for when we implement the Activate and Deactivated
            _mainWindow.DidBecomeKey += delegate(object sender, EventArgs e) {
                //if (!IsMouseVisible)
                //	_gameWindow.HideCursor();
                //Console.WriteLine("BecomeKey");
            };

            _mainWindow.DidResignKey += delegate(object sender, EventArgs e) {
                //if (!IsMouseVisible)
                //	_gameWindow.UnHideCursor();
                //Console.WriteLine("ResignKey");
            };

            _mainWindow.DidBecomeMain += delegate(object sender, EventArgs e) {
                //if (!IsMouseVisible)
                    //_gameWindow.HideCursor();
                ////Console.WriteLine("BecomeMain");
            };

            _mainWindow.DidResignMain += delegate(object sender, EventArgs e) {
                //if (!IsMouseVisible)
                //	_gameWindow.UnHideCursor();
                //Console.WriteLine("ResignMain");
            };
        }
Exemple #46
0
        public Game()
        {
            // Initialize collections
            _services = new GameServiceContainer ();
            _gameComponentCollection = new GameComponentCollection ();

            _gameComponentCollection.ComponentAdded += Handle_gameComponentCollectionComponentAdded;

            // The default for Windows is 480 x 800
            //RectangleF frame = NSScreen.MainScreen.Frame;
            RectangleF frame = new RectangleF(0,0,Microsoft.Xna.Framework.Graphics.PresentationParameters._defaultBackBufferWidth,
                Microsoft.Xna.Framework.Graphics.PresentationParameters._defaultBackBufferHeight);

            //Create a window
            _mainWindow = new NSWindow (frame, NSWindowStyle.Titled | NSWindowStyle.Closable, NSBackingStore.Buffered, true);

            // Perform any other window configuration you desire
            _mainWindow.IsOpaque = true;

            _view = new GameWindow (frame);
            _view.game = this;

            _mainWindow.ContentView.AddSubview (_view);
            _mainWindow.AcceptsMouseMovedEvents = false;

            // Initialize GameTime
            _updateGameTime = new GameTime ();
            _drawGameTime = new GameTime ();
        }
Exemple #47
0
        /// <summary>
        ///     Initializes the services.
        /// </summary>
        private void InitializeServices(GameServiceContainer services)
        {
            ResourceContents = new ResourceContentManager(services, "Content");
            services.AddService(typeof (ResourceContentManager), ResourceContents);

            Time = new TimeManager();
            services.AddService(typeof (TimeManager), Time);

            Camera = new CameraManager();
            services.AddService(typeof (CameraManager), Camera);

            Audio = new AudioManager();
            services.AddService(typeof (AudioManager), Audio);

            if (!windows)
            {
                DeviceManager = new GraphicsDeviceManager(Application);
                services.AddService(typeof (GraphicsDeviceManager), DeviceManager);
            }

            Settings = new Settings();
            services.AddService(typeof (Settings), Settings);

            Resources = new ResourceManager(ResourceContents);
            services.AddService(typeof (ResourceManager), Resources);

            Input = new InputManager();
            services.AddService(typeof (InputManager), Input);

            Scenes = new SceneManager();
            services.AddService(typeof (SceneManager), Scenes);

            InitializeExports();
        }
     /// <summary>Initializs a new mocked graphics device service</summary>
     /// <param name="deviceType">Type of graphics device that will be created</param>
     /// <param name="graphicsProfile">Profile the graphics device will be initialized for</param>
     public MockedGraphicsDeviceService(
   DeviceType deviceType, GraphicsProfile graphicsProfile
 )
     {
         this.deviceType = deviceType;
           this.graphicsProfile = graphicsProfile;
           this.serviceContainer = new GameServiceContainer();
           this.serviceContainer.AddService(typeof(IGraphicsDeviceService), this);
     }
Exemple #49
0
        public Game(Activity context)
        {
            contextInstance = context;

            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            view = new AndroidGameWindow(context);
            view.game = this;
            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime = new GameTime();
        }
 public static void Init(GameServiceContainer serviceContainer, string rootDir)
 {
     ContentManager = new ContentManager(serviceContainer);
     ContentManager.RootDirectory = rootDir;
 }
Exemple #51
0
        public Game()
        {
            _instance = this;

            System.Diagnostics.Debug.Assert(contextInstance != null, "Must set Game.Activity before creating the Game instance");
            contextInstance.Game = this;

            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            _content = new ContentManager(_services);

            view = new AndroidGameWindow(contextInstance);
            view.game = this;
            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime = new GameTime();
        }
        public void ProcessKeybindings()
        {
            GameServiceContainer services = new GameServiceContainer();
            ContentManager Content = new ContentManager(services);
            Content.RootDirectory = "Content";

            Game.KeyBindings = Content.Load<KeybindingsConfig>("KeybindingsSettings");
        }