private void CreateHoles() { bool flag = Enumerable.Contains <string>((IEnumerable <string>)BlackHolesHost.AlwaysEnabledLevels, this.LevelManager.Name) || !this.GameState.SaveData.ThisLevel.FirstVisit && !this.GameState.IsTrialMode && RandomHelper.Probability((double)Math.Min(this.GameState.SaveData.CubeShards + this.GameState.SaveData.SecretCubes, 32) / 64.0); foreach (Volume volume in Enumerable.Where <Volume>((IEnumerable <Volume>) this.LevelManager.Volumes.Values, (Func <Volume, bool>)(x => { if (x.ActorSettings != null) { return(x.ActorSettings.IsBlackHole); } else { return(false); } }))) { BlackHolesHost.HoleState holeState = new BlackHolesHost.HoleState(volume, this); holeState.Build(); holeState.Enabled = flag; if (holeState.Enabled) { holeState.Emitter = SoundEffectExtensions.EmitAt(this.buzz, holeState.Center, true, 0.0f, 0.0f); holeState.Visible = true; } this.holes.Add(holeState); } this.InstanceData = new Matrix[this.holes.Count]; for (int index = 0; index < this.InstanceData.Length; ++index) { this.InstanceData[index] = new Matrix(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1f, 1f, 0.0f, 0.0f); } this.HolesBodyMesh.Collapse <VertexPositionInstance>(); this.HolesFringeMesh.Collapse <VertexPositionTextureInstance>(); }
public override void Update(GameTime gameTime) { if (this.GameState.Loading || this.GameState.Paused || (this.GameState.InMenuCube || this.GameState.InMap) || (!FezMath.IsOrthographic(this.CameraManager.Viewpoint) || this.CameraManager.ProjectionTransition)) return; Vector3 vector3_1 = FezMath.RightVector(this.CameraManager.Viewpoint) * (float) FezMath.Sign(this.PlayerManager.LookingDirection); if (this.PlayerManager.Action != ActionType.SuckedIn && this.currentHole != null) { this.currentHole.Sucking = false; this.currentHole = (BlackHolesHost.HoleState) null; } if (this.PlayerManager.Action == ActionType.SuckedIn && this.currentHole == null) { foreach (BlackHolesHost.HoleState holeState in this.holes) { if (holeState.Volume.ActorSettings.IsBlackHole && holeState.Volume.ActorSettings.Sucking) { this.PlayerManager.Velocity = Vector3.Zero; holeState.Volume.ActorSettings.Sucking = false; holeState.Sucking = true; this.currentHole = holeState; break; } } } if (this.currentHole != null) { Vector3 vector3_2 = -FezMath.ForwardVector(this.CameraManager.Viewpoint); this.PlayerManager.Position = Vector3.Lerp(this.PlayerManager.Position, this.currentHole.Center + -0.25f * Vector3.UnitY + 0.375f * vector3_1 + (this.currentHole.Size + new Vector3(0.6f)) * vector3_2, 0.025f); } foreach (BlackHolesHost.HoleState holeState in this.holes) { if (holeState.Visible && holeState.Enabled) { if (!this.GameState.SaveData.OneTimeTutorials.ContainsKey("DOT_BLACKHOLE_A") && !this.GameState.FarawaySettings.InTransition && (!this.PlayerManager.InDoorTransition && ActionTypeExtensions.AllowsLookingDirectionChange(this.PlayerManager.Action)) && (this.SpeechBubble.Hidden && !ActionTypeExtensions.DisallowsRespawn(this.PlayerManager.Action) && (this.CameraManager.ViewTransitionReached && this.PlayerManager.CarriedInstance == null))) { this.DotSpeak(); this.GameState.SaveData.OneTimeTutorials.Add("DOT_BLACKHOLE_A", true); } holeState.SinceEnabled += (float) (gameTime.ElapsedGameTime.TotalSeconds * 0.5); bool flag1 = (holeState.Sucking ? 0.2 : gameTime.ElapsedGameTime.TotalSeconds * 0.5) > this.random.NextDouble(); if (flag1 && (double) holeState.SinceEnabled > 1.0) { SoundEffectExtensions.EmitAt(this.glitches[this.random.Next(this.glitches.Length)], holeState.Center, false, (float) (this.random.NextDouble() - 0.5) * 0.1f); bool flag2 = 0.5 > this.random.NextDouble(); bool flag3 = 0.5 > this.random.NextDouble(); holeState.SetTextureTransform(new Vector2(flag2 ? 1f : 0.0f, flag3 ? 1f : 0.0f), new Vector2(flag2 ? -1f : 1f, flag3 ? -1f : 1f)); } float num1 = (float) this.random.NextDouble() * 16f; float num2 = (float) (3.0 / 32.0 * (flag1 ? (double) num1 : 1.0) * 2.0); for (int index = 0; index < 3; ++index) { holeState.Offsets[index].X = (float) (this.random.NextDouble() - 0.5) * num2; holeState.Offsets[index].Y = (float) (this.random.NextDouble() - 0.5) * num2; holeState.Offsets[index].Z = (float) (this.random.NextDouble() - 0.5) * num2; } } } }
private void CreateHoles() { bool flag = Enumerable.Contains<string>((IEnumerable<string>) BlackHolesHost.AlwaysEnabledLevels, this.LevelManager.Name) || !this.GameState.SaveData.ThisLevel.FirstVisit && !this.GameState.IsTrialMode && RandomHelper.Probability((double) Math.Min(this.GameState.SaveData.CubeShards + this.GameState.SaveData.SecretCubes, 32) / 64.0); foreach (Volume volume in Enumerable.Where<Volume>((IEnumerable<Volume>) this.LevelManager.Volumes.Values, (Func<Volume, bool>) (x => { if (x.ActorSettings != null) return x.ActorSettings.IsBlackHole; else return false; }))) { BlackHolesHost.HoleState holeState = new BlackHolesHost.HoleState(volume, this); holeState.Build(); holeState.Enabled = flag; if (holeState.Enabled) { holeState.Emitter = SoundEffectExtensions.EmitAt(this.buzz, holeState.Center, true, 0.0f, 0.0f); holeState.Visible = true; } this.holes.Add(holeState); } this.InstanceData = new Matrix[this.holes.Count]; for (int index = 0; index < this.InstanceData.Length; ++index) this.InstanceData[index] = new Matrix(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1f, 1f, 0.0f, 0.0f); this.HolesBodyMesh.Collapse<VertexPositionInstance>(); this.HolesFringeMesh.Collapse<VertexPositionTextureInstance>(); }
public override void Update(GameTime gameTime) { if (this.GameState.Loading || this.GameState.Paused || (this.GameState.InMenuCube || this.GameState.InMap) || (!FezMath.IsOrthographic(this.CameraManager.Viewpoint) || this.CameraManager.ProjectionTransition)) { return; } Vector3 vector3_1 = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection); if (this.PlayerManager.Action != ActionType.SuckedIn && this.currentHole != null) { this.currentHole.Sucking = false; this.currentHole = (BlackHolesHost.HoleState)null; } if (this.PlayerManager.Action == ActionType.SuckedIn && this.currentHole == null) { foreach (BlackHolesHost.HoleState holeState in this.holes) { if (holeState.Volume.ActorSettings.IsBlackHole && holeState.Volume.ActorSettings.Sucking) { this.PlayerManager.Velocity = Vector3.Zero; holeState.Volume.ActorSettings.Sucking = false; holeState.Sucking = true; this.currentHole = holeState; break; } } } if (this.currentHole != null) { Vector3 vector3_2 = -FezMath.ForwardVector(this.CameraManager.Viewpoint); this.PlayerManager.Position = Vector3.Lerp(this.PlayerManager.Position, this.currentHole.Center + -0.25f * Vector3.UnitY + 0.375f * vector3_1 + (this.currentHole.Size + new Vector3(0.6f)) * vector3_2, 0.025f); } foreach (BlackHolesHost.HoleState holeState in this.holes) { if (holeState.Visible && holeState.Enabled) { if (!this.GameState.SaveData.OneTimeTutorials.ContainsKey("DOT_BLACKHOLE_A") && !this.GameState.FarawaySettings.InTransition && (!this.PlayerManager.InDoorTransition && ActionTypeExtensions.AllowsLookingDirectionChange(this.PlayerManager.Action)) && (this.SpeechBubble.Hidden && !ActionTypeExtensions.DisallowsRespawn(this.PlayerManager.Action) && (this.CameraManager.ViewTransitionReached && this.PlayerManager.CarriedInstance == null))) { this.DotSpeak(); this.GameState.SaveData.OneTimeTutorials.Add("DOT_BLACKHOLE_A", true); } holeState.SinceEnabled += (float)(gameTime.ElapsedGameTime.TotalSeconds * 0.5); bool flag1 = (holeState.Sucking ? 0.2 : gameTime.ElapsedGameTime.TotalSeconds * 0.5) > this.random.NextDouble(); if (flag1 && (double)holeState.SinceEnabled > 1.0) { SoundEffectExtensions.EmitAt(this.glitches[this.random.Next(this.glitches.Length)], holeState.Center, false, (float)(this.random.NextDouble() - 0.5) * 0.1f); bool flag2 = 0.5 > this.random.NextDouble(); bool flag3 = 0.5 > this.random.NextDouble(); holeState.SetTextureTransform(new Vector2(flag2 ? 1f : 0.0f, flag3 ? 1f : 0.0f), new Vector2(flag2 ? -1f : 1f, flag3 ? -1f : 1f)); } float num1 = (float)this.random.NextDouble() * 16f; float num2 = (float)(3.0 / 32.0 * (flag1 ? (double)num1 : 1.0) * 2.0); for (int index = 0; index < 3; ++index) { holeState.Offsets[index].X = (float)(this.random.NextDouble() - 0.5) * num2; holeState.Offsets[index].Y = (float)(this.random.NextDouble() - 0.5) * num2; holeState.Offsets[index].Z = (float)(this.random.NextDouble() - 0.5) * num2; } } } }