public void Rumble() { if (this.c++ != 2) { this.Instance.PhysicsState.Velocity = Vector3.Zero; if (this.System == null) { return; } this.System.Offset = Vector3.Zero; } else { this.c = 0; Vector3 vector3 = new Vector3(RandomHelper.Centered(0.0399999991059303), 0.0f, RandomHelper.Centered(0.0399999991059303)); Vector3 center = this.Instance.PhysicsState.Center; this.Instance.PhysicsState.Center += -this.lastJitter + vector3; if (this.System != null) { this.System.Offset = -this.lastJitter + vector3; } this.Instance.PhysicsState.Velocity = this.Instance.PhysicsState.Center - center; this.Instance.PhysicsState.UpdateInstance(); this.lastJitter = vector3; this.LevelManager.UpdateInstance(this.Instance); } }
private void TryAddRay(bool wide, bool midLife) { Mesh mesh = this.Meshes[FezMath.AsViewpoint(FezMath.OrientationFromPhi((float)RandomHelper.Random.Next(0, 4) * 1.570796f))]; if (mesh.Groups.Count >= 15) { return; } float num1 = wide ? this.CameraManager.Radius * 2f : this.CameraManager.Radius; Vector3 vector3 = RandomHelper.Between(-(double)num1 / 2.0, (double)(num1 / 2f)) * Vector3.UnitX; float num2 = RandomHelper.Between(0.75, 4.0); float num3 = 8f + RandomHelper.Centered(4.0); lock (mesh) { Group local_9 = mesh.AddColoredQuad(new Vector3(0.0f, 0.0f, 0.0f), new Vector3(-num3 - num2, -num3, 0.0f), new Vector3(-num3, -num3, 0.0f), new Vector3(-num2, 0.0f, 0.0f), new Color((int)byte.MaxValue, (int)byte.MaxValue, (int)byte.MaxValue), Color.Black, Color.Black, new Color((int)byte.MaxValue, (int)byte.MaxValue, (int)byte.MaxValue)); local_9.CustomData = (object)new GodRays.RayCustomData() { RandomOpacity = RandomHelper.Between(0.125, 0.5), Layer = RandomHelper.Random.Next(0, 4), RandomSpeed = RandomHelper.Between(0.25, 2.0), AccumulatedTime = (midLife ? TimeSpan.FromSeconds((double)RandomHelper.Between(0.0, 8.0)) : TimeSpan.Zero) }; local_9.Material = new Material() { Diffuse = Vector3.Zero }; local_9.Position = vector3; } }
public void Rotate(bool clockwise, int turns) { this.SpinSign = clockwise ? 1 : -1; this.Turns = turns; foreach (TrileInstance instance in this.Group.Triles) { this.LevelMaterializer.UnregisterViewedInstance(instance); if (instance.InstanceId == -1) { this.LevelMaterializer.CullInstanceInNoRegister(instance); } instance.SkipCulling = true; } this.LevelMaterializer.CommitBatchesIfNeeded(); this.RecordStates(); for (int index = 0; index < this.AttachedArtObjects.Length; ++index) { this.AttachedAoRotations[index] = this.AttachedArtObjects[index].Rotation; this.AttachedAoOrigins[index] = this.AttachedArtObjects[index].Position; } this.HeldOnto = this.Group.Triles.Contains(this.PlayerManager.HeldInstance); this.GroundedOn = this.PlayerManager.Grounded && this.TopLayer.Contains(this.PlayerManager.Ground.First); if (this.GroundedOn || this.HeldOnto) { this.PlayerManager.IsOnRotato = true; } this.OriginalForward = FezMath.ForwardVector(this.CameraManager.Viewpoint); this.OriginalPlayerPosition = this.PlayerManager.Position; this.Action = SpinAction.Spinning; if (this.sSpin == null) { return; } SoundEffectExtensions.EmitAt(this.sSpin, this.Center, false, RandomHelper.Centered(0.100000001490116), false).FadeDistance = 50f; }
private void UpdateRays(float elapsedSeconds) { if (RandomHelper.Probability(0.03)) { float x = 6f + RandomHelper.Centered(4.0); float num = RandomHelper.Between(0.5, (double)x / 2.5); Group group = this.RaysMesh.AddGroup(); group.Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <FezVertexPositionTexture>(new FezVertexPositionTexture[6] { new FezVertexPositionTexture(new Vector3(0.0f, (float)((double)num / 2.0 * 0.100000001490116), 0.0f), new Vector2(0.0f, 0.0f)), new FezVertexPositionTexture(new Vector3(x, num / 2f, 0.0f), new Vector2(1f, 0.0f)), new FezVertexPositionTexture(new Vector3(x, (float)((double)num / 2.0 * 0.100000001490116), 0.0f), new Vector2(1f, 0.45f)), new FezVertexPositionTexture(new Vector3(x, (float)(-(double)num / 2.0 * 0.100000001490116), 0.0f), new Vector2(1f, 0.55f)), new FezVertexPositionTexture(new Vector3(x, (float)(-(double)num / 2.0), 0.0f), new Vector2(1f, 1f)), new FezVertexPositionTexture(new Vector3(0.0f, (float)(-(double)num / 2.0 * 0.100000001490116), 0.0f), new Vector2(0.0f, 1f)) }, new int[12] { 0, 1, 2, 0, 2, 5, 5, 2, 3, 5, 3, 4 }, PrimitiveType.TriangleList); group.CustomData = (object)new DotHost.RayState(); group.Material = new Material() { Diffuse = new Vector3(0.0f) }; group.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Forward, RandomHelper.Between(0.0, 6.28318548202515)); } for (int i = this.RaysMesh.Groups.Count - 1; i >= 0; --i) { Group group = this.RaysMesh.Groups[i]; DotHost.RayState rayState = group.CustomData as DotHost.RayState; rayState.Age += elapsedSeconds * 0.15f; float num1 = Easing.EaseOut(Math.Sin((double)rayState.Age * 6.28318548202515 - 1.57079637050629) * 0.5 + 0.5, EasingType.Quadratic); group.Material.Diffuse = new Vector3(num1 * 0.0375f) + rayState.Tint.ToVector3() * 0.075f * num1; float num2 = rayState.Speed; group.Rotation *= Quaternion.CreateFromAxisAngle(Vector3.Forward, (float)((double)elapsedSeconds * (double)num2 * 0.300000011920929)); group.Scale = new Vector3((float)((double)num1 * 0.75 + 0.25), (float)((double)num1 * 0.5 + 0.5), 1f); if ((double)rayState.Age > 1.0) { this.RaysMesh.RemoveGroupAt(i); } } this.FlareMesh.Position = this.RaysMesh.Position = this.DotMesh.Position; this.FlareMesh.Rotation = this.RaysMesh.Rotation = Quaternion.Identity; this.RaysMesh.Scale = this.DotMesh.Scale * 0.5f; this.FlareMesh.Scale = new Vector3(MathHelper.Lerp(this.DotMesh.Scale.X * 0.875f, (float)Math.Pow((double)this.DotMesh.Scale.X * 1.5, 1.5), 1f)); this.FlareMesh.Material.Diffuse = new Vector3(0.25f * FezMath.Saturate(this.Opacity * 2f)); }
private void UpdateRays(float elapsedSeconds) { if (this.TrialRaysMesh.Groups.Count < 50 && RandomHelper.Probability(0.2)) { float x = 6f + RandomHelper.Centered(4.0); float num = RandomHelper.Between(0.5, (double)x / 2.5); Group group = this.TrialRaysMesh.AddGroup(); group.Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <FezVertexPositionTexture>(new FezVertexPositionTexture[6] { new FezVertexPositionTexture(new Vector3(0.0f, (float)((double)num / 2.0 * 0.100000001490116), 0.0f), new Vector2(0.0f, 0.0f)), new FezVertexPositionTexture(new Vector3(x, num / 2f, 0.0f), new Vector2(1f, 0.0f)), new FezVertexPositionTexture(new Vector3(x, (float)((double)num / 2.0 * 0.100000001490116), 0.0f), new Vector2(1f, 0.45f)), new FezVertexPositionTexture(new Vector3(x, (float)(-(double)num / 2.0 * 0.100000001490116), 0.0f), new Vector2(1f, 0.55f)), new FezVertexPositionTexture(new Vector3(x, (float)(-(double)num / 2.0), 0.0f), new Vector2(1f, 1f)), new FezVertexPositionTexture(new Vector3(0.0f, (float)(-(double)num / 2.0 * 0.100000001490116), 0.0f), new Vector2(0.0f, 1f)) }, new int[12] { 0, 1, 2, 0, 2, 5, 5, 2, 3, 5, 3, 4 }, PrimitiveType.TriangleList); group.CustomData = (object)new DotHost.RayState(); group.Material = new Material() { Diffuse = new Vector3(0.0f) }; group.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Forward, RandomHelper.Between(0.0, 6.28318548202515)); } for (int i = this.TrialRaysMesh.Groups.Count - 1; i >= 0; --i) { Group group = this.TrialRaysMesh.Groups[i]; DotHost.RayState rayState = group.CustomData as DotHost.RayState; rayState.Age += elapsedSeconds * 0.15f; float num1 = Easing.EaseOut((double)Easing.EaseOut(Math.Sin((double)rayState.Age * 6.28318548202515 - 1.57079637050629) * 0.5 + 0.5, EasingType.Quintic), EasingType.Quintic); group.Material.Diffuse = Vector3.Lerp(Vector3.One, rayState.Tint.ToVector3(), 0.05f) * 0.15f * num1; float num2 = rayState.Speed; group.Rotation *= Quaternion.CreateFromAxisAngle(Vector3.Forward, (float)((double)elapsedSeconds * (double)num2 * (0.100000001490116 + (double)Easing.EaseIn((double)this.TrialTimeAccumulator / 3.0, EasingType.Quadratic) * 0.200000002980232))); group.Scale = new Vector3((float)((double)num1 * 0.75 + 0.25), (float)((double)num1 * 0.5 + 0.5), 1f); if ((double)rayState.Age > 1.0) { this.TrialRaysMesh.RemoveGroupAt(i); } } this.TrialFlareMesh.Position = this.TrialRaysMesh.Position = this.Rings[0].Position; this.TrialFlareMesh.Rotation = this.TrialRaysMesh.Rotation = this.CameraManager.Rotation; this.TrialRaysMesh.Scale = new Vector3(Easing.EaseIn((double)this.TrialTimeAccumulator / 2.0, EasingType.Quadratic) + 1f); this.TrialFlareMesh.Material.Opacity = (float)(0.125 + (double)Easing.EaseIn((double)FezMath.Saturate((float)(((double)this.TrialTimeAccumulator - 2.0) / 3.0)), EasingType.Cubic) * 0.875); this.TrialFlareMesh.Scale = Vector3.One + this.TrialRaysMesh.Scale * Easing.EaseIn((double)Math.Max(this.TrialTimeAccumulator - 2.5f, 0.0f) / 1.5, EasingType.Cubic) * 4f; }
public CrumblerState(TrileInstance instance, CrumblersHost host) { ServiceHelper.InjectServices((object)this); this.Host = host; this.Instance = instance; this.OriginalCenter = instance.PhysicsState.Center; Waiters.Wait(0.5, new Action(this.StartCrumbling)).AutoPause = true; Waiters.Wait(2.5, new Action(this.Respawn)).AutoPause = true; SoundEffectExtensions.EmitAt(host.sWarning, this.OriginalCenter, RandomHelper.Centered(0.00999999977648258)); }
public LongRunningAction PlaySoundAt(int id, string soundName, bool loop, float initialDelay, float perLoopDelay, bool directional, float pitchVariation) { SoundEffect sfx = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/" + soundName); float duration = (float)sfx.Duration.TotalSeconds; Volume volume = this.LevelManager.Volumes[id]; Vector3 center = (volume.From + volume.To) / 2f; Vector3 direction = Vector3.One; if (directional) { direction = Enumerable.Aggregate <Vector3>(Enumerable.Select <FaceOrientation, Vector3>((IEnumerable <FaceOrientation>)volume.Orientations, (Func <FaceOrientation, Vector3>)(x => FezMath.GetMask(FezMath.AsAxis(x)))), (Func <Vector3, Vector3, Vector3>)((a, b) => a + b)); } if (!loop && (double)initialDelay <= 0.0) { SoundEffectExtensions.EmitAt(sfx, center, RandomHelper.Centered((double)pitchVariation)).AxisMask = direction; return((LongRunningAction)null); } else { float toWait = initialDelay; bool perfectLoop = loop && (double)perLoopDelay <= 0.0 && (double)pitchVariation <= 0.0; if (perfectLoop) { return(new LongRunningAction((Func <float, float, bool>)((elapsed, total) => { toWait -= elapsed; if ((double)toWait > 0.0) { return false; } SoundEffectExtensions.EmitAt(sfx, center, perfectLoop, RandomHelper.Centered((double)pitchVariation)).AxisMask = direction; return true; }))); } else { return(new LongRunningAction((Func <float, float, bool>)((elapsed, total) => { toWait -= elapsed; if ((double)toWait <= 0.0) { SoundEffectExtensions.EmitAt(sfx, center, RandomHelper.Centered((double)pitchVariation)).AxisMask = direction; if (!loop) { return true; } toWait += perLoopDelay + duration; } return false; }))); } } }
public override void Update(GameTime gameTime) { if (this.EngineState.Loading || this.EngineState.Paused || this.EngineState.InMap) { return; } this.SinceStarted += gameTime.ElapsedGameTime; if (this.SinceStarted > this.Duration) { ServiceHelper.RemoveComponent <CamShake>(this); this.IsDisposed = true; } this.RemainingDistance = MathHelper.Lerp(this.Distance, 0.0f, (float)Math.Sqrt(this.SinceStarted.TotalSeconds / this.Duration.TotalSeconds)); this.CameraManager.InterpolatedCenter += new Vector3(RandomHelper.Centered((double)this.RemainingDistance * 2.0), RandomHelper.Centered((double)this.RemainingDistance * 2.0), RandomHelper.Centered((double)this.RemainingDistance * 2.0)); }
public LongRunningAction Flicker(int id, float factor) { Vector3 baseScale = this.LevelManager.BackgroundPlanes[id].Scale; return(new LongRunningAction((Func <float, float, bool>)((elapsedSeconds, _) => { if (RandomHelper.Probability(0.25)) { BackgroundPlane local_0; if (!this.LevelManager.BackgroundPlanes.TryGetValue(id, out local_0)) { return true; } local_0.Scale = baseScale + new Vector3(RandomHelper.Centered((double)factor)); } return false; }))); }
public void Update(TimeSpan elapsed) { if (this.ArtObject.ActorSettings.Inactive && this.State == SpinBlocksHost.SpinState.Idle) { return; } this.SinceChanged += elapsed; switch (this.State) { case SpinBlocksHost.SpinState.Idle: if (this.SinceChanged.TotalSeconds < (double)this.ArtObject.ActorSettings.SpinEvery - 0.5 - 0.100000001490116) { break; } this.OriginalRotation = this.ArtObject.Rotation; this.SinceChanged -= TimeSpan.FromSeconds((double)this.ArtObject.ActorSettings.SpinEvery - 0.5 - 0.100000001490116); this.State = SpinBlocksHost.SpinState.Warning; Vector3 right = this.CameraManager.InverseView.Right; Vector3 interpolatedCenter = this.CameraManager.InterpolatedCenter; float num1 = new Vector2() { X = FezMath.Dot(this.ArtObject.Position - interpolatedCenter, right), Y = (interpolatedCenter.Y - this.ArtObject.Position.Y) }.Length(); if (((double)num1 > 10.0 ? 0.600000023841858 / (((double)num1 - 10.0) / 5.0 + 1.0) : 1.0 - (double)Easing.EaseIn((double)num1 / 10.0, EasingType.Quadratic) * 0.400000005960464) <= 0.0500000007450581) { break; } this.Emitter = SoundEffectExtensions.EmitAt(this.SoundEffect, this.ArtObject.Position, RandomHelper.Centered(0.0799999982118607)); if (!this.IsRotato) { break; } this.Emitter.PauseViewTransitions = false; break; case SpinBlocksHost.SpinState.Warning: Quaternion fromAxisAngle1 = Quaternion.CreateFromAxisAngle(FezMath.ForwardVector(this.ArtObject.ActorSettings.SpinView), (float)(-1.57079637050629 * Math.Sin(FezMath.Saturate(this.SinceChanged.TotalSeconds / 0.100000001490116) * 0.785398185253143) * 0.100000001490116)); this.ArtObject.Rotation = fromAxisAngle1 * this.OriginalRotation; this.ArtObject.Position = this.OriginalPosition + Vector3.Transform(-this.RotationOffset, this.SpinAccumulatedRotation * fromAxisAngle1) + this.RotationOffset; if (this.SinceChanged.TotalSeconds < 0.100000001490116) { break; } this.SinceChanged -= TimeSpan.FromSeconds(0.100000001490116); this.State = SpinBlocksHost.SpinState.Spinning; break; case SpinBlocksHost.SpinState.Spinning: double num2 = FezMath.Saturate(this.SinceChanged.TotalSeconds / 0.5); float num3 = this.IsRotato ? Easing.EaseInOut(FezMath.Saturate(num2 / 0.75), EasingType.Quartic, EasingType.Quadratic) : Easing.EaseIn(num2 < 0.75 ? num2 / 0.75 : 1.0 + Math.Sin((num2 - 0.75) / 0.25 * 6.28318548202515) * 0.0149999996647239, EasingType.Quintic); bool flag1 = this.PlayerManager.Grounded && this.Triles.Contains(this.PlayerManager.Ground.First); if (flag1) { if (!this.IsRotato) { IPlayerManager playerManager = this.PlayerManager; Vector3 vector3 = playerManager.Velocity + FezMath.RightVector(this.ArtObject.ActorSettings.SpinView) * num3 * 0.1f; playerManager.Velocity = vector3; if ((double)num3 > 0.25) { this.PlayerManager.Position -= 0.01f * Vector3.UnitY; } } else if ((double)num3 > 0.0 && !this.hasRotated) { this.PlayerManager.IsOnRotato = true; this.Rotate(); this.OriginalPlayerPosition = this.PlayerManager.Position; this.CameraManager.ChangeViewpoint(FezMath.GetRotatedView(this.CameraManager.Viewpoint, this.ArtObject.ActorSettings.SpinView == Viewpoint.Up ? 1 : -1), 0.5f); this.hasRotated = true; } } if (!this.IsRotato) { foreach (TrileInstance trileInstance in this.Triles) { trileInstance.Enabled = (double)num3 <= 0.25; } } bool flag2 = ActionTypeExtensions.IsOnLedge(this.PlayerManager.Action) && this.Triles.Contains(this.PlayerManager.HeldInstance); if (flag2) { if (!this.IsRotato) { IPlayerManager playerManager = this.PlayerManager; Vector3 vector3 = playerManager.Velocity + FezMath.RightVector(this.ArtObject.ActorSettings.SpinView) * num3 * 0.1f; playerManager.Velocity = vector3; if ((double)num3 > 0.25) { this.PlayerManager.Action = ActionType.Falling; this.PlayerManager.HeldInstance = (TrileInstance)null; } } else if ((double)num3 > 0.0 && (double)num3 < 0.5 && !this.hasRotated) { this.PlayerManager.IsOnRotato = true; this.Rotate(); this.OriginalPlayerPosition = this.PlayerManager.Position; this.CameraManager.ChangeViewpoint(FezMath.GetRotatedView(this.CameraManager.Viewpoint, this.ArtObject.ActorSettings.SpinView == Viewpoint.Up ? 1 : -1), 0.5f); this.hasRotated = true; } } this.TrixelParticleSystems.PropagateEnergy(this.ArtObject.Position - FezMath.RightVector(this.ArtObject.ActorSettings.SpinView), num3 * 0.1f); Quaternion fromAxisAngle2 = Quaternion.CreateFromAxisAngle(FezMath.ForwardVector(this.ArtObject.ActorSettings.SpinView), (float)(1.57079637050629 * (double)num3 * 1.10000002384186 - 0.157079637050629)); this.ArtObject.Rotation = fromAxisAngle2 * this.OriginalRotation; this.ArtObject.Position = this.OriginalPosition + Vector3.Transform(-this.RotationOffset, this.SpinAccumulatedRotation * fromAxisAngle2) + this.RotationOffset; if (this.IsRotato && (flag1 || flag2)) { Vector3 vector3 = this.ArtObject.ActorSettings.RotationCenter; if (!this.ArtObject.ActorSettings.OffCenter) { vector3 = this.ArtObject.Position; } this.PlayerManager.Position = Vector3.Transform(this.OriginalPlayerPosition - vector3, fromAxisAngle2) + vector3; } if (this.SinceChanged.TotalSeconds < 0.5) { break; } foreach (TrileInstance trileInstance in this.Triles) { trileInstance.Enabled = true; } if ((!this.IsRotato || !this.hasRotated) && (double)this.Triles.Count != (double)this.ArtObject.ArtObject.Size.X * (double)this.ArtObject.ArtObject.Size.Y * (double)this.ArtObject.ArtObject.Size.Z) { this.Rotate(); } this.SpinAccumulatedRotation = this.SpinAccumulatedRotation * fromAxisAngle2; this.State = SpinBlocksHost.SpinState.Idle; this.hasRotated = false; this.SinceChanged -= TimeSpan.FromSeconds(0.5); this.PlayerManager.IsOnRotato = false; break; } }
public override void Update(GameTime gameTime) { if (this.GameState.Loading || this.GameState.Paused || (this.GameState.InMap || !this.CameraManager.ActionRunning) || (this.Solved || this.CameraManager.ProjectionTransition || !FezMath.IsOrthographic(this.CameraManager.Viewpoint))) { return; } this.SinceHit += gameTime.ElapsedGameTime; Vector3 vector = (this.PlayerManager.Position - this.BellAo.Position - new Vector3(0.0f, 1f, 0.0f)) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint); vector.X += vector.Z; Vector3 vector3_1 = FezMath.Abs(vector); if (this.InputManager.GrabThrow == FezButtonState.Pressed && ((double)vector3_1.X < 2.0 && (double)vector3_1.Y < 1.5) && (this.PlayerManager.CarriedInstance == null && this.PlayerManager.Grounded) && this.PlayerManager.Action != ActionType.ReadingSign) { if (this.wutex1 != null || this.wutex2 != null) { if (this.stackedHits < 10) { ++this.stackedHits; } } else { this.PlayerManager.Action = ActionType.TurnToBell; this.ScheduleTurnTo(); } } if (this.wutex1 == null && this.wutex2 == null && this.stackedHits > 0) { this.ScheduleTurnTo(); --this.stackedHits; } this.AngularVelocity *= MathHelper.Clamp((float)(0.995000004768372 - this.SinceHit.TotalSeconds * (1.0 / 400.0)), 0.0f, 1f); this.Angle += this.AngularVelocity * 0.1f; this.AngularVelocity += -this.Angle * 0.01f; Vector3 scale; Quaternion rotation; Vector3 translation; (Matrix.CreateTranslation(0.0f, -3.5f, 0.0f) * Matrix.CreateFromYawPitchRoll(RandomHelper.Centered(FezMath.Saturate((3.0 - this.SinceHit.TotalSeconds) / 3.0) * 0.0125000001862645), this.Angle.X, this.Angle.Y) * Matrix.CreateTranslation(this.OriginalPosition.X, this.OriginalPosition.Y + 3.5f, this.OriginalPosition.Z)).Decompose(out scale, out rotation, out translation); this.BellAo.Position = translation; this.BellAo.Rotation = rotation; double max = FezMath.Saturate((1.5 - this.SinceHit.TotalSeconds) / 1.5) * 0.0750000029802322; IGameCameraManager cameraManager = this.CameraManager; Vector3 vector3_2 = cameraManager.InterpolatedCenter + new Vector3(RandomHelper.Between(-max, max), RandomHelper.Between(-max, max), RandomHelper.Between(-max, max)); cameraManager.InterpolatedCenter = vector3_2; }
public override void Update(GameTime gameTime) { if (this.CameraManager.Viewpoint == Viewpoint.Perspective || !this.CameraManager.ActionRunning || (this.GameState.Paused || this.GameState.InMap) || (this.CameraManager.RequestedViewpoint != Viewpoint.None || this.GameState.Loading)) { return; } foreach (BombsHost.DestructibleGroup destructibleGroup1 in this.destructibleGroups) { if (destructibleGroup1.RespawnIn.HasValue) { BombsHost.DestructibleGroup destructibleGroup2 = destructibleGroup1; float?nullable1 = destructibleGroup2.RespawnIn; float num = (float)gameTime.ElapsedGameTime.TotalSeconds; float?nullable2 = nullable1.HasValue ? new float?(nullable1.GetValueOrDefault() - num) : new float?(); destructibleGroup2.RespawnIn = nullable2; if ((double)destructibleGroup1.RespawnIn.Value <= 0.0) { bool flag = true; foreach (TrileInstance instance in destructibleGroup1.AllTriles) { if (!instance.Enabled || instance.Hidden || instance.Removed) { instance.Enabled = false; instance.Hidden = true; ServiceHelper.AddComponent((IGameComponent) new GlitchyRespawner(ServiceHelper.Game, instance, flag || RandomHelper.Probability(0.25))); flag = false; } } destructibleGroup1.RespawnIn = new float?(); } } } TrileInstance carriedInstance = this.PlayerManager.CarriedInstance; if (carriedInstance != null && ActorTypeExtensions.IsBomb(carriedInstance.Trile.ActorSettings.Type) && !this.bombStates.ContainsKey(carriedInstance)) { carriedInstance.Foreign = carriedInstance.PhysicsState.Respawned = false; this.bombStates.Add(carriedInstance, new BombsHost.BombState()); } bool flag1 = false; bool flag2 = false; foreach (TrileInstance instance in this.bombStates.Keys) { BombsHost.BombState state = this.bombStates[instance]; if (!ActionTypeExtensions.IsEnteringDoor(this.PlayerManager.Action)) { state.SincePickup += gameTime.ElapsedGameTime; } bool flag3 = instance.Trile.ActorSettings.Type == ActorType.BigBomb; bool flag4 = instance.Trile.ActorSettings.Type == ActorType.TntBlock || instance.Trile.ActorSettings.Type == ActorType.TntPickup; if (ActorTypeExtensions.IsBomb(instance.Trile.ActorSettings.Type) && instance.Hidden) { this.bsToRemove.Add(instance); if (state.Flash != null) { this.flashesMesh.RemoveGroup(state.Flash); state.Flash = (Group)null; } if (state.Emitter != null && state.Emitter.Cue != null) { state.Emitter.Cue.Stop(false); } } else { if (state.SincePickup > this.FlashTime && state.Explosion == null) { if (state.Flash == null) { state.Flash = this.flashesMesh.AddFace(Vector3.One, Vector3.Zero, FaceOrientation.Front, this.FlashColor, true); if (ActorTypeExtensions.IsBomb(instance.Trile.ActorSettings.Type) && !state.IsChainsploding) { state.Emitter = SoundEffectExtensions.EmitAt(this.countdownSound, instance.Center); state.Emitter.PauseViewTransitions = true; } } double totalSeconds = state.SincePickup.TotalSeconds; if (totalSeconds > this.ExplodeStart.TotalSeconds - 1.0) { totalSeconds *= 2.0; } state.Flash.Enabled = FezMath.Frac(totalSeconds) < 0.5; if (state.Flash.Enabled) { state.Flash.Position = instance.Center; state.Flash.Rotation = this.CameraManager.Rotation; } } if (state.SincePickup > this.ExplodeStart && state.Explosion == null) { if (flag4 && !flag1 || !flag4 && !flag2) { SoundEffectExtensions.EmitAt(flag4 ? this.crystalsplodeSound : this.explodeSound, instance.Center, RandomHelper.Centered(0.025)); if (flag4) { flag1 = true; } else { flag2 = true; } } if (state.ChainsplodedBy != null && state.ChainsplodedBy.Emitter != null) { state.ChainsplodedBy.Emitter.FadeOutAndDie(0.0f); } float num1 = (flag3 ? 0.6f : 0.3f) * FezMath.Saturate((float)(1.0 - (double)(instance.Center - this.PlayerManager.Center).Length() / 15.0)); if (CamShake.CurrentCamShake == null) { ServiceHelper.AddComponent((IGameComponent) new CamShake(this.Game) { Duration = TimeSpan.FromSeconds(0.75), Distance = num1 }); } else { CamShake.CurrentCamShake.Reset(); } this.ParticleSystemManager.PropagateEnergy(instance.Center, flag3 ? 6f : 3f); this.flashesMesh.RemoveGroup(state.Flash); state.Flash = (Group)null; switch (instance.Trile.ActorSettings.Type) { case ActorType.BigBomb: state.Explosion = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, this.bigBombAnimation) { ActorType = ActorType.Bomb }; break; case ActorType.TntBlock: case ActorType.TntPickup: state.Explosion = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, this.tntAnimation) { ActorType = ActorType.Bomb }; break; default: state.Explosion = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, this.bombAnimation) { ActorType = ActorType.Bomb }; break; } state.Explosion.Timing.Loop = false; state.Explosion.Billboard = true; state.Explosion.Fullbright = true; state.Explosion.OriginalRotation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (float)RandomHelper.Random.Next(0, 4) * 1.570796f); state.Explosion.Timing.Restart(); this.LevelManager.AddPlane(state.Explosion); state.Flare = new BackgroundPlane(this.LevelMaterializer.StaticPlanesMesh, (Texture)this.flare) { AlwaysOnTop = true, LightMap = true, AllowOverbrightness = true, Billboard = true }; this.LevelManager.AddPlane(state.Flare); state.Flare.Scale = Vector3.One * (flag3 ? 3f : 1.5f); state.Explosion.Position = state.Flare.Position = instance.Center + (RandomHelper.Centered(1.0 / 1000.0) - 0.5f) * FezMath.ForwardVector(this.CameraManager.Viewpoint); float num2 = flag3 ? 3f : 1.5f; float num3 = ((this.PlayerManager.Position - instance.Center) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint)).Length(); if ((this.PlayerManager.CarriedInstance == instance || (double)num3 < (double)num2) && this.PlayerManager.Action != ActionType.Dying) { this.PlayerManager.Action = ActionType.Suffering; } if ((instance.Trile.ActorSettings.Type == ActorType.TntBlock || state.IsChainsploding) && instance.InstanceId != -1) { this.ParticleSystemManager.Add(new TrixelParticleSystem(this.Game, new TrixelParticleSystem.Settings() { ExplodingInstance = instance, EnergySource = new Vector3?(instance.Center), MaximumSize = 7, Energy = flag4 ? 3f : 1.5f, Darken = true, ParticleCount = 4 + 12 / Math.Max(1, this.TrixelParticleSystems.Count - 3) })); } if (ActorTypeExtensions.IsPickable(instance.Trile.ActorSettings.Type)) { instance.Enabled = false; this.LevelMaterializer.GetTrileMaterializer(instance.Trile).UpdateInstance(instance); } else { this.ClearDestructible(instance, false); } this.DropSupportedTriles(instance); this.DestroyNeighborhood(instance, state); } if (state.Explosion != null) { state.Flare.Filter = Color.Lerp(flag4 ? new Color(0.5f, 1f, 0.25f) : new Color(1f, 0.5f, 0.25f), Color.Black, state.Explosion.Timing.NormalizedStep); if (state.Explosion.Timing.Ended) { this.bsToRemove.Add(instance); if (instance.PhysicsState != null) { instance.PhysicsState.ShouldRespawn = ActorTypeExtensions.IsPickable(instance.Trile.ActorSettings.Type); } this.LevelManager.RemovePlane(state.Explosion); this.LevelManager.RemovePlane(state.Flare); } } } } foreach (TrileInstance key in this.bsToRemove) { this.bombStates.Remove(key); } this.bsToRemove.Clear(); foreach (KeyValuePair <TrileInstance, BombsHost.BombState> keyValuePair in this.bsToAdd) { if (!this.bombStates.ContainsKey(keyValuePair.Key)) { this.bombStates.Add(keyValuePair.Key, keyValuePair.Value); } } this.bsToAdd.Clear(); }
public void UpdateAction() { if (this.Emitter != null) { if (this.Emitter.Cue != null && this.Emitter.Cue.IsLooped) { this.Emitter.Cue.Stop(true); } this.Emitter = (SoundEmitter)null; } AnimatedTexture animation = this.Npc.Actions[this.CurrentAction].Animation; SoundEffect sound = this.Npc.Actions[this.CurrentAction].Sound; if (this.CurrentAction == NpcAction.Talk && this.CurrentLine != null && this.CurrentLine.OverrideContent != null) { if (this.CurrentLine.OverrideContent.Animation != null) { animation = this.CurrentLine.OverrideContent.Animation; } if (this.CurrentLine.OverrideContent.Sound != null) { sound = this.CurrentLine.OverrideContent.Sound; } } this.CurrentTiming = animation.Timing.Clone(); this.CurrentAnimation = animation; this.Group.Texture = (Texture)animation.Texture; this.UpdateScale(); if (sound == null || this.Npc.ActorType == ActorType.Owl && this.OwlInvisible || !this.initialized) { return; } if (this.CurrentAction == NpcAction.Talk) { if (this.talkEmitter == null || this.talkEmitter.Dead) { this.talkEmitter = SoundEffectExtensions.EmitAt(sound, this.Position, true, RandomHelper.Centered(0.05)); } else { this.talkEmitter.Position = this.Position; Waiters.Wait(0.100000001490116, (Action)(() => { this.talkEmitter.Cue.Resume(); this.talkEmitter.VolumeFactor = 1f; })).AutoPause = true; } } else { this.Emitter = SoundEffectExtensions.EmitAt(sound, this.Position, true, RandomHelper.Centered(0.05)); } }
private void StartCrumbling() { SoundEffectExtensions.EmitAt(this.Host.sCrumble, this.OriginalCenter, RandomHelper.Centered(0.00999999977648258)); Vector3 vector3_1 = FezMath.SideMask(this.CameraManager.Viewpoint); Vector3 vector3_2 = FezMath.ForwardVector(this.CameraManager.Viewpoint); bool flag1 = (double)vector3_1.X != 0.0; bool flag2 = flag1; int num = flag2 ? (int)vector3_2.Z : (int)vector3_2.X; Point key = new Point(flag1 ? this.Instance.Emplacement.X : this.Instance.Emplacement.Z, this.Instance.Emplacement.Y); this.LevelManager.WaitForScreenInvalidation(); Limit limit; if (this.LevelManager.ScreenSpaceLimits.TryGetValue(key, out limit)) { limit.End += num; TrileEmplacement id = new TrileEmplacement(flag1 ? key.X : limit.Start, key.Y, flag2 ? limit.Start : key.X); while ((flag2 ? id.Z : id.X) != limit.End) { TrileInstance toRemove = this.LevelManager.TrileInstanceAt(ref id); if (toRemove != null && !toRemove.Hidden && toRemove.Trile.ActorSettings.Type == ActorType.Crumbler) { toRemove.Hidden = true; this.LevelMaterializer.CullInstanceOut(toRemove); this.InstancesToClear.Add(toRemove); ITrixelParticleSystems particleSystems = this.ParticleSystems; CrumblersHost.CrumblerState crumblerState = this; Game game = ServiceHelper.Game; TrixelParticleSystem.Settings settings = new TrixelParticleSystem.Settings() { BaseVelocity = Vector3.Zero, Energy = 0.1f, ParticleCount = (int)(20.0 / (double)this.InstancesToClear.Count), GravityModifier = 0.6f, Crumble = true, ExplodingInstance = toRemove }; TrixelParticleSystem trixelParticleSystem1; TrixelParticleSystem trixelParticleSystem2 = trixelParticleSystem1 = new TrixelParticleSystem(game, settings); crumblerState.System = trixelParticleSystem1; TrixelParticleSystem system = trixelParticleSystem2; particleSystems.Add(system); } if (flag2) { id.Z += num; } else { id.X += num; } } } Waiters.Wait(1.0, new Action(this.ClearTriles)).AutoPause = true; }
private void ChangeSegment() { this.sinceSegmentStarted -= this.CurrentNode.Duration + this.CurrentNode.WaitTimeOnFinish; if (this.CurrentNode.Sound != null) { SoundEffectExtensions.EmitAt(this.CurrentNode.Sound, this.CameraManager.Center, false, RandomHelper.Centered(0.0750000029802322), false); } ++this.nodeIndex; if (this.nodeIndex == this.Nodes.Count || this.nodeIndex == -1) { this.EndPath(); } if (this.Enabled && !this.Path.NeedsTrigger) { this.StartNewSegment(); } if (!this.Path.RunSingleSegment) { return; } this.Path.NeedsTrigger = true; this.Path.RunSingleSegment = false; }
public void Update(TimeSpan elapsed) { if (!this.Enabled || this.Path.NeedsTrigger) { return; } if (this.justStarted) { this.originalViewpoint = this.CameraManager.Viewpoint; this.originalCenter = this.CameraManager.Center; this.originalDirection = this.CameraManager.Direction; this.originalPixelsPerTrixel = this.CameraManager.PixelsPerTrixel; this.originalRadius = this.CameraManager.Radius; bool perspective = (this.Nodes[0].CustomData as CameraNodeData).Perspective; if (this.Path.InTransition) { this.nodeIndex = 1; this.Nodes.Insert(0, new PathSegment() { Destination = this.originalCenter, Orientation = Quaternion.Inverse(this.CameraManager.Rotation), CustomData = (ICloneable) new CameraNodeData() { PixelsPerTrixel = (int)this.originalPixelsPerTrixel, Perspective = perspective } }); } if (this.Path.OutTransition) { this.Nodes.Add(new PathSegment() { Destination = this.originalCenter, Orientation = Quaternion.Inverse(this.CameraManager.Rotation), CustomData = (ICloneable) new CameraNodeData() { PixelsPerTrixel = (int)this.originalPixelsPerTrixel, Perspective = perspective } }); } if (this.Nodes.Count < 2) { this.EndPath(); return; } else { CameraNodeData cameraNodeData = this.Nodes[0].CustomData as CameraNodeData; this.firstNodeViewpoint = FezMath.AsViewpoint(FezMath.OrientationFromDirection(FezMath.MaxClampXZ(Vector3.Transform(Vector3.Forward, this.Nodes[0].Orientation)))); this.CameraManager.ChangeViewpoint(cameraNodeData.Perspective ? Viewpoint.Perspective : this.firstNodeViewpoint); if (cameraNodeData.Perspective) { this.CameraManager.Radius = 1.0 / 1000.0; } if (cameraNodeData.PixelsPerTrixel != 0 && (double)this.CameraManager.PixelsPerTrixel != (double)cameraNodeData.PixelsPerTrixel) { this.CameraManager.PixelsPerTrixel = (float)cameraNodeData.PixelsPerTrixel; } this.StartNewSegment(); this.justStarted = false; } } if (this.CameraManager.ActionRunning) { this.sinceSegmentStarted += elapsed; } if (this.sinceSegmentStarted >= this.CurrentNode.Duration + this.CurrentNode.WaitTimeOnFinish) { this.ChangeSegment(); } if (!this.Enabled || this.Path.NeedsTrigger) { return; } float num1 = (float)FezMath.Saturate(this.sinceSegmentStarted.TotalSeconds / this.CurrentNode.Duration.TotalSeconds); float amount = (double)this.CurrentNode.Deceleration != 0.0 || (double)this.CurrentNode.Acceleration != 0.0 ? ((double)this.CurrentNode.Acceleration != 0.0 ? ((double)this.CurrentNode.Deceleration != 0.0 ? Easing.EaseInOut((double)num1, EasingType.Sine, this.CurrentNode.Acceleration, EasingType.Sine, this.CurrentNode.Deceleration) : Easing.Ease((double)num1, this.CurrentNode.Acceleration, EasingType.Quadratic)) : Easing.Ease((double)num1, -this.CurrentNode.Deceleration, EasingType.Quadratic)) : num1; PathSegment pathSegment1 = this.Nodes[Math.Max(this.nodeIndex - 1, 0)]; PathSegment currentNode = this.CurrentNode; Vector3 vector3_1; Quaternion quat; if (this.Path.IsSpline) { PathSegment pathSegment2 = this.Nodes[Math.Max(this.nodeIndex - 2, 0)]; PathSegment pathSegment3 = this.Nodes[Math.Min(this.nodeIndex + 1, this.Nodes.Count - 1)]; vector3_1 = Vector3.CatmullRom(pathSegment2.Destination, pathSegment1.Destination, currentNode.Destination, pathSegment3.Destination, amount); quat = Quaternion.Slerp(pathSegment1.Orientation, currentNode.Orientation, amount); } else { vector3_1 = Vector3.Lerp(pathSegment1.Destination, currentNode.Destination, amount); quat = Quaternion.Slerp(pathSegment1.Orientation, currentNode.Orientation, amount); } float num2 = MathHelper.Lerp(pathSegment1.JitterFactor, currentNode.JitterFactor, amount); if ((double)num2 > 0.0) { vector3_1 += new Vector3(RandomHelper.Centered((double)num2) * 0.5f, RandomHelper.Centered((double)num2) * 0.5f, RandomHelper.Centered((double)num2) * 0.5f); } Vector3 vector3_2 = Vector3.Transform(Vector3.Forward, quat); CameraNodeData cameraNodeData1 = pathSegment1.CustomData as CameraNodeData; CameraNodeData cameraNodeData2 = currentNode.CustomData as CameraNodeData; if (!cameraNodeData2.Perspective) { this.CameraManager.PixelsPerTrixel = MathHelper.Lerp(cameraNodeData1.PixelsPerTrixel == 0 ? this.originalPixelsPerTrixel : (float)cameraNodeData1.PixelsPerTrixel, cameraNodeData2.PixelsPerTrixel == 0 ? this.originalPixelsPerTrixel : (float)cameraNodeData2.PixelsPerTrixel, amount); } Viewpoint view = cameraNodeData2.Perspective ? Viewpoint.Perspective : this.firstNodeViewpoint; if (view != this.CameraManager.Viewpoint) { if (view == Viewpoint.Perspective) { this.CameraManager.Radius = 1.0 / 1000.0; } this.CameraManager.ChangeViewpoint(view); } this.CameraManager.Center = vector3_1; this.CameraManager.Direction = vector3_2; if (!cameraNodeData2.Perspective) { return; } if (this.nodeIndex == 1) { this.CameraManager.Radius = MathHelper.Lerp(this.originalRadius, 1.0 / 1000.0, amount); } else if (this.nodeIndex == this.Nodes.Count - 1) { this.CameraManager.Radius = MathHelper.Lerp(1.0 / 1000.0, this.originalRadius, amount); } else { this.CameraManager.Radius = 1.0 / 1000.0; } }
public override void Draw(GameTime gameTime) { if (this.GameState.Loading) { return; } TimeSpan elapsedGameTime = gameTime.ElapsedGameTime; if (!this.GameState.Paused && FezMath.IsOrthographic(this.CameraManager.Viewpoint) && (this.CameraManager.ActionRunning && !this.GameState.InMap)) { this.flashIn -= elapsedGameTime; this.distantIn -= elapsedGameTime; } if (!this.doThunder) { return; } if (this.distantIn.Ticks <= 0L) { this.distantIn = TimeSpan.FromSeconds((double)RandomHelper.Between(3.0, 6.0)); SoundEffectExtensions.EmitAt(RandomHelper.InList <SoundEffect>(this.thunderDistant), this.CameraManager.Center + this.LevelManager.Size / 2f * FezMath.ForwardVector(this.CameraManager.Viewpoint) + (float)((double)RandomHelper.Centered(1.0) * (double)this.CameraManager.Radius * 0.5) * FezMath.RightVector(this.CameraManager.Viewpoint) + this.CameraManager.Center * Vector3.UnitY, RandomHelper.Centered(0.0500000007450581), RandomHelper.Between(0.75, 1.0)).NoAttenuation = true; } if (this.flashIn.Ticks <= 0L) { this.flashes = RandomHelper.Random.Next(1, 3); this.sinceFlash = TimeSpan.FromSeconds(-0.200000002980232); this.flashSpeed = RandomHelper.Between(1.5, 3.5); this.flashOpacity = RandomHelper.Between(0.2, 0.4); this.flashIn = TimeSpan.FromSeconds((double)RandomHelper.Between(4.0, 6.0)); this.lightning.Rotation = this.CameraManager.Rotation; this.lightningSideOffset = RandomHelper.Centered(1.0); this.lightning.Position = this.CameraManager.Center + this.LevelManager.Size / 2f * FezMath.ForwardVector(this.CameraManager.Viewpoint) + (float)((double)this.lightningSideOffset * (double)this.CameraManager.Radius * 0.5) * FezMath.RightVector(this.CameraManager.Viewpoint) + RandomHelper.Centered(10.0) * Vector3.UnitY; if (this.ePreThunder != null) { this.ePreThunder.Cue.Stop(false); this.ePreThunder = (SoundEmitter)null; } (this.ePreThunder = SoundEffectExtensions.EmitAt(this.sPreThunder, this.lightning.Position * FezMath.XZMask + this.CameraManager.Center * Vector3.UnitY, RandomHelper.Centered(0.025000000372529))).NoAttenuation = true; } if (this.sinceFlash.TotalSeconds < 0.200000002980232) { float alpha = Easing.EaseOut((double)FezMath.Saturate(1f - (float)(this.sinceFlash.TotalSeconds / 0.200000002980232)), EasingType.Quadratic) * this.flashOpacity; GraphicsDeviceExtensions.SetBlendingMode(this.GraphicsDevice, BlendingMode.Alphablending); GraphicsDeviceExtensions.PrepareStencilRead(this.GraphicsDevice, CompareFunction.Equal, StencilMask.Sky); this.ImmediateRenderer.DrawFullscreen(new Color(1f, 1f, 1f, alpha)); GraphicsDeviceExtensions.PrepareStencilRead(this.GraphicsDevice, CompareFunction.Equal, StencilMask.Trails); this.ImmediateRenderer.DrawFullscreen(new Color(1f, 1f, 1f, alpha)); GraphicsDeviceExtensions.PrepareStencilRead(this.GraphicsDevice, CompareFunction.Equal, StencilMask.SkyLayer1); this.ImmediateRenderer.DrawFullscreen(new Color(0.9f, 0.9f, 0.9f, alpha)); GraphicsDeviceExtensions.PrepareStencilRead(this.GraphicsDevice, CompareFunction.Equal, StencilMask.SkyLayer2); this.ImmediateRenderer.DrawFullscreen(new Color(0.8f, 0.8f, 0.8f, alpha)); GraphicsDeviceExtensions.PrepareStencilRead(this.GraphicsDevice, CompareFunction.Equal, StencilMask.SkyLayer3); this.ImmediateRenderer.DrawFullscreen(new Color(0.7f, 0.7f, 0.7f, alpha)); GraphicsDeviceExtensions.PrepareStencilRead(this.GraphicsDevice, CompareFunction.Less, StencilMask.SkyLayer3); this.ImmediateRenderer.DrawFullscreen(new Color(0.0f, 0.0f, 0.0f, alpha)); this.sinceFlash += TimeSpan.FromTicks((long)((double)elapsedGameTime.Ticks * (double)this.flashSpeed)); if (this.flashes == 1 && (double)alpha / (double)this.flashOpacity < 0.5) { this.lightning.Material.Opacity = 1f; GraphicsDeviceExtensions.PrepareStencilRead(this.GraphicsDevice, CompareFunction.NotEqual, StencilMask.SkyLayer3); this.lightning.Draw(); } else if (this.flashes == 0 && this.sinceFlash.Ticks < 0L) { this.lightning.Material.Opacity = (float)(this.sinceFlash.TotalSeconds / -0.200000002980232); GraphicsDeviceExtensions.PrepareStencilRead(this.GraphicsDevice, CompareFunction.NotEqual, StencilMask.SkyLayer3); this.lightning.Draw(); } GraphicsDeviceExtensions.PrepareStencilWrite(this.GraphicsDevice, new StencilMask?(StencilMask.None)); } if (this.sinceFlash.TotalSeconds <= 0.200000002980232 || this.flashes == 0) { return; } --this.flashes; this.sinceFlash = TimeSpan.FromSeconds(-0.200000002980232); this.flashSpeed = this.flashes == 0 ? 1f : RandomHelper.Between(2.0, 4.0); this.flashOpacity = this.flashes == 0 ? 1f : RandomHelper.Between(0.2, 0.4); if (this.flashes != 0) { return; } if (this.ePreThunder != null && !this.ePreThunder.Dead) { this.ePreThunder.Cue.Stop(false); } this.ePreThunder = (SoundEmitter)null; SoundEmitter emitter = SoundEffectExtensions.EmitAt(RandomHelper.InList <SoundEffect>(this.lightningSounds), this.lightning.Position * FezMath.XZMask + this.CameraManager.Center * Vector3.UnitY, RandomHelper.Centered(0.025000000372529)); emitter.NoAttenuation = true; emitter.Persistent = true; Waiters.DoUntil((Func <bool>)(() => emitter.Dead), (Action <float>)(_ => emitter.Position = Vector3.Lerp(emitter.Position, this.CameraManager.Center, 0.025f))).AutoPause = true; }
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)); } } }
public override void Update(GameTime gameTime) { if (this.GameState.Loading || this.GameState.InMap || (this.GameState.InMenuCube || this.GameState.Paused)) { return; } bool flag1 = !FezMath.IsOrthographic(this.CameraManager.Viewpoint); Vector3 forward = this.CameraManager.InverseView.Forward; BoundingFrustum frustum = this.CameraManager.Frustum; foreach (FlickeringNeon.NeonState neonState in this.NeonPlanes) { neonState.Time -= (float)gameTime.ElapsedGameTime.TotalSeconds; if ((double)neonState.Time <= 0.0) { if (neonState.FlickersLeft == 0) { neonState.FlickersLeft = RandomHelper.Random.Next(4, 18); } BackgroundPlane backgroundPlane = neonState.Neon; bool flag2 = backgroundPlane.Visible = !backgroundPlane.Hidden && (flag1 || backgroundPlane.Doublesided || (backgroundPlane.Crosshatch || backgroundPlane.Billboard) || (double)FezMath.Dot(forward, backgroundPlane.Forward) > 0.0) && frustum.Contains(backgroundPlane.Bounds) != ContainmentType.Disjoint; neonState.Enabled = !neonState.Enabled; neonState.Neon.Hidden = neonState.Enabled; neonState.Neon.Visible = !neonState.Neon.Hidden; neonState.Neon.Update(); if (flag2 && RandomHelper.Probability(0.5)) { SoundEffectExtensions.EmitAt(RandomHelper.InList <SoundEffect>(this.Glitches), neonState.Neon.Position, false, RandomHelper.Centered(0.100000001490116), RandomHelper.Between(0.0, 1.0), false); } neonState.Time = Easing.EaseIn((double)RandomHelper.Between(0.0, 0.449999988079071), EasingType.Quadratic); --neonState.FlickersLeft; if (neonState.FlickersLeft == 0) { neonState.Enabled = true; neonState.Neon.Hidden = false; neonState.Neon.Visible = true; neonState.Neon.Update(); neonState.Time = RandomHelper.Between(3.0, 8.0); } } } }
private void OpenDoor(TimeSpan elapsed) { if (!this.opening) { this.doorOrigin = this.AoInstance.Position + this.GetOpenOffset() * FezMath.XZMask; this.doorDestination = this.AoInstance.Position + this.GetOpenOffset(); this.opening = true; this.rumbleEmitter = SoundEffectExtensions.EmitAt(this.RumbleSound, this.doorOrigin, true); this.LevelService.ResolvePuzzle(); } this.sinceMoving += elapsed; this.AoInstance.Position = (!(this.sinceMoving > BitDoorState.DoorShakeTime) ? this.doorOrigin : Vector3.Lerp(this.doorOrigin, this.doorDestination, FezMath.Saturate(Easing.EaseInOut((double)(this.sinceMoving.Ticks - BitDoorState.DoorShakeTime.Ticks) / (double)BitDoorState.DoorOpenTime.Ticks, EasingType.Sine)))) + new Vector3(RandomHelper.Centered(0.0149999996647239), RandomHelper.Centered(0.0149999996647239), RandomHelper.Centered(0.0149999996647239)) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint); if (!(this.sinceMoving > BitDoorState.DoorOpenTime + BitDoorState.DoorShakeTime)) { return; } this.rumbleEmitter.FadeOutAndDie(0.25f); this.BitDoorService.OnOpen(this.AoInstance.Id); this.AoInstance.ActorSettings.Inactive = true; this.GameState.SaveData.ThisLevel.InactiveArtObjects.Add(this.AoInstance.Id); this.GameState.Save(); this.opening = false; }
public WaterfallState(BackgroundPlane plane, PlaneParticleSystem ps, WaterfallsHost host) { WaterfallsHost.WaterfallState waterfallState = this; ServiceHelper.InjectServices((object)this); this.Host = host; this.Plane = plane; this.ParticleSystem = ps; bool flag = plane.ActorType == ActorType.Trickle; this.Splash = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, this.LevelManager.WaterType != LiquidType.Sewer ? (this.LevelManager.WaterType != LiquidType.Purple ? this.CMProvider.CurrentLevel.Load <AnimatedTexture>("Background Planes/water/" + (flag ? "water_small_splash" : "water_large_splash")) : this.CMProvider.CurrentLevel.Load <AnimatedTexture>("Background Planes/waterPink/" + (flag ? "water_small_splash" : "water_large_splash"))) : this.CMProvider.CurrentLevel.Load <AnimatedTexture>("Background Planes/sewer/" + (flag ? "sewer_small_splash" : "sewer_large_splash"))) { Doublesided = true, Crosshatch = true }; this.LevelManager.AddPlane(this.Splash); this.Top = FezMath.Dot(this.Plane.Position + this.Plane.Scale * this.Plane.Size / 2f, Vector3.UnitY); this.TerminalPosition = this.Plane.Position - this.Plane.Scale * this.Plane.Size / 2f * Vector3.UnitY + Vector3.Transform(Vector3.UnitZ, plane.Rotation) / 16f; foreach (BackgroundPlane backgroundPlane in Enumerable.Where <BackgroundPlane>((IEnumerable <BackgroundPlane>) this.LevelManager.BackgroundPlanes.Values, (Func <BackgroundPlane, bool>)(x => { int?local_0 = x.AttachedPlane; int local_1 = plane.Id; if ((local_0.GetValueOrDefault() != local_1 ? 0 : (local_0.HasValue ? 1 : 0)) != 0) { return(FezMath.AlmostEqual(Vector3.Transform(Vector3.UnitZ, plane.Rotation).Y, 0.0f)); } else { return(false); } }))) { this.AttachedPlanes.Add(backgroundPlane); } Vector3 position = this.LevelManager.WaterType == LiquidType.None ? this.Top * Vector3.UnitY + this.Plane.Position * FezMath.XZMask : this.TerminalPosition * FezMath.XZMask + this.LevelManager.WaterHeight * Vector3.UnitY; Waiters.Wait((double)RandomHelper.Between(0.0, 1.0), (Action)(() => waterfallState.BubblingEmitter = SoundEffectExtensions.EmitAt(waterfallState.Host.SewageFallSound, position, true, RandomHelper.Centered(0.025), 0.0f))); }
public override void Initialize() { base.Initialize(); lock (TileTransition.Mutex) { if (TileTransition.sTransition == null) { TileTransition.sTransition = this.CMProvider.Global.Load <SoundEffect>("Sounds/Ui/CubeTransition"); } } TileTransition tileTransition = this; Mesh mesh1 = new Mesh(); Mesh mesh2 = mesh1; DefaultEffect.Textured textured1 = new DefaultEffect.Textured(); textured1.ForcedProjectionMatrix = new Matrix?(Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(60f), 1f, 0.1f, 100f)); textured1.ForcedViewMatrix = new Matrix?(Matrix.CreateLookAt(new Vector3(0.0f, 0.0f, -1.365f), new Vector3(0.0f, 0.0f, 0.0f), Vector3.Up)); DefaultEffect.Textured textured2 = textured1; mesh2.Effect = (BaseEffect)textured2; mesh1.DepthWrites = false; mesh1.AlwaysOnTop = true; mesh1.Blending = new BlendingMode?(BlendingMode.Opaque); Mesh mesh3 = mesh1; tileTransition.mesh = mesh3; for (int index1 = 0; index1 < 1; ++index1) { for (int index2 = 0; index2 < 1; ++index2) { float x = (float)index1 / 1f; float num1 = (float)(index1 + 1) / 1f; float y = (float)index2 / 1f; float num2 = (float)(index2 + 1) / 1f; bool flag1 = RandomHelper.Probability(0.5); bool flag2 = RandomHelper.Probability(0.5); Group group1 = this.mesh.AddGroup(); if (flag2) { group1.Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <VertexPositionTexture>(new VertexPositionTexture[4] { new VertexPositionTexture(new Vector3(-0.5f, 0.5f, -0.5f), new Vector2(1f - x, 1f - num2)), new VertexPositionTexture(new Vector3(0.5f, 0.5f, -0.5f), new Vector2(1f - num1, 1f - num2)), new VertexPositionTexture(new Vector3(-0.5f, -0.5f, -0.5f), new Vector2(1f - x, 1f - y)), new VertexPositionTexture(new Vector3(0.5f, -0.5f, -0.5f), new Vector2(1f - num1, 1f - y)) }, new int[6] { 0, 2, 1, 2, 3, 1 }, PrimitiveType.TriangleList); } else { group1.Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <VertexPositionTexture>(new VertexPositionTexture[4] { new VertexPositionTexture(new Vector3(-0.5f, 0.5f, -0.5f), new Vector2(1f - x, 1f - num2)), new VertexPositionTexture(new Vector3(0.5f, 0.5f, -0.5f), new Vector2(1f - num1, 1f - num2)), new VertexPositionTexture(new Vector3(-0.5f, -0.5f, -0.5f), new Vector2(1f - x, 1f - y)), new VertexPositionTexture(new Vector3(0.5f, -0.5f, -0.5f), new Vector2(1f - num1, 1f - y)) }, new int[6] { 0, 2, 1, 2, 3, 1 }, PrimitiveType.TriangleList); } group1.Scale = new Vector3(1f, 1f, (float)(1.0 / (flag2 ? 1.0 : 1.0))); group1.Position = new Vector3(x, y, 0.0f); group1.CustomData = (object)new TileTransition.TileData() { X = (x + RandomHelper.Centered(0.150000005960464)), Y = (y + RandomHelper.Centered(0.150000005960464)), B = false, Inverted = flag1, Vertical = flag2 }; group1.Material = new Material(); Group group2 = this.mesh.AddGroup(); if (flag2) { Group group3 = group2; VertexPositionTexture[] vertices = new VertexPositionTexture[4] { new VertexPositionTexture(new Vector3(-0.5f, flag1 ? 0.5f : -0.5f, -0.5f), new Vector2(1f - x, flag1 ? 1f - y : 1f - num2)), new VertexPositionTexture(new Vector3(0.5f, flag1 ? 0.5f : -0.5f, -0.5f), new Vector2(1f - num1, flag1 ? 1f - y : 1f - num2)), new VertexPositionTexture(new Vector3(-0.5f, flag1 ? 0.5f : -0.5f, 0.5f), new Vector2(1f - x, flag1 ? 1f - num2 : 1f - y)), new VertexPositionTexture(new Vector3(0.5f, flag1 ? 0.5f : -0.5f, 0.5f), new Vector2(1f - num1, flag1 ? 1f - num2 : 1f - y)) }; int[] indices; if (!flag1) { indices = new int[6] { 0, 2, 1, 2, 3, 1 } } ; else { indices = new int[6] { 0, 1, 2, 2, 1, 3 } }; int num3 = 0; IndexedUserPrimitives <VertexPositionTexture> indexedUserPrimitives = new IndexedUserPrimitives <VertexPositionTexture>(vertices, indices, (PrimitiveType)num3); group3.Geometry = (IIndexedPrimitiveCollection)indexedUserPrimitives; } else { Group group3 = group2; VertexPositionTexture[] vertices = new VertexPositionTexture[4] { new VertexPositionTexture(new Vector3(flag1 ? 0.5f : -0.5f, 0.5f, 0.5f), new Vector2(flag1 ? 1f - num1 : 1f - x, 1f - num2)), new VertexPositionTexture(new Vector3(flag1 ? 0.5f : -0.5f, 0.5f, -0.5f), new Vector2(flag1 ? 1f - x : 1f - num1, 1f - num2)), new VertexPositionTexture(new Vector3(flag1 ? 0.5f : -0.5f, -0.5f, 0.5f), new Vector2(flag1 ? 1f - num1 : 1f - x, 1f - y)), new VertexPositionTexture(new Vector3(flag1 ? 0.5f : -0.5f, -0.5f, -0.5f), new Vector2(flag1 ? 1f - x : 1f - num1, 1f - y)) }; int[] indices; if (!flag1) { indices = new int[6] { 0, 2, 1, 2, 3, 1 } } ; else { indices = new int[6] { 0, 1, 2, 2, 1, 3 } }; int num3 = 0; IndexedUserPrimitives <VertexPositionTexture> indexedUserPrimitives = new IndexedUserPrimitives <VertexPositionTexture>(vertices, indices, (PrimitiveType)num3); group3.Geometry = (IIndexedPrimitiveCollection)indexedUserPrimitives; } group2.Scale = new Vector3(1f, 1f, (float)(1.0 / (flag2 ? 1.0 : 1.0))); group2.Position = new Vector3(x, y, 0.0f); group2.CustomData = (object)new TileTransition.TileData() { X = (x + RandomHelper.Centered(0.150000005960464)), Y = (y + RandomHelper.Centered(0.150000005960464)), B = true, Inverted = flag1, Vertical = flag2 }; group2.Material = new Material(); } } this.mesh.Position = new Vector3(0.0f, 0.0f, 0.0f); this.textureA = this.TargetRenderer.TakeTarget(); this.textureB = this.TargetRenderer.TakeTarget(); foreach (Group group in this.mesh.Groups) { group.Texture = !((TileTransition.TileData)group.CustomData).B ? (Texture)this.textureA.Target : (Texture)this.textureB.Target; } this.TargetRenderer.ScheduleHook(this.DrawOrder, this.textureA.Target); SoundEffectExtensions.Emit(TileTransition.sTransition); }