Пример #1
0
 public DebugManager(Game game, Camera camera, ChunkCache chunkCache, SpriteFont debugFont)
     : base(game)
 {
     m_graphs = new GraphManager(game);
     m_debugger = new InGameDebugger(game, camera);
     var statistics = new Statistics(game, chunkCache);
     m_components = new GameComponentCollection
     {
         m_debugger,
         new DebugBar(game, statistics, chunkCache),
         statistics,
         m_graphs,
         new GameConsole(game,  new SpriteBatch(game.GraphicsDevice), new GameConsoleOptions
         {
             Font = debugFont,
             FontColor = Color.LawnGreen,
             Prompt = ">",
             PromptColor = Color.Crimson,
             CursorColor = Color.OrangeRed,
             BackgroundColor = Color.Black*0.8f,
             PastCommandOutputColor = Color.Aqua,
             BufferColor = Color.Gold
         }, m_debugger.ToggleInGameDebugger)
     };
 }
Пример #2
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 };
        }
Пример #3
0
        //public List<DrawableGameComponent> _solids { get; set; }
        public Room01(Game game, Point loc, int hack)
        {
            _hack = hack;
            _location = loc;
            _game = game;
            _spriteBatch = game.Services.GetService<SpriteBatch>();
            _components = game.Services.GetService<GameComponentCollection>();

            int m1;
            Int16 m2;
            if (hack == 3)
            {
                m1 = 2;
                m2 = 3;
                RoomType = "big";
            }
            else
            {
                m1 = 1;
                m2 = 1;
                RoomType = "small";
            }

            _solids = new List<Rectangle>();
            _position = new Vector2(0 + _location.X*Settings.Screensize.X, 0 + _location.Y*Settings.Screensize.Y);
            Bounds = new Rectangle((int) _position.X, (int) _position.Y, 800*m1, 600*m2);
            drawwalls();
        }
Пример #4
0
 public Screen(Game game, SpriteBatch spriteBatch, Action<ScreenManager.GameScreen> navigateToScreen)
     : base(game)
 {
     this.game = game;
     this.spriteBatch = spriteBatch;
     this.navigateToScreen = navigateToScreen;
     ScreenGameComponents = new GameComponentCollection();
 }
Пример #5
0
 public Scene6(Game game, ContentManager content, GameComponentCollection components)
     : base(game, content, components)
 {
     Components = components;
     Content = content;
     colorList = GameTools.elementColors(colorList);
     gameStorage = new GameData("lobby");
 }
Пример #6
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_isDisposed)
            {
                if (disposing)
                {
                    // Dispose loaded game components
                    for (int i = 0; i < _components.Count; i++)
                    {
                        var disposable = _components[i] as IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                    _components = null;

                    if (Content != null)
                    {
                        Content.Dispose();
                        Content = null;
                    }

                    if (_graphicsDeviceManager != null)
                    {
                        (_graphicsDeviceManager as GraphicsDeviceManager).Dispose();
                        _graphicsDeviceManager = null;
                    }

                    if (Platform != null)
                    {
                        Platform.Activated   -= OnActivated;
                        Platform.Deactivated -= OnDeactivated;
                        _services.RemoveService(typeof(GamePlatform));
#if WINDOWS_STOREAPP
                        Platform.ViewStateChanged -= Platform_ApplicationViewChanged;
#endif
                        Platform.Dispose();
                        Platform = null;
                    }

                    Effect.FlushCache();
                    ContentTypeReaderManager.ClearTypeCreators();

                    SoundEffect.PlatformShutdown();

                    BlendState.ResetStates();
                    DepthStencilState.ResetStates();
                    RasterizerState.ResetStates();
                    SamplerState.ResetStates();
                }
#if ANDROID
                Activity = null;
#endif
                _isDisposed = true;
                _instance   = null;
            }
        }
Пример #7
0
        public GameScreen()
        {
            components = new GameComponentCollection();
            components.ComponentAdded += new EventHandler<GameComponentCollectionEventArgs>(ComponentAdded);
            components.ComponentRemoved += new EventHandler<GameComponentCollectionEventArgs>(ComponentRemoved);

            updateOrdered = new List<GameComponent>();
            drawOrdered = new List<DrawableGameComponent>();
        }
Пример #8
0
        public Scene5(Game game, ContentManager content, GameComponentCollection components)
            : base(game, content, components)
        {
            Components = components;
            Content = content;
            colorList = GameTools.elementColors(colorList);
            gameStorage = new GameData("lobby");

            // TODO: Construct any child components here
        }
        public MasterScene(Game game, ContentManager content, GameComponentCollection components)
            : base(game)
        {
            Components = components;
            Content = content;

            vibration  = VibrateController.Default;
            gameMS = game;
            // TODO: Construct any child components here
        }
Пример #10
0
        private int wichLevel = 0, sceneProgression=0, timer = 0; //lobby = 0

        #endregion Fields

        #region Constructors

        public Lobby(Game game, ContentManager content, GameComponentCollection components)
            : base(game)
        {
            Components = components;

            Content = content;

            sceneProgression = gameData.getProgression("lobby");
            vibration = VibrateController.Default;
        }
Пример #11
0
 public Scene1(Game game, ContentManager content, GameComponentCollection components)
     : base(game, content, components)
 {
     Components = components;
     Content = content;
     colorList = GameTools.elementColors(colorList);
     gameStorage = new GameData("lobby");
     if (gameStorage.fileExists(gameStorage.FileName) == false)
         gameStorage.saveProgression(0);
 }
Пример #12
0
        public MasterScene(Game game, ContentManager content, GameComponentCollection components)
            : base(game)
        {
            Components = components;
            Content = content;
              textures = new Texture2D[toyCount];
            rectangles = new Rectangle[toyCount];

            vibration  = VibrateController.Default;
            gameMS = game;
        }
Пример #13
0
        public diagnostics_manager(Game g)
            : base(g)
        {
            components = new GameComponentCollection();
            position = Vector2.Zero;

            foreground_color = Color.White;
            background_color = new Color(0f, 0f, 0f, 0.65f);

            UpdateOrder = DrawOrder = int.MaxValue;
        }
Пример #14
0
        public Screen(Game1 game)
            : base(game, Shape.None, new Vector2(), new Vector2())
        {
            this.Components = new GameComponentCollection();
            HuDComponents = new GameComponentCollection();

            Translucent = false;

            Content = new ContentManager(game.Services);
            Content.RootDirectory = "Content";
            Batch = new SpriteBatch(game.GraphicsDevice);
        }
Пример #15
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_isDisposed)
            {
                if (disposing)
                {
                    // Dispose loaded game components
                    for (int i = 0; i < _components.Count; i++)
                    {
                        var disposable = _components[i] as IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                    _components = null;

                    if (_content != null)
                    {
                        _content.Dispose();
                        _content = null;
                    }

                    if (_graphicsDeviceManager != null)
                    {
                        (_graphicsDeviceManager as GraphicsDeviceManager).Dispose();
                        _graphicsDeviceManager = null;
                    }

                    if (Platform != null)
                    {
                        Platform.Activated   -= OnActivated;
                        Platform.Deactivated -= OnDeactivated;
                        _services.RemoveService(typeof(GamePlatform));

                        Platform.Dispose();
                        Platform = null;
                    }

                    ContentTypeReaderManager.ClearTypeCreators();

                    if (SoundEffect._systemState == SoundEffect.SoundSystemState.Initialized)
                    {
                        SoundEffect.PlatformShutdown();
                    }
                }
#if ANDROID
                Activity = null;
#endif
                _isDisposed = true;
                _instance   = null;
            }
        }
Пример #16
0
        public static bool ContainsAll(this XNAFramework.GameComponentCollection collection, XNAFramework.GameComponentCollection other)
        {
            foreach (XNAFramework.GameComponent component in other)
            {
                if (!collection.Contains(component))
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #17
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();
        }
        public DrawableGameComponentAsSpriteModel(Game game)
            : base(game)
        {
            this.Position = Vector2.Zero;
            this.Origin = Vector2.Zero;
            this.Scale = 1f;
            this.Rotation = 0f;
            this.Effect = SpriteEffects.None;
            this.Color = Color.White;
            this.Depth = 1f;

            GameComponentCollection c = new GameComponentCollection();
        }
Пример #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);
        }
Пример #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);
        }
Пример #21
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Screen(Game game, string name)
            : base(game)
        {
            components = new GameComponentCollection();
            components.ComponentAdded += new EventHandler<GameComponentCollectionEventArgs>(ComponentAdded);
            components.ComponentRemoved += new EventHandler<GameComponentCollectionEventArgs>(ComponentRemoved);

            isInitialized = false;
            this.name = name;

            updatingComponents = new List<IUpdateable>();
            drawingComponents = new List<IDrawable>();
        }
Пример #22
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_isDisposed)
            {
                if (disposing)
                {
                    // Dispose loaded game components.
                    for (int i = 0; i < _components.Count; i += 1)
                    {
                        IDisposable disposable = _components[i] as IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                    _components = null;

                    if (_content != null)
                    {
                        _content.Dispose();
                        _content = null;
                    }


                    if (_graphicsDeviceService != null)
                    {
                        // FIXME: Does XNA4 require the GDM to be disposable? -flibit
                        (_graphicsDeviceService as IDisposable).Dispose();
                        _graphicsDeviceService = null;
                    }

                    AudioDevice.Dispose();

                    if (Platform != null)
                    {
                        Platform.Activated   -= OnActivated;
                        Platform.Deactivated -= OnDeactivated;
                        _services.RemoveService(typeof(GamePlatform));
                        Platform.Dispose();
                        Platform = null;
                    }

                    ContentTypeReaderManager.ClearTypeCreators();
                }

                AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException;

                _isDisposed = true;
                Instance    = null;
            }
        }
Пример #23
0
        public SpawnManager(Game1 game)
            : base(game)
        {
            Components = new GameComponentCollection();

            //for (int i = 0; i <= 30000; i += 1000)
            //{
            //    Console.WriteLine(i + ": " + CalcSpawnDelay(i));
            //}

            _lastSpawnTime = TimeSpan.FromSeconds(0);

            LevelNumber = 1;
        }
Пример #24
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();
        }
Пример #25
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();
		}
Пример #26
0
 public Game()
 {
     this.EnsureHost();
     this.gameComponents = new GameComponentCollection();
     this.gameComponents.ComponentAdded   += new EventHandler <GameComponentCollectionEventArgs>(this.GameComponentAdded);
     this.gameComponents.ComponentRemoved += new EventHandler <GameComponentCollectionEventArgs>(this.GameComponentRemoved);
     this.host.Window.Paint         += new EventHandler(this.Paint);
     this.clock                      = new GameClock();
     this.totalGameTime              = TimeSpan.Zero;
     this.accumulatedElapsedGameTime = TimeSpan.Zero;
     this.lastFrameElapsedGameTime   = TimeSpan.Zero;
     this.targetElapsedTime          = TimeSpan.FromTicks(0x28b0bL);
     this.inactiveSleepTime          = TimeSpan.FromMilliseconds(20.0);
 }
Пример #27
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_isDisposed)
            {
                if (disposing)
                {
                    // Dispose loaded game components.
                    for (int i = 0; i < _components.Count; i += 1)
                    {
                        IDisposable disposable = _components[i] as IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                    _components = null;

                    if (_content != null)
                    {
                        _content.Dispose();
                        _content = null;
                    }


                    if (_graphicsDeviceManager != null)
                    {
                        Effect.FlushCache();

                        // FIXME: Does XNA4 require the GDM to be disposable? -flibit
                        (_graphicsDeviceManager as IDisposable).Dispose();
                        _graphicsDeviceManager = null;
                    }

                    if (Platform != null)
                    {
                        Platform.Activated   -= OnActivated;
                        Platform.Deactivated -= OnDeactivated;
                        _services.RemoveService(typeof(GamePlatform));
                        Platform.Dispose();
                        Platform = null;
                    }

                    ContentTypeReaderManager.ClearTypeCreators();
                }

                _isDisposed = true;
                _instance   = null;
            }
        }
Пример #28
0
        public Physics(Game game, Player player, ContentManager Content, TanksOnAHeightmap.GameBase.Shapes.Terrain terrain, Space space)
        {
            Cannon = new Cannon(game, player.tank);
            CannonBallManager = new CannonBallManager(game);
            EnemyCannon.playerTank = player.tank;

            healthManager = new HealthManager(game, space);
            this.Content = Content;
            this.Components = game.Components;
            this.game = game;
            this.player = player;
            this.tank = player.tank;
            this.terrain = terrain;
            this.space = space;
        }
Пример #29
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_isDisposed)
            {
                if (disposing)
                {
                    // Dispose loaded game components.
                    for (int i = 0; i < _components.Count; i += 1)
                    {
                        IDisposable disposable = _components[i] as IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                    _components = null;

                    if (_content != null)
                    {
                        _content.Dispose();
                        _content = null;
                    }


                    if (_graphicsDeviceService != null)
                    {
                        // FIXME: Does XNA4 require the GDM to be disposable? -flibit
                        (_graphicsDeviceService as IDisposable).Dispose();
                        _graphicsDeviceService = null;
                    }

                    AudioDevice.Dispose();

                    if (Window != null)
                    {
                        FNAPlatform.DisposeWindow(Window);
                        Window = null;
                    }
                    Mouse.WindowHandle = IntPtr.Zero;

                    ContentTypeReaderManager.ClearTypeCreators();
                }

                AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException;

                _isDisposed = true;
            }
        }
Пример #30
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;
        }
        public GameUpdateClassComponents(MouseState curMouseState, ContentManager Content, Model.StaticTextureImages staticTextureImages, Model.StaticFonts staticFonts, Game1 _This, GameComponentCollection Components, GraphicsDevice graphicsDevice, int screenWidth, int screenHeight)
        {
            _curMouseState = curMouseState;
            _Content = Content;
            _staticTextureImages = staticTextureImages;
            _staticFonts = staticFonts;
            _this = _This;
            _Components = Components;

            _graphicsDevice = graphicsDevice;

            _screenWidth = screenWidth;
            _screenHeight = screenHeight;

            _isNull = false;
        }
Пример #32
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();
        }
Пример #33
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();
        }
Пример #34
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;
        }
Пример #35
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();
        }
Пример #36
0
        public void GameOver()
        {
            GameComponentCollection bricks = new GameComponentCollection();

            foreach (GameComponent component in Components)
            {
                if (component is EnemyComponent)
                    bricks.Add(component);
            }

            foreach (GameComponent brick in bricks)
            {
                Components.Remove(brick);
                Game.Components.Remove(brick);
            }

            (this.Game as Game1).ScreenMgr.ActivateScreen(2);
        }
Пример #37
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();
        }
Пример #38
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();
        }
Пример #39
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
        }
Пример #40
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
        }
Пример #41
0
        protected virtual void Update(GameTime gameTime)
        {
            // GG EDITED -- removed background thread stuff
            _initializing = false;
            _initialized  = true;
            // super crappy copy
            GameComponentCollection gcc = new GameComponentCollection();

            foreach (GameComponent gc in _gameComponentCollection)
            {
                gcc.Add(gc);
            }
            foreach (GameComponent gc in gcc)
            {
                if (gc.Enabled)
                {
                    gc.Update(gameTime);
                }
            }
        }
Пример #42
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();
        }
Пример #43
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);
            for (int i = 0; i < previousSleepTimes.Length; i += 1)
            {
                previousSleepTimes[i] = TimeSpan.FromMilliseconds(1);
            }

            textInputControlDown   = new bool[FNAPlatform.TextInputCharacters.Length];
            textInputControlRepeat = new int[FNAPlatform.TextInputCharacters.Length];

            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;
        }
Пример #44
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
        }
Пример #45
0
        public GameWorld(Game game, ContentManager cm, Camera cam)
            : base(game)
        {
            content = cm;
            camera = cam;
            components = game.Components;
            physworld = new PhysicsWorld(game);
            modelmgr = new ModelManager(game, cam);
            level = new Level();

            components.Add(physworld);
            components.Add(modelmgr);

            sfx = game.Content.Load<SoundEffect>(@"Audio/punch");
            punch = sfx.CreateInstance();
            punch.IsLooped = false;
            sfx = game.Content.Load<SoundEffect>(@"Audio/bgm");
            bgm = sfx.CreateInstance();
            bgm.IsLooped = true;
            bgm.Play();
        }
        public void DumpDebugInfo(GameComponentCollection collection)
        {
            if (m_streamWriter != null)
            {
                StringBuilder stringBuilder = new StringBuilder();
                // timestamp
                stringBuilder.AppendLine("Timestamp : "+DateTime.Now.ToString());
                foreach (GameComponent gc in collection)
                {
                    IDebuggable i = gc as IDebuggable;
                    if (i != null)
                    {
                        i.DumpDebugInfo(stringBuilder);
                        stringBuilder.AppendLine();
                        stringBuilder.AppendLine("--------------------------------------------------------------------------");
                        stringBuilder.AppendLine();
                    }
                }

                m_streamWriter.Write(stringBuilder.ToString());
                m_streamWriter.Flush();
            }
        }
Пример #47
0
        public Game(string rootDir)
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            RootDirectory = rootDir;

            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();
            Renderer = new Renderer(this);

            // Ready to run the loop!
            RunApplication = true;
        }
Пример #48
0
 public static void SaveAll(GameComponentCollection gameComponentCollection)
 {
     var savingObjects = new List<SavingObject>();
     foreach (var component in gameComponentCollection)
     {
         if (component.GetType() == typeof(Django))
         {
             savingObjects.Add(ConvertTo.SavingObject((Django)component));
         }
         else if (component.GetType() == typeof(Enemy))
         {
             savingObjects.Add(ConvertTo.SavingObject((Enemy)component));
         }
         else if (component.GetType() == typeof(HealthBonus))
         {
             savingObjects.Add(ConvertTo.SavingObject((HealthBonus)component));
         }
         else if (component.GetType() == typeof(Platform))
         {
             savingObjects.Add(ConvertTo.SavingObject((Platform)component));
         }
         else if (component.GetType() == typeof(Level))
         {
             savingObjects.Add(ConvertTo.SavingObject((Level)component));
         }
         else if (component.GetType() == typeof(HealthBar))
         {
             savingObjects.Add(ConvertTo.SavingObject((HealthBar)component));
         }
         else if (component.GetType() == typeof(BulletsBar))
         {
             savingObjects.Add(ConvertTo.SavingObject((BulletsBar)component));
         }
     }
     Save(savingObjects);
 }
Пример #49
0
        public Game()
        {
            content = new ContentManager(null, "");

            _components = new GameComponentCollection();
        }
Пример #50
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();
        }
Пример #51
0
        public Game()
        {
            content = new ContentManager(null, "");

            _components = new GameComponentCollection();
        }
Пример #52
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();
        }
Пример #53
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();
        }
Пример #54
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();
        }
Пример #55
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 ();
        }
Пример #56
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");
            };
        }
Пример #57
0
 public Game()
 {
     _targetElapsedTime = TimeSpan.FromMilliseconds(1000f / 60f);
     Content            = new ContentManager();
     _components        = new GameComponentCollection();
 }
Пример #58
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");
                IsActive = true;
            };

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

            _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");
            };
        }