private void Respawn() { foreach (TrileInstance instance in this.InstancesToClear) { ServiceHelper.AddComponent((IGameComponent) new GlitchyRespawner(ServiceHelper.Game, instance)); } }
public static IWaiter DoUntil(Func <bool> endCondition, Action <float> action, Action onComplete) { Waiter waiter; ServiceHelper.AddComponent((IGameComponent)(waiter = new Waiter(endCondition, (Action <TimeSpan>)(elapsed => action((float)elapsed.TotalSeconds)), onComplete))); return((IWaiter)waiter); }
public override void Initialize() { base.Initialize(); Material material = new Material(); this.LastLevelMesh = new Mesh() { Effect = (BaseEffect) new FarawayEffect(), DepthWrites = false, Material = material, Blending = new BlendingMode?(BlendingMode.Alphablending), SamplerState = SamplerState.PointClamp }; this.ThisLevelMesh = new Mesh() { Effect = (BaseEffect) new FarawayEffect(), DepthWrites = false, Material = material, Blending = new BlendingMode?(BlendingMode.Alphablending), SamplerState = SamplerState.PointClamp }; this.NextLevelMesh = new Mesh() { Effect = (BaseEffect) new FarawayEffect(), DepthWrites = false, Material = material, Blending = new BlendingMode?(BlendingMode.Alphablending), SamplerState = SamplerState.PointClamp }; this.LevelManager.LevelChanged += new Action(this.TryInitialize); ServiceHelper.AddComponent((IGameComponent)(this.Fader = new FarawayPlaceHost.PlaceFader(this.Game))); this.Fader.Visible = false; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (this.GraphicsDevice != null) { this.GraphicsDevice.DeviceReset -= new EventHandler <EventArgs>(this.UpdateViewScale); } if (this.TextTexture != null) { this.TextTexture.Dispose(); this.TextTexture = (RenderTarget2D)null; } if (this.ScrollMesh != null) { this.ScrollMesh.Dispose(); this.ScrollMesh = (Mesh)null; } if (this.GameState == null) { return; } this.GameState.ActiveScroll = this.NextScroll; if (this.NextScroll == null) { return; } ServiceHelper.AddComponent((IGameComponent)this.GameState.ActiveScroll); }
protected override bool Act(TimeSpan elapsed) { if (!this.PlayerManager.CanControl) { return(true); } if (this.fade == null && this.sinceHurt.TotalSeconds > (this.doneFor ? 1.25 : 1.0)) { this.sinceHurt = TimeSpan.Zero; this.causedByHurtActor = false; if (this.doneFor) { this.fade = new ScreenFade(ServiceHelper.Game) { FromColor = ColorEx.TransparentBlack, ToColor = Color.Black, Duration = 1f }; ServiceHelper.AddComponent((IGameComponent)this.fade); this.fade.Faded += new Action(this.Respawn); } else { this.PlayerManager.Action = ActionType.Idle; } } else { this.sinceHurt += elapsed; this.PlayerManager.BlinkSpeed = Easing.EaseIn(this.sinceHurt.TotalSeconds / 1.25, EasingType.Cubic) * 1.5f; } return(true); }
public static IWaiter Wait(Func <bool> endCondition, Action onValid) { Waiter waiter; ServiceHelper.AddComponent((IGameComponent)(waiter = new Waiter(endCondition, onValid))); return((IWaiter)waiter); }
protected override bool Act(TimeSpan elapsed) { this.sinceStarted += elapsed; if (this.fade == null && this.sinceStarted.TotalSeconds > (this.doneFor ? 1.25 : 2.0)) { if (this.doneFor) { this.fade = new ScreenFade(ServiceHelper.Game) { FromColor = ColorEx.TransparentBlack, ToColor = Color.Black, Duration = 1f }; ServiceHelper.AddComponent((IGameComponent)this.fade); this.fade.Faded += new Action(this.Respawn); } else { this.PlayerManager.Respawn(); } } else { this.PlayerManager.BlinkSpeed = Easing.EaseIn(this.sinceStarted.TotalSeconds / (this.doneFor ? 1.25 : 2.0), EasingType.Cubic) * 1.5f; } return(true); }
public override void Initialize() { base.Initialize(); DrawableGameComponent drawableGameComponent1; ServiceHelper.AddComponent((IGameComponent)(drawableGameComponent1 = (DrawableGameComponent) new ZoomOut(this.Game, this))); this.Scenes.Add(drawableGameComponent1); DrawableGameComponent drawableGameComponent2; ServiceHelper.AddComponent((IGameComponent)(drawableGameComponent2 = (DrawableGameComponent) new MulticoloredSpace(this.Game, this))); this.Scenes.Add(drawableGameComponent2); DrawableGameComponent drawableGameComponent3; ServiceHelper.AddComponent((IGameComponent)(drawableGameComponent3 = (DrawableGameComponent) new DotsAplenty(this.Game, this))); this.Scenes.Add(drawableGameComponent3); DrawableGameComponent drawableGameComponent4; ServiceHelper.AddComponent((IGameComponent)(drawableGameComponent4 = (DrawableGameComponent) new WhiteNoise(this.Game, this))); this.Scenes.Add(drawableGameComponent4); foreach (DrawableGameComponent drawableGameComponent5 in this.Scenes) { drawableGameComponent5.Enabled = drawableGameComponent5.Visible = false; } this.Scenes[0].Enabled = this.Scenes[0].Visible = true; this.LevelManager.LevelChanged += new Action(this.TryDestroy); }
public void EndTrial(bool forceRestart) { if (!this.GameState.IsTrialMode) { return; } ScreenFade screenFade1 = new ScreenFade(ServiceHelper.Game); screenFade1.FromColor = ColorEx.TransparentBlack; screenFade1.ToColor = Color.Black; screenFade1.EaseOut = true; screenFade1.CaptureScreen = true; screenFade1.Duration = 1f; screenFade1.DrawOrder = 2050; screenFade1.WaitUntil = (Func <bool>)(() => !this.GameState.Loading); ScreenFade screenFade2 = screenFade1; screenFade2.ScreenCaptured += (Action)(() => { this.GameState.SkipLoadBackground = true; this.GameState.Loading = true; Worker <bool> worker = this.ThreadPool.Take <bool>(new Action <bool>(this.DoSellScreen)); worker.Finished += (Action)(() => { this.ThreadPool.Return <bool>(worker); this.GameState.ScheduleLoadEnd = true; this.GameState.SkipLoadBackground = false; }); worker.Start(forceRestart); }); ServiceHelper.AddComponent((IGameComponent)screenFade2); }
public void StartTransition() { ServiceHelper.AddComponent((IGameComponent)(this.Transition = new RainHost.RainTransition(this.Game, this.RainPS))); this.PlaneSystems.Remove(this.RainPS, false); this.RainPS.SetViewProjectionSticky(true); this.transitionCenter = this.CameraManager.Center; }
public void PlayNewSong(float fadeDuration) { if (SoundManager.NoMusic) { return; } TrackedSong currentlyPlayingSong = this.CurrentlyPlayingSong; if (this.ActiveSong != null) { this.ActiveSong.FadeOutAndRemoveComponent(fadeDuration); } if (this.LevelManager.Song == null) { this.ActiveSong = (ActiveTrackedSong)null; } else { ServiceHelper.AddComponent((IGameComponent)(this.ActiveSong = new ActiveTrackedSong(this.Game))); } if (currentlyPlayingSong == this.CurrentlyPlayingSong) { return; } this.SongChanged(); }
public void PlayNewSong(string name, float fadeDuration, bool interrupt) { if (SoundManager.NoMusic) { return; } TrackedSong currentlyPlayingSong = this.CurrentlyPlayingSong; if (!interrupt) { this.ShelvedSong = this.ActiveSong; } else if (this.ActiveSong != null) { this.ActiveSong.FadeOutAndRemoveComponent(fadeDuration); } if (string.IsNullOrEmpty(name)) { this.ActiveSong = (ActiveTrackedSong)null; } else { TrackedSong song = this.CMProvider.CurrentLevel.Load <TrackedSong>("Music/" + name); song.Initialize(); ServiceHelper.AddComponent((IGameComponent)(this.ActiveSong = new ActiveTrackedSong(this.Game, song, this.LevelManager.MutedLoops))); } if (currentlyPlayingSong == this.CurrentlyPlayingSong) { return; } this.SongChanged(); }
private void ScheduleHit() { this.wutex2 = (IWaiter)null; this.wutex1 = Waiters.Wait(0.25, (Action)(() => { Waiters.Wait(0.25, (Action)(() => this.wutex1 = (IWaiter)null)); this.PlayerManager.Action = ActionType.HitBell; this.PlayerManager.Animation.Timing.Restart(); this.SinceHit = TimeSpan.Zero; SoundEffectExtensions.EmitAt(this.sBellHit[(int)(this.CameraManager.Viewpoint - 1)], this.BellAo.Position); this.SoundManager.FadeVolume(0.25f, 1f, 2f); this.AngularVelocity += new Vector2(-FezMath.Dot(FezMath.ForwardVector(this.CameraManager.Viewpoint), Vector3.UnitZ), FezMath.Dot(FezMath.ForwardVector(this.CameraManager.Viewpoint), Vector3.UnitX)) * 0.075f; if (this.Solved) { return; } if (this.LastHit != Viewpoint.None && this.LastHit != this.CameraManager.Viewpoint) { this.Hits[this.CameraManager.Viewpoint] = 0; } this.LastHit = this.CameraManager.Viewpoint; Dictionary <Viewpoint, int> local_1; Viewpoint local_2; (local_1 = this.Hits)[local_2 = this.CameraManager.Viewpoint] = local_1[local_2] + 1; if (!Enumerable.All <KeyValuePair <Viewpoint, int> >((IEnumerable <KeyValuePair <Viewpoint, int> >) this.Hits, (Func <KeyValuePair <Viewpoint, int>, bool>)(kvp => kvp.Value == this.ExpectedHits[kvp.Key]))) { return; } this.Solved = true; this.GameState.SaveData.ThisLevel.InactiveArtObjects.Add(this.BellAo.Id); this.LevelService.ResolvePuzzle(); ServiceHelper.AddComponent((IGameComponent) new GlitchyDespawner(this.Game, this.BellAo, this.OriginalPosition)); })); this.wutex1.AutoPause = true; }
public void Restart() { if (this.ForcedSignOut) { this.SinceSaveRequest = -1f; this.ActiveGamerSignedOut(); } this.ForceTimePaused = true; ScreenFade screenFade1 = new ScreenFade(ServiceHelper.Game); screenFade1.FromColor = ColorEx.TransparentBlack; screenFade1.ToColor = Color.Black; screenFade1.EaseOut = true; screenFade1.CaptureScreen = true; screenFade1.Duration = 0.5f; screenFade1.WaitUntil = (Func <bool>)(() => !this.Loading); screenFade1.DrawOrder = 2050; ScreenFade screenFade2 = screenFade1; screenFade2.ScreenCaptured += (Action)(() => { this.Loading = true; Worker <bool> worker = this.ThreadPool.Take <bool>(new Action <bool>(this.DoRestart)); worker.Finished += (Action)(() => { this.ThreadPool.Return <bool>(worker); this.SkipLoadBackground = false; this.Loading = false; }); worker.Start(false); }); ServiceHelper.AddComponent((IGameComponent)screenFade2); }
public void Pause(bool toCredits) { if (this.Paused) { return; } this.paused = true; this.OnPauseStateChanged(); PauseMenu pauseMenu = new PauseMenu(ServiceHelper.Game); if (toCredits) { pauseMenu.EndGameMenu = true; ServiceHelper.AddComponent((IGameComponent)pauseMenu); pauseMenu.nextMenuLevel = (MenuLevel)pauseMenu.CreditsMenu; pauseMenu.nextMenuLevel.Reset(); } else { ServiceHelper.AddComponent((IGameComponent) new TileTransition(ServiceHelper.Game) { ScreenCaptured = (Action)(() => ServiceHelper.AddComponent((IGameComponent)pauseMenu)), WaitFor = (Func <bool>)(() => pauseMenu.Ready) }); } }
public override void Initialize() { base.Initialize(); this.DestinationRadius = 20f * SettingsManager.GetViewScale(this.GraphicsDevice); this.Flare = new Mesh() { Blending = new BlendingMode?(BlendingMode.Additive), SamplerState = SamplerState.LinearClamp, DepthWrites = false }; this.Flare.AddFace(Vector3.One, Vector3.Zero, FaceOrientation.Front, true, true); this.StarMesh = new Mesh() { Blending = new BlendingMode?(BlendingMode.Alphablending), DepthWrites = false }; Color color = new Color(1f, 1f, 0.3f, 0.0f); for (int index = 0; index < 8; ++index) { float num1 = (float)((double)index * 6.28318548202515 / 8.0); float num2 = (float)(((double)index + 0.5) * 6.28318548202515 / 8.0); this.StarMesh.AddColoredTriangle(Vector3.Zero, new Vector3((float)Math.Sin((double)num1), (float)Math.Cos((double)num1), 0.0f), new Vector3((float)Math.Sin((double)num2), (float)Math.Cos((double)num2), 0.0f), new Color(1f, 1f, 0.5f, 0.7f), color, color); } this.Flare.Effect = (BaseEffect) new DefaultEffect.Textured(); this.StarMesh.Effect = (BaseEffect) new DefaultEffect.VertexColored(); this.Flare.Texture = (Dirtyable <Texture>)((Texture)this.CMProvider.Global.Load <Texture2D>("Background Planes/flare")); ServiceHelper.AddComponent((IGameComponent)(this.FezLogo = new FezLogo(this.Game))); this.FezLogo.Enabled = false; this.sTitleBassHit = this.CMProvider.Global.Load <SoundEffect>("Sounds/Intro/LogoZoom"); }
public LongRunningAction ChangeLevel(string levelName, bool asDoor, bool spin, bool trialEnding) { if (asDoor) { this.PlayerManager.SpinThroughDoor = spin; this.PlayerManager.NextLevel = levelName; this.PlayerManager.DoorVolume = this.ScriptingManager.EvaluatedScript.InitiatingTrigger.Object.Identifier; this.PlayerManager.DoorEndsTrial = trialEnding && this.GameState.IsTrialMode; IGameLevelManager levelManager = this.LevelManager; int num = (levelManager.WentThroughSecretPassage ? 1 : 0) | (!this.PlayerManager.DoorVolume.HasValue || this.LevelManager.Volumes[this.PlayerManager.DoorVolume.Value].ActorSettings == null ? 0 : (this.LevelManager.Volumes[this.PlayerManager.DoorVolume.Value].ActorSettings.IsSecretPassage ? 1 : 0)); levelManager.WentThroughSecretPassage = num != 0; return(new LongRunningAction((Action)(() => { this.PlayerManager.NextLevel = (string)null; this.PlayerManager.DoorVolume = new int?(); this.PlayerManager.DoorEndsTrial = false; if (ActionTypeExtensions.IsEnteringDoor(this.PlayerManager.Action)) { return; } this.LevelManager.WentThroughSecretPassage = false; }))); } else { ServiceHelper.AddComponent((IGameComponent) new LevelTransition(ServiceHelper.Game, levelName)); return(new LongRunningAction()); } }
public LongRunningAction(Func <float, float, bool> onUpdate, Action onDispose) : base(ServiceHelper.Game) { ServiceHelper.AddComponent((IGameComponent)this); this.OnDispose = onDispose; this.OnUpdate = onUpdate; }
public void SpawnTrileAt(int id, string actorTypeName) { BoundingBox boundingBox = this.LevelManager.Volumes[id].BoundingBox; Vector3 position1 = (boundingBox.Min + boundingBox.Max) / 2f; Trile trile = Enumerable.FirstOrDefault <Trile>(this.LevelManager.ActorTriles((ActorType)Enum.Parse(typeof(ActorType), actorTypeName, true))); if (trile == null) { return; } Vector3 vector3 = position1 - Vector3.One / 2f; NearestTriles nearestTriles = this.LevelManager.NearestTrile(position1); TrileInstance trileInstance = nearestTriles.Surface ?? nearestTriles.Deep; if (trileInstance != null) { vector3 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) * vector3 + trileInstance.Center * FezMath.DepthMask(this.CameraManager.Viewpoint) - FezMath.ForwardVector(this.CameraManager.Viewpoint) * 2f; } Vector3 position2 = Vector3.Clamp(vector3, Vector3.Zero, this.LevelManager.Size - Vector3.One); ServiceHelper.AddComponent((IGameComponent) new GlitchyRespawner(ServiceHelper.Game, new TrileInstance(position2, trile.Id) { OriginalEmplacement = new TrileEmplacement(position2) })); }
public void Shake(float distance, float durationSeconds) { ServiceHelper.AddComponent((IGameComponent) new CamShake(ServiceHelper.Game) { Duration = TimeSpan.FromSeconds((double)durationSeconds), Distance = distance }); }
protected override void ResumeGame() { ServiceHelper.AddComponent((IGameComponent) new TileTransition(ServiceHelper.Game) { ScreenCaptured = (Action)(() => ServiceHelper.RemoveComponent <PauseMenu>(this)) }); this.Enabled = false; SoundEffectExtensions.Emit(this.sDisappear).Persistent = true; }
public void Add(PlaneParticleSystem system) { if (!system.Initialized) { ServiceHelper.AddComponent((IGameComponent)system); } system.Revive(); this.ActiveParticleSystems.Add(system); }
public override void Initialize() { base.Initialize(); ServiceHelper.AddComponent((IGameComponent)(this.trailsRenderer = new SplitUpCubeHost.TrailsRenderer(this.Game, this))); this.LevelManager.LevelChanged += new Action(this.TryInitialize); this.trailsRenderer.Visible = this.Enabled = this.Visible = false; this.SoundManager.SongChanged += new Action(this.RefreshSounds); this.LightingPostProcess.DrawGeometryLights += new Action(this.DrawLights); }
private void GlitchReboot() { ServiceHelper.AddComponent((IGameComponent) new Reboot(this.Game, "GOMEZ_HOUSE_END_32")); Waiters.Wait(0.100000001490116, (Action)(() => { this.Destroy(); this.Enabled = this.Visible = false; })); this.Enabled = false; }
public static IWaiter Wait(double secondsToWait, Action onValid) { Func <Waiters.TimeKeeper, bool> condition = (Func <Waiters.TimeKeeper, bool>)(waited => waited.Elapsed.TotalSeconds > secondsToWait); Action <TimeSpan, Waiters.TimeKeeper> whileWaiting = (Action <TimeSpan, Waiters.TimeKeeper>)((elapsed, waited) => waited.Elapsed += elapsed); Action onValid1 = onValid; Waiter <Waiters.TimeKeeper> waiter; ServiceHelper.AddComponent((IGameComponent)(waiter = new Waiter <Waiters.TimeKeeper>(condition, whileWaiting, onValid1))); return((IWaiter)waiter); }
private void AddAction(PlayerAction action) { ServiceHelper.AddComponent((IGameComponent)action); if (action.UpdateOrder != 0 || action.IsUpdateOverridden || !(action.GetType().Name != "Jump")) { return; } this.LightActions.Add(action); action.Enabled = false; }
public LongRunningAction GlitchUp() { NesGlitches nesGlitches = new NesGlitches(this.Game); ServiceHelper.AddComponent((IGameComponent)nesGlitches); bool disposed = false; nesGlitches.Disposed += (EventHandler <EventArgs>)((_, __) => disposed = true); return(new LongRunningAction((Func <float, float, bool>)((_, __) => disposed))); }
public LongRunningAction Reboot(string toLevel) { Reboot reboot = new Reboot(this.Game, toLevel); ServiceHelper.AddComponent((IGameComponent)reboot); bool disposed = false; reboot.Disposed += (EventHandler <EventArgs>)((_, __) => disposed = true); return(new LongRunningAction((Func <float, float, bool>)((_, __) => disposed))); }
private TrileInstance TestSecretFor(bool condition, ArtObjectInstance ao, TrileInstance secretTrile, TrileInstance topMost) { Vector3 position = topMost.Position + Vector3.Up * 1.5f; if (condition) { if (secretTrile != null && secretTrile.Collected) { ServiceHelper.AddComponent((IGameComponent) new GlitchyDespawner(this.Game, ao)); this.GameState.SaveData.ThisLevel.InactiveArtObjects.Add(ao.Id); ao.Enabled = false; this.TestAllSolved(); this.LevelService.ResolvePuzzle(); return((TrileInstance)null); } else { if (secretTrile == null) { secretTrile = new TrileInstance(position, Enumerable.FirstOrDefault <Trile>(this.LevelManager.ActorTriles(ActorType.SecretCube)).Id); ServiceHelper.AddComponent((IGameComponent) new GlitchyRespawner(this.Game, secretTrile) { DontCullIn = true }); } secretTrile.Position = position; if (!secretTrile.Hidden) { this.LevelManager.UpdateInstance(secretTrile); } } } else if (secretTrile != null) { if (secretTrile.Collected) { ServiceHelper.AddComponent((IGameComponent) new GlitchyDespawner(this.Game, ao)); this.GameState.SaveData.ThisLevel.InactiveArtObjects.Add(ao.Id); ao.Enabled = false; this.TestAllSolved(); this.LevelService.ResolvePuzzle(); return((TrileInstance)null); } else { ServiceHelper.AddComponent((IGameComponent) new GlitchyDespawner(this.Game, secretTrile)); TrileInstance rs = secretTrile; Vector3 p = position; Waiters.Interpolate(2.5, (Action <float>)(_ => rs.Position = p)); return((TrileInstance)null); } } return(secretTrile); }
public void PlayNewAmbience() { if (this.ActiveAmbience == null) { ServiceHelper.AddComponent((IGameComponent)(this.ActiveAmbience = new ActiveAmbience(this.Game, (IEnumerable <AmbienceTrack>) this.LevelManager.AmbienceTracks))); } else { this.ActiveAmbience.ChangeTracks((IEnumerable <AmbienceTrack>) this.LevelManager.AmbienceTracks); } }