public override void Initialize() { base.Initialize(); this.CameraManager.ViewpointChanged += (Action)(() => this.LevelManager.ScreenInvalidated += (Action)(() => { this.PhysicsManager.DetermineOverlaps((IComplexPhysicsEntity)this.PlayerManager); if (FezMath.IsOrthographic(this.CameraManager.Viewpoint) && this.CameraManager.LastViewpoint != this.CameraManager.Viewpoint && !this.PlayerManager.HandlesZClamping) { this.CorrectWallOverlap(true); this.PhysicsManager.DetermineInBackground((IPhysicsEntity)this.PlayerManager, !this.PlayerManager.IsOnRotato, true, !this.PlayerManager.Climbing && !this.LevelManager.LowPass); } this.PhysicsManager.DetermineOverlaps((IComplexPhysicsEntity)this.PlayerManager); })); this.LevelManager.LevelChanged += (Action)(() => this.LevelManager.ScreenInvalidated += (Action)(() => this.PhysicsManager.HugWalls((IPhysicsEntity)this.PlayerManager, false, false, !this.PlayerManager.Climbing))); foreach (SurfaceType key in Util.GetValues <SurfaceType>()) { this.SurfaceHits.Add(key, Enumerable.ToArray <SoundEffect>(Enumerable.Select <string, SoundEffect>(this.CMProvider.GetAllIn("Sounds/Gomez\\Footsteps\\" + (object)key), (Func <string, SoundEffect>)(f => this.CMProvider.Global.Load <SoundEffect>(f))))); } this.LeftStep = this.CMProvider.Global.Load <SoundEffect>("Sounds/Gomez\\Footsteps\\Left"); this.RightStep = this.CMProvider.Global.Load <SoundEffect>("Sounds/Gomez\\Footsteps\\Right"); this.ScriptingManager.CutsceneSkipped += (Action)(() => { while (!this.PlayerManager.CanControl) { this.PlayerManager.CanControl = true; } }); }
private void UpdateDoors() { if (!FezMath.IsOrthographic(this.CameraManager.Viewpoint) || this.InputManager.Up != FezButtonState.Pressed || (!this.PlayerManager.Grounded || this.PlayerManager.Action == ActionType.GateWarp) || (this.PlayerManager.Action == ActionType.WakingUp || this.PlayerManager.Action == ActionType.LesserWarp || !this.SpeechBubble.Hidden)) { return; } Vector3 vector3_1 = this.PlayerManager.Position * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint); Vector3 vector3_2 = this.warpGateAo.Position * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint); if ((double)this.warpGateAo.ArtObject.Size.Y == 8.0) { vector3_2 -= new Vector3(0.0f, 1f, 0.0f); } Vector3 a = vector3_2 - vector3_1; if ((double)Math.Abs(FezMath.Dot(a, FezMath.SideMask(this.CameraManager.Viewpoint))) > 1.5 || (double)Math.Abs(a.Y) > 2.0) { return; } foreach (WarpPanel warpPanel in this.panels.Values) { if (warpPanel.Enabled && warpPanel.Face == FezMath.VisibleOrientation(this.CameraManager.Viewpoint)) { this.PlayerManager.Action = ActionType.GateWarp; this.PlayerManager.WarpPanel = warpPanel; this.PlayerManager.OriginWarpViewpoint = FezMath.AsViewpoint(Enumerable.First <WarpPanel>((IEnumerable <WarpPanel>) this.panels.Values, (Func <WarpPanel, bool>)(x => x.Destination == this.CurrentLevelName)).Face); break; } } }
public override void Update(GameTime gameTime) { if (this.GameState.Loading || this.GameState.InMap || this.GameState.InMenuCube) { return; } TimeSpan timeSpan = gameTime.ElapsedGameTime; if (this.GameState.Paused || this.GameState.InMap || (!FezMath.IsOrthographic(this.CameraManager.Viewpoint) || !this.CameraManager.ActionRunning)) { timeSpan = TimeSpan.Zero; } int count = this.ActiveParticleSystems.Count; if (count >= 8) { this.otherThread.Start(new MtUpdateContext <List <PlaneParticleSystem> >() { Elapsed = timeSpan, StartIndex = 0, EndIndex = count / 2, Result = this.OtherDeadParticleSystems }); this.UpdateParticleSystems(new MtUpdateContext <List <PlaneParticleSystem> >() { Elapsed = timeSpan, StartIndex = count / 2, EndIndex = count, Result = this.DeadParticleSystems }); this.otherThread.Join(); } else { this.UpdateParticleSystems(new MtUpdateContext <List <PlaneParticleSystem> >() { Elapsed = timeSpan, StartIndex = 0, EndIndex = count, Result = this.DeadParticleSystems }); } if (this.OtherDeadParticleSystems.Count > 0) { this.DeadParticleSystems.AddRange((IEnumerable <PlaneParticleSystem>) this.OtherDeadParticleSystems); this.OtherDeadParticleSystems.Clear(); } if (this.DeadParticleSystems.Count <= 0) { return; } foreach (PlaneParticleSystem planeParticleSystem in this.DeadParticleSystems) { this.ActiveParticleSystems.Remove(planeParticleSystem); planeParticleSystem.Clear(); this.PooledParticleSystems.Return(planeParticleSystem); } this.DeadParticleSystems.Clear(); }
public override void Update(GameTime gameTime) { if (this.GameState.Paused || this.GameState.Loading || this.GameState.InMap) { return; } FezMath.IsOrthographic(this.CameraManager.Viewpoint); }
public override void Update(GameTime gameTime) { if (!FezMath.IsOrthographic(this.CameraManager.Viewpoint) || this.GameState.InMap || (this.GameState.Paused || this.GameState.Loading) || (this.GameState.InCutscene || this.GameState.IsTrialMode)) { return; } this.TestInput(); this.SinceInput += gameTime.ElapsedGameTime; }
public virtual bool ChangeViewpoint(Viewpoint newViewpoint, float speedFactor) { bool flag = FezMath.IsOrthographic(newViewpoint) != FezMath.IsOrthographic(this.viewpoint); if (flag && this.ProjectionTransition) { return(false); } this.ProjectionTransition = flag && (double)speedFactor > 0.0; this.radiusBeforeTransition = FezMath.IsOrthographic(this.viewpoint) ? this.current.Radius : this.predefinedViews[this.lastViewpoint].Radius; if ((double)speedFactor > 0.0) { float num = (float)((double)(Math.Abs(FezMath.GetDistance(newViewpoint, this.Viewpoint)) - 1) / 2.0 + 1.0); if (newViewpoint == Viewpoint.Perspective || this.Viewpoint == Viewpoint.Perspective) { num = 1f; } Vector3 from = this.current.Direction; Vector3 to = this.predefinedViews[newViewpoint].Direction; this.directionTransition = new Vector3SplineInterpolation(TimeSpan.FromSeconds((double)DefaultCameraManager.TransitionSpeed * (double)num * (double)speedFactor), new Vector3[3] { from, DefaultCameraManager.GetIntemediateVector(from, to), to }); this.directionTransition.Start(); } if (FezMath.IsOrthographic(this.viewpoint)) { this.current.Direction = -FezMath.ForwardVector(this.viewpoint); this.current.Radius = this.DefaultViewableWidth; } this.olderViewpoint = this.lastViewpoint; this.lastViewpoint = this.viewpoint; this.viewpoint = newViewpoint; Vector3 center = this.Center; this.current = this.predefinedViews[newViewpoint]; this.current.Center = center; if (this.lastViewpoint != Viewpoint.None) { this.PreViewpointChanged(); if (!this.ViewTransitionCancelled) { this.ViewpointChanged(); } } if ((double)speedFactor == 0.0 && !this.ViewTransitionCancelled) { this.RebuildView(); } bool transitionCancelled = this.ViewTransitionCancelled; this.ViewTransitionCancelled = false; return(!transitionCancelled); }
public void RecullAt(TrileEmplacement emplacement) { Viewpoint viewpoint = this.CameraManager.Viewpoint; if (!FezMath.IsOrthographic(viewpoint)) { return; } this.RecullAt(new Point(FezMath.SideMask(viewpoint) == Vector3.Right ? emplacement.X : emplacement.Z, emplacement.Y)); }
public override void Update(GameTime gameTime) { if (this.EngineState.Paused || this.EngineState.InMap || (!FezMath.IsOrthographic(this.CameraManager.Viewpoint) || !this.CameraManager.ActionRunning) || this.EngineState.Loading) { return; } foreach (AttachedPlanesHost.AttachedPlaneState attachedPlaneState in this.TrackedPlanes) { attachedPlaneState.Plane.Position = attachedPlaneState.FirstTrile.Position + attachedPlaneState.Offset; } }
private void RebuildInterpolatedProj() { if (!FezMath.IsOrthographic(this.viewpoint) || (double)this.interpolated.Radius == (double)this.current.Radius && !this.projNewlyReached || this.ProjectionTransition) { return; } float width = this.interpolated.Radius / SettingsManager.GetViewScale(this.GraphicsService.GraphicsDevice); this.projection = Matrix.CreateOrthographic(width, width / this.AspectRatio, 0.1f, 500f); this.OnProjectionChanged(); }
public override void Update(GameTime gameTime) { if (this.EngineState.Paused || this.EngineState.InMap || (!FezMath.IsOrthographic(this.CameraManager.Viewpoint) || !this.CameraManager.ActionRunning)) { return; } foreach (HeavyGroupState heavyGroupState in this.trackedGroups) { heavyGroupState.Update(gameTime.ElapsedGameTime); } }
protected override void DollyZoom() { float viewScale = SettingsManager.GetViewScale(this.GraphicsDevice); if (!this.GameState.InFpsMode) { base.DollyZoom(); } else { bool flag = FezMath.IsOrthographic(this.viewpoint); float amount = (double)this.directionTransition.TotalStep == 0.0 ? 1.0 / 1000.0 : this.directionTransition.TotalStep; float num1 = MathHelper.Lerp(flag ? GameCameraManager.FirstPersonFov : 0.0f, flag ? 0.0f : GameCameraManager.FirstPersonFov, amount); float num2 = this.radiusBeforeTransition; if (this.DollyZoomOut) { num2 = this.radiusBeforeTransition + (float)((1.0 - (double)Easing.EaseIn((double)amount, EasingType.Quadratic)) * 15.0); } float num3 = (float)((double)num2 / (double)this.AspectRatio / (2.0 * Math.Tan((double)num1 / 2.0))) / viewScale; if (this.directionTransition.Reached) { this.ProjectionTransition = false; if (!flag) { this.predefinedViews[this.lastViewpoint].Direction = -FezMath.ForwardVector(this.lastViewpoint); this.current.Radius = 0.1f; } else { this.current.Radius = this.radiusBeforeTransition; this.NearPlane = 0.1f; this.FarPlane = 500f; this.GameState.InFpsMode = false; } this.FogManager.Density = this.LevelManager.Sky == null ? 0.0f : this.LevelManager.Sky.FogDensity; this.DollyZoomOut = false; this.RebuildProjection(); this.SnapInterpolation(); } else { this.FogManager.Density = (this.LevelManager.Sky == null ? 0.0f : this.LevelManager.Sky.FogDensity) * Easing.EaseIn(flag ? 1.0 - (double)amount : (double)amount, EasingType.Quadratic); float num4 = (float)((double)num3 * (flag ? (double)amount : 1.0 - (double)amount) + 0.100000001490116); this.NearPlane = Math.Max(0.1f, 0.1f + num4 - num2); this.FarPlane = Math.Max(num4 + this.NearPlane, 499.9f); this.FieldOfView = num1; this.projection = Matrix.CreatePerspectiveFieldOfView(this.FieldOfView, this.AspectRatio, this.NearPlane, this.FarPlane); this.OnProjectionChanged(); this.current.Radius = num4; this.view = Matrix.CreateLookAt(this.current.Radius * this.current.Direction + this.current.Center, this.current.Center, Vector3.UnitY); this.OnViewChanged(); } } }
private void PauseGroupOverlaps(bool force) { if (!force && this.GameState.Loading || (!FezMath.IsOrthographic(this.CameraManager.Viewpoint) || this.LevelManager.PickupGroups.Count == 0)) { return; } Vector3 b1 = FezMath.ForwardVector(this.CameraManager.Viewpoint); Vector3 b2 = FezMath.SideMask(this.CameraManager.Viewpoint); Vector3 vector3 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint); foreach (TrileGroup trileGroup in Enumerable.Distinct <TrileGroup>((IEnumerable <TrileGroup>) this.LevelManager.PickupGroups.Values)) { float num = float.MaxValue; float?nullable = new float?(); foreach (TrileInstance trileInstance in trileGroup.Triles) { num = Math.Min(num, FezMath.Dot(trileInstance.Center, b1)); if (!trileInstance.PhysicsState.Puppet) { nullable = new float?(FezMath.Dot(trileInstance.Center, b2)); } } foreach (PickupState pickupState1 in this.PickupStates) { if (pickupState1.Group == trileGroup) { TrileInstance trileInstance = pickupState1.Instance; bool flag = !FezMath.AlmostEqual(FezMath.Dot(trileInstance.Center, b1), num); trileInstance.PhysicsState.Paused = flag; if (flag) { trileInstance.PhysicsState.Puppet = true; pickupState1.LastMovement = Vector3.Zero; } else { pickupState1.VisibleOverlapper = (PickupState)null; foreach (PickupState pickupState2 in this.PickupStates) { if (FezMath.AlmostEqual(pickupState2.Instance.Center * vector3, pickupState1.Instance.Center * vector3)) { pickupState2.VisibleOverlapper = pickupState1; } } if (nullable.HasValue && FezMath.AlmostEqual(FezMath.Dot(trileInstance.Center, b2), nullable.Value)) { trileInstance.PhysicsState.Puppet = false; } } } } } }
protected override void DrawLightOccluders() { if (this.PlayerManager.Hidden || this.GameState.InFpsMode) { return; } this.PlayerManager.Mesh.Rotation = FezMath.IsOrthographic(this.CameraManager.Viewpoint) || this.CameraManager.LastViewpoint == Viewpoint.None ? this.CameraManager.Rotation : Quaternion.CreateFromAxisAngle(Vector3.UnitY, FezMath.ToPhi(this.CameraManager.LastViewpoint)); if (this.PlayerManager.LookingDirection == HorizontalDirection.Left) { this.PlayerManager.Mesh.Rotation *= FezMath.QuaternionFromPhi(3.141593f); } this.PlayerManager.Mesh.Draw(); }
private void ScaleStarBackground() { if (this.CameraManager.ProjectionTransition || !FezMath.IsOrthographic(this.CameraManager.Viewpoint)) { return; } Viewport viewport = this.GraphicsDevice.Viewport; float num = (float)((double)viewport.Width / (double)this.CameraManager.Radius / 16.0) * SettingsManager.GetViewScale(this.GraphicsDevice); float m11 = (float)viewport.Width / (float)this.starsTexture.Width / num; float m22 = (float)viewport.Height / (float)this.starsTexture.Height / num; this.textureMatrix = new Matrix(m11, 0.0f, 0.0f, 0.0f, 0.0f, m22, 0.0f, 0.0f, (float)(-(double)m11 / 2.0), (float)(-(double)m22 / 2.0), 1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f); }
public override void Update(GameTime gameTime) { if (this.LevelMaterializer.LevelPlanes.Count == 0 || this.EngineState.Paused || (this.EngineState.InMap || this.EngineState.Loading)) { return; } bool flag = FezMath.IsOrthographic(this.CameraManager.Viewpoint) && this.CameraManager.ActionRunning; bool inEditor = this.EngineState.InEditor; foreach (BackgroundPlane backgroundPlane in this.LevelMaterializer.LevelPlanes) { if (backgroundPlane.Visible || backgroundPlane.ActorType == ActorType.Bomb) { if (flag && backgroundPlane.Animated) { int frame = backgroundPlane.Timing.Frame; backgroundPlane.Timing.Update(gameTime.ElapsedGameTime); if (!backgroundPlane.Loop && frame > backgroundPlane.Timing.Frame) { this.LevelManager.BackgroundPlanes.Remove(backgroundPlane.Id); backgroundPlane.Dispose(); } else { backgroundPlane.MarkDirty(); } } if (backgroundPlane.Billboard) { backgroundPlane.Rotation = this.CameraManager.Rotation * backgroundPlane.OriginalRotation; } if (!inEditor && (double)backgroundPlane.ParallaxFactor != 0.0 && flag) { Viewpoint view = FezMath.AsViewpoint(backgroundPlane.Orientation); if (!backgroundPlane.OriginalPosition.HasValue) { backgroundPlane.OriginalPosition = new Vector3?(backgroundPlane.Position); } float num = (float)((double)(-4 * (this.LevelManager.Descending ? -1 : 1)) / (double)this.CameraManager.PixelsPerTrixel - 15.0 / 32.0 + 1.0); Vector3 vector3 = this.CameraManager.InterpolatedCenter - backgroundPlane.OriginalPosition.Value + num * Vector3.UnitY; backgroundPlane.Position = backgroundPlane.OriginalPosition.Value + vector3 * FezMath.ScreenSpaceMask(view) * backgroundPlane.ParallaxFactor; } else if (!inEditor && (double)backgroundPlane.ParallaxFactor != 0.0 && backgroundPlane.OriginalPosition.HasValue && backgroundPlane.Position != backgroundPlane.OriginalPosition.Value) { backgroundPlane.Position = backgroundPlane.OriginalPosition.Value; } } } }
public void RebuildProjection() { this.AspectRatio = this.GraphicsService.GraphicsDevice.Viewport.AspectRatio; float width = this.interpolated.Radius / SettingsManager.GetViewScale(this.GraphicsService.GraphicsDevice); if (FezMath.IsOrthographic(this.viewpoint)) { this.projection = Matrix.CreateOrthographic(width, width / this.AspectRatio, this.NearPlane, this.FarPlane); } else { this.projection = Matrix.CreatePerspectiveFieldOfView(this.FieldOfView, this.AspectRatio, this.NearPlane, this.FarPlane); } this.OnProjectionChanged(); }
public override void Update(GameTime gameTime) { if (this.PlayerManager.Animation == null) { return; } this.playerMesh.Position = this.PlayerManager.Position + (float)((1.0 - ((double)this.PlayerManager.Size.Y + (this.PlayerManager.CarriedInstance != null || this.PlayerManager.Action == ActionType.ThrowingHeavy ? -2.0 : 0.0))) / 2.0) * Vector3.UnitY; if (this.lastAnimation != this.PlayerManager.Animation) { this.effect.Animation = (Texture)this.PlayerManager.Animation.Texture; this.lastAnimation = this.PlayerManager.Animation; } int width = this.lastAnimation.Texture.Width; int height = this.lastAnimation.Texture.Height; Rectangle rectangle = this.lastAnimation.Offsets[this.lastAnimation.Timing.Frame]; this.playerMesh.FirstGroup.TextureMatrix.Set(new Matrix?(new Matrix((float)rectangle.Width / (float)width, 0.0f, 0.0f, 0.0f, 0.0f, (float)rectangle.Height / (float)height, 0.0f, 0.0f, (float)rectangle.X / (float)width, (float)rectangle.Y / (float)height, 1f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f))); if (this.lastBackground != this.PlayerManager.Background && !ActionTypeExtensions.NoBackgroundDarkening(this.PlayerManager.Action)) { this.sinceBackgroundChanged = TimeSpan.Zero; this.lastBackground = this.PlayerManager.Background; if (!this.LevelManager.LowPass && EndCutscene32Host.Instance == null && EndCutscene64Host.Instance == null) { this.SoundManager.FadeFrequencies(this.PlayerManager.Background); } } if (this.sinceBackgroundChanged.TotalSeconds < 1.0) { this.sinceBackgroundChanged += gameTime.ElapsedGameTime; } this.effect.Background = ActionTypeExtensions.NoBackgroundDarkening(this.PlayerManager.Action) ? 0.0f : FezMath.Saturate(this.PlayerManager.Background ? (float)(this.sinceBackgroundChanged.TotalSeconds * 2.0) : (float)(1.0 - this.sinceBackgroundChanged.TotalSeconds * 2.0)); bool flag1 = (double)this.CollisionManager.GravityFactor < 0.0; Viewpoint view = FezMath.IsOrthographic(this.CameraManager.Viewpoint) || !this.CameraManager.ActionRunning ? this.CameraManager.Viewpoint : this.CameraManager.LastViewpoint; Vector2 vector2 = ActionTypeExtensions.GetOffset(this.PlayerManager.Action) / 16f; vector2.Y -= this.lastAnimation.PotOffset.Y / 64f; this.playerMesh.Scale = new Vector3((float)this.PlayerManager.Animation.FrameWidth / 16f, (float)this.PlayerManager.Animation.FrameHeight / 16f * (float)Math.Sign(this.CollisionManager.GravityFactor), 1f); this.playerMesh.Position += vector2.X * FezMath.RightVector(view) * (float)FezMath.Sign(this.PlayerManager.LookingDirection) + (flag1 ? (float)(-(double)vector2.Y - 1.0 / 16.0) : vector2.Y) * Vector3.UnitY; bool flag2 = this.PlayerManager.HideFez && !this.GameState.SaveData.IsNewGamePlus && !this.PlayerManager.Animation.NoHat && !ActionTypeExtensions.IsCarry(this.PlayerManager.Action); if (this.lastHideFez == flag2) { return; } this.lastHideFez = flag2; this.effect.NoMoreFez = this.lastHideFez; }
public override void Update(GameTime gameTime) { if (!FezMath.IsOrthographic(this.CameraManager.Viewpoint) || this.GameState.InMap || (this.GameState.Paused || this.GameState.Loading) || this.LevelManager.IsInvalidatingScreen) { return; } if (this.LevelManager.Volumes.Count != this.levelVolumes.Length || this.VolumeService.RegisterNeeded) { this.RegisterVolumes(); } if (this.levelVolumes.Length == 0) { return; } this.TestVolumes(false); this.SinceInput += gameTime.ElapsedGameTime; }
private void CullHolesByBounds() { if (!this.Enabled || this.GameState.Loading) { return; } bool flag1 = this.GameState.FarawaySettings.InTransition; bool flag2 = this.CameraManager.ProjectionTransition || !FezMath.IsOrthographic(this.CameraManager.Viewpoint) || this.CameraManager.ProjectionTransitionNewlyReached; foreach (BlackHolesHost.HoleState holeState in this.holes) { holeState.Visible = flag2 || !flag1 && this.CameraManager.Frustum.Contains(holeState.Volume.BoundingBox) != ContainmentType.Disjoint; if (holeState.Emitter != null && !holeState.Emitter.Dead) { holeState.Emitter.FactorizeVolume = holeState.Visible; } } }
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 ChangeApproach() { if (!this.IsActionAllowed(this.PlayerManager.Action) || !FezMath.IsOrthographic(this.CameraManager.Viewpoint) || (this.CameraManager.Viewpoint == this.CameraManager.LastViewpoint || this.PlayerManager.IsOnRotato)) { return; } int num = (int)(this.currentApproach + FezMath.GetDistance(this.CameraManager.Viewpoint, this.CameraManager.LastViewpoint)); if (num > 4) { num -= 4; } if (num < 1) { num += 4; } this.currentApproach = (ClimbingApproach)num; this.RefreshPlayerAction(true); this.shouldSyncAnimationHalfway = true; }
private bool LoopVisible() { if (!FezMath.IsOrthographic(this.CameraManager.Viewpoint)) { return(true); } Vector3 vector3_1 = FezMath.Abs(FezMath.RightVector(this.CameraManager.Viewpoint)); BoundingFrustum frustum = this.CameraManager.Frustum; BoundingBox boundingBox = new BoundingBox() { Min = { X = -frustum.Left.D * frustum.Left.DotNormal(vector3_1), Y = -frustum.Bottom.D * frustum.Bottom.Normal.Y }, Max = { X = -frustum.Right.D * frustum.Right.DotNormal(vector3_1), Y = -frustum.Top.D * frustum.Top.Normal.Y } }; Vector3 vector3_2 = FezMath.Min(boundingBox.Min, boundingBox.Max); Vector3 vector3_3 = FezMath.Max(boundingBox.Min, boundingBox.Max); Rectangle rectangle = new Rectangle() { X = (int)Math.Floor((double)vector3_2.X), Y = (int)Math.Floor((double)vector3_2.Y), Width = (int)Math.Ceiling((double)vector3_3.X - (double)vector3_2.X), Height = (int)Math.Ceiling((double)vector3_3.Y - (double)vector3_2.Y) }; if (rectangle.Y >= 0) { return((double)(rectangle.Y + rectangle.Height) >= (double)this.LevelManager.Size.Y); } else { return(true); } }
public void DoDraw() { if (this.GameState.Loading || this.PlayerManager.Hidden || (this.GameState.InMap || FezMath.AlmostEqual(this.PlayerManager.GomezOpacity, 0.0f))) { return; } if (this.GameState.StereoMode || this.LevelManager.Quantum) { this.PlayerManager.Mesh.Rotation = FezMath.IsOrthographic(this.CameraManager.Viewpoint) || this.CameraManager.LastViewpoint == Viewpoint.None ? this.CameraManager.Rotation : Quaternion.CreateFromAxisAngle(Vector3.UnitY, FezMath.ToPhi(this.CameraManager.LastViewpoint)); if (this.PlayerManager.LookingDirection == HorizontalDirection.Left) { this.PlayerManager.Mesh.Rotation *= FezMath.QuaternionFromPhi(3.141593f); } } this.PlayerManager.Mesh.Material.Opacity = this.PlayerManager.Action == ActionType.Suffering || this.PlayerManager.Action == ActionType.Sinking ? (float)FezMath.Saturate((Math.Sin((double)this.PlayerManager.BlinkSpeed * 6.28318548202515 * 5.0) + 0.5 - (double)this.PlayerManager.BlinkSpeed * 1.25) * 2.0) : this.PlayerManager.GomezOpacity; GraphicsDevice graphicsDevice = this.GraphicsDevice; if (!ActionTypeExtensions.SkipSilhouette(this.PlayerManager.Action)) { GraphicsDeviceExtensions.PrepareStencilRead(graphicsDevice, CompareFunction.Greater, StencilMask.NoSilhouette); this.playerMesh.DepthWrites = false; this.playerMesh.AlwaysOnTop = true; this.effect.Silhouette = true; this.playerMesh.Draw(); } if (!this.PlayerManager.Background) { GraphicsDeviceExtensions.PrepareStencilRead(graphicsDevice, CompareFunction.Equal, StencilMask.Hole); this.playerMesh.AlwaysOnTop = true; this.playerMesh.DepthWrites = false; this.effect.Silhouette = false; this.playerMesh.Draw(); } GraphicsDeviceExtensions.PrepareStencilWrite(graphicsDevice, new StencilMask?(StencilMask.Gomez)); this.playerMesh.AlwaysOnTop = ActionTypeExtensions.NeedsAlwaysOnTop(this.PlayerManager.Action); this.playerMesh.DepthWrites = true; this.effect.Silhouette = false; this.playerMesh.Draw(); GraphicsDeviceExtensions.PrepareStencilWrite(graphicsDevice, new StencilMask?(StencilMask.None)); }
public override void Update(GameTime gameTime) { if (!this.shadowMesh.Enabled || this.EngineState.Paused || (this.EngineState.InMap || this.EngineState.Loading)) { return; } if (this.LevelManager.Sky != null && !this.LevelManager.Sky.FoliageShadows) { float m31 = (float)(-gameTime.ElapsedGameTime.TotalSeconds * 0.00999999977648258 * (double)this.TimeManager.TimeFactor / 360.0) * this.LevelManager.Sky.WindSpeed; foreach (Group index in this.axisPerGroup.Keys) { if (this.axisPerGroup[index] != FezMath.VisibleAxis(this.CameraManager.Viewpoint)) { index.TextureMatrix.Set(new Matrix?(index.TextureMatrix.Value.Value + new Matrix(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, m31, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f))); } } } else { this.SineSpeed = MathHelper.Lerp(this.SineSpeed, RandomHelper.Between(0.0, gameTime.ElapsedGameTime.TotalSeconds), 0.1f); this.SineAccumulator += this.SineSpeed; } foreach (Group index in this.axisPerGroup.Keys) { Vector3 mask = FezMath.GetMask(this.axisPerGroup[index]); index.Material.Opacity = (1f - Math.Abs(FezMath.Dot(this.CameraManager.View.Forward, mask))) * this.LevelManager.Sky.ShadowOpacity; if (!this.LevelManager.Sky.FoliageShadows) { index.Material.Opacity *= (float)this.LevelManager.ActualDiffuse.G / (float)byte.MaxValue; } if (this.CameraManager.ProjectionTransition) { index.Material.Opacity *= FezMath.IsOrthographic(this.CameraManager.Viewpoint) ? this.CameraManager.ViewTransitionStep : 1f - this.CameraManager.ViewTransitionStep; } else if (this.CameraManager.Viewpoint == Viewpoint.Perspective) { index.Material.Opacity = 0.0f; } } }
public override void Initialize() { base.Initialize(); this.LevelManager.LevelChanged += new Action(this.InitializePickups); this.InitializePickups(); this.CameraManager.ViewpointChanged += (Action)(() => { if (this.GameState.Loading || !FezMath.IsOrthographic(this.CameraManager.Viewpoint) || this.CameraManager.LastViewpoint == this.CameraManager.Viewpoint) { return; } this.PauseGroupOverlaps(false); this.LevelManager.ScreenInvalidated += new Action(this.DetectBackground); }); this.CollisionManager.GravityChanged += (Action)(() => { foreach (PickupState item_0 in this.PickupStates) { item_0.Instance.PhysicsState.Ground = new MultipleHits <TrileInstance>(); } }); }
protected void UpdateRotation() { Quaternion rotation = this.CameraManager.Rotation; if (this.oldRotation == rotation && this.oldDirection == this.LookingDirection) { return; } this.oldRotation = rotation; this.oldDirection = this.LookingDirection; int num = -Math.Sign(FezMath.Dot(this.CameraManager.InverseView.Right, FezMath.Sign(this.Npc.DestinationOffset))); if (this.LookingDirection == HorizontalDirection.Left) { num *= -1; } if (num != 0) { rotation *= FezMath.QuaternionFromPhi((float)(3.14159274101257 * ((double)num / 2.0 + 0.5))); } this.Group.Rotation = rotation; if (!FezMath.IsOrthographic(this.CameraManager.Viewpoint)) { return; } this.InBackground = false; Vector3 b = FezMath.ForwardVector(this.CameraManager.Viewpoint); NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.Position, QueryOptions.Simple); TrileInstance trileInstance = nearestTriles.Surface ?? nearestTriles.Deep; if (trileInstance == null) { return; } Vector3 a = trileInstance.Center + trileInstance.TransformedSize / 2f * -b; this.InBackground = (double)FezMath.Dot(this.Position, b) > (double)FezMath.Dot(a, b); }
public override bool ChangeViewpoint(Viewpoint newView, float speedFactor) { if ((double)speedFactor != 0.0 && (newView == this.viewpoint || this.concurrentChanges >= 1) || this.PlayerManager.Action == ActionType.GrabTombstone && !this.PlayerManager.Animation.Timing.Ended) { return(false); } if (!this.ViewTransitionReached && (double)speedFactor != 0.0) { ++this.concurrentChanges; } this.shouldRotateInstance = FezMath.IsOrthographic(newView) && FezMath.IsOrthographic(this.viewpoint); if (newView == Viewpoint.Perspective) { this.predefinedViews[newView].Direction = this.current.Direction; } base.ChangeViewpoint(newView, speedFactor); if (this.PlayerManager.CarriedInstance != null && this.concurrentChanges == 0) { this.originalCarriedPhi = this.PlayerManager.CarriedInstance.Phi; } this.CameraService.OnRotate(); return(true); }
protected override void LoadContent() { this.sound = this.CMProvider.Global.Load <SoundEffect>("Sounds/Gomez/LedgeGrab"); this.CameraManager.ViewpointChanged += (Action)(() => { if (!this.IsActionAllowed(this.PlayerManager.Action) || !FezMath.IsOrthographic(this.CameraManager.Viewpoint) || (this.CameraManager.Viewpoint == this.CameraManager.LastViewpoint || this.PlayerManager.IsOnRotato)) { return; } if (this.rotatedFrom.HasValue && this.rotatedFrom.Value == this.CameraManager.Viewpoint) { this.rotatedFrom = new Viewpoint?(); } else { if (this.rotatedFrom.HasValue) { return; } this.rotatedFrom = new Viewpoint?(this.CameraManager.LastViewpoint); } }); }
public override void Update(GameTime gameTime) { if (this.GameState.Loading || this.GameState.Paused || (this.GameState.InMap || !FezMath.IsOrthographic(this.CameraManager.Viewpoint)) || !this.CameraManager.ActionRunning) { return; } TimeSpan elapsedGameTime = gameTime.ElapsedGameTime; int count = this.ActiveParticleSystems.Count; if (count >= 2) { this.otherThread.Start(new MtUpdateContext <List <TrixelParticleSystem> >() { Elapsed = elapsedGameTime, StartIndex = 0, EndIndex = count / 2, Result = this.OtherDeadParticleSystems }); this.UpdateParticleSystems(new MtUpdateContext <List <TrixelParticleSystem> >() { Elapsed = elapsedGameTime, StartIndex = count / 2, EndIndex = count, Result = this.DeadParticleSystems }); this.otherThread.Join(); } else { this.UpdateParticleSystems(new MtUpdateContext <List <TrixelParticleSystem> >() { Elapsed = elapsedGameTime, StartIndex = 0, EndIndex = count, Result = this.DeadParticleSystems }); } if (this.OtherDeadParticleSystems.Count > 0) { this.DeadParticleSystems.AddRange((IEnumerable <TrixelParticleSystem>) this.OtherDeadParticleSystems); this.OtherDeadParticleSystems.Clear(); } if (this.DeadParticleSystems.Count <= 0) { return; } foreach (TrixelParticleSystem component in this.DeadParticleSystems) { this.ActiveParticleSystems.Remove(component); ServiceHelper.RemoveComponent <TrixelParticleSystem>(component); } this.DeadParticleSystems.Clear(); }
public override void Update(GameTime gameTime) { if (this.GameState.Paused || this.GameState.InMap || (!this.CameraManager.ActionRunning || !FezMath.IsOrthographic(this.CameraManager.Viewpoint)) || (this.GameState.Loading || this.PlayerManager.Action == ActionType.FindingTreasure || this.GameState.FarawaySettings.InTransition)) { return; } TimeSpan timeSpan = TimeSpan.FromTicks(TimeSpan.FromTicks((DateTime.UtcNow - DateTime.FromFileTimeUtc(this.GameState.SaveData.CreationTime)).Ticks).Ticks % 6048000000000L); if (this.RedAo.Enabled) { float angle = FezMath.CurveAngle(this.lastRedAngle, FezMath.WrapAngle((float)((double)FezMath.Round(timeSpan.TotalSeconds) / 60.0 * 6.28318548202515)), 0.1f); this.lastRedAngle = angle; this.RedAo.Rotation = Quaternion.CreateFromAxisAngle(-Vector3.UnitZ, angle) * this.RedOriginalRotation; this.RedAo.Position = this.RedOriginalPosition + new Vector3(-(float)Math.Cos((double)angle), (float)Math.Sin((double)angle), 0.0f) * 1.45f; this.RedSecret = this.TestSecretFor((double)angle >= 1.19579637050629 && (double)angle <= 1.69579637050629, this.RedAo, this.RedSecret, this.RedTopMost); } if (this.BlueAo.Enabled) { float num = FezMath.WrapAngle((float)(timeSpan.TotalMinutes / 60.0 * 6.28318548202515)); this.BlueAo.Rotation = Quaternion.CreateFromAxisAngle(-Vector3.UnitX, num) * this.BlueOriginalRotation; this.BlueAo.Position = this.BlueOriginalPosition + new Vector3(0.0f, (float)Math.Sin((double)num), (float)Math.Cos((double)num)) * 1.45f; this.BlueSecret = this.TestSecretFor(FezMath.AlmostEqual(num, 1.570796f, 0.125f), this.BlueAo, this.BlueSecret, this.BlueTopMost); } if (this.GreenAo.Enabled) { float num = FezMath.WrapAngle((float)(timeSpan.TotalHours / 24.0 * 6.28318548202515)); this.GreenAo.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, num) * this.GreenOriginalRotation; this.GreenAo.Position = this.GreenOriginalPosition + new Vector3((float)Math.Cos((double)num), (float)Math.Sin((double)num), 0.0f) * 1.45f; this.GreenSecret = this.TestSecretFor(FezMath.AlmostEqual(num, 1.570796f, 0.125f), this.GreenAo, this.GreenSecret, this.GreenTopMost); } if (!this.WhiteAo.Enabled) { return; } float num1 = FezMath.WrapAngle((float)(timeSpan.TotalDays / 7.0 * 6.28318548202515)); this.WhiteAo.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, num1) * this.WhiteOriginalRotation; this.WhiteAo.Position = this.WhiteOriginalPosition + new Vector3(0.0f, (float)Math.Sin((double)num1), -(float)Math.Cos((double)num1)) * 1.45f; this.WhiteSecret = this.TestSecretFor(FezMath.AlmostEqual(num1, 1.570796f, 0.125f), this.WhiteAo, this.WhiteSecret, this.WhiteTopMost); }