Exemplo n.º 1
0
 private void SetupInstances()
 {
   float num1 = this.settings.ExplodingInstance.Trile.ActorSettings.Type == ActorType.Vase ? 0.05f : 0.15f;
   int maxValue = 16 - this.settings.MinimumSize;
   Vector3 b1 = FezMath.SideMask(this.CameraManager.Viewpoint);
   Vector3 b2 = FezMath.DepthMask(this.CameraManager.Viewpoint);
   bool flag1 = (double) b1.X != 0.0;
   bool flag2 = this.CameraManager.Viewpoint == Viewpoint.Front || this.CameraManager.Viewpoint == Viewpoint.Left;
   Random random = RandomHelper.Random;
   Vector3 a1 = this.settings.EnergySource.Value;
   Vector3 vector3_1 = new Vector3(FezMath.Dot(a1, b1), a1.Y, 0.0f);
   Vector3 vector3_2 = FezMath.Dot(this.settings.ExplodingInstance.Center, b2) * b2;
   Vector3 vector3_3 = a1 - FezMath.Dot(a1, b2) * b2;
   Vector2 vector2_1 = new Vector2((float) this.settings.ExplodingInstance.Trile.TrileSet.TextureAtlas.Width, (float) this.settings.ExplodingInstance.Trile.TrileSet.TextureAtlas.Height);
   Vector2 vector2_2 = new Vector2(128f / vector2_1.X, 16f / vector2_1.Y);
   Vector2 atlasOffset = this.settings.ExplodingInstance.Trile.AtlasOffset;
   List<SpaceDivider.DividedCell> list = (List<SpaceDivider.DividedCell>) null;
   if (this.settings.Crumble)
     list = SpaceDivider.Split(this.settings.ParticleCount);
   for (int instanceIndex = 0; instanceIndex < this.settings.ParticleCount; ++instanceIndex)
   {
     TrixelParticleSystem.Particle particle = new TrixelParticleSystem.Particle(this, instanceIndex)
     {
       Elasticity = num1
     };
     Vector3 vector3_4;
     Vector3 vector1;
     if (this.settings.Crumble)
     {
       SpaceDivider.DividedCell dividedCell = list[instanceIndex];
       vector3_4 = ((float) (dividedCell.Left - 8) * b1 + (float) (dividedCell.Bottom - 8) * Vector3.UnitY + (float) (dividedCell.Left - 8) * b2) / 16f;
       vector1 = ((float) dividedCell.Width * (b1 + b2) + (float) dividedCell.Height * Vector3.UnitY) / 16f;
     }
     else
     {
       vector3_4 = new Vector3((float) random.Next(0, maxValue), (float) random.Next(0, maxValue), (float) random.Next(0, maxValue));
       do
       {
         vector1 = new Vector3((float) random.Next(this.settings.MinimumSize, Math.Min(17 - (int) vector3_4.X, this.settings.MaximumSize)), (float) random.Next(this.settings.MinimumSize, Math.Min(17 - (int) vector3_4.Y, this.settings.MaximumSize)), (float) random.Next(this.settings.MinimumSize, Math.Min(17 - (int) vector3_4.Z, this.settings.MaximumSize)));
       }
       while ((double) Math.Abs(vector1.X - vector1.Y) > ((double) vector1.X + (double) vector1.Y) / 2.0 || (double) Math.Abs(vector1.Z - vector1.Y) > ((double) vector1.Z + (double) vector1.Y) / 2.0);
       vector3_4 = (vector3_4 - new Vector3(8f)) / 16f;
       vector1 /= 16f;
     }
     particle.Size = vector1;
     float num2 = flag1 ? vector1.X : vector1.Z;
     particle.TextureMatrix = new Vector4(num2 * vector2_2.X, vector1.Y * vector2_2.Y, (float) (((flag2 ? 1.0 : -1.0) * (flag1 ? (double) vector3_4.X : (double) vector3_4.Z) + (flag2 ? 0.0 : -(double) num2) + 0.5 + 1.0 / 16.0) / 8.0) * vector2_2.X + atlasOffset.X, (float) (-((double) vector3_4.Y + (double) vector1.Y) + 0.5 + 1.0 / 16.0) * vector2_2.Y + atlasOffset.Y);
     float num3 = this.settings.Darken ? RandomHelper.Between(0.3, 1.0) : 1f;
     particle.Color = new Vector3(num3, num3, num3);
     Vector3 a2 = this.settings.ExplodingInstance.Center + vector3_4 + vector1 / 2f;
     Vector3 vector3_5 = new Vector3(FezMath.Dot(a2, b1), a2.Y, 0.0f);
     Vector3 vector3_6 = a2 - vector3_2 - vector3_3;
     if (vector3_6 != Vector3.Zero)
       vector3_6.Normalize();
     if (this.settings.Crumble)
       vector3_6 = Vector3.Normalize(new Vector3(RandomHelper.Centered(1.0), RandomHelper.Centered(1.0), RandomHelper.Centered(1.0)));
     float num4 = Math.Min(1f, 1.5f - Vector3.Dot(vector1, Vector3.One));
     float num5 = (float) Math.Pow(1.0 / (1.0 + (double) (vector3_5 - vector3_1).Length()), 1.5);
     particle.Center = a2;
     particle.Velocity = vector3_6 * this.settings.Energy * num4 * 0.2f * num5 + this.settings.BaseVelocity;
     if (this.settings.Incandesce)
       particle.Incandescence = 2f;
     particle.Update();
     this.particles.Add(particle);
     if (this.settings.Crumble)
       particle.Delay = FezMath.Saturate(Easing.EaseOut((double) vector3_4.Y + 0.5, EasingType.Cubic) + RandomHelper.Centered(0.100000001490116));
   }
 }
Exemplo n.º 2
0
        private void SetupInstances()
        {
            float   num1        = this.settings.ExplodingInstance.Trile.ActorSettings.Type == ActorType.Vase ? 0.05f : 0.15f;
            int     maxValue    = 16 - this.settings.MinimumSize;
            Vector3 b1          = FezMath.SideMask(this.CameraManager.Viewpoint);
            Vector3 b2          = FezMath.DepthMask(this.CameraManager.Viewpoint);
            bool    flag1       = (double)b1.X != 0.0;
            bool    flag2       = this.CameraManager.Viewpoint == Viewpoint.Front || this.CameraManager.Viewpoint == Viewpoint.Left;
            Random  random      = RandomHelper.Random;
            Vector3 a1          = this.settings.EnergySource.Value;
            Vector3 vector3_1   = new Vector3(FezMath.Dot(a1, b1), a1.Y, 0.0f);
            Vector3 vector3_2   = FezMath.Dot(this.settings.ExplodingInstance.Center, b2) * b2;
            Vector3 vector3_3   = a1 - FezMath.Dot(a1, b2) * b2;
            Vector2 vector2_1   = new Vector2((float)this.settings.ExplodingInstance.Trile.TrileSet.TextureAtlas.Width, (float)this.settings.ExplodingInstance.Trile.TrileSet.TextureAtlas.Height);
            Vector2 vector2_2   = new Vector2(128f / vector2_1.X, 16f / vector2_1.Y);
            Vector2 atlasOffset = this.settings.ExplodingInstance.Trile.AtlasOffset;
            List <SpaceDivider.DividedCell> list = (List <SpaceDivider.DividedCell>)null;

            if (this.settings.Crumble)
            {
                list = SpaceDivider.Split(this.settings.ParticleCount);
            }
            for (int instanceIndex = 0; instanceIndex < this.settings.ParticleCount; ++instanceIndex)
            {
                TrixelParticleSystem.Particle particle = new TrixelParticleSystem.Particle(this, instanceIndex)
                {
                    Elasticity = num1
                };
                Vector3 vector3_4;
                Vector3 vector1;
                if (this.settings.Crumble)
                {
                    SpaceDivider.DividedCell dividedCell = list[instanceIndex];
                    vector3_4 = ((float)(dividedCell.Left - 8) * b1 + (float)(dividedCell.Bottom - 8) * Vector3.UnitY + (float)(dividedCell.Left - 8) * b2) / 16f;
                    vector1   = ((float)dividedCell.Width * (b1 + b2) + (float)dividedCell.Height * Vector3.UnitY) / 16f;
                }
                else
                {
                    vector3_4 = new Vector3((float)random.Next(0, maxValue), (float)random.Next(0, maxValue), (float)random.Next(0, maxValue));
                    do
                    {
                        vector1 = new Vector3((float)random.Next(this.settings.MinimumSize, Math.Min(17 - (int)vector3_4.X, this.settings.MaximumSize)), (float)random.Next(this.settings.MinimumSize, Math.Min(17 - (int)vector3_4.Y, this.settings.MaximumSize)), (float)random.Next(this.settings.MinimumSize, Math.Min(17 - (int)vector3_4.Z, this.settings.MaximumSize)));
                    }while ((double)Math.Abs(vector1.X - vector1.Y) > ((double)vector1.X + (double)vector1.Y) / 2.0 || (double)Math.Abs(vector1.Z - vector1.Y) > ((double)vector1.Z + (double)vector1.Y) / 2.0);
                    vector3_4 = (vector3_4 - new Vector3(8f)) / 16f;
                    vector1  /= 16f;
                }
                particle.Size = vector1;
                float num2 = flag1 ? vector1.X : vector1.Z;
                particle.TextureMatrix = new Vector4(num2 * vector2_2.X, vector1.Y * vector2_2.Y, (float)(((flag2 ? 1.0 : -1.0) * (flag1 ? (double)vector3_4.X : (double)vector3_4.Z) + (flag2 ? 0.0 : -(double)num2) + 0.5 + 1.0 / 16.0) / 8.0) * vector2_2.X + atlasOffset.X, (float)(-((double)vector3_4.Y + (double)vector1.Y) + 0.5 + 1.0 / 16.0) * vector2_2.Y + atlasOffset.Y);
                float num3 = this.settings.Darken ? RandomHelper.Between(0.3, 1.0) : 1f;
                particle.Color = new Vector3(num3, num3, num3);
                Vector3 a2        = this.settings.ExplodingInstance.Center + vector3_4 + vector1 / 2f;
                Vector3 vector3_5 = new Vector3(FezMath.Dot(a2, b1), a2.Y, 0.0f);
                Vector3 vector3_6 = a2 - vector3_2 - vector3_3;
                if (vector3_6 != Vector3.Zero)
                {
                    vector3_6.Normalize();
                }
                if (this.settings.Crumble)
                {
                    vector3_6 = Vector3.Normalize(new Vector3(RandomHelper.Centered(1.0), RandomHelper.Centered(1.0), RandomHelper.Centered(1.0)));
                }
                float num4 = Math.Min(1f, 1.5f - Vector3.Dot(vector1, Vector3.One));
                float num5 = (float)Math.Pow(1.0 / (1.0 + (double)(vector3_5 - vector3_1).Length()), 1.5);
                particle.Center   = a2;
                particle.Velocity = vector3_6 * this.settings.Energy * num4 * 0.2f * num5 + this.settings.BaseVelocity;
                if (this.settings.Incandesce)
                {
                    particle.Incandescence = 2f;
                }
                particle.Update();
                this.particles.Add(particle);
                if (this.settings.Crumble)
                {
                    particle.Delay = FezMath.Saturate(Easing.EaseOut((double)vector3_4.Y + 0.5, EasingType.Cubic) + RandomHelper.Centered(0.100000001490116));
                }
            }
        }