Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Game"/> class.
        /// </summary>
        public Game()
        {
            // Register the logger backend before anything else
            logListener = GetLogListener();

            if (logListener != null)
            {
                GlobalLogger.GlobalMessageLogged += logListener;
            }

            // Create all core services, except Input which is created during `Initialize'.
            // Registration takes place in `Initialize'.
            Script = new ScriptSystem(Services);
            Services.AddService(Script);

            SceneSystem = new SceneSystem(Services);
            Services.AddService(SceneSystem);

            Streaming = new StreamingManager(Services);

            Audio = new AudioSystem(Services);
            Services.AddService(Audio);
            Services.AddService <IAudioEngineProvider>(Audio);

            gameFontSystem = new GameFontSystem(Services);
            Services.AddService(gameFontSystem.FontSystem);
            Services.AddService <IFontFactory>(gameFontSystem.FontSystem);

            SpriteAnimation = new SpriteAnimationSystem(Services);
            Services.AddService(SpriteAnimation);

            DebugTextSystem = new DebugTextSystem(Services);
            Services.AddService(DebugTextSystem);

            DebugRenderSystem = new DebugRenderSystem(Services);
            Services.AddService(DebugRenderSystem);

            ProfilingSystem = new GameProfilingSystem(Services);
            Services.AddService(ProfilingSystem);

            VRDeviceSystem = new VRDeviceSystem(Services);
            Services.AddService(VRDeviceSystem);

            // Creates the graphics device manager
            GraphicsDeviceManager = new GraphicsDeviceManager(this);
            Services.AddService <IGraphicsDeviceManager>(GraphicsDeviceManager);
            Services.AddService <IGraphicsDeviceService>(GraphicsDeviceManager);

            AutoLoadDefaultSettings = true;
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Game"/> class.
        /// </summary>
        public Game()
        {
            // Register the logger backend before anything else
            logListener = GetLogListener();

            if (logListener != null)
            {
                GlobalLogger.GlobalMessageLogged += logListener;
            }

            // Create all core services, except Input which is created during `Initialize'.
            // Registration takes place in `Initialize'.
            Script = new ScriptSystem(Services);
            Services.AddService(typeof(ScriptSystem), Script);

            SceneSystem = new SceneSystem(Services);
            Services.AddService(typeof(SceneSystem), SceneSystem);

            Audio = new AudioSystem(Services);
            Services.AddService(typeof(AudioSystem), Audio);
            Services.AddService(typeof(IAudioEngineProvider), Audio);

            gameFontSystem = new GameFontSystem(Services);
            Services.AddService(typeof(FontSystem), gameFontSystem.FontSystem);
            Services.AddService(typeof(IFontFactory), gameFontSystem.FontSystem);

            SpriteAnimation = new SpriteAnimationSystem(Services);
            Services.AddService(typeof(SpriteAnimationSystem), SpriteAnimation);

            DebugConsoleSystem = new DebugConsoleSystem(Services);
            Services.AddService(typeof(DebugConsoleSystem), DebugConsoleSystem);

            ProfilerSystem = new GameProfilingSystem(Services);
            Services.AddService(typeof(GameProfilingSystem), ProfilerSystem);

            VRDeviceSystem = new VRDeviceSystem(Services);
            Services.AddService(typeof(VRDeviceSystem), VRDeviceSystem);

            Content.Serializer.LowLevelSerializerSelector = ParameterContainerExtensions.DefaultSceneSerializerSelector;

            // Creates the graphics device manager
            GraphicsDeviceManager = new GraphicsDeviceManager(this);
            Services.AddService(typeof(IGraphicsDeviceManager), GraphicsDeviceManager);
            Services.AddService(typeof(IGraphicsDeviceService), GraphicsDeviceManager);

            AutoLoadDefaultSettings = true;
        }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Create game systems
            InputSystem              = new InputSystem(this);
            NetworkSystem            = new NetworkSystem(this);
            RenderingSystem          = new RenderingSystem(this);
            MovementSystem           = new MovementSystem(this);
            WeaponSystem             = new WeaponSystem(this);
            EnemyAISystem            = new EnemyAISystem(this);
            NpcAISystem              = new NpcAISystem(this);
            GarbagemanSystem         = new GarbagemanSystem(this);
            CollisionSystem          = new Systems.CollisionSystem(this);
            RoomChangingSystem       = new RoomChangingSystem(this);
            QuestLogSystem           = new QuestLogSystem(this);
            SpriteAnimationSystem    = new SpriteAnimationSystem(this);
            SkillSystem              = new SkillSystem(this);
            TextSystem               = new TextSystem(this);
            EngineeringOffenseSystem = new EngineeringOffenseSystem(this);
            HUDSystem    = new HUDSystem(this);
            SplashSystem = new SplashSystem(this);

            InputHelper.Load(4);
            HUDSystem.LoadContent();

            // Testing code.
            LevelManager.LoadContent();
            LevelManager.LoadLevel("D01F01R01");
            //Song bg = Content.Load<Song>("Audio/Main_Loop");
            //MediaPlayer.Stop();
            //MediaPlayer.IsRepeating = true;
            //MediaPlayer.Play(bg);
            //End Testing Code
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Game"/> class.
        /// </summary>
        public Game()
        {
            // Register the logger backend before anything else
            logListener = GetLogListener();

            if (logListener != null)
                GlobalLogger.GlobalMessageLogged += logListener;

            // Create and register all core services
            Input = new InputManager(Services);
            Script = new ScriptSystem(Services);
            SceneSystem = new SceneSystem(Services);
            Audio = new AudioSystem(Services);
            UI = new UISystem(Services);
            gameFontSystem = new GameFontSystem(Services);
            SpriteAnimation = new SpriteAnimationSystem(Services);

            // ---------------------------------------------------------
            // Add common GameSystems - Adding order is important 
            // (Unless overriden by gameSystem.UpdateOrder)
            // ---------------------------------------------------------

            // Add the input manager
            GameSystems.Add(Input);

            // Add the scheduler system
            // - Must be after Input, so that scripts are able to get latest input
            // - Must be before Entities/Camera/Audio/UI, so that scripts can apply 
            // changes in the same frame they will be applied
            GameSystems.Add(Script);

            // Add the UI System
            GameSystems.Add(UI);

            // Add the Audio System
            GameSystems.Add(Audio);

            // Add the Font system
            GameSystems.Add(gameFontSystem);

            //Add the sprite animation System
            GameSystems.Add(SpriteAnimation);

            Asset.Serializer.LowLevelSerializerSelector = ParameterContainerExtensions.DefaultSceneSerializerSelector;

            // Creates the graphics device manager
            GraphicsDeviceManager = new GraphicsDeviceManager(this);

            AutoLoadDefaultSettings = true;
        }
Example #5
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            font = Content.Load <SpriteFont>("Status");
            SpriteSheetLoader loader = new SpriteSheetLoader(Content, _fileReader);
            var ss = loader.Load("fanatiblaster");

            var frame = ss.SpriteList[SpriteNames.Down_spritesheetforthegame_1_0];

            var animationCache = new AnimationCache(ss);

            animationCache.Animations.Add("down", new string[] {
                SpriteNames.Down_spritesheetforthegame_1_1,
                SpriteNames.Down_spritesheetforthegame_1_2,
                SpriteNames.Down_spritesheetforthegame_1_3,
                SpriteNames.Down_spritesheetforthegame_1_4,
                SpriteNames.Down_spritesheetforthegame_1_5,
                SpriteNames.Down_spritesheetforthegame_1_6,
                SpriteNames.Down_spritesheetforthegame_1_7,
                SpriteNames.Down_spritesheetforthegame_1_8
            });

            MovementSystem        movementSystem        = new MovementSystem(_channelManager, 25, new string[] { "default" });
            TextRenderSystem      textRenderSystem      = new TextRenderSystem(spriteBatch, _channelManager, 100, "default");
            TextureRenderSystem   textureRenderSystem   = new TextureRenderSystem(spriteBatch, _channelManager, 101, "default");
            SpriteAnimationSystem spriteAnimationSystem = new SpriteAnimationSystem(animationCache, _channelManager, 30, "default");

            _gameManager.AddSystem(textRenderSystem);
            _gameManager.AddSystem(movementSystem);
            _gameManager.AddSystem(textureRenderSystem);
            _gameManager.AddSystem(spriteAnimationSystem);

            var te = _gameManager.EntityManager.Get("text", new string[] { "default" });

            te.CreateTextRenderEntity("Some Text", Color.Black, new Vector2(100, 100), 5, 1.0f, font);
            var teMove = _gameManager.EntityManager.Get("text2", new string[] { "default" });

            teMove.CreateTextRenderEntity("I'm Moving!", Color.Black, new Vector2(1, 1), 5, 1.0f, font)
            .AddComponent(new VelocityComponent()
            {
                Direction = new Vector2(1, 1), Speed = new Vector2(15, 15)
            });
            var teSprite = _gameManager.EntityManager.Get("sprite");

            teSprite.MakeTextureRenderAspect(new Vector2(150, 150), frame.IsRotated, frame.Origin, frame.SourceRectangle,
                                             frame.Texture, SpriteEffects.None, Color.White, 1.0f, 0.0f)
            .AddComponent(new AnimationComponent()
            {
                Active            = true,
                CurrentAnimation  = "down",
                CurrentFrameIndex = 0,
                ShouldLoop        = true,
                FPS = 8.0f
            });

            _gameManager.AddEntity(te);
            _gameManager.AddEntity(teMove);
            _gameManager.AddEntity(teSprite);
        }