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();
        }
        /// <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();
            }
        }
示例#3
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();
        }
示例#4
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);
        }
示例#5
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);
        }
示例#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()
        {
            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();
        }
示例#7
0
        /// <summary>
        /// Instantiates the renderer.
        /// </summary>
        private Renderer InstantiateRenderer()
        {
            Renderer renderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = GraphicsDeviceService.Instance
            };

            renderer.LoadContent(null);

            return renderer;
        }
示例#8
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;
        }
示例#9
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();
        }