Пример #1
0
        public override void Initialize()
        {
            base.Initialize();

            _spriteBatch = Game.Services.GetService<SpriteBatch>();
            _input = Game.Services.GetService<InputState>();
            _particleRenderer = Game.Services.GetService<SpriteBatchRenderer>();
        }
Пример #2
0
        public PlayerShip(Game game, Vector2 position)
        {
            Game = game;
            _soundBank = Game.Services.GetService<SoundBank[]>();
            _world = Game.Services.GetService<World>();
            krypton = Game.Services.GetService<KryptonEngine>();

            thrustLR = _soundBank[0].GetCue("thrust01");
            thrustLR.Play();
            thrustLR.Pause();

            thrustUD = _soundBank[0].GetCue("thrust01");
            thrustUD.Play();
            thrustUD.Pause();

            Position = position;
            _particleRenderer = Game.Services.GetService<SpriteBatchRenderer>();
            //_textures = Game.Services.GetService<Textures>();

            //Loadcontentstuff
            _shiptxture = Game.Content.Load<Texture2D>("player_ship");
            _turretTxture = Game.Content.Load<Texture2D>(".\\guns\\turret01");
            _centreVect = new Vector2(_shiptxture.Width / 2, _shiptxture.Height / 2);

            ProximityBox = new Rectangle(0, 0, _shiptxture.Width+Globals.PhysBuffer, _shiptxture.Height + Globals.PhysBuffer);

            //make ship fixture in for farseer
            box = BodyFactory.CreateCircle(_world, ConvertUnits.ToSimUnits(_shiptxture.Width / 2), 7.0f);
            box.BodyType = BodyType.Dynamic;
            box.Restitution = 0.5f;
            box.Friction = 0.2f;
            box.FixedRotation = true;
            box.LinearDamping = 0.4f;
            box.Position = ConvertUnits.ToSimUnits(Position.X + _centreVect.X, Position.Y + _centreVect.Y);
            box.UserData = "player";

            //box.OnCollision += Collide;
            box.OnSeparation += Collide;

            //make light in krypton
            var mLightTexture = LightTextureBuilder.CreateConicLight(Game.GraphicsDevice, 256, 2.0f);
            light = CreateLights(mLightTexture,400);
            var mLightTexture2 = LightTextureBuilder.CreatePointLight(Game.GraphicsDevice, 64);
            light2 = CreateLights(mLightTexture2,200);

            //set up thruster particle
            _thrustparticle = Game.Content.Load<ParticleEffect>(".\\mercury\\thruster");
            _thrustparticle.LoadContent(Game.Content);
            _thrusterEmitter = (ConeEmitter)_thrustparticle[0];
            //_thrusterEmitter.Initialise();
            _thrusterEmitter.ParticleTexture = Game.Content.Load<Texture2D>(".\\mercury\\Particle004");
            _thrustparticle.Initialise();
            _particleRenderer.LoadContent(Game.Content);

            //_centerVect = new Vector2(_shiptxture.Width / 2,_shiptxture.Width / 2);
            currentWeapon = new Gun(Game, true, BulletsStats.Plasma01);
        }
        public Game1()
        {
            _graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            TargetElapsedTime = TimeSpan.FromTicks(333333);
            InactiveSleepTime = TimeSpan.FromSeconds(1);

            _spriteBatchRenderer = new SpriteBatchRenderer();//{ GraphicsDeviceService = _graphics };
        }
Пример #4
0
        public ParticleEffectVisual(ParticleSystemActor actor,  SpriteBatchRenderer renderer,  IResourceDictionary resourceDictionary)
            : base (resourceDictionary)
        {
            this._renderer = renderer;
            this._actor = actor;

            world = view = projection = Matrix.Identity;
            cameraPosition = Vector3.Up;
        }
Пример #5
0
 public ParticleFX(GraphicsDeviceManager graphics, String name)
 {
     myRenderer = new SpriteBatchRenderer
     {
         GraphicsDeviceService = graphics
     };
     this.name = name;
     Visible = true;
 }
Пример #6
0
        /// <summary> 
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Graphics.PreferredBackBufferWidth = 1280;
            Graphics.PreferredBackBufferHeight = 720;
            Graphics.ApplyChanges();
            
            Components.Add(new FrameRateCounter(this, "Content\\debugfont", 1f));
            Components.Add(new GameObjectInfoDisplay(this, 5, "Content\\debugfont", new Vector2(0f, 25f)));

            ComponentFactory componentFactory = new ComponentFactory();
            TiledGameObjectFactory gameObjectFactory = new TiledGameObjectFactory(this.Content);
            gameObjectFactory.PathToXML = "EntityDefinitions\\entity.xml";
            
            inputHandler = new InputHandler(false);
            playerManager = new PlayerManager();

            particleManager = new ParticleManager(Content, "ParticleEffects\\", "Textures\\");

            PhysicsManager physicsManager = new PhysicsManager();
            particleRenderer = new SpriteBatchRenderer();
            particleRenderer.GraphicsDeviceService = Graphics;

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            renderer = new Renderer(Graphics, spriteBatch);
            renderer.SetInternalResolution(1280, 720);
            renderer.SetScreenResolution(1280, 720, false);

            GameServiceManager.AddService(typeof(IGameObjectFactory), gameObjectFactory);
            GameServiceManager.AddService(typeof(IComponentFactory), componentFactory);
            GameServiceManager.AddService(typeof(RenderableFactory), new RenderableFactory(this.Content));
            GameServiceManager.AddService(typeof(IInputHandler), inputHandler);
            GameServiceManager.AddService(typeof(PlayerManager), playerManager);
            GameServiceManager.AddService(typeof(IScoreManager), new ScoreManager());
            GameServiceManager.AddService(typeof(IGameObjectManager), new GameObjectManager());
            GameServiceManager.AddService(typeof(IPhysicsManager), physicsManager);
            GameServiceManager.AddService(typeof(IBehaviorFactory), new BehaviorFactory());
            GameServiceManager.AddService(typeof(IActionFactory), new ActionFactory());
            GameServiceManager.AddService(typeof(IActionManager), new ActionManager());
            GameServiceManager.AddService(typeof(ILevelLogicManager), new LevelLogicManager(this.Content));
            GameServiceManager.AddService(typeof(IRandomGenerator), new RandomGenerator());
            GameServiceManager.AddService(typeof(IParticleManager), particleManager);
            GameServiceManager.AddService(typeof(IRenderer), renderer);

            debugView = new DebugViewXNA(GameServiceManager.GetService<IPhysicsManager>().PhysicsWorld);

            //Initialize the GameServices
            GameServiceManager.Initialize();
            
            CameraController.Initialize(this);
            CameraController.MoveCamera(new Vector2(GraphicsDevice.Viewport.Width / 2f, GraphicsDevice.Viewport.Height / 2f));
            
            base.Initialize();
        }
        public ParticlesComponent()
        {
            Scene.Listener.EntityAdded += new EntityEvent(Listener_EntityAdded);
            Scene.Listener.PostDraw[DrawLayer.First] += new DrawEvent(Draw);
            Scene.Listener.Update += new UpdateEvent(Listener_Update);
            Scene.Listener.LoadContent += new BasicEvent(LoadConent);

            mSpriteBatchRenderer = new SpriteBatchRenderer();

            mSpriteBatchRenderer.GraphicsDeviceService = MilkShake.GraphicsManager;
        }
Пример #8
0
        public Video(Engine engine)
            : base(engine)
        {
            // particle effects
            ParticleRenderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = Global.GraphicsDeviceManager
            };

            GraphicsDevice = Global.Game.GraphicsDevice;

            Engine.AddComponent(this);
        }
Пример #9
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            myRenderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = graphics
            };
            myEffect = new ParticleEffect();

            //graphics.PreferredBackBufferHeight = 600;

            //graphics.PreferredBackBufferWidth = 800;
        }
Пример #10
0
        protected override void Initialize()
        {
            _screenCenter = new Vector2(GraphicsDevice.PresentationParameters.BackBufferWidth / 2, GraphicsDevice.PresentationParameters.BackBufferHeight / 2);

            _particleRenderer = new SpriteBatchRenderer {GraphicsDeviceService = _graphics};
            _particleRenderer.LoadContent(Content);

            _spriteBatch = new SpriteBatch(GraphicsDevice);
            _input = new InputState();

            Services.AddService(typeof(SpriteBatch), _spriteBatch);
            Services.AddService(typeof(InputState), _input);
            Services.AddService(typeof(SpriteBatchRenderer), _particleRenderer);

            _ship = new Ship(this) {Position = new Vector2(900, 360)};
            Components.Add(_ship);
            IsMouseVisible = true;
            base.Initialize();
        }
        //static GameTime gameTimer;

        //static public ParticleEffects(GraphicsDeviceManager graphics, Camera2D cam, GraphicsDevice graphicsDevice)
        //{
        //    myRenderer = new SpriteBatchRenderer
        //    {
        //        GraphicsDeviceService = graphics,
        //        Transformation = Matrix.CreateTranslation(0f, 0f, 0f)
        //        //Transformation = cam.get_transformation(graphicsDevice)                
        //    };

        //    World = Matrix.Identity;
        //    Projection = Matrix.Identity;
        //    View = Matrix.Identity;
        //}

        //static public ParticleEffects()
        //{

        //}

        static public void Initialize(GraphicsDeviceManager graphics, GraphicsDevice graphicsDevice)
        {
            myRenderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = graphics,
                
                //Transformation = Matrix.CreateTranslation(0f, 0f, 0f)    
                
            };


            View = Matrix.Identity;
            World = Matrix.Identity;
            Projection = Matrix.Identity;
            //Projection = Matrix.CreateOrthographicOffCenter(0, 800, 480, 0, 0, 2000);

            //View = new Matrix(1.0f, 0.0f, 0.0f, 0.0f,
            //            0.0f, -1.0f, 0.0f, 0.0f,
            //            0.0f, 0.0f, -1.0f, 0.0f,
            //            0.0f, 0.0f, 0.0f, 1.0f);
            
        }
Пример #12
0
        public override void Initialize()
        {
            Renderer = new SpriteBatchRenderer {BlendMode = SpriteBlendMode.Additive, Batch = CurrGame.SpriteBatch};

            //TowerSelector = CurrGame.Content.Load<RectEmitter>("GUI/TowerSelector");
            TowerSelector = new RectEmitter
                            {
                                ReleaseColour = Color.Lime.ToVector3(),
                                ReleaseOpacity = 1,
                                ReleaseQuantity = 100,
                                ReleaseScale = new VariableFloat {Anchor = 15, Variation = 1},
                                ReleaseSpeed = new VariableFloat {Anchor = 10, Variation = 5},
                                Frame = true,
                                Height = 50,
                                Width = 50,
                                Budget = 10000,
                                Term = 0.5f
                            };

            TowerSelector.Initialize();
            TowerSelector.LoadContent(CurrGame.Content);
            base.Initialize();
        }
Пример #13
0
 public particleeffects(master _master)
 {
     this.master = _master;
     _particles = new Dictionary<string, ParticleEffect>();
     renderer = new SpriteBatchRenderer();
 }
Пример #14
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.Register((container, parameters) =>
                {
                    Renderer renderer = new SpriteBatchRenderer() { BlendMode = SpriteBlendMode.Additive, GraphicsDeviceService = this.GraphicsDeviceService };
                    //Renderer renderer = new SpriteBatchRenderer() { BlendMode = SpriteBlendMode.AlphaBlend, GraphicsDeviceService = this.GraphicsDeviceService };
                    renderer.LoadContent(this.ContentManager);
                    return renderer;
                }).SingletonScoped();

            builder.Register((container, parameters) =>
                {
                    var emitterName = parameters.TypedAs<string>();
                    Emitter emitter = this.ContentManager.Load<Emitter>("Effects\\" + emitterName);
                    emitter.LoadContent(this.ContentManager);
                    emitter.Initialize();
                    System.Diagnostics.Debug.Assert(emitter.ParticleTexture != null, "Emitter MUST have a texture otherwise nothing will be drawn!", "Probably need to specify the ParticleTextureAssetName xml tag in the Effect .em file.");
                    return emitter;
                }).FactoryScoped();

            builder.Register<MercuryLineParticleEffect>
                (c => new MercuryLineParticleEffect
                    (
                        c.Resolve<Renderer>(),
                        c.Resolve<Emitter>(new TypedParameter(typeof(string), "line"))
                    )).As<ILineEffect>().SingletonScoped();
            builder.Register<MercuryPointParticleEffect>
                (c => new MercuryPointParticleEffect
                    (
                        c.Resolve<Renderer>(),
                        c.Resolve<Emitter>(new TypedParameter(typeof(string), "point")),
                        c.Resolve<Emitter>(new TypedParameter(typeof(string), "explosion"))
                    )).As<IEffect>().SingletonScoped();
            builder.RegisterGeneratedFactory<Frenetic.Graphics.Effects.LineEffect.Factory>(new TypedService(typeof(ILineEffect)));
            builder.Register<EffectUpdater>().ContainerScoped();

            // WEAPONS:
            builder.Register<RailGun>().As<RailGun>().FactoryScoped();
            builder.Register<RocketLauncher>().As<RocketLauncher>().FactoryScoped();

            builder.Register((container) =>
                {
                    Dictionary<WeaponType, IWeapon> weapons = new Dictionary<WeaponType, IWeapon>();
                    weapons.Add(WeaponType.RailGun, container.Resolve<RailGun>());
                    weapons.Add(WeaponType.RocketLauncher, container.Resolve<RocketLauncher>());

                    return new WeaponList(weapons);
                }).As<IWeapons>().FactoryScoped();
            
            builder.Register<Rocket>().FactoryScoped();
            builder.RegisterGeneratedFactory<Rocket.Factory>(new TypedService(typeof(Rocket)));

            builder.Register<RocketLauncherView>().FactoryScoped();
            builder.Register<RailGunView>().FactoryScoped();

            builder.Register((container) =>
                {
                    List<IWeaponView> weaponViews = new List<IWeaponView>() { container.Resolve<RocketLauncherView>(), container.Resolve<RailGunView>() };
                    return new WeaponDrawer(container.Resolve<IPlayerController>(), container.Resolve<IPlayerList>(), weaponViews);
                }).As<IWeaponDrawer>().ContainerScoped();
        }
Пример #15
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void Activate(bool instancePreserved)
        {
            if (!instancePreserved)
            {
                if (content == null)
                    content = new ContentManager(ScreenManager.Game.Services, "main");

                // Start the action background music FIRST
                actionBgm = ((GameMain)ScreenManager.Game).AudioEM.GetCue("actionBg1");
                actionBgm.Play();

                // LOAD FONTS & BLANK TEXTURE
                debugFont = content.Load<SpriteFont>(@"fonts\debug");
                gameFont = content.Load<SpriteFont>(@"fonts\game1");
                blank = content.Load<Texture2D>(@"textures\blank");

                // LOAD SOUNDS
                AudioEngine audioEngine = ((GameMain)ScreenManager.Game).AudioEM.AudioEngine;
                weaponWaves = new WaveBank(audioEngine, @"main\audio\weaponWaves.xwb");
                weaponSounds = new SoundBank(audioEngine, @"main\audio\weaponSounds.xsb");

                // LOAD WEAPONS
                Texture2D bulletPath1 = content.Load<Texture2D>(@"textures\weapons\bulletPath1");
                Texture2D bulletPath2 = content.Load<Texture2D>(@"textures\weapons\bulletPath2");
                lazerTexture = content.Load<Texture2D>(@"textures\weapons\lazer");
                crosshairTexture = content.Load<Texture2D>(@"textures\weapons\crosshair");

                // LOAD VEHICLES
                bobcatTexture = content.Load<Texture2D>(@"textures\vehicles\pickup_nfw");
                bobcatWheelsTexture = content.Load<Texture2D>(@"textures\vehicles\pickup_w");

                // LOAD PED SPRITE TEXTURES
                cowboySheetTexture = content.Load<Texture2D>(@"textures\peds\cowboy1");
                zombieSheetTexture = content.Load<Texture2D>(@"textures\peds\zombie1");
                zombieSheetTexture2 = content.Load<Texture2D>(@"textures\peds\zombie2");
                evilCowboySheetTexture = content.Load<Texture2D>(@"textures\peds\zombiecowboy");

                // LOAD PARTICLE EFFECTS
                particleRenderer = new SpriteBatchRenderer { GraphicsDeviceService = (IGraphicsDeviceService)ScreenManager.Game.Services.GetService(typeof(IGraphicsDeviceService)), };
                particleRenderer.LoadContent(content);
                ParticleEffect bloodBlastEffect = content.Load<ParticleEffect>(@"particles\bloodSplit1");
                ParticleEffect deathBlastEffect = content.Load<ParticleEffect>(@"particles\deathBlast1");
                ParticleEffect powerUpBlastEffect = content.Load<ParticleEffect>(@"particles\powerUpBlast");
                bloodBlastEffect.LoadContent(content); bloodBlastEffect.Initialise();
                deathBlastEffect.LoadContent(content); deathBlastEffect.Initialise();
                powerUpBlastEffect.LoadContent(content); powerUpBlastEffect.Initialise();

                // LOAD MAP TEXTURES
                Vector2 worldSize = new Vector2(4000, 3000);
                Texture2D tileBackgroundTexture = content.Load<Texture2D>(@"textures\map\map" + random.Next(2).ToString());
                Texture2D healthPowerUpTexture = content.Load<Texture2D>(@"textures\powerups\health");
                Texture2D ammoPowerUpTexture = content.Load<Texture2D>(@"textures\powerups\ammo");
                Texture2D moneyPowerUpTexture = content.Load<Texture2D>(@"textures\powerups\money");
                Texture2D revivePowerUpTexture = content.Load<Texture2D>(@"textures\powerups\revive");
                Texture2D shieldPowerUpTexture = content.Load<Texture2D>(@"textures\powerups\shield");
                Texture2D weaponShop = content.Load<Texture2D>(@"textures\map\weaponShop");
                Texture2D modShop = content.Load<Texture2D>(@"textures\map\modShop");

                // Construct world
                world = new World(ScreenManager.Game, worldSize, tileBackgroundTexture, new Texture2D[] { bulletPath1, bulletPath2 }, new Texture2D[] { healthPowerUpTexture, ammoPowerUpTexture, moneyPowerUpTexture, revivePowerUpTexture, shieldPowerUpTexture }, new Texture2D[] { weaponShop, modShop }, weaponSounds, new ParticleEffect[] { bloodBlastEffect, deathBlastEffect, powerUpBlastEffect });

                // Construct Essential Peds
                cowboy = new Cowboy(new Vector2(1000, 1000), new Vector2(0, -1), cowboySheetTexture, world);

                // give guns to player cowboy
                cowboy.GetGun(new M1911(cowboy, world));
                world.playerList.Add(cowboy);
                cowboy.AddMoney(90);
                world.LoadPresetMap(0, blank); // LOADS PRESET DEBUG MAP
                p1Cam = new ChasingCamera2D();
                p1Cam.maxChaseSpeed = 1200;
                inputC = new InputState();

                // LOAD HUD & ITS ELEMENTS (MUST BE DONE LAST!)
                Texture2D barTexture = content.Load<Texture2D>(@"textures\hud\healthBar");
                Texture2D hudM1911 = content.Load<Texture2D>(@"textures\hud\m1911");
                Texture2D hudAk74u = content.Load<Texture2D>(@"textures\hud\ak74u");
                Texture2D hudM4a1 = content.Load<Texture2D>(@"textures\hud\m4a1");
                Texture2D hudR870mcs = content.Load<Texture2D>(@"textures\hud\r870mcs");
                Texture2D hudM60 = content.Load<Texture2D>(@"textures\hud\m60");
                Texture2D screenBlood = content.Load<Texture2D>(@"textures\hud\screenBlood");
                SpriteFont hudFont = content.Load<SpriteFont>(@"fonts\hud");
                statusDisplay = new StatusDisplay(cowboy, new Vector2(500, 108), barTexture, blank, new Texture2D[] { hudM1911, hudAk74u, hudM4a1, hudR870mcs, hudM60 }, screenBlood, hudFont);

            #if XBOX

            #else
                FAZEngine.ScriptEngine.ScriptLoader.LoadModScripts(this);
            #endif

                // once the load has finished, we use ResetElapsedTime to tell the game's
                // timing mechanism that we have just finished a very long frame, and that
                // it should not try to catch up.
                ScreenManager.Game.ResetElapsedTime();
            }
        }
Пример #16
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void Activate(bool instancePreserved)
        {
            if (!instancePreserved)
            {
                if (content == null)
                    content = new ContentManager(ScreenManager.Game.Services, "Content");

                #region Instantiating Fields:

                gameFont = ScreenManager.Font;

                world = new GameWorld(9.8f * Vector2.UnitY, 0.4f, new Camera2D(ScreenManager.GraphicsDevice));

                player = new Player(this, world, camera);
                player.Initialize();
                player.Position = new Vector2(0, 50);

                scenario = new Scenario(this, world, camera);
                scenario.Initialize();

                camera.Zoom = 7f;
                camera.trakingSpeedMult = new Vector2(0.5f, 0.25f);
                camera.trakingOffset = new Vector2(0f, -2f);
                camera.TrackingBody = player.getBody(0);
                camera.Update(new GameTime());
                camera.Jump2Target();

                debugView = new DebugViewXNA(world);
                debugView.AppendFlags(DebugViewFlags.DebugPanel | DebugViewFlags.PerformanceGraph);
                debugView.AppendFlags(DebugViewFlags.ContactNormals | DebugViewFlags.ContactPoints);
                debugView.DefaultShapeColor = Color.Black;
                debugView.SleepingShapeColor = Color.LightGray;

                collectibles = new List<Collectible>();
                myEffect = new ParticleEffect();
                myRenderer = new SpriteBatchRenderer
                {
                    GraphicsDeviceService = (IGraphicsDeviceService)ScreenManager.Game.Services.GetService(typeof(IGraphicsDeviceService))
                };
                sbRenderer = new SpriteBatchRenderer
                {
                    GraphicsDeviceService = (IGraphicsDeviceService)ScreenManager.Game.Services.GetService(typeof(IGraphicsDeviceService))
                };
                #endregion

                loadContent(content);

                ScreenManager.Game.ResetElapsedTime();
            }
        }
Пример #17
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Graphics.PreferredBackBufferWidth = Constants.InternalResolutionWidth;
            Graphics.PreferredBackBufferHeight = Constants.InternalResolutionHeight;

            Graphics.SynchronizeWithVerticalRetrace = false;
            IsFixedTimeStep = false;

            Graphics.ApplyChanges();

            //Components.Add(new FrameRateCounter(this, "Content\\Fonts\\fpsfont", 1f));
            Components.Add(new GameObjectInfoDisplay(this, 0.5f, "Content\\Fonts\\debugfont", new Vector2(0f, 25f)));


            var componentFactory = new ComponentFactory();
            var gameObjectFactory = new GameObjectFactory(this.Content);
            gameObjectFactory.PathToXML = "EntityDefinitions\\entity.xml";

            var inputHandler = new InputHandler(false);
            var playerManager = new PlayerManager();

            var collisionManager = new CollisionManager(new RectangleF(0f, 0f, Constants.InternalResolutionWidth, Constants.InternalResolutionHeight));

            particleManager = new ParticleManager(Content, "ParticleEffects\\", "Textures\\");

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            renderer = new Renderer(Graphics, spriteBatch);
            renderer.SpriteSortMode = SpriteSortMode.FrontToBack;
            renderer.SetInternalResolution(Constants.InternalResolutionWidth, Constants.InternalResolutionHeight);
            renderer.SetScreenResolution(1920, 1080, false);

            particleRenderer = new SpriteBatchRenderer();
            particleRenderer.GraphicsDeviceService = Graphics;

            cameraService =  new CameraManager();

            var camera = new BasicCamera2D(GraphicsDevice, "main");

            cameraService.AddCamera(camera);

            GameServiceManager.AddService(typeof(IGameObjectFactory), gameObjectFactory);
            GameServiceManager.AddService(typeof(IComponentFactory), componentFactory);
            GameServiceManager.AddService(typeof(RenderableFactory), new RenderableFactory(Content));
            GameServiceManager.AddService(typeof(IInputHandler), inputHandler);
            GameServiceManager.AddService(typeof(PlayerManager), playerManager);
            GameServiceManager.AddService(typeof(IGameObjectManager), new GameObjectManager());
            GameServiceManager.AddService(typeof(ICollisionManager), collisionManager);
            GameServiceManager.AddService(typeof(IBehaviorFactory), new BehaviorFactory());
            GameServiceManager.AddService(typeof(IActionFactory), new ActionFactory());
            GameServiceManager.AddService(typeof(IRandomGenerator), new RandomGenerator());
            GameServiceManager.AddService(typeof(IParticleManager), particleManager);
            GameServiceManager.AddService(typeof(IProjectileManager), new ProjectileManager());
            GameServiceManager.AddService(typeof(IActionManager), new ActionManager());
            GameServiceManager.AddService(typeof(ILayerManager), new LayerManager("layers.xml", Content));
            GameServiceManager.AddService(typeof(IRenderer), renderer);
            GameServiceManager.AddService(typeof(ICameraService), cameraService);
            GameServiceManager.AddService(typeof(ILevelLogicManager), new LevelLogicManager());

            //Initialize the GameServices););
            foreach (var service in GameServiceManager.Services)
            {
                service.Initialize();
            }

            base.Initialize();
        }
Пример #18
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        /// 
        protected override void Initialize()
        {
            krypton.Initialize();
            _world = new World(new Vector2(0, 0));

            _camera = new Camera(new Viewport(0, 0, (int)Globals.Screensize.X, (int)Globals.Screensize.Y));
            _particleRenderer = new SpriteBatchRenderer { GraphicsDeviceService = graphics };
            _particleRenderer.LoadContent(Content);
            spriteBatch = new SpriteBatch(GraphicsDevice);
            gameTextures = new Textures(this);

            //audio initialise
            audioEngine = new AudioEngine("Content\\Audio\\artefactAudio.xgs");
            waveBank = new WaveBank(audioEngine, "Content\\Audio\\Wave Bank.xwb");
            SoundBanks[0] = new SoundBank(audioEngine, "Content\\Audio\\Sound Bank.xsb");
            SoundBanks[1] = new SoundBank(audioEngine, "Content\\Audio\\AMB.xsb");
            SoundBanks[2] = new SoundBank(audioEngine, "Content\\Audio\\Menu.xsb");

            //_ambcues = new AMBCues();
            AMBCues.LoadContent(SoundBanks[1]);

            //Add services
            Services.AddService(typeof(World), _world);
            Services.AddService(typeof(SpriteBatch), spriteBatch);
            Services.AddService(typeof(GameComponentCollection), Components);
            Services.AddService(typeof(SpriteBatchRenderer), _particleRenderer);
            Services.AddService(typeof(Camera), _camera);
            Services.AddService(typeof(KryptonEngine), krypton);
            Services.AddService(typeof(Textures), gameTextures);
            Services.AddService(typeof(SoundBank[]), SoundBanks);
            //Services.AddService(typeof(AMBCues), _ambcues);

            //Services.AddService(typeof(KeyboardState), _keyboardState);

            SolidsMaker.Initialise(this);

            /*/TESTDOOR!!! HACK!!!
            var door = new DoorVert(this, new Vector2(800-Globals.SmallGridSize.X,600-(Globals.SmallGridSize.Y*10)), 0);
            Components.Add(door);
            //Globals.CurrentRoom = Globals.LevelList[0].Roomlist[0];
            */

            base.Initialize();
        }
Пример #19
0
        /// <summary>
        /// Instantiates the renderer.
        /// </summary>
        private Renderer InstantiateRenderer()
        {
            Trace.WriteLine("Instantiating particle renderer...", "CORE");

            Renderer renderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = GraphicsDeviceService.Instance
            };

            renderer.LoadContent(null);

            return renderer;
        }
Пример #20
0
        public GameEnvironment(Controller ctrl)
            : base(ctrl)
        {
            Sound.StopAll(true);

            CollisionWorld = new Physics.Dynamics.World(Vector2.Zero);
            Controller.Window.ClientSizeChanged += WindowSizeChanged;
            Camera = new Camera2D(this);
            WindowSizeChanged(null, null);

            // Create a new SpriteBatch which can be used to draw textures.
            m_spriteBatch = new SpriteBatch(ctrl.GraphicsDevice);

            ParticleRenderer = new SpriteBatchRenderer {
                GraphicsDeviceService = ctrl.Graphics
            };

            ExplosionEffect = contentManager.Load<ParticleEffect>("ExplosionEffect");
            ThrusterEffect = contentManager.Load<ParticleEffect>("ThrusterEffect");
            FrostThrusterEffect = contentManager.Load<ParticleEffect>("FrostThrusterEffect");
            AttachEffect = contentManager.Load<ParticleEffect>("AttachEffect");
            BlackHoleEffect = contentManager.Load<ParticleEffect>("BlackHoleEffect");
            AlertEffect = contentManager.Load<ParticleEffect>("AlertEffect");
            TractorBeamEffect = contentManager.Load<ParticleEffect>("TractorBeamEffect");

            EffectsBelowShip.Add(ThrusterEffect);
            EffectsBelowShip.Add(FrostThrusterEffect);
            EffectsBelowShip.Add(TractorBeamEffect);

            EffectsAboveShip.Add(ExplosionEffect);
            EffectsAboveShip.Add(AttachEffect);
            EffectsAboveShip.Add(BlackHoleEffect);
            EffectsAboveShip.Add(AlertEffect);

            ParticleRenderer.LoadContent(contentManager);

            foreach (var e in EffectsBelowShip) {
                e.Initialise();
                e.LoadContent(contentManager);
            }

            foreach (var e in EffectsAboveShip) {
                e.Initialise();
                e.LoadContent(contentManager);
            }

            // Create collision notification callbacks.
            CollisionWorld.ContactManager.PreSolve += PreSolve;
            CollisionWorld.ContactManager.BeginContact += BeginContact;
            CollisionWorld.ContactManager.EndContact += EndContact;
            CollisionWorld.ContactManager.ContactFilter += ContactFilter;

            // first parameter controls how strong the pull is; the second parameter controls the radius of the pull.
            BlackHoleController = new BlackHolePhysicsController(500.0f, 250.0f * k_physicsScale, 9.0f * k_physicsScale);
            CollisionWorld.AddController(BlackHoleController);

            ShipCollisionAvoidanceController shipAvoid = new ShipCollisionAvoidanceController(150.0f * k_physicsScale);
            shipAvoid.MaxRadius = 80.0f * k_physicsScale;
            CollisionWorld.AddController(shipAvoid);

            // HUD.
            HUD = new Menus.HUD(this);

            // Farseer freaks out unless we call Update here when changing Environments.  FIXME: Why?
            Update(0.0f);
        }
Пример #21
0
        /// <summary>
        /// Instantiates the renderer.
        /// </summary>
        private Renderer InstantiateRenderer()
        {
            Renderer renderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = GraphicsDeviceService.Instance
            };

            renderer.LoadContent(null);

            return renderer;
        }
Пример #22
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            this.Components.Add(this.krypton);
            _camera = new Camera(new Viewport(0, 0, Settings.Screensize.Y, Settings.Screensize.X));

            _particleRenderer = new SpriteBatchRenderer { GraphicsDeviceService = graphics };
            _particleRenderer.LoadContent(Content);
            spriteBatch = new SpriteBatch(GraphicsDevice);

            Services.AddService(typeof(SpriteBatch), spriteBatch);
            Services.AddService(typeof(SpriteBatchRenderer), _particleRenderer);
            Services.AddService(typeof(Camera), _camera);
            Services.AddService(typeof(GameComponentCollection),Components);
            Services.AddService(typeof(KryptonEngine), krypton);

            //var _block = new SmallBlock01(this, spriteBatch, new Vector2(0, 0));

            _roomlist.Add(new Room01(this, new Point(0, 0), 0));
            _roomlist.Add(new Room01(this,new Point(1,0),1));
            _roomlist.Add(new Room01(this, new Point(0,1), 2));

            _lastroom01 = new Room01(this, new Point(1, 1), 3);
            _roomlist.Add(_lastroom01);

            _playership = new PlayerShip(this);
            Components.Add(_playership);

            _cursor = new Cursor(this, spriteBatch);
            Components.Add(_cursor);

            this.krypton.Initialize();

            base.Initialize();
        }
Пример #23
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            // Create new renderer and set its graphics devide to "this" device
            myRenderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = graphics
            };

            myEffect = new ParticleEffect();
        }