コード例 #1
0
        /// <summary>
        /// The default constructor for an explosion.
        /// </summary>
        /// <param name="physics">A reference to the physics engine.</param>
        /// <param name="explosionModel">The model to use for a particle in the explosion.</param>
        /// <param name="explosionTransforms">The graphical transforms to apply to the model.</param>
        /// <param name="explosionPosition">The position of the explosion.</param>
        public Explosion(PhysicsEngine.Environment physics, Model explosionModel,
                         Matrix[] explosionTransforms, Vector3 explosionPosition)
        {
            this.objectModel = explosionModel;
            this.transforms  = explosionTransforms;

            // Set up the particle parameters based on game constants
            ParticleSystemParameters psp = new ParticleSystemParameters();

            psp.BirthTime         = GameConstants.particleBirthTime;
            psp.BirthTimeVariance = 0;
            psp.Colour            = GameConstants.explosionColour;
            psp.ColourVariance    = GameConstants.colourVariance;
            psp.Direction         = GameConstants.particleBaseDirection;
            psp.DirectionVariance = GameConstants.particleDirectionVariance;
            psp.InitialParticles  = GameConstants.initialNumParticles;
            psp.LifeTime          = GameConstants.particleLifeTime;
            psp.LifeTimeVariance  = GameConstants.particleLifeTimeVariance;
            psp.Mass          = 1;
            psp.MassVariance  = 0.1f;
            psp.MaxParticles  = GameConstants.explosionNumParticles;
            psp.Position      = explosionPosition;
            psp.Speed         = GameConstants.explosionParticleSpeed;
            psp.SpeedVariance = 0;

            // Create the particle system and add it to the physics engine.
            this.physicsReference = new ParticleSystem(psp);
            physics.Add(physicsReference);
        }
コード例 #2
0
 private static bool TryCreateModParticleParams(Workbench workbench)
 {
     if (modParticlesParams != null)
     {
         return(true);
     }
     try
     {
         var sparks = ((GameObject[])sparksField.GetValue(workbench))[0].GetComponent <ParticleSystem>();
         originParticlesParams = new ParticleSystemParameters()
         {
             startColor = sparks.main.startColor
         };
         modParticlesParams = new ParticleSystemParameters()
         {
             startColor = Config.BeamAlphaColor
         };
         return(true);
     }
     catch (Exception e)
     {
         Logger.Log(Logger.Level.Error, null, e);
         return(false);
     }
 }
コード例 #3
0
 private static bool TryCreateModParticleParams(Fabricator fabricator)
 {
     if (modParticlesParams != null)
     {
         return(true);
     }
     try
     {
         var sparksL = ((GameObject)sparksLFieldInfo.GetValue(fabricator)).GetComponent <ParticleSystem>();
         originParticlesParams = new ParticleSystemParameters()
         {
             startColor = sparksL.main.startColor
         };
         modParticlesParams = new ParticleSystemParameters()
         {
             startColor = Config.BeamAlphaColor
         };
         return(true);
     }
     catch (Exception e)
     {
         Logger.Log(Logger.Level.Error, null, e);
         return(false);
     }
 }
コード例 #4
0
 private static void SetFabricatorParticlesParams(Fabricator fabricator, ParticleSystemParameters @params)
 {
     try
     {
         var sparksL = ((GameObject)sparksLFieldInfo.GetValue(fabricator)).GetComponent <ParticleSystem>();
         var sparksR = ((GameObject)sparksRFieldInfo.GetValue(fabricator)).GetComponent <ParticleSystem>();
         @params.Apply(sparksL);
         @params.Apply(sparksR);
     }
     catch (Exception e) { Logger.Log(Logger.Level.Error, null, e); }
 }
コード例 #5
0
 private static void SetWorkbenchParticlesParams(Workbench workbench, ParticleSystemParameters @params)
 {
     try
     {
         var sparks = (GameObject[])sparksField.GetValue(workbench);
         foreach (var spark in sparks)
         {
             @params.Apply(spark.GetComponent <ParticleSystem>());
         }
     }
     catch (Exception e) { Logger.Log(Logger.Level.Error, null, e); }
 }