Exemplo n.º 1
0
        private Scene3D(Game game, Func <Viewport> getViewport, InputMessageBuffer inputMessageBuffer, int randomSeed, bool isDiagnosticScene, MapFile mapFile, string mapPath)
        {
            Game = game;

            PlayerManager = new PlayerManager();

            Camera = new Camera(getViewport);

            SelectionGui = new SelectionGui();

            DebugOverlay = new DebugOverlay(this, game.ContentManager);

            Random = new Random(randomSeed);

            if (mapFile != null)
            {
                MapFile    = mapFile;
                Terrain    = AddDisposable(new Terrain.Terrain(mapFile, game.AssetStore.LoadContext));
                WaterAreas = AddDisposable(new WaterAreaCollection(mapFile.PolygonTriggers, mapFile.StandingWaterAreas, mapFile.StandingWaveAreas, game.AssetStore.LoadContext));
                Navigation = new Navigation.Navigation(mapFile.BlendTileData, Terrain.HeightMap);
            }

            RegisterInputHandler(_cameraInputMessageHandler = new CameraInputMessageHandler(), inputMessageBuffer);

            if (!isDiagnosticScene)
            {
                RegisterInputHandler(new SelectionMessageHandler(game.Selection), inputMessageBuffer);
                RegisterInputHandler(_orderGeneratorInputHandler = new OrderGeneratorInputHandler(game.OrderGenerator), inputMessageBuffer);
                RegisterInputHandler(_debugMessageHandler        = new DebugMessageHandler(DebugOverlay), inputMessageBuffer);
            }

            ParticleSystemManager = AddDisposable(new ParticleSystemManager(game.AssetStore.LoadContext));

            Radar = new Radar(this, game.AssetStore, mapPath);

            if (mapFile != null)
            {
                var borderWidth = mapFile.HeightMapData.BorderWidth * HeightMap.HorizontalScale;
                var width       = mapFile.HeightMapData.Width * HeightMap.HorizontalScale;
                var height      = mapFile.HeightMapData.Height * HeightMap.HorizontalScale;
                Quadtree = new Quadtree <GameObject>(new RectangleF(-borderWidth, -borderWidth, width, height));
            }

            GameContext = new GameContext(
                game.AssetStore.LoadContext,
                game.Audio,
                ParticleSystemManager,
                new ObjectCreationListManager(),
                Terrain,
                Navigation,
                Radar,
                Quadtree,
                this);

            GameObjects = AddDisposable(new GameObjectCollection(GameContext));

            GameContext.GameObjects = GameObjects;

            _orderGeneratorSystem = game.OrderGenerator;
        }
Exemplo n.º 2
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _worldModels = GetTemplateChild("PART_WorldModels") as Model3DGroup;
            _camera      = GetTemplateChild("PART_Camera") as OrthographicCamera;
            _world       = GetTemplateChild("PART_World") as Viewport3D;

            _frameTimer          = new System.Windows.Threading.DispatcherTimer();
            _frameTimer.Tick    += OnFrame;
            _frameTimer.Interval = TimeSpan.FromSeconds(1.0 / 45.0);
            _frameTimer.Start();

            this._lastTick = Environment.TickCount;

            _pm = new ParticleSystemManager();

            this._worldModels.Children.Add(_pm.CreateParticleSystem(1000, Colors.Gray, ImageSource));
            this._worldModels.Children.Add(_pm.CreateParticleSystem(1000, Colors.Red, ImageSource));
            this._worldModels.Children.Add(_pm.CreateParticleSystem(1000, Colors.Silver, ImageSource));
            this._worldModels.Children.Add(_pm.CreateParticleSystem(1000, Colors.OldLace, ImageSource));
            this._worldModels.Children.Add(_pm.CreateParticleSystem(1000, Colors.YellowGreen, ImageSource));
            this._worldModels.Children.Add(_pm.CreateParticleSystem(1000, Colors.Orange, ImageSource));

            _rand = new Random(this.GetHashCode());
        }
Exemplo n.º 3
0
		//===========================================================
		// Overridden Particle System Functions
		//===========================================================

		// Initialize internal particle systems after this one has been Initialized
		protected override void AfterInitialize()
		{
			mcParticleSystemManager = new ParticleSystemManager();

			mcFireworksExplosionParticleSystem1 = new FireworksExplosionParticleParticleSystem(Game);
			mcFireworksExplosionParticleSystem2 = new FireworksExplosionParticleParticleSystem(Game);
			mcFireworksExplosionParticleSystem3 = new FireworksExplosionParticleParticleSystem(Game);
			mcFireworksExplosionParticleSystem4 = new FireworksExplosionParticleParticleSystem(Game);
			mcFireworksExplosionSmokeParticleSystem = new FireworksExplosionParticleParticleSystem(Game);

			// Add all of the particle systems to the manager
			mcParticleSystemManager.AddParticleSystem(mcFireworksExplosionParticleSystem1);
			mcParticleSystemManager.AddParticleSystem(mcFireworksExplosionParticleSystem2);
			mcParticleSystemManager.AddParticleSystem(mcFireworksExplosionParticleSystem3);
			mcParticleSystemManager.AddParticleSystem(mcFireworksExplosionParticleSystem4);
			mcParticleSystemManager.AddParticleSystem(mcFireworksExplosionSmokeParticleSystem);

			// Initialize all of the Fireworks Particle Systems
			mcParticleSystemManager.AutoInitializeAllParticleSystems(GraphicsDevice, ContentManager, null);

			// Perform additional initialization work on the particle systems
			mcFireworksExplosionParticleSystem1.SetTexture("Textures/Star");
			mcFireworksExplosionParticleSystem2.SetTexture("Textures/Cloud");
			mcFireworksExplosionParticleSystem3.SetTexture("Textures/Spark");
			mcFireworksExplosionParticleSystem4.SetTexture("Textures/Particle");
			mcFireworksExplosionParticleSystem4.LoadShimmeringExplosionParticleEvents();
			mcFireworksExplosionSmokeParticleSystem.SetTexture("Textures/Smoke");
			mcFireworksExplosionSmokeParticleSystem.LoadExplosionSmokeParticleEvents();

			mcFireworksExplosionParticleSystem1.AutoMemoryManagerSettings.SecondsMaxNumberOfParticlesMustExistForBeforeReducingSize = 10;
			mcFireworksExplosionParticleSystem2.AutoMemoryManagerSettings.SecondsMaxNumberOfParticlesMustExistForBeforeReducingSize = 10;
			mcFireworksExplosionParticleSystem3.AutoMemoryManagerSettings.SecondsMaxNumberOfParticlesMustExistForBeforeReducingSize = 10;
			mcFireworksExplosionParticleSystem4.AutoMemoryManagerSettings.SecondsMaxNumberOfParticlesMustExistForBeforeReducingSize = 10;
			mcFireworksExplosionSmokeParticleSystem.AutoMemoryManagerSettings.SecondsMaxNumberOfParticlesMustExistForBeforeReducingSize = 10;
		}
Exemplo n.º 4
0
        }   // end of DrawSolidSphere()

        public static void DrawSolidEllipsoid(Camera camera, Vector3 position, Vector3 radii, Vector4 color)
        {
            Sphere sphere = Sphere.GetInstance();

            // Get the effect we need.  Borrow it from the particle system manager.
            ParticleSystemManager manager = InGame.inGame.ParticleSystemManager;

            // Set up common rendering values.
            Effect effect = manager.Effect3d;

            effect.CurrentTechnique = color.W > 0.99f
                ? manager.Technique(ParticleSystemManager.EffectTech3d.OpaqueColorPass)
                : manager.Technique(ParticleSystemManager.EffectTech3d.TransparentColorPass);

            // Set parameters.
            manager.Parameter(ParticleSystemManager.EffectParams3d.Radius).SetValue(1.0f);
            manager.Parameter(ParticleSystemManager.EffectParams3d.DiffuseColor).SetValue(color);
            manager.Parameter(ParticleSystemManager.EffectParams3d.EmissiveColor).SetValue(Vector4.Zero);
            manager.Parameter(ParticleSystemManager.EffectParams3d.SpecularColor).SetValue(new Vector4(0.9f));
            manager.Parameter(ParticleSystemManager.EffectParams3d.SpecularPower).SetValue(16.0f);
            manager.Parameter(ParticleSystemManager.EffectParams3d.Alpha).SetValue(color.W);

            manager.Parameter(ParticleSystemManager.EffectParams3d.Shininess).SetValue(0.4f);

            // Set up world matrix.
            Matrix worldMatrix = Matrix.CreateScale(radii);

            // Set radius and translation.
            worldMatrix.Translation = position;
            Matrix worldViewProjMatrix = worldMatrix * camera.ViewProjectionMatrix;

            // Render
            sphere.Render(camera, ref worldMatrix, effect);
        }   // end of Node Render()
Exemplo n.º 5
0
        /// <summary>
        /// Construct game object
        /// </summary>
        public BeatShift()
        {
            singleton = this;
            graphics = new GraphicsDeviceManager(this);
            //#if XBOX
            graphics.PreferredBackBufferWidth = 1280;
            graphics.PreferredBackBufferHeight = 720;
            //#endif
            // TODO: uncomment the above at your peril, performance profiling needed
            particleManager = new ParticleSystemManager();
            Content.RootDirectory = "Content";
            contentManager = Content;

            //Turn on antialiasing
            graphics.PreferMultiSampling = true;

            //Profiling option
            #if DEBUG
            //this.IsFixedTimeStep = false;
            //graphics.SynchronizeWithVerticalRetrace = false;
            #endif

            //Components.Add(new GamerServicesComponent(this));
            //TODO: xbox-live
        }
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
Exemplo n.º 7
0
        static bool Prefix(Agent __instance, ref Blow b)
        {
            if (InvulnerableSettings.Instance.Enabled == false)
            {
                return(true);
            }
            if (__instance.IsMainAgent)
            {
                if (!b.BlowFlag.HasAnyFlag(BlowFlags.NoSound))
                {
                    Agent agent = (b.OwnerId != -1) ? __instance.Mission.FindAgentWithIndex(b.OwnerId) : __instance;

                    int   soundIndex     = GetSoundIndex(GetWeaponClass(ref b));
                    float forceParameter = GetForceParameter(ref b);
                    SoundEventParameter soundEventParameter = new SoundEventParameter("Force", forceParameter);
                    Mission.Current.MakeSound(soundIndex, b.Position, true, false, -1, -1, ref soundEventParameter);
                    MatrixFrame f       = __instance.Frame;
                    Vec3        dirDist = b.Position - f.origin;
                    Vec3        dir     = dirDist.NormalizedCopy();
                    float       offset  = 0.05f * agent.GetEyeGlobalHeight();
                    f.origin = b.Position + dir * offset;
                    Mission.Current.Scene.CreateBurstParticle(ParticleSystemManager.GetRuntimeIdByName("psys_game_metal_metal_coll"), f);
                    __instance.Mission.AddSoundAlarmFactorToAgents(b.OwnerId, b.Position, 15f);
                }
                return(false);
            }
            return(true);
        }
Exemplo n.º 8
0
 public void CreateParticleSystemAttachedToBone(
     string particleName,
     sbyte boneIndex,
     ref MatrixFrame boneLocalParticleFrame)
 {
     this.CreateParticleSystemAttachedToBone(ParticleSystemManager.GetRuntimeIdByName(particleName), boneIndex, ref boneLocalParticleFrame);
 }
Exemplo n.º 9
0
        /// <summary>
        /// Initialize all of the particle systems used by this particle system class.
        /// </summary>
        private void AutoInitializeOtherParticleSystems()
        {
            _particleSystemManager = new ParticleSystemManager();

            // Create all the particle systems
            _debrisParticleSystem       = new ExplosionDebrisParticleSystem();
            _fireSmokeParticleSystem    = new ExplosionFireSmokeParticleSystem();
            _flashParticleSystem        = new ExplosionFlashParticleSystem();
            _flyingSparksParticleSystem = new ExplosionFlyingSparksParticleSystem();
            _roundSparksParticleSystem  = new ExplosionRoundSparksParticleSystem();
            _shockwaveParticleSystem    = new ExplosionShockwaveParticleSystem();
            _smokeTrailsParticleSystem  = new ExplosionSmokeTrailsParticleSystem();

            // Specify the order the particle systems should be drawn in
            _debrisParticleSystem.DrawOrder       = 100;
            _fireSmokeParticleSystem.DrawOrder    = 200;
            _flashParticleSystem.DrawOrder        = 200;
            _flyingSparksParticleSystem.DrawOrder = 200;
            _roundSparksParticleSystem.DrawOrder  = 200;
            _shockwaveParticleSystem.DrawOrder    = 200;
            _smokeTrailsParticleSystem.DrawOrder  = 200;

            // Add all of the particle systems to the manager
            _particleSystemManager.AddParticleSystem(_debrisParticleSystem);
            _particleSystemManager.AddParticleSystem(_fireSmokeParticleSystem);
            _particleSystemManager.AddParticleSystem(_flashParticleSystem);
            _particleSystemManager.AddParticleSystem(_flyingSparksParticleSystem);
            _particleSystemManager.AddParticleSystem(_roundSparksParticleSystem);
            _particleSystemManager.AddParticleSystem(_shockwaveParticleSystem);
            _particleSystemManager.AddParticleSystem(_smokeTrailsParticleSystem);

            // Initialize all of the particle systems
            _particleSystemManager.AutoInitializeAllParticleSystems(this.GraphicsDevice, this.ContentManager, null);
        }
Exemplo n.º 10
0
        public Scene3D(
            Game game,
            ICameraController cameraController,
            MapFile mapFile,
            Terrain.Terrain terrain,
            MapScriptCollection scripts,
            GameObjectCollection gameObjects,
            WaypointCollection waypoints,
            WaypointPathCollection waypointPaths,
            WorldLighting lighting)
        {
            Camera           = new CameraComponent(game);
            CameraController = cameraController;

            MapFile       = mapFile;
            Terrain       = terrain;
            Scripts       = scripts;
            GameObjects   = AddDisposable(gameObjects);
            Waypoints     = waypoints;
            WaypointPaths = waypointPaths;
            Lighting      = lighting;

            _cameraInputMessageHandler = new CameraInputMessageHandler();
            game.InputMessageBuffer.Handlers.Add(_cameraInputMessageHandler);
            AddDisposeAction(() => game.InputMessageBuffer.Handlers.Remove(_cameraInputMessageHandler));

            _particleSystemManager = AddDisposable(new ParticleSystemManager(game, this));

            _players = new List <Player>();
        }
Exemplo n.º 11
0
        public Racer(RacerId rID, int ship_Number, RacerType racer_Type)
        {
            shipNumber = ship_Number;
            racerType = racer_Type;
            racerID = rID;
            raceTiming=new RaceTiming(this);
            shipDrawing = new ShipDrawing(new Func<Matrix>(() => Matrix.Identity), new Func<Vector3>(() => Vector3.Zero), this);
            beatQueue = new BeatQueue(this);
            racerPoints = new RacerPoints();
            visualizationSystems = new ParticleSystemManager();
            globalSystems = new ParticleSystemManager();
            //setColour(1);//Set to red
            //Hum = SoundManager.getEngineHum();
            //if (this.GetType() == typeof(RacerHuman))
            //{
            //    Hum.Play();
            //}
            constructRaceVariables();

            if (racerType == RacerType.AI)
            {
                constructRandomShip(shipNumber);
            }

            //Setup effect to render the ConvexHull of physicsBody with transparency
            //SetupHullRenderer();
        }
Exemplo n.º 12
0
        public Racer(RacerId rID, int ship_Number, RacerType racer_Type)
        {
            shipNumber           = ship_Number;
            racerType            = racer_Type;
            racerID              = rID;
            raceTiming           = new RaceTiming(this);
            shipDrawing          = new ShipDrawing(new Func <Matrix>(() => Matrix.Identity), new Func <Vector3>(() => Vector3.Zero), this);
            beatQueue            = new BeatQueue(this);
            racerPoints          = new RacerPoints();
            visualizationSystems = new ParticleSystemManager();
            globalSystems        = new ParticleSystemManager();
            //setColour(1);//Set to red
            //Hum = SoundManager.getEngineHum();
            //if (this.GetType() == typeof(RacerHuman))
            //{
            //    Hum.Play();
            //}
            constructRaceVariables();

            if (racerType == RacerType.AI)
            {
                constructRandomShip(shipNumber);
            }

            //Setup effect to render the ConvexHull of physicsBody with transparency
            //SetupHullRenderer();
        }
Exemplo n.º 13
0
        /// <summary>
        /// Construct game object
        /// </summary>
        public BeatShift()
        {
            singleton = this;
            graphics  = new GraphicsDeviceManager(this);
//#if XBOX
            graphics.PreferredBackBufferWidth  = 1280;
            graphics.PreferredBackBufferHeight = 720;
//#endif
            // TODO: uncomment the above at your peril, performance profiling needed
            particleManager       = new ParticleSystemManager();
            Content.RootDirectory = "Content";
            contentManager        = Content;

            //Turn on antialiasing
            graphics.PreferMultiSampling = true;

            //Profiling option
#if DEBUG
            //this.IsFixedTimeStep = false;
            //graphics.SynchronizeWithVerticalRetrace = false;
#endif

            //Components.Add(new GamerServicesComponent(this));
            //TODO: xbox-live
        }
        public void Test()
        {
            var m = new ParticleSystemManager();

              var parent = new ParticleSystem() { Service = m };
              var a = new ParticleSystem();
              var b = new ParticleSystem();
              var c = new ParticleSystem();

              var psc = new ParticleSystemCollection();
              parent.Children = psc;

              psc.Add(a);

              Assert.AreEqual(parent, a.Parent);
              Assert.AreEqual(m, a.Service);

              psc[0] = b;

              Assert.AreEqual(null, a.Parent);
              Assert.AreEqual(null, a.Service);
              Assert.AreEqual(parent, b.Parent);
              Assert.AreEqual(m, b.Service);

              psc.Add(a);

              psc.Remove(b);
              Assert.AreEqual(null, b.Parent);
              Assert.AreEqual(null, b.Service);

              psc.Clear();
              Assert.AreEqual(null, a.Parent);
              Assert.AreEqual(null, a.Service);
        }
Exemplo n.º 15
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.relativeVelocity.magnitude > 1.0f)
     {
         GetComponent <GenerateView>().GetCurrentView().GetComponent <HookeScale>().Perturb();
         ScreenShakeManager.Perturb();
         ParticleSystemManager.RequestParticlesAtPositionAndDirection(collision.contacts[0].point, collision.contacts[0].normal);
     }
 }
Exemplo n.º 16
0
        public static ParticleSystemManager getSingleton()
        {
            ParticleSystemManager ret = new ParticleSystemManager(OgrePINVOKE.ParticleSystemManager_getSingleton(), false);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 18
0
        protected override void AfterDestroy()
        {
            base.AfterDestroy();

            // Remove all particle systems from the manager and destroy it
            if (_particleSystemManager != null)
            {
                _particleSystemManager.RemoveAllParticleSystems();
                _particleSystemManager = null;
            }

            // Destroy all of the particle systems
            if (_debrisParticleSystem != null)
            {
                _debrisParticleSystem.Destroy();
                _debrisParticleSystem = null;
            }

            if (_fireSmokeParticleSystem != null)
            {
                _fireSmokeParticleSystem.Destroy();
                _fireSmokeParticleSystem = null;
            }

            if (_flashParticleSystem != null)
            {
                _flashParticleSystem.Destroy();
                _flashParticleSystem = null;
            }

            if (_flyingSparksParticleSystem != null)
            {
                _flyingSparksParticleSystem.Destroy();
                _flyingSparksParticleSystem = null;
            }

            if (_roundSparksParticleSystem != null)
            {
                _roundSparksParticleSystem.Destroy();
                _roundSparksParticleSystem = null;
            }

            if (_shockwaveParticleSystem != null)
            {
                _shockwaveParticleSystem.Destroy();
                _shockwaveParticleSystem = null;
            }

            if (_smokeTrailsParticleSystem != null)
            {
                _smokeTrailsParticleSystem.Destroy();
                _smokeTrailsParticleSystem = null;
            }
        }
Exemplo n.º 19
0
 public GameContext(
     AssetLoadContext assetLoadContext,
     AudioSystem audioSystem,
     ParticleSystemManager particleSystems,
     Terrain.Terrain terrain)
 {
     AssetLoadContext = assetLoadContext;
     AudioSystem      = audioSystem;
     ParticleSystems  = particleSystems;
     Terrain          = terrain;
 }
Exemplo n.º 20
0
		protected override void AfterDestroy()
		{
			if (mcParticleSystemManager != null)
				mcParticleSystemManager.DestroyAndRemoveAllParticleSystems();
			mcParticleSystemManager = null;

			mcFireworksExplosionParticleSystem1 = null;
			mcFireworksExplosionParticleSystem2 = null;
			mcFireworksExplosionParticleSystem3 = null;
			mcFireworksExplosionParticleSystem4 = null;
			mcFireworksExplosionSmokeParticleSystem = null;
		}
Exemplo n.º 21
0
        public Scene3D(
            Game game,
            InputMessageBuffer inputMessageBuffer,
            Func <Viewport> getViewport,
            ICameraController cameraController,
            MapFile mapFile,
            Terrain.Terrain terrain,
            Terrain.WaterArea[] waterAreas,
            Terrain.Road[] roads,
            Terrain.Bridge[] bridges,
            MapScriptCollection scripts,
            GameObjectCollection gameObjects,
            WaypointCollection waypoints,
            WaypointPathCollection waypointPaths,
            WorldLighting lighting,
            Player[] players,
            Team[] teams,
            bool isDiagnosticScene = false)
        {
            Camera           = new Camera(getViewport);
            CameraController = cameraController;

            MapFile       = mapFile;
            Terrain       = terrain;
            WaterAreas    = waterAreas;
            Roads         = roads;
            Bridges       = bridges;
            Scripts       = scripts;
            GameObjects   = AddDisposable(gameObjects);
            Waypoints     = waypoints;
            WaypointPaths = waypointPaths;
            Lighting      = lighting;

            SelectionGui = new SelectionGui();

            RegisterInputHandler(_cameraInputMessageHandler = new CameraInputMessageHandler(), inputMessageBuffer);

            DebugOverlay = new DebugOverlay(this, game.ContentManager);

            if (!isDiagnosticScene)
            {
                RegisterInputHandler(_selectionMessageHandler    = new SelectionMessageHandler(game.Selection), inputMessageBuffer);
                RegisterInputHandler(_orderGeneratorInputHandler = new OrderGeneratorInputHandler(game.OrderGenerator), inputMessageBuffer);
                RegisterInputHandler(_debugMessageHandler        = new DebugMessageHandler(DebugOverlay), inputMessageBuffer);
            }

            _particleSystemManager = AddDisposable(new ParticleSystemManager(this));

            _players = players.ToList();
            _teams   = teams.ToList();
            // TODO: This is completely wrong.
            LocalPlayer = _players.FirstOrDefault();
        }
Exemplo n.º 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()
		{
			// Define the type of Gestures to accept
			TouchPanel.EnabledGestures = GestureType.DoubleTap | GestureType.Pinch;

			// Create the Particle Systems
			_dpsfSplashScreenParticleSystem = new DPSFSplashScreenParticleSystem(this);
			_spriteParticleSystem = new SpriteParticleSystem(this);
			_particleSystemManager = new ParticleSystemManager();
			_particleSystemManager.UpdatesPerSecond = 30;

			base.Initialize();
		}
Exemplo n.º 23
0
        public Scene3D(
            Game game,
            ICameraController cameraController,
            MapFile mapFile,
            Terrain.Terrain terrain,
            Terrain.WaterArea[] waterAreas,
            Terrain.Road[] roads,
            Terrain.Bridge[] bridges,
            MapScriptCollection scripts,
            GameObjectCollection gameObjects,
            WaypointCollection waypoints,
            WaypointPathCollection waypointPaths,
            WorldLighting lighting,
            Player[] players,
            Team[] teams)
        {
            Camera           = new Camera(() => game.Viewport);
            CameraController = cameraController;

            MapFile       = mapFile;
            Terrain       = terrain;
            WaterAreas    = waterAreas;
            Roads         = roads;
            Bridges       = bridges;
            Scripts       = scripts;
            GameObjects   = AddDisposable(gameObjects);
            Waypoints     = waypoints;
            WaypointPaths = waypointPaths;
            Lighting      = lighting;

            SelectionGui             = new SelectionGui();
            _selectionMessageHandler = new SelectionMessageHandler(game.Selection);
            game.InputMessageBuffer.Handlers.Add(_selectionMessageHandler);
            AddDisposeAction(() => game.InputMessageBuffer.Handlers.Remove(_selectionMessageHandler));

            _cameraInputMessageHandler = new CameraInputMessageHandler();
            game.InputMessageBuffer.Handlers.Add(_cameraInputMessageHandler);
            AddDisposeAction(() => game.InputMessageBuffer.Handlers.Remove(_cameraInputMessageHandler));

            DebugOverlay         = new DebugOverlay(this, game.ContentManager);
            _debugMessageHandler = new DebugMessageHandler(DebugOverlay);
            game.InputMessageBuffer.Handlers.Add(_debugMessageHandler);
            AddDisposeAction(() => game.InputMessageBuffer.Handlers.Remove(_debugMessageHandler));

            _particleSystemManager = AddDisposable(new ParticleSystemManager(game, this));

            _players = players.ToList();
            _teams   = teams.ToList();
            // TODO: This is completely wrong.
            LocalPlayer = _players.FirstOrDefault();
        }
Exemplo n.º 24
0
        public static void Trigger(string particleEffect, string sound, MatrixFrame location, int relatedAgentIndex = -1)
        {
            if (!string.IsNullOrEmpty(particleEffect))
            {
                Mission.Current.Scene.CreateBurstParticle(
                    ParticleSystemManager.GetRuntimeIdByName(particleEffect),
                    location);
            }

            if (!string.IsNullOrEmpty(sound))
            {
                Mission.Current.MakeSound(SoundEvent.GetEventIdFromString(sound),
                                          location.origin, false, true, relatedAgentIndex, -1);
            }
        }
Exemplo n.º 25
0
 public GameContext(
     AssetLoadContext assetLoadContext,
     AudioSystem audioSystem,
     ParticleSystemManager particleSystems,
     ObjectCreationListManager objectCreationLists,
     Terrain.Terrain terrain,
     Navigation.Navigation navigation)
 {
     AssetLoadContext    = assetLoadContext;
     AudioSystem         = audioSystem;
     ParticleSystems     = particleSystems;
     ObjectCreationLists = objectCreationLists;
     Terrain             = terrain;
     Navigation          = navigation;
 }
Exemplo n.º 26
0
        private Scene3D(Game game, Func <Viewport> getViewport, InputMessageBuffer inputMessageBuffer, int randomSeed, bool isDiagnosticScene, MapFile mapFile)
        {
            Camera = new Camera(getViewport);

            SelectionGui = new SelectionGui();

            DebugOverlay = new DebugOverlay(this, game.ContentManager);

            Random = new Random(randomSeed);

            if (mapFile != null)
            {
                MapFile    = mapFile;
                Terrain    = AddDisposable(new Terrain.Terrain(mapFile, game.AssetStore.LoadContext));
                WaterAreas = AddDisposable(new WaterAreaCollection(mapFile.PolygonTriggers, mapFile.StandingWaterAreas, mapFile.StandingWaveAreas, game.AssetStore.LoadContext));
                Navigation = new Navigation.Navigation(mapFile.BlendTileData, Terrain.HeightMap);
            }

            RegisterInputHandler(_cameraInputMessageHandler = new CameraInputMessageHandler(), inputMessageBuffer);

            if (!isDiagnosticScene)
            {
                RegisterInputHandler(new SelectionMessageHandler(game.Selection), inputMessageBuffer);
                RegisterInputHandler(_orderGeneratorInputHandler = new OrderGeneratorInputHandler(game.OrderGenerator), inputMessageBuffer);
                RegisterInputHandler(_debugMessageHandler        = new DebugMessageHandler(DebugOverlay), inputMessageBuffer);
            }

            _particleSystemManager = AddDisposable(new ParticleSystemManager(game.AssetStore.LoadContext));

            GameContext = new GameContext(
                game.AssetStore.LoadContext,
                game.Audio,
                _particleSystemManager,
                new ObjectCreationListManager(),
                Terrain,
                Navigation);

            GameObjects = AddDisposable(
                new GameObjectCollection(
                    GameContext,
                    game.CivilianPlayer,
                    Navigation));

            GameContext.GameObjects = GameObjects;

            _orderGeneratorSystem = game.OrderGenerator;
        }
Exemplo n.º 27
0
        // c'tor
        public GlorpEmitter(ParticleSystemManager manager)
            : base(manager)
        {
            base.Init();
            LoadGraphicsContent(BokuGame.Graphics);

            Color        = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
            StartRadius  = 0.0f;
            EndRadius    = 1.0f;
            StartAlpha   = 1.0f;
            EndAlpha     = 0.0f;
            MinLifetime  = 0.2f;   // Particle lifetime.
            MaxLifetime  = 1.0f;
            EmissionRate = 10.0f;  // Particles per second.

            MaxRotationRate = 2.0f;
        }   // end of c'tor
Exemplo n.º 28
0
        private Scene3D(Game game, Func <Viewport> getViewport, InputMessageBuffer inputMessageBuffer, bool isDiagnosticScene)
        {
            Camera = new Camera(getViewport);

            SelectionGui = new SelectionGui();

            DebugOverlay = new DebugOverlay(this, game.ContentManager);

            RegisterInputHandler(_cameraInputMessageHandler = new CameraInputMessageHandler(), inputMessageBuffer);

            if (!isDiagnosticScene)
            {
                RegisterInputHandler(_selectionMessageHandler    = new SelectionMessageHandler(game.Selection), inputMessageBuffer);
                RegisterInputHandler(_orderGeneratorInputHandler = new OrderGeneratorInputHandler(game.OrderGenerator), inputMessageBuffer);
                RegisterInputHandler(_debugMessageHandler        = new DebugMessageHandler(DebugOverlay), inputMessageBuffer);
            }

            _particleSystemManager = AddDisposable(new ParticleSystemManager(this));
        }
Exemplo n.º 29
0
    private void Shoot(float deltaTime)
    {
        if (myShootTimer <= 0.0 || myShootTimer == shootRate)
        {
            GameplayState.TotalShoots++;

            RaycastHit hitInfo;
            bool       hasHit = Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hitInfo, shootMaxDistance, shootBitMask);

            Vector3 targetPosition;

            if (hasHit)
            {
                targetPosition = hitInfo.point;

                if (hitInfo.collider.gameObject.tag == "Enemy")
                {
                    GameplayState.SuccessShoots++;

                    HealthState enemyHealthState = hitInfo.collider.gameObject.GetComponent <HealthState> ();

                    enemyHealthState.ReceiveDamage(shootDamage);
                }

                ParticleSystem currentPS = ParticleSystemManager.GetParticleInstance("PSShootImpact", GameplayState.TotalShoots);
                currentPS.transform.position = hitInfo.point;
                currentPS.Stop();
                currentPS.Play();
            }
            else
            {
                targetPosition = Camera.main.transform.forward * shootMaxDistance;
            }

            FXAudio.PlayClip("fire");
            StartCoroutine(DrawShootLine(targetPosition, shootRate * 0.5f));

            currentAmmo--;
            myShootTimer = shootRate;
        }

        myShootTimer -= deltaTime;
    }
 public bool CheckRemove()
 {
     if (config.Duration.HasValue &&
         MBCommon.GetTime(MBCommon.TimeType.Mission) > config.Duration.Value + started)
     {
         Log.LogFeedEvent($"{config.Name} expired on {agent.Name}!");
         if (!string.IsNullOrEmpty(config.DeactivateParticleEffect))
         {
             Mission.Current.Scene.CreateBurstParticle(ParticleSystemManager.GetRuntimeIdByName(config.DeactivateParticleEffect), agent.AgentVisuals.GetGlobalFrame());
         }
         if (!string.IsNullOrEmpty(config.DeactivateSound))
         {
             Mission.Current.MakeSound(SoundEvent.GetEventIdFromString(config.DeactivateSound), agent.AgentVisuals.GetGlobalFrame().origin, false, true, agent.Index, -1);
         }
         Stop();
         return(true);
     }
     return(false);
 }
Exemplo n.º 31
0
 public GameContext(
     AssetLoadContext assetLoadContext,
     AudioSystem audioSystem,
     ParticleSystemManager particleSystems,
     ObjectCreationListManager objectCreationLists,
     Terrain.Terrain terrain,
     Navigation.Navigation navigation,
     Radar radar,
     Quadtree <GameObject> quadtree,
     Scene3D scene)
 {
     AssetLoadContext    = assetLoadContext;
     AudioSystem         = audioSystem;
     ParticleSystems     = particleSystems;
     ObjectCreationLists = objectCreationLists;
     Terrain             = terrain;
     Navigation          = navigation;
     Radar    = radar;
     Scene3D  = scene;
     Quadtree = quadtree;
 }
Exemplo n.º 32
0
        public Scene3D(
            Game game,
            ICameraController cameraController,
            MapFile mapFile,
            Terrain.Terrain terrain,
            MapScriptCollection scripts,
            GameObjectCollection gameObjects,
            WaypointCollection waypoints,
            WaypointPathCollection waypointPaths,
            WorldLighting lighting,
            Player[] players,
            Team[] teams)
        {
            Camera           = new CameraComponent(game);
            CameraController = cameraController;

            MapFile       = mapFile;
            Terrain       = terrain;
            Scripts       = scripts;
            GameObjects   = AddDisposable(gameObjects);
            Waypoints     = waypoints;
            WaypointPaths = waypointPaths;
            Lighting      = lighting;

            SelectionGui             = new SelectionGui();
            _selectionMessageHandler = new SelectionMessageHandler(game.Selection);
            game.InputMessageBuffer.Handlers.Add(_selectionMessageHandler);
            AddDisposeAction(() => game.InputMessageBuffer.Handlers.Remove(_selectionMessageHandler));

            _cameraInputMessageHandler = new CameraInputMessageHandler();
            game.InputMessageBuffer.Handlers.Add(_cameraInputMessageHandler);
            AddDisposeAction(() => game.InputMessageBuffer.Handlers.Remove(_cameraInputMessageHandler));

            _particleSystemManager = AddDisposable(new ParticleSystemManager(game, this));

            _players = players.ToList();
            _teams   = teams.ToList();
            // TODO: This is completely wrong.
            LocalPlayer = _players.FirstOrDefault();
        }
        public void Test()
        {
            var m = new ParticleSystemManager();

            var parent = new ParticleSystem()
            {
                Service = m
            };
            var a = new ParticleSystem();
            var b = new ParticleSystem();
            var c = new ParticleSystem();

            var psc = new ParticleSystemCollection();

            parent.Children = psc;

            psc.Add(a);

            Assert.AreEqual(parent, a.Parent);
            Assert.AreEqual(m, a.Service);

            psc[0] = b;

            Assert.AreEqual(null, a.Parent);
            Assert.AreEqual(null, a.Service);
            Assert.AreEqual(parent, b.Parent);
            Assert.AreEqual(m, b.Service);

            psc.Add(a);

            psc.Remove(b);
            Assert.AreEqual(null, b.Parent);
            Assert.AreEqual(null, b.Service);

            psc.Clear();
            Assert.AreEqual(null, a.Parent);
            Assert.AreEqual(null, a.Service);
        }
Exemplo n.º 34
0
                /// <summary>
                /// Render a node like sphere at givin position with given color.
                /// </summary>
                /// <param name="camera"></param>
                /// <param name="pos"></param>
                /// <param name="radius"></param>
                /// <param name="color"></param>
                private void RenderSphere(Camera camera, Vector3 pos, float radius, Vector4 color)
                {
                    if (camera.Frustum.CullTest(pos, radius) == Frustum.CullResult.TotallyOutside)
                    {
                        return;
                    }

                    Sphere sphere = Sphere.GetInstance();
                    ParticleSystemManager manager = InGame.inGame.ParticleSystemManager;
                    Effect effect = manager.Effect3d;

                    effect.CurrentTechnique = manager.Technique(ParticleSystemManager.EffectTech3d.TransparentColorPassNoZ);

                    Matrix worldMatrix = Matrix.Identity;

                    worldMatrix.Translation = pos;

                    manager.Parameter(ParticleSystemManager.EffectParams3d.DiffuseColor).SetValue(color);
                    manager.Parameter(ParticleSystemManager.EffectParams3d.EmissiveColor).SetValue(color);
                    manager.Parameter(ParticleSystemManager.EffectParams3d.Alpha).SetValue(color.W);
                    manager.Parameter(ParticleSystemManager.EffectParams3d.Radius).SetValue(radius);

                    sphere.Render(camera, ref worldMatrix, effect);
                }
Exemplo n.º 35
0
        public SongOfIce()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            this.Window.Title = "Song of Ice";
            IsMouseVisible = true;

            particleManager = new ParticleSystemManager();
            mainMenu = new Menu(this);
            metas = LevelFactory.CreateDefaultMetaLevelList();
            InitializeLevelLockStatus();

            /* Fullscreen Options */
            if (windowed)
            {
                graphics.PreferredBackBufferWidth = 1024;
                graphics.PreferredBackBufferHeight = 768;
            } else {
                graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings);
                graphics.IsFullScreen = true;
            }

            currentView = mainMenu;
        }
Exemplo n.º 36
0
        /// <summary>
        /// Initialize all of the particle systems used by this particle system class.
        /// </summary>
        private void AutoInitializeOtherParticleSystems(SpriteBatch spriteBatch)
        {
            _particleSystemManager = new ParticleSystemManager();

            // Create all the particle systems
            _debrisParticleSystem = new ExplosionDebrisParticleSystem(this.Game);
            _fireSmokeParticleSystem = new ExplosionFireSmokeParticleSystem(this.Game);
            _flashParticleSystem = new ExplosionFlashParticleSystem(this.Game);
            _flyingSparksParticleSystem = new ExplosionFlyingSparksParticleSystem(this.Game);
            _roundSparksParticleSystem = new ExplosionRoundSparksParticleSystem(this.Game);
            _shockwaveParticleSystem = new ExplosionShockwaveParticleSystem(this.Game);
            _smokeTrailsParticleSystem = new ExplosionSmokeTrailsParticleSystem(this.Game);

            // Specify the order the particle systems should be drawn in
            _debrisParticleSystem.DrawOrder = 100;
            _fireSmokeParticleSystem.DrawOrder = 200;
            _flashParticleSystem.DrawOrder = 200;
            _flyingSparksParticleSystem.DrawOrder = 200;
            _roundSparksParticleSystem.DrawOrder = 200;
            _shockwaveParticleSystem.DrawOrder = 200;
            _smokeTrailsParticleSystem.DrawOrder = 200;

            // Add all of the particle systems to the manager
            _particleSystemManager.AddParticleSystem(_debrisParticleSystem);
            _particleSystemManager.AddParticleSystem(_fireSmokeParticleSystem);
            _particleSystemManager.AddParticleSystem(_flashParticleSystem);
            _particleSystemManager.AddParticleSystem(_flyingSparksParticleSystem);
            _particleSystemManager.AddParticleSystem(_roundSparksParticleSystem);
            _particleSystemManager.AddParticleSystem(_shockwaveParticleSystem);
            _particleSystemManager.AddParticleSystem(_smokeTrailsParticleSystem);

            // Initialize all of the particle systems
			_particleSystemManager.AutoInitializeAllParticleSystems(this.GraphicsDevice, this.ContentManager, spriteBatch);

			// Turn off Lerping on the particle system emitters so that they don't trail from one explosion location to the next.
			_debrisParticleSystem.Emitter.LerpEmittersPositionAndOrientation = false;
			_fireSmokeParticleSystem.Emitter.LerpEmittersPositionAndOrientation = false;
			_flashParticleSystem.Emitter.LerpEmittersPositionAndOrientation = false;
			_flyingSparksParticleSystem.Emitter.LerpEmittersPositionAndOrientation = false;
			_roundSparksParticleSystem.Emitter.LerpEmittersPositionAndOrientation = false;
			_shockwaveParticleSystem.Emitter.LerpEmittersPositionAndOrientation = false;
			_smokeTrailsParticleSystem.Emitter.LerpEmittersPositionAndOrientation = false;
        }
Exemplo n.º 37
0
        protected override void ExecuteInternal(ReplyContext context, object baseConfig,
                                                Action <string> onSuccess, Action <string> onFailure)
        {
            if (Mission.Current == null)
            {
                onFailure($"No mission is active!");
                return;
            }

            if (BLTBuffetModule.EffectsConfig.DisableEffectsInTournaments &&
                MissionHelpers.InTournament())
            {
                onFailure($"Not allowed during tournament!");
                return;
            }

            if (!Mission.Current.IsLoadingFinished ||
                Mission.Current.CurrentState != Mission.State.Continuing ||
                Mission.Current?.GetMissionBehaviour <TournamentFightMissionController>() != null && Mission.Current.Mode != MissionMode.Battle)
            {
                onFailure($"The mission has not started yet!");
                return;
            }

            if (Mission.Current.IsMissionEnding || Mission.Current.MissionResult?.BattleResolved == true)
            {
                onFailure($"The mission is ending!");
                return;
            }

            var effectsBehaviour = BLTEffectsBehaviour.Get();

            var config = (Config)baseConfig;

            bool GeneralAgentFilter(Agent agent)
            => agent.IsHuman && (!config.TargetOnFootOnly || agent.HasMount == false) && !effectsBehaviour.Contains(agent, config);

            var target = config.Target switch
            {
                Target.Player => Agent.Main,
                Target.AdoptedHero => Mission.Current.Agents.FirstOrDefault(a => a.IsAdoptedBy(context.UserName)),
                Target.Any => Mission.Current.Agents.Where(GeneralAgentFilter).Where(a => !a.IsAdopted()).SelectRandom(),
                Target.EnemyTeam => Mission.Current.Agents.Where(GeneralAgentFilter)
                .Where(a => a.Team?.IsValid == true &&
                       Mission.Current.PlayerTeam?.IsValid == true &&
                       !a.Team.IsFriendOf(Mission.Current.PlayerTeam) &&
                       !a.IsAdopted())
                .SelectRandom(),
                Target.PlayerTeam => Mission.Current.Agents.Where(GeneralAgentFilter)
                .Where(a => a.Team?.IsPlayerTeam == true && !a.IsAdopted())
                .SelectRandom(),
                Target.AllyTeam => Mission.Current.Agents.Where(GeneralAgentFilter)
                .Where(a => a.Team?.IsPlayerAlly == false && !a.IsAdopted())
                .SelectRandom(),
                _ => null
            };

            if (target == null || target.AgentVisuals == null)
            {
                onFailure($"Couldn't find the target!");
                return;
            }

            if (string.IsNullOrEmpty(config.Name))
            {
                onFailure($"CharacterEffect {context.Source} configuration error: Name is missing!");
                return;
            }

            if (effectsBehaviour.Contains(target, config))
            {
                onFailure($"{target.Name} already affected by {config.Name}!");
                return;
            }

            if (config.TargetOnFootOnly && target.HasMount)
            {
                onFailure($"{target.Name} is mounted so cannot be affected by {config.Name}!");
                return;
            }

            var effectState = effectsBehaviour.Add(target, config);

            foreach (var pfx in config.ParticleEffects ?? Enumerable.Empty <ParticleEffectDef>())
            {
                var pfxState = new CharacterEffectState.PfxState();
                switch (pfx.AttachPoint)
                {
                case ParticleEffectDef.AttachPointEnum.OnWeapon:
                    pfxState.weaponEffects = CreateWeaponEffects(target, pfx.Name);
                    break;

                case ParticleEffectDef.AttachPointEnum.OnHands:
                    pfxState.boneAttachments = CreateAgentEffects(target,
                                                                  pfx.Name,
                                                                  MatrixFrame.Identity,
                                                                  Game.Current.HumanMonster.MainHandItemBoneIndex,
                                                                  Game.Current.HumanMonster.OffHandItemBoneIndex);
                    break;

                case ParticleEffectDef.AttachPointEnum.OnHead:
                    pfxState.boneAttachments = CreateAgentEffects(target,
                                                                  pfx.Name,
                                                                  MatrixFrame.Identity.Strafe(0.1f),
                                                                  Game.Current.HumanMonster.HeadLookDirectionBoneIndex);
                    break;

                case ParticleEffectDef.AttachPointEnum.OnBody:
                    pfxState.boneAttachments = CreateAgentEffects(target, pfx.Name, MatrixFrame.Identity.Elevate(0.1f));
                    break;

                default:
                    Log.Error($"{config.Name}: No location specified for particle Id {pfx.Name} in CharacterEffect");
                    break;
                }
                effectState.state.Add(pfxState);
            }

            // if (config.Properties != null && target.AgentDrivenProperties != null)
            // {
            //     ApplyPropertyModifiers(target, config);
            // }

            // if (config.Light != null)
            // {
            //     effectState.light = CreateLight(target, config.Light.Radius, config.Light.Intensity, config.Light.ColorParsed);
            // }

            if (config.RemoveArmor)
            {
                foreach (var(_, index) in target.SpawnEquipment.YieldArmorSlots())
                {
                    target.SpawnEquipment[index] = EquipmentElement.Invalid;
                }
                target.UpdateSpawnEquipmentAndRefreshVisuals(target.SpawnEquipment);
            }

            if (!string.IsNullOrEmpty(config.ActivateParticleEffect))
            {
                Mission.Current.Scene.CreateBurstParticle(ParticleSystemManager.GetRuntimeIdByName(config.ActivateParticleEffect), target.AgentVisuals.GetGlobalFrame());
            }
            if (!string.IsNullOrEmpty(config.ActivateSound))
            {
                Mission.Current.MakeSound(SoundEvent.GetEventIdFromString(config.ActivateSound), target.AgentVisuals.GetGlobalFrame().origin, false, true, target.Index, -1);
            }

            Log.LogFeedEvent($"{config.Name} is active on {target.Name}!");

            onSuccess($"{config.Name} is active on {target.Name}!");
        }
Exemplo n.º 38
0
 public ParticleEngine(ContentManager content, Game game)
 {
     ParticleSystemManager = new ParticleSystemManager();
     Particles = new Dictionary<string, Dictionary<string, ParticleSystem>>();
     FillParticles(content, game);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DPSFParticleManager"/> class.
 /// </summary>
 public DPSFParticleManager()
 {
     manager = new ParticleSystemManager();
 }
Exemplo n.º 40
0
        protected override void AfterDestroy()
        {
            base.AfterDestroy();

            // Remove all particle systems from the manager and destroy it
            if (_particleSystemManager != null)
            {
                _particleSystemManager.RemoveAllParticleSystems();
                _particleSystemManager = null;
            }

            // Destroy all of the particle systems
            if (_debrisParticleSystem != null)
            {
                _debrisParticleSystem.Destroy();
                _debrisParticleSystem = null;
            }

            if (_fireSmokeParticleSystem != null)
            {
                _fireSmokeParticleSystem.Destroy();
                _fireSmokeParticleSystem = null;
            }

            if (_flashParticleSystem != null)
            {
                _flashParticleSystem.Destroy();
                _flashParticleSystem = null;
            }

            if (_flyingSparksParticleSystem != null)
            {
                _flyingSparksParticleSystem.Destroy();
                _flyingSparksParticleSystem = null;
            }

            if (_roundSparksParticleSystem != null)
            {
                _roundSparksParticleSystem.Destroy();
                _roundSparksParticleSystem = null;
            }

            if (_shockwaveParticleSystem != null)
            {
                _shockwaveParticleSystem.Destroy();
                _shockwaveParticleSystem = null;
            }

            if (_smokeTrailsParticleSystem != null)
            {
                _smokeTrailsParticleSystem.Destroy();
                _smokeTrailsParticleSystem = null;
            }
        }
Exemplo n.º 41
0
        /// <summary>
        /// Initialize all of the particle systems used by this particle system class.
        /// </summary>
        private void AutoInitializeOtherParticleSystems()
        {
            _particleSystemManager = new ParticleSystemManager();

            // Create all the particle systems
            _debrisParticleSystem = new ExplosionDebrisParticleSystem();
            _fireSmokeParticleSystem = new ExplosionFireSmokeParticleSystem();
            _flashParticleSystem = new ExplosionFlashParticleSystem();
            _flyingSparksParticleSystem = new ExplosionFlyingSparksParticleSystem();
            _roundSparksParticleSystem = new ExplosionRoundSparksParticleSystem();
            _shockwaveParticleSystem = new ExplosionShockwaveParticleSystem();
            _smokeTrailsParticleSystem = new ExplosionSmokeTrailsParticleSystem();

            // Specify the order the particle systems should be drawn in
            _debrisParticleSystem.DrawOrder = 100;
            _fireSmokeParticleSystem.DrawOrder = 200;
            _flashParticleSystem.DrawOrder = 200;
            _flyingSparksParticleSystem.DrawOrder = 200;
            _roundSparksParticleSystem.DrawOrder = 200;
            _shockwaveParticleSystem.DrawOrder = 200;
            _smokeTrailsParticleSystem.DrawOrder = 200;
            
            // Add all of the particle systems to the manager
            _particleSystemManager.AddParticleSystem(_debrisParticleSystem);
            _particleSystemManager.AddParticleSystem(_fireSmokeParticleSystem);
            _particleSystemManager.AddParticleSystem(_flashParticleSystem);
            _particleSystemManager.AddParticleSystem(_flyingSparksParticleSystem);
            _particleSystemManager.AddParticleSystem(_roundSparksParticleSystem);
            _particleSystemManager.AddParticleSystem(_shockwaveParticleSystem);
            _particleSystemManager.AddParticleSystem(_smokeTrailsParticleSystem);

            // Initialize all of the particle systems
			_particleSystemManager.AutoInitializeAllParticleSystems(this.GraphicsDevice, this.ContentManager, null);
        }
Exemplo n.º 42
0
        private Scene3D(Game game, Func <Viewport> getViewport, InputMessageBuffer inputMessageBuffer, int randomSeed, bool isDiagnosticScene, MapFile mapFile, string mapPath)
        {
            Camera = new Camera(getViewport);

            SelectionGui = new SelectionGui();

            DebugOverlay = new DebugOverlay(this, game.ContentManager);

            Random = new Random(randomSeed);

            if (mapFile != null)
            {
                MapFile    = mapFile;
                Terrain    = AddDisposable(new Terrain.Terrain(mapFile, game.AssetStore.LoadContext));
                WaterAreas = AddDisposable(new WaterAreaCollection(mapFile.PolygonTriggers, mapFile.StandingWaterAreas, mapFile.StandingWaveAreas, game.AssetStore.LoadContext));
                Navigation = new Navigation.Navigation(mapFile.BlendTileData, Terrain.HeightMap);
            }

            if (mapPath != null)
            {
                var mapCache = game.AssetStore.MapCaches.GetByName(mapPath.ToLower());
                if (mapCache == null)
                {
                    mapCache = game.AssetStore.MapCaches.GetByName(Path.Combine(game.UserDataFolder, mapPath).ToLower());
                }
                if (mapCache == null)
                {
                    throw new Exception($"Failed to load MapCache \"{mapPath}\"");
                }
                MapCache = mapCache;
            }

            RegisterInputHandler(_cameraInputMessageHandler = new CameraInputMessageHandler(), inputMessageBuffer);

            if (!isDiagnosticScene)
            {
                RegisterInputHandler(new SelectionMessageHandler(game.Selection), inputMessageBuffer);
                RegisterInputHandler(_orderGeneratorInputHandler = new OrderGeneratorInputHandler(game.OrderGenerator), inputMessageBuffer);
                RegisterInputHandler(_debugMessageHandler        = new DebugMessageHandler(DebugOverlay), inputMessageBuffer);
            }

            _particleSystemManager = AddDisposable(new ParticleSystemManager(game.AssetStore.LoadContext));

            Radar = new Radar(this, game.AssetStore, MapCache);

            GameContext = new GameContext(
                game.AssetStore.LoadContext,
                game.Audio,
                _particleSystemManager,
                new ObjectCreationListManager(),
                Terrain,
                Navigation,
                Radar);

            GameObjects = AddDisposable(
                new GameObjectCollection(
                    GameContext,
                    game.CivilianPlayer,
                    Navigation));

            GameContext.GameObjects = GameObjects;

            _orderGeneratorSystem = game.OrderGenerator;
        }
	void Awake() 
	{
		instance = this;
	}