private void InitializeShadows() { if (this.LevelManager.Name == null || this.LevelManager.Sky == null || this.LevelManager.Sky.Shadows == null) { this.shadowMesh.Texture.Set((Texture)null); this.shadowMesh.Enabled = false; } else { this.shadowMesh.Enabled = true; this.shadowMesh.Texture = (Dirtyable <Texture>)((Texture)this.CMProvider.CurrentLevel.Load <Texture2D>("Skies/" + this.LevelManager.Sky.Name + "/" + this.LevelManager.Sky.Shadows)); this.shadowMesh.Scale = this.LevelManager.Size + new Vector3(65f, 65f, 65f); this.shadowMesh.Position = this.LevelManager.Size / 2f; int num1 = 0; foreach (Group index in this.axisPerGroup.Keys) { index.Material = new Material(); Axis axis = this.axisPerGroup[index]; float m11 = FezMath.Dot(this.shadowMesh.Scale, FezMath.GetMask(axis)) / 32f; float num2 = this.shadowMesh.Scale.Y / FezMath.Dot(this.shadowMesh.Scale, FezMath.GetMask(axis)); index.TextureMatrix = (Dirtyable <Matrix?>) new Matrix?(new Matrix(m11, 0.0f, 0.0f, 0.0f, 0.0f, m11 * num2, 0.0f, 0.0f, (float)num1 / 2f, 0.0f, 1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f)); ++num1; } this.SineAccumulator = 0.0f; } }
public void ClampToGround(IPhysicsEntity entity, Vector3?distance, Viewpoint viewpoint) { if (!distance.HasValue) { return; } Vector3 mask = FezMath.GetMask(FezMath.VisibleAxis(viewpoint)); entity.Center = distance.Value * mask + (Vector3.One - mask) * entity.Center; }
public CollisionType GetRotatedFace(FaceOrientation face) { FaceOrientation index = FezMath.OrientationFromPhi(FezMath.ToPhi(face) - this.Phi); CollisionType collisionType = this.Trile.Faces[index]; if (collisionType == CollisionType.TopOnly) { TrileEmplacement emplacement = this.Emplacement; ++emplacement.Y; Vector3 mask = FezMath.GetMask(FezMath.AsAxis(face)); TrileInstance trileInstance; if (TrileInstance.LevelManager.Triles.TryGetValue(emplacement, out trileInstance) && trileInstance.Enabled && !trileInstance.IsMovingGroup && (trileInstance.Trile.Geometry == null || !trileInstance.Trile.Geometry.Empty || trileInstance.Trile.Faces[index] != CollisionType.None) && (!trileInstance.Trile.Immaterial && trileInstance.Trile.Faces[index] != CollisionType.Immaterial && (!trileInstance.Trile.Thin && !ActorTypeExtensions.IsPickable(trileInstance.Trile.ActorSettings.Type)) && (((double)trileInstance.Trile.Size.Y == 1.0 || trileInstance.ForceTopMaybe) && FezMath.AlmostEqual(FezMath.Dot(trileInstance.Center, mask), FezMath.Dot(this.Center, mask))))) { collisionType = CollisionType.None; } } return(collisionType); }
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; } } }
protected override void TryTalk() { switch (this.PlayerManager.Action) { case ActionType.Idle: case ActionType.Walking: case ActionType.Running: case ActionType.Sliding: if (this.PlayerManager.Background || !this.SpeechManager.Hidden || this.Npc.ActorType == ActorType.Owl && (this.OwlInvisible || this.CurrentAction == NpcAction.TakeOff || this.CurrentAction == NpcAction.Fly)) { break; } if (this.Npc.CustomSpeechLine == null) { if (this.InputManager.CancelTalk != FezButtonState.Pressed) { break; } Vector3 vector3_1 = Vector3.UnitY + (FezMath.SideMask(this.CameraManager.Viewpoint) + FezMath.DepthMask(this.CameraManager.Viewpoint)) * 1.5f; BoundingBox boundingBox = new BoundingBox(this.Position - vector3_1, this.Position + vector3_1); Vector3 mask = FezMath.GetMask(FezMath.VisibleAxis(this.CameraManager.Viewpoint)); Vector3 vector3_2 = FezMath.ForwardVector(this.CameraManager.Viewpoint); Ray ray = new Ray() { Position = this.PlayerManager.Center * (Vector3.One - mask) - vector3_2 * this.LevelManager.Size, Direction = vector3_2 }; float?nullable = boundingBox.Intersects(ray); if (!nullable.HasValue || this.TestObstruction(ray.Position, nullable.Value)) { break; } } this.Talk(); break; } }
protected override void Begin() { if (this.PlayerManager.CarriedInstance == null && this.PlayerManager.PushedInstance == null) { this.PlayerManager.Action = ActionType.Idle; } else { Vector3 vector = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection); Vector3 mask = FezMath.GetMask(FezMath.VisibleAxis(this.CameraManager.Viewpoint)); Vector3 vector3_1 = FezMath.Abs(vector); if (this.PlayerManager.PushedInstance != null) { this.PlayerManager.CarriedInstance = this.PlayerManager.PushedInstance; this.PlayerManager.PushedInstance = (TrileInstance)null; } TrileInstance carriedInstance = this.PlayerManager.CarriedInstance; TrileInstance first = this.PlayerManager.Ground.First; Vector3 vector3_2 = carriedInstance.Center * vector3_1 + this.PlayerManager.Position * mask + (first.Center.Y + (float)((double)first.Trile.Size.Y / 2.0 + (double)carriedInstance.Trile.Size.Y / 2.0) * (float)Math.Sign(this.CollisionManager.GravityFactor)) * Vector3.UnitY; this.PlayerManager.CarriedInstance.PhysicsState.Center = vector3_2; this.PlayerManager.CarriedInstance.PhysicsState.UpdateInstance(); this.PlayerManager.Position = this.PlayerManager.Position * (Vector3.One - vector3_1) + vector3_2 * vector3_1 + -carriedInstance.TransformedSize / 2f * vector + -3.0 / 16.0 * vector; if (ActorTypeExtensions.IsHeavy(this.PlayerManager.CarriedInstance.Trile.ActorSettings.Type)) { SoundEffectExtensions.EmitAt(this.liftHeavySound, this.PlayerManager.Position); } else { SoundEffectExtensions.EmitAt(this.liftLightSound, this.PlayerManager.Position); } this.GomezService.OnLiftObject(); IPlayerManager playerManager = this.PlayerManager; Vector3 vector3_3 = playerManager.Velocity * Vector3.UnitY; playerManager.Velocity = vector3_3; } }
private void TestVolumes(bool force) { if (!force && this.GameState.Loading) { return; } if (!force && this.deferredScripts) { foreach (Volume volume in this.PlayerManager.CurrentVolumes) { this.VolumeService.OnEnter(volume.Id); } this.HeightCheck(); this.deferredScripts = false; } else { SoundService.ImmediateEffect = false; } if (force) { this.deferredScripts = true; } Vector3 mask = FezMath.GetMask(FezMath.VisibleAxis(this.CameraManager.Viewpoint)); Vector3 vector3 = FezMath.ForwardVector(this.CameraManager.Viewpoint); if (this.PlayerManager.Background) { vector3 *= -1f; } Ray ray = new Ray() { Position = this.PlayerManager.Center * (Vector3.One - mask) - vector3 * this.LevelManager.Size, Direction = vector3 }; if (this.PlayerManager.Action == ActionType.PullUpBack || this.PlayerManager.Action == ActionType.PullUpFront || this.PlayerManager.Action == ActionType.PullUpCornerLedge) { ray.Position += new Vector3(0.0f, 0.5f, 0.0f); } foreach (Volume volume in this.levelVolumes) { if (volume.Enabled) { if (!this.GameState.FarawaySettings.InTransition) { bool flag = (double)this.CameraManager.Center.Y > ((double)volume.From.Y + (double)volume.To.Y) / 2.0; if (!volume.PlayerIsHigher.HasValue || flag != volume.PlayerIsHigher.Value) { if (flag) { this.VolumeService.OnGoHigher(volume.Id); } else { this.VolumeService.OnGoLower(volume.Id); } volume.PlayerIsHigher = new bool?(flag); } } if (this.checkForContainment && (volume.Id == 1 || volume.Id == 2)) { if (volume.BoundingBox.Contains(this.PlayerManager.Position) != ContainmentType.Disjoint) { this.PlayerIsInside(volume, force); } } else { float?nullable = volume.BoundingBox.Intersects(ray); if (volume.ActorSettings != null && volume.ActorSettings.IsBlackHole) { if (!nullable.HasValue) { nullable = volume.BoundingBox.Intersects(new Ray(ray.Position + new Vector3(0.0f, 0.3f, 0.0f), ray.Direction)); } if (!nullable.HasValue) { nullable = volume.BoundingBox.Intersects(new Ray(ray.Position - new Vector3(0.0f, 0.3f, 0.0f), ray.Direction)); } } if (nullable.HasValue) { bool flag = false; bool isBlackHole = volume.ActorSettings != null && volume.ActorSettings.IsBlackHole; if (this.PlayerManager.CarriedInstance != null) { this.PlayerManager.CarriedInstance.PhysicsState.UpdatingPhysics = true; } NearestTriles nearestTriles = this.LevelManager.NearestTrile(ray.Position, this.PlayerManager.Background ? QueryOptions.Background : QueryOptions.None); if (this.LevelManager.Name != "PIVOT_TWO" && nearestTriles.Surface != null) { flag = flag | this.TestObstruction(nearestTriles.Surface, nullable.Value, ray.Position, isBlackHole); } if (nearestTriles.Deep != null) { flag = flag | this.TestObstruction(nearestTriles.Deep, nullable.Value, ray.Position, isBlackHole); } if (this.PlayerManager.CarriedInstance != null) { this.PlayerManager.CarriedInstance.PhysicsState.UpdatingPhysics = false; } if (!flag && (volume.ActorSettings != null && volume.ActorSettings.IsBlackHole || volume.Orientations.Contains(this.CameraManager.VisibleOrientation))) { this.PlayerIsInside(volume, force); } } } } } for (int index = this.PlayerManager.CurrentVolumes.Count - 1; index >= 0; --index) { Volume volume = this.PlayerManager.CurrentVolumes[index]; if (!volume.PlayerInside) { if (!force) { this.VolumeService.OnExit(volume.Id); } this.PlayerManager.CurrentVolumes.RemoveAt(index); } volume.PlayerInside = false; } if (this.PlayerManager.CurrentVolumes.Count <= 0) { return; } if (this.PlayerManager.Action == ActionType.LesserWarp || this.PlayerManager.Action == ActionType.GateWarp) { this.Input.Clear(); } if (!this.GrabInput()) { return; } foreach (Volume volume in this.PlayerManager.CurrentVolumes) { if (volume.ActorSettings != null && volume.ActorSettings.CodePattern != null && volume.ActorSettings.CodePattern.Length > 0) { this.TestCodePattern(volume); } } }
public override void Update(GameTime gameTime) { if (this.CameraManager.Viewpoint == Viewpoint.Perspective || this.GameState.InMap || (this.GameState.Paused || this.GameState.Loading) || this.watchers.Count == 0) { return; } Vector3 vector3_1 = FezMath.RightVector(this.CameraManager.Viewpoint); Vector3 vector3_2 = FezMath.Abs(vector3_1); Vector3 vector3_3 = FezMath.ForwardVector(this.CameraManager.Viewpoint); foreach (TrileInstance index in this.watchers.Keys) { WatchersHost.WatcherState watcherState = this.watchers[index]; Vector3 vector3_4 = index.PhysicsState.Center + vector3_2 * -5f / 16f + Vector3.UnitY * -2f / 16f - 0.5f * vector3_3; watcherState.Eyes.Groups[0].Position = vector3_4 + watcherState.EyeOffset; watcherState.Eyes.Groups[1].Position = vector3_4 + vector3_2 * 9f / 16f + watcherState.EyeOffset; watcherState.Eyes.Groups[0].Enabled = true; watcherState.Eyes.Groups[1].Enabled = true; } if (!this.CameraManager.ActionRunning || !this.CameraManager.ViewTransitionReached) { return; } Vector3 center1 = this.PlayerManager.Center; BoundingBox box = FezMath.Enclose(center1 - this.PlayerManager.Size / 2f, center1 + this.PlayerManager.Size / 2f); Vector3 vector3_5 = vector3_1 * 8f; Vector3 vector3_6 = vector3_3 * this.LevelManager.Size; Vector3 vector3_7 = Vector3.Up * 8f; this.lastCrushDirections.Clear(); bool flag1 = false; foreach (TrileInstance index in this.watchers.Keys) { WatchersHost.WatcherState watcherState1 = this.watchers[index]; Vector3 vector1 = FezMath.Sign(center1 - index.Position) * vector3_2; Vector3 vector3_4 = FezMath.Sign(center1 - index.Position) * Vector3.UnitY; BoundingBox boundingBox1 = (double)Vector3.Dot(vector1, vector3_1) > 0.0 ? FezMath.Enclose(index.Position + Vector3.UnitY * 0.05f - vector3_6, index.Position + vector3_5 + vector3_6 + new Vector3(0.9f)) : FezMath.Enclose(index.Position + Vector3.UnitY * 0.05f - vector3_6 - vector3_5, index.Position + vector3_6 + new Vector3(0.9f)); BoundingBox boundingBox2 = FezMath.Enclose(index.Position + Vector3.UnitY * 0.05f - vector3_7 - vector3_6, index.Position + vector3_7 + new Vector3(0.9f) + vector3_6); switch (watcherState1.Action) { case WatchersHost.WatcherAction.Idle: bool flag2 = boundingBox1.Intersects(box); bool flag3 = boundingBox2.Intersects(box); watcherState1.EyeOffset = !flag2 ? (!flag3 ? Vector3.Lerp(watcherState1.EyeOffset, Vector3.Zero, 0.1f) : Vector3.Lerp(watcherState1.EyeOffset, vector3_4 * 1f / 16f, 0.25f)) : Vector3.Lerp(watcherState1.EyeOffset, vector1 * 1f / 16f, 0.25f); watcherState1.CrushDirection = flag2 ? vector1 : (flag3 ? vector3_4 : Vector3.Zero); watcherState1.Eyes.Material.Opacity = 1f; WatchersHost.WatcherState watcherState2; if (this.LevelManager.NearestTrile(index.Position + new Vector3(0.5f)).Deep == index && (flag2 || flag3) && (!FezMath.In <ActionType>(this.PlayerManager.Action, ActionType.GrabCornerLedge, ActionType.Suffering, ActionType.Dying, (IEqualityComparer <ActionType>)ActionTypeComparer.Default) && (watcherState2 = this.HasPair(index)) != null)) { watcherState1.Action = WatchersHost.WatcherAction.Spotted; watcherState2.StartTime = watcherState1.StartTime = gameTime.TotalGameTime; if (!watcherState1.SkipNextSound) { SoundEffectExtensions.EmitAt(this.seeSound, index.Center); watcherState2.SkipNextSound = true; break; } else { break; } } else { break; } case WatchersHost.WatcherAction.Spotted: watcherState1.EyeOffset = Vector3.Lerp(watcherState1.EyeOffset, watcherState1.CrushDirection * 1f / 16f, 0.25f); if ((gameTime.TotalGameTime - watcherState1.StartTime).TotalSeconds > 1.0) { watcherState1.Action = WatchersHost.WatcherAction.Crushing; watcherState1.StartTime = gameTime.TotalGameTime; index.PhysicsState.Velocity = watcherState1.OriginalCenter - index.Center; this.PhysicsManager.Update((ISimplePhysicsEntity)index.PhysicsState, true, false); index.PhysicsState.UpdateInstance(); this.LevelManager.UpdateInstance(index); watcherState1.MoveEmitter = watcherState1.SkipNextSound ? (SoundEmitter)null : SoundEffectExtensions.EmitAt(this.moveSound, index.Center); break; } else { Vector3 vector3_8 = watcherState1.CrushDirection * RandomHelper.Unit() * 0.5f / 16f; index.PhysicsState.Sticky = true; index.PhysicsState.Velocity = watcherState1.OriginalCenter + vector3_8 - index.Center; this.PhysicsManager.Update((ISimplePhysicsEntity)index.PhysicsState, true, false); index.PhysicsState.UpdateInstance(); this.LevelManager.UpdateInstance(index); break; } case WatchersHost.WatcherAction.Crushing: if (index.PhysicsState.Sticky) { index.PhysicsState.Sticky = false; index.PhysicsState.Velocity = Vector3.Zero; } watcherState1.EyeOffset = watcherState1.CrushDirection * 1f / 16f; Vector3 vector3_9 = watcherState1.CrushDirection * (float)gameTime.ElapsedGameTime.TotalSeconds * 15f; Vector3 vector3_10 = Vector3.Lerp(index.PhysicsState.Velocity, vector3_9, 0.025f); index.PhysicsState.Velocity = vector3_10 * watcherState1.CrashAttenuation; if (FezMath.VisibleAxis(this.CameraManager.Viewpoint) != FezMath.AsAxis(FezMath.OrientationFromDirection(watcherState1.CrushDirection))) { this.PhysicsManager.Update((ISimplePhysicsEntity)index.PhysicsState, false, false); } Vector3 vector3_11 = vector3_10 * watcherState1.CrashAttenuation - index.PhysicsState.Velocity; if (watcherState1.MoveEmitter != null) { watcherState1.MoveEmitter.Position = index.Center; } index.PhysicsState.UpdateInstance(); this.LevelManager.UpdateInstance(index); this.PlayerManager.ForceOverlapsDetermination(); bool flag4 = this.PlayerManager.HeldInstance == index || this.PlayerManager.WallCollision.FarHigh.Destination == index || (this.PlayerManager.WallCollision.NearLow.Destination == index || this.PlayerManager.Ground.NearLow == index) || this.PlayerManager.Ground.FarHigh == index; if (!flag4) { foreach (PointCollision pointCollision in this.PlayerManager.CornerCollision) { if (pointCollision.Instances.Deep == index) { flag4 = true; break; } } } if (flag1 && flag4 && this.lastCrushDirections.Contains(-watcherState1.CrushDirection)) { this.PlayerManager.Position = index.Center + Vector3.One / 2f * watcherState1.CrushDirection + -FezMath.SideMask(this.CameraManager.Viewpoint) * FezMath.Abs(watcherState1.CrushDirection) * 1.5f / 16f; this.PlayerManager.Velocity = Vector3.Zero; this.PlayerManager.Action = (double)watcherState1.CrushDirection.Y == 0.0 ? ActionType.CrushHorizontal : ActionType.CrushVertical; watcherState1.CrashAttenuation = this.PlayerManager.Action == ActionType.CrushVertical ? 0.5f : 0.75f; } flag1 = flag1 | flag4; if (flag4 && this.PlayerManager.Action != ActionType.CrushHorizontal && this.PlayerManager.Action != ActionType.CrushVertical) { this.lastCrushDirections.Add(watcherState1.CrushDirection); if ((double)watcherState1.CrushDirection.Y == 0.0) { this.PlayerManager.Position += index.PhysicsState.Velocity; } } if ((double)vector3_11.LengthSquared() > 4.99999987368938E-05 || (double)Math.Abs(Vector3.Dot(index.Center - watcherState1.OriginalCenter, FezMath.Abs(watcherState1.CrushDirection))) >= 8.0) { if (watcherState1.MoveEmitter != null && !watcherState1.MoveEmitter.Dead) { watcherState1.MoveEmitter.Cue.Stop(false); } watcherState1.MoveEmitter = (SoundEmitter)null; if (!watcherState1.SkipNextSound) { SoundEffectExtensions.EmitAt(this.collideSound, index.Center); } watcherState1.Action = WatchersHost.WatcherAction.Wait; index.PhysicsState.Velocity = Vector3.Zero; watcherState1.StartTime = TimeSpan.Zero; watcherState1.CrashAttenuation = 1f; break; } else { break; } case WatchersHost.WatcherAction.Wait: watcherState1.StartTime += gameTime.ElapsedGameTime; if (watcherState1.StartTime.TotalSeconds > 1.5) { watcherState1.Action = WatchersHost.WatcherAction.Withdrawing; watcherState1.StartTime = gameTime.TotalGameTime; watcherState1.WithdrawEmitter = watcherState1.SkipNextSound ? (SoundEmitter)null : SoundEffectExtensions.EmitAt(this.withdrawSound, index.Center, true); break; } else { break; } case WatchersHost.WatcherAction.Withdrawing: watcherState1.EyeOffset = Vector3.Lerp(watcherState1.EyeOffset, -watcherState1.CrushDirection * 0.5f / 16f, 0.05f); Vector3 vector3_12 = -watcherState1.CrushDirection * (float)gameTime.ElapsedGameTime.TotalSeconds * 2f; index.PhysicsState.Velocity = Vector3.Lerp(index.PhysicsState.Velocity, vector3_12, 0.025f); if (watcherState1.WithdrawEmitter != null) { watcherState1.WithdrawEmitter.VolumeFactor = 0.0f; } bool flag5 = false; if (FezMath.DepthMask(this.CameraManager.Viewpoint) == FezMath.GetMask(FezMath.AsAxis(FezMath.OrientationFromDirection(watcherState1.CrushDirection)))) { flag5 = true; } if (watcherState1.WithdrawEmitter != null) { watcherState1.WithdrawEmitter.VolumeFactor = 1f; } Vector3 center2 = index.PhysicsState.Center; Vector3 velocity = index.PhysicsState.Velocity; this.PhysicsManager.Update((ISimplePhysicsEntity)index.PhysicsState, true, false); index.PhysicsState.Center = center2 + velocity; if (watcherState1.WithdrawEmitter != null) { watcherState1.WithdrawEmitter.Position = index.Center; } if (flag5 ? (double)Math.Abs(Vector3.Dot(index.Center - watcherState1.OriginalCenter, vector3_1 + Vector3.Up)) <= 1.0 / 32.0 : (double)Vector3.Dot(index.Center - watcherState1.OriginalCenter, watcherState1.CrushDirection) <= 1.0 / 1000.0) { if (watcherState1.WithdrawEmitter != null) { watcherState1.WithdrawEmitter.FadeOutAndDie(0.1f); watcherState1.WithdrawEmitter = (SoundEmitter)null; } watcherState1.SkipNextSound = false; watcherState1.Action = WatchersHost.WatcherAction.Cooldown; watcherState1.CrushDirection = Vector3.Zero; watcherState1.StartTime = TimeSpan.Zero; } index.PhysicsState.UpdateInstance(); this.LevelManager.UpdateInstance(index); break; case WatchersHost.WatcherAction.Cooldown: index.PhysicsState.Velocity = watcherState1.OriginalCenter - index.Center; this.PhysicsManager.Update((ISimplePhysicsEntity)index.PhysicsState, true, false); index.PhysicsState.UpdateInstance(); this.LevelManager.UpdateInstance(index); watcherState1.EyeOffset = Vector3.Lerp(watcherState1.EyeOffset, Vector3.Zero, 0.05f); watcherState1.Eyes.Material.Opacity = 0.5f; watcherState1.StartTime += gameTime.ElapsedGameTime; if (watcherState1.StartTime.TotalSeconds > 0.5) { index.PhysicsState.Velocity = Vector3.Zero; watcherState1.Action = WatchersHost.WatcherAction.Idle; break; } else { break; } } Vector3 vector3_13 = index.PhysicsState.Center + vector3_2 * -5f / 16f + Vector3.UnitY * -2f / 16f - 0.5f * vector3_3; watcherState1.Eyes.Groups[0].Position = vector3_13 + watcherState1.EyeOffset; watcherState1.Eyes.Groups[1].Position = vector3_13 + vector3_2 * 9f / 16f + watcherState1.EyeOffset; watcherState1.Eyes.Groups[2].Position = watcherState1.Eyes.Groups[0].Position; watcherState1.Eyes.Groups[3].Position = watcherState1.Eyes.Groups[1].Position; watcherState1.Eyes.Groups[0].Enabled = false; watcherState1.Eyes.Groups[1].Enabled = false; } }
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; }))); } } }