示例#1
0
 public void FadeOutAndPause(float forSeconds)
 {
     if ((double)forSeconds == 0.0)
     {
         if (this.Cue == null || this.Cue.IsDisposed || this.Cue.State == SoundState.Paused)
         {
             return;
         }
         this.Cue.Pause();
     }
     else
     {
         if (this.Dead || this.fadePauseWaiter != null)
         {
             return;
         }
         float volumeFactor = this.VolumeFactor * this.VolumeLevel * this.VolumeMaster;
         this.fadePauseWaiter = Waiters.Interpolate((double)forSeconds, (Action <float>)(s => this.VolumeFactor = volumeFactor * (1f - s)), (Action)(() =>
         {
             if (this.Cue != null && !this.Cue.IsDisposed && this.Cue.State != SoundState.Paused)
             {
                 this.Cue.Pause();
             }
             this.fadePauseWaiter = (IWaiter)null;
         }));
         this.fadePauseWaiter.AutoPause = true;
     }
 }
示例#2
0
        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);
        }
示例#3
0
            public void MoveToHeight()
            {
                if (this.MovingToHeight)
                {
                    return;
                }
                this.MovingToHeight = true;
                float y = this.ArtObject.ActorSettings.ShouldMoveToHeight.Value;

                this.ArtObject.ActorSettings.ShouldMoveToHeight = new float?();
                Vector3 vector3     = this.ArtObject.Position + this.CenterOffset;
                Vector3 movement    = (new Vector3(0.0f, y, 0.0f) - vector3) * Vector3.UnitY + Vector3.UnitY / 2f;
                Vector3 origin      = vector3;
                Vector3 destination = vector3 + movement;
                float   lastHeight  = origin.Y;

                if (this.PlayerManager.Action == ActionType.PivotTombstone || this.PlayerManager.Grounded && this.AttachedGroup.Triles.Contains(this.PlayerManager.Ground.First))
                {
                    this.MovingToHeight = false;
                }
                else if ((double)Math.Abs(movement.Y) < 1.0)
                {
                    this.MovingToHeight = false;
                }
                else
                {
                    IWaiter waiter = Waiters.Interpolate((double)Math.Abs(movement.Y / 2f), (Action <float>)(step =>
                    {
                        float local_0           = Easing.EaseInOut((double)step, EasingType.Sine);
                        this.ArtObject.Position = Vector3.Lerp(origin, destination, local_0);
                        this.ArtObject.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, local_0 * 1.570796f * (float)(int)Math.Round((double)movement.Y / 2.0));
                        foreach (TrileInstance item_0 in this.AttachedGroup.Triles)
                        {
                            item_0.Position += Vector3.UnitY * (this.ArtObject.Position.Y - lastHeight);
                            item_0.PhysicsState.Velocity = Vector3.UnitY * (this.ArtObject.Position.Y - lastHeight);
                            this.LevelManager.UpdateInstance(item_0);
                        }
                        lastHeight = this.ArtObject.Position.Y;
                    }), (Action)(() =>
                    {
                        this.ArtObject.Position = destination;
                        this.ArtObject.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, 1.570796f * (float)(int)Math.Round((double)movement.Y / 2.0));
                        foreach (TrileInstance item_1 in this.AttachedGroup.Triles)
                        {
                            item_1.PhysicsState.Velocity = Vector3.Zero;
                        }
                        this.MovingToHeight = false;
                    }));
                    waiter.AutoPause   = true;
                    waiter.UpdateOrder = -2;
                }
            }
示例#4
0
 private void KillDrone()
 {
     Waiters.Interpolate(1.0, (Action <float>)(s => this.iDrone.Volume = FezMath.Saturate(1f - s)), (Action)(() =>
     {
         this.iDrone.Stop(false);
         this.iDrone.Dispose();
         this.iDrone = (SoundEffectInstance)null;
     }));
     foreach (SoundEmitter soundEmitter in this.SoundManager.Emitters)
     {
         soundEmitter.VolumeMaster = 1f;
     }
     this.SoundManager.MusicVolumeFactor = 1f;
 }
示例#5
0
        public override void Update(GameTime gameTime)
        {
            if (this.GameState.Loading || this.GameState.Paused)
            {
                return;
            }
            float num = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if ((double)num == 0.0)
            {
                this.Reset();
            }
            this.StepTime += num;
            switch (this.ActiveState)
            {
            case WhiteNoise.State.Wait:
                this.VignetteEffect.SinceStarted = 0.0f;
                if ((double)this.StepTime <= 3.0)
                {
                    break;
                }
                SoundEffectExtensions.Emit(this.sTvOff);
                if (this.eNoise != null)
                {
                    this.eNoise.FadeOutAndDie(0.15f);
                }
                this.ChangeState();
                break;

            case WhiteNoise.State.TVOff:
                this.VignetteEffect.SinceStarted = this.StepTime;
                if ((double)this.StepTime <= 6.5)
                {
                    break;
                }
                this.ChangeState();
                this.GameState.SkyOpacity = 1f;
                break;

            case WhiteNoise.State.ToCredits:
                this.eNoise = (SoundEmitter)null;
                this.Host.Cycle();
                Waiters.Interpolate(1.0, (Action <float>)(s => PauseMenu.Starfield.Opacity = s));
                PauseMenu.Starfield.Opacity = 0.0f;
                this.GameState.Pause(true);
                break;
            }
        }
示例#6
0
        public void SlowFocusOn(int id, float duration, float trixPerPix)
        {
            Volume  volume = this.LevelManager.Volumes[id];
            Vector3 center = (volume.From + volume.To) / 2f;

            this.CameraManager.Constrained = true;
            Vector3 c          = this.CameraManager.Center;
            float   currentTpP = this.CameraManager.PixelsPerTrixel;

            Waiters.Interpolate((double)duration, (Action <float>)(s =>
            {
                float local_0 = Easing.EaseInOut((double)s, EasingType.Sine);
                this.CameraManager.PixelsPerTrixel = MathHelper.Lerp(currentTpP, trixPerPix, local_0);
                this.CameraManager.Center          = Vector3.Lerp(c, center - new Vector3(0.0f, 1f, 0.0f), local_0);
            })).AutoPause = true;
        }
示例#7
0
        public void FadeVolume(float fromVolume, float toVolume, float overSeconds)
        {
            IWaiter thisWaiter = (IWaiter)null;

            this.volTransitionWaiter = thisWaiter = Waiters.Interpolate((double)overSeconds, (Action <float>)(step =>
            {
                if (this.volTransitionWaiter != thisWaiter || this.EngineState.DotLoading)
                {
                    return;
                }
                this.MusicVolumeFactor = MathHelper.Lerp(fromVolume, toVolume, step);
            }), (Action)(() =>
            {
                if (this.volTransitionWaiter != thisWaiter)
                {
                    return;
                }
                if (!this.EngineState.DotLoading)
                {
                    this.MusicVolumeFactor = toVolume;
                }
                this.volTransitionWaiter = (IWaiter)null;
            }));
        }
示例#8
0
        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.TrackedSuckBlocks.Count == 0))
            {
                return;
            }
            FaceOrientation visibleOrientation = this.CameraManager.VisibleOrientation;
            Vector3         vector3_1          = FezMath.ForwardVector(this.CameraManager.Viewpoint);
            Vector3         vector3_2          = FezMath.DepthMask(this.CameraManager.Viewpoint);
            Vector3         vector3_3          = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);
            Vector3         vector3_4          = vector3_3 / 2f;
            bool            flag1 = false;

            foreach (SuckBlocksHost.SuckBlockState suckBlockState in this.TrackedSuckBlocks)
            {
                TrileInstance instance = suckBlockState.Instance;
                if (this.PlayerManager.HeldInstance != instance)
                {
                    int     num1      = instance.ActorSettings.HostVolume.Value;
                    Vector3 vector3_5 = instance.Center * (Vector3.One - vector3_2) + this.CameraManager.Position * vector3_2;
                    this.cornerRays[0] = new Ray()
                    {
                        Position  = vector3_5 + vector3_4 * new Vector3(1f, 0.499f, 1f),
                        Direction = vector3_1
                    };
                    this.cornerRays[1] = new Ray()
                    {
                        Position  = vector3_5 + vector3_4 * new Vector3(1f, -1f, 1f),
                        Direction = vector3_1
                    };
                    this.cornerRays[2] = new Ray()
                    {
                        Position  = vector3_5 + vector3_4 * new Vector3(-1f, 0.499f, -1f),
                        Direction = vector3_1
                    };
                    this.cornerRays[3] = new Ray()
                    {
                        Position  = vector3_5 + vector3_4 * new Vector3(-1f, -1f, -1f),
                        Direction = vector3_1
                    };
                    suckBlockState.Update(gameTime.ElapsedGameTime);
                    this.eCratePush.Position = instance.Center;
                    bool flag2 = false;
                    foreach (Volume volume in this.HostingVolumes)
                    {
                        if (volume.Orientations.Contains(visibleOrientation))
                        {
                            bool flag3 = false;
                            foreach (Ray ray in this.cornerRays)
                            {
                                flag3 = flag3 | volume.BoundingBox.Intersects(ray).HasValue;
                            }
                            if (flag3)
                            {
                                flag2 = true;
                                if (suckBlockState.Action == SuckBlocksHost.SuckBlockAction.Sucking && (this.eSuck == null || this.eSuck.Dead))
                                {
                                    this.eSuck = SoundEffectExtensions.EmitAt(this.sSuck, instance.Center, true);
                                }
                                flag1 = ((flag1 ? 1 : 0) | (suckBlockState.Action == SuckBlocksHost.SuckBlockAction.Sucking ? 1 : (suckBlockState.Action == SuckBlocksHost.SuckBlockAction.Processing ? 1 : 0))) != 0;
                                Vector3 vector3_6 = (volume.BoundingBox.Min + volume.BoundingBox.Max) / 2f;
                                Vector3 vector3_7 = (vector3_6 - instance.Center) * vector3_3;
                                float   num2      = vector3_7.Length();
                                if ((double)num2 < 0.00999999977648258)
                                {
                                    if (suckBlockState.Action == SuckBlocksHost.SuckBlockAction.Sucking)
                                    {
                                        suckBlockState.Action        = SuckBlocksHost.SuckBlockAction.Processing;
                                        this.PlayerManager.CanRotate = false;
                                        this.eCratePush.VolumeFactor = 0.5f;
                                        this.eCratePush.Cue.Pitch    = -0.4f;
                                    }
                                    if (suckBlockState.Action == SuckBlocksHost.SuckBlockAction.Processing)
                                    {
                                        Vector3 vector3_8  = (volume.BoundingBox.Max - volume.BoundingBox.Min) / 2f;
                                        Vector3 vector3_9  = volume.BoundingBox.Min * vector3_3 + vector3_6 * vector3_2 + vector3_8 * vector3_1 - vector3_1 * 0.5f - vector3_2 * 0.5f;
                                        Vector3 vector3_10 = vector3_9 - vector3_1;
                                        instance.Position = Vector3.Lerp(vector3_10, vector3_9, (float)suckBlockState.SinceActionChanged.Ticks / (float)SuckBlocksHost.SuckBlockState.ProcessingTime.Ticks);
                                        this.LevelManager.UpdateInstance(instance);
                                        if (suckBlockState.SinceActionChanged > SuckBlocksHost.SuckBlockState.ProcessingTime)
                                        {
                                            this.PlayerManager.CanRotate = true;
                                            if (volume.Id == num1)
                                            {
                                                // ISSUE: object of a compiler-generated type is created
                                                // ISSUE: variable of a compiler-generated type
                                                SuckBlocksHost.\u003C\u003Ec__DisplayClassb cDisplayClassb = new SuckBlocksHost.\u003C\u003Ec__DisplayClassb();
                                                SuckBlocksHost.DisableTrile(instance);
                                                suckBlockState.Action = SuckBlocksHost.SuckBlockAction.Accepted;
                                                if (this.eCratePush.Cue.State != SoundState.Paused)
                                                {
                                                    this.eCratePush.Cue.Pause();
                                                }
                                                this.SuckBlockService.OnSuck(suckBlockState.Group.Id);
                                                SoundEffectExtensions.Emit(this.sAccept[4 - this.TrackedSuckBlocks.Count]);
                                                Texture2D texture2D = this.CMProvider.CurrentLevel.Load <Texture2D>("Other Textures/suck_blocks/four_highlight_" + instance.Trile.CubemapPath.Substring(instance.Trile.CubemapPath.Length - 1).ToLower(CultureInfo.InvariantCulture));
                                                // ISSUE: reference to a compiler-generated field
                                                cDisplayClassb.plane = new BackgroundPlane(this.LevelMaterializer.StaticPlanesMesh, (Texture)texture2D)
                                                {
                                                    Position    = instance.Center + FezMath.AsVector(visibleOrientation) * (17.0 / 32.0),
                                                    Rotation    = this.CameraManager.Rotation,
                                                    Doublesided = true,
                                                    Fullbright  = true,
                                                    Opacity     = 0.0f
                                                };
                                                // ISSUE: reference to a compiler-generated field
                                                this.highlightPlanes.Add(cDisplayClassb.plane);
                                                // ISSUE: reference to a compiler-generated field
                                                this.LevelManager.AddPlane(cDisplayClassb.plane);
                                                // ISSUE: reference to a compiler-generated method
                                                Waiters.Interpolate(1.0, new Action <float>(cDisplayClassb.\u003CUpdate\u003Eb__6));
                                                if (this.TrackedSuckBlocks.Count == 1)
                                                {
                                                    Waiters.Wait(2.0, (Action)(() => Waiters.Interpolate(1.0, (Action <float>)(s =>
                                                    {
                                                        foreach (BackgroundPlane item_3 in this.highlightPlanes)
                                                        {
                                                            item_3.Opacity = 1f - s;
                                                        }
                                                    }), (Action)(() => this.eSuck = (SoundEmitter)null))));
                                                    this.eSuck.FadeOutAndDie(1f);
                                                }
                                            }
                                            else
                                            {
                                                suckBlockState.Action = SuckBlocksHost.SuckBlockAction.Rejected;
                                            }
                                        }
                                    }
                                    if (suckBlockState.Action == SuckBlocksHost.SuckBlockAction.Rejected && FezMath.XZ(instance.PhysicsState.Velocity) == Vector2.Zero)
                                    {
                                        int     num3      = RandomHelper.Probability(0.5) ? -1 : 1;
                                        Vector3 vector3_8 = new Vector3((float)num3, 0.75f, (float)num3) * vector3_3;
                                        ServiceHelper.AddComponent((IGameComponent) new CamShake(this.Game)
                                        {
                                            Distance = 0.1f,
                                            Duration = TimeSpan.FromSeconds(0.25)
                                        });
                                        SoundEffectExtensions.Emit(this.sDenied);
                                        if (this.eCratePush.Cue.State != SoundState.Paused)
                                        {
                                            this.eCratePush.Cue.Pause();
                                        }
                                        instance.PhysicsState.Velocity += 6f * vector3_8 * (float)gameTime.ElapsedGameTime.TotalSeconds;
                                    }
                                }
                                else if (suckBlockState.Action != SuckBlocksHost.SuckBlockAction.Rejected)
                                {
                                    if (instance.PhysicsState.Grounded && this.eCratePush.Cue.State != SoundState.Playing)
                                    {
                                        this.eCratePush.Cue.Pitch = 0.0f;
                                        this.eCratePush.Cue.Resume();
                                    }
                                    else if (!instance.PhysicsState.Grounded && this.eCratePush.Cue.State != SoundState.Paused)
                                    {
                                        this.eCratePush.Cue.Pause();
                                    }
                                    if (this.eCratePush.Cue.State == SoundState.Playing)
                                    {
                                        this.eCratePush.VolumeFactor = FezMath.Saturate(Math.Abs(FezMath.Dot(instance.PhysicsState.Velocity, FezMath.XZMask) / 0.1f));
                                    }
                                    suckBlockState.Action           = SuckBlocksHost.SuckBlockAction.Sucking;
                                    instance.PhysicsState.Velocity += 0.25f * vector3_7 / num2 * (float)gameTime.ElapsedGameTime.TotalSeconds;
                                }
                            }
                        }
                    }
                    if (!flag2)
                    {
                        suckBlockState.Action = SuckBlocksHost.SuckBlockAction.Idle;
                    }
                }
            }
            if (!flag1 && this.eSuck != null && !this.eSuck.Dead)
            {
                this.eSuck.FadeOutAndDie(0.1f);
                this.eSuck = (SoundEmitter)null;
            }
            for (int index = 0; index < this.TrackedSuckBlocks.Count; ++index)
            {
                if (this.TrackedSuckBlocks[index].Action == SuckBlocksHost.SuckBlockAction.Accepted)
                {
                    this.TrackedSuckBlocks.RemoveAt(index);
                    --index;
                }
            }
        }
示例#9
0
 private void StartTransition(Vector3 originalCenter, Vector3 destinationCenter)
 {
     Waiters.Interpolate(1.75, (Action <float>)(s => this.CameraManager.Center = Vector3.Lerp(originalCenter, destinationCenter, Easing.EaseInOut((double)s, EasingType.Quadratic)))).AutoPause = true;
 }
示例#10
0
 public void FadeFrequencies(bool toLowPass, float fadeDuration)
 {
     if (!this.IsLowPass && toLowPass)
     {
         float   originalStep = this.FrequencyStep;
         IWaiter thisWaiter   = (IWaiter)null;
         this.freqTransitionWaiter = thisWaiter = Waiters.Interpolate((double)fadeDuration * (1.0 - (double)originalStep), (Action <float>)(s =>
         {
             if (this.freqTransitionWaiter != thisWaiter)
             {
                 return;
             }
             this.FrequencyStep = originalStep + s * (1f - originalStep);
             if (!OggStreamer.HasInstance)
             {
                 return;
             }
             OggStreamer.Instance.LowPassHFGain = MathHelper.Lerp(1f, 0.025f, Easing.EaseOut((double)this.FrequencyStep, EasingType.Cubic));
         }), (Action)(() =>
         {
             if (this.freqTransitionWaiter != thisWaiter)
             {
                 return;
             }
             this.FrequencyStep = 1f;
             if (!OggStreamer.HasInstance)
             {
                 return;
             }
             OggStreamer.Instance.LowPassHFGain = 0.025f;
         }));
     }
     else if (this.IsLowPass && !toLowPass)
     {
         float   originalStep = this.FrequencyStep;
         IWaiter thisWaiter   = (IWaiter)null;
         this.freqTransitionWaiter = thisWaiter = Waiters.Interpolate((double)fadeDuration * (double)originalStep, (Action <float>)(s =>
         {
             if (this.freqTransitionWaiter != thisWaiter)
             {
                 return;
             }
             this.FrequencyStep = originalStep * (1f - s);
             if (!OggStreamer.HasInstance)
             {
                 return;
             }
             OggStreamer.Instance.LowPassHFGain = MathHelper.Lerp(1f, 0.025f, Easing.EaseIn((double)this.FrequencyStep, EasingType.Cubic));
         }), (Action)(() =>
         {
             if (this.freqTransitionWaiter != thisWaiter)
             {
                 return;
             }
             this.FrequencyStep = 0.0f;
             if (!OggStreamer.HasInstance)
             {
                 return;
             }
             OggStreamer.Instance.LowPassHFGain = 1f;
         }));
     }
     this.IsLowPass = toLowPass;
 }
示例#11
0
        public LongRunningAction Open(int id)
        {
            if (id != this.WaterfallPlane.Id)
            {
                return((LongRunningAction)null);
            }
            this.GameState.SaveData.ThisLevel.ScriptingState = "WATERFALL_OPEN";
            this.GameState.Save();
            SoundEmitter eWaterfallOpen = SoundEffectExtensions.EmitAt(this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/MiscActors/BigWaterfallOpen"), this.WaterfallPlane.Position, true, true);

            eWaterfallOpen.VolumeFactor = 0.0f;
            eWaterfallOpen.Cue.Play();
            this.opening = true;
            Waiters.Interpolate(6.0, (Action <float>)(s =>
            {
                if (this.eWaterfallClosed == null || this.eWaterfallClosed.Dead)
                {
                    return;
                }
                this.eWaterfallClosed.VolumeFactor = (1f - s) * this.sinceAlive;
                if (eWaterfallOpen.Dead)
                {
                    return;
                }
                eWaterfallOpen.VolumeFactor = s * this.sinceAlive;
            })).AutoPause = true;
            SoundEffectExtensions.EmitAt(this.sWaterfallOpening, this.WaterfallPlane.Position);
            this.ScriptId = this.ScriptingManager.EvaluatedScript.Script.Id;
            this.LevelManager.RemovePlane(this.WaterfallPlane);
            this.LevelManager.RemovePlane(this.SplashPlane);
            Vector3    position1 = this.SplashPlane.Position;
            Vector3    scale1    = this.SplashPlane.Scale;
            Quaternion rotation1 = this.SplashPlane.Rotation;

            this.SplashPlane = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, this.OpeningSplash)
            {
                Doublesided = true
            };
            this.LevelManager.AddPlane(this.SplashPlane);
            this.SplashPlane.Timing.Restart();
            this.WaterfallPlane.Timing.Loop = false;
            this.SplashPlane.Position       = position1;
            this.SplashPlane.Scale          = scale1;
            this.SplashPlane.Rotation       = rotation1;
            Vector3    position2 = this.WaterfallPlane.Position;
            Vector3    scale2    = this.WaterfallPlane.Scale;
            Quaternion rotation2 = this.WaterfallPlane.Rotation;

            this.WaterfallPlane = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, this.OpeningWaterfall)
            {
                Doublesided = true
            };
            this.LevelManager.AddPlane(this.WaterfallPlane);
            this.WaterfallPlane.Timing.Restart();
            this.WaterfallPlane.Timing.Loop    = false;
            this.WaterfallPlane.YTextureRepeat = true;
            this.WaterfallPlane.Position       = position2;
            this.WaterfallPlane.Scale          = scale2;
            this.WaterfallPlane.Rotation       = rotation2;
            return(new LongRunningAction((Func <float, float, bool>)((_, __) =>
            {
                if (!this.WaterfallPlane.Timing.Ended)
                {
                    return false;
                }
                this.opening = false;
                this.SwapOpened();
                return true;
            })));
        }
示例#12
0
 public void ChangeLevel(string levelName)
 {
     this.GameState.SaveToCloud(false);
     this.GameState.DotLoading = this.DotLoadLevels.Contains(this.Name + "+" + levelName) || this.PlayerManager.Action == ActionType.LesserWarp || this.PlayerManager.Action == ActionType.GateWarp;
     if (this.GameState.DotLoading)
     {
         this.SoundManager.PlayNewSong((string)null, 1f);
         List <AmbienceTrack> ambienceTracks = this.levelData.AmbienceTracks;
         this.levelData.AmbienceTracks = new List <AmbienceTrack>();
         this.SoundManager.PlayNewAmbience();
         this.levelData.AmbienceTracks = ambienceTracks;
     }
     this.GameService.CloseScroll((string)null);
     if (levelName == this.Name && this.DestinationVolumeId.HasValue && this.Volumes.ContainsKey(this.DestinationVolumeId.Value))
     {
         this.LastLevelName = this.Name;
         Volume    volume = this.Volumes[this.DestinationVolumeId.Value];
         Viewpoint view   = FezMath.AsViewpoint(Enumerable.FirstOrDefault <FaceOrientation>((IEnumerable <FaceOrientation>)volume.Orientations));
         this.CameraManager.ChangeViewpoint(view, 1.5f);
         Vector3 position = (volume.BoundingBox.Min + volume.BoundingBox.Max) / 2f + new Vector3(1.0 / 1000.0);
         position.Y = volume.BoundingBox.Min.Y - 0.25f;
         TrileInstance trileInstance = this.NearestTrile(position, QueryOptions.None, new Viewpoint?(view)).Deep;
         this.GameState.SaveData.Ground = trileInstance.Center;
         this.GameState.SaveData.View   = view;
         float num = this.PlayerManager.Position.Y;
         this.PlayerManager.Position      = trileInstance.Center + (trileInstance.TransformedSize / 2f + this.PlayerManager.Size / 2f) * Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor);
         this.PlayerManager.WallCollision = new MultipleHits <CollisionResult>();
         this.PlayerManager.Ground        = new MultipleHits <TrileInstance>();
         this.PlayerManager.Velocity      = (float)(3.15000009536743 * (double)Math.Sign(this.CollisionManager.GravityFactor) * 0.150000005960464 * 0.0166666675359011) * -Vector3.UnitY;
         this.PhysicsManager.Update((IComplexPhysicsEntity)this.PlayerManager);
         this.PlayerManager.Velocity = (float)(3.15000009536743 * (double)Math.Sign(this.CollisionManager.GravityFactor) * 0.150000005960464 * 0.0166666675359011) * -Vector3.UnitY;
         Vector3 originalCenter = this.CameraManager.Center;
         float   diff           = this.PlayerManager.Position.Y - num;
         Waiters.Interpolate(1.5, (Action <float>)(s => this.CameraManager.Center = new Vector3(originalCenter.X, originalCenter.Y + diff / 2f * Easing.EaseInOut((double)s, EasingType.Sine), originalCenter.Z)));
         this.OnLevelChanging();
         this.OnLevelChanged();
     }
     else
     {
         bool   flag1 = this.GameState.SaveData.World.Count > 0;
         string str1  = this.GameState.SaveData.Level;
         this.LastLevelName = !flag1 ? (string)null : this.Name;
         this.Load(levelName);
         this.Rebuild();
         if (!this.GameState.SaveData.World.ContainsKey(this.Name))
         {
             this.GameState.SaveData.World.Add(this.Name, new LevelSaveData()
             {
                 FirstVisit = true
             });
         }
         this.GameState.SaveData.Level = this.Name;
         this.OnLevelChanging();
         LevelSaveData thisLevel = this.GameState.SaveData.ThisLevel;
         foreach (TrileEmplacement emplacement in thisLevel.DestroyedTriles)
         {
             this.ClearTrile(emplacement);
         }
         foreach (int num in thisLevel.InactiveArtObjects)
         {
             if (num < 0)
             {
                 this.RemoveArtObject(this.ArtObjects[-(num + 1)]);
             }
         }
         TrileInstance trileInstance = !flag1 || !(str1 == levelName) ? (TrileInstance)null : this.ActualInstanceAt(this.GameState.SaveData.Ground);
         float?        nullable      = new float?();
         Viewpoint     spawnView     = !flag1 || !(str1 == levelName) ? Viewpoint.Left : this.GameState.SaveData.View;
         bool          flag2         = false;
         if (this.LastLevelName != null)
         {
             Volume volume = (Volume)null;
             if (this.DestinationVolumeId.HasValue && this.DestinationVolumeId.Value != -1 && this.Volumes.ContainsKey(this.DestinationVolumeId.Value))
             {
                 volume = this.Volumes[this.DestinationVolumeId.Value];
                 flag2  = true;
                 this.DestinationVolumeId = new int?();
             }
             else
             {
                 string str2       = this.LastLevelName.Replace('\\', '/');
                 string trimmedLln = str2.Substring(str2.LastIndexOf('/') + 1);
                 foreach (Script script in Enumerable.Where <Script>(Enumerable.Where <Script>((IEnumerable <Script>) this.Scripts.Values, (Func <Script, bool>)(s => Enumerable.Any <ScriptTrigger>((IEnumerable <ScriptTrigger>)s.Triggers, (Func <ScriptTrigger, bool>)(t => t.Object.Type == "Volume")))), (Func <Script, bool>)(s => Enumerable.Any <ScriptAction>((IEnumerable <ScriptAction>)s.Actions, (Func <ScriptAction, bool>)(a =>
                 {
                     if (!(a.Object.Type == "Level") || !a.Operation.Contains("ChangeLevel"))
                     {
                         return(false);
                     }
                     if (!(a.Arguments[0] == this.LastLevelName))
                     {
                         return(a.Arguments[0] == trimmedLln);
                     }
                     else
                     {
                         return(true);
                     }
                 })))))
                 {
                     int key = Enumerable.First <ScriptTrigger>(Enumerable.Where <ScriptTrigger>((IEnumerable <ScriptTrigger>)script.Triggers, (Func <ScriptTrigger, bool>)(x => x.Object.Type == "Volume"))).Object.Identifier.Value;
                     if (this.Volumes.ContainsKey(key))
                     {
                         volume = this.Volumes[key];
                         flag2  = true;
                     }
                 }
             }
             if (flag2 && volume != null)
             {
                 Vector3 vector3 = (volume.BoundingBox.Min + volume.BoundingBox.Max) / 2f + new Vector3(1.0 / 1000.0);
                 vector3.Y = volume.BoundingBox.Min.Y - 0.25f;
                 spawnView = FezMath.AsViewpoint(Enumerable.FirstOrDefault <FaceOrientation>((IEnumerable <FaceOrientation>)volume.Orientations));
                 nullable  = new float?(FezMath.Dot(vector3, FezMath.SideMask(spawnView)));
                 float   num      = (float)((double)FezMath.Dot(volume.BoundingBox.Max - volume.BoundingBox.Min, FezMath.DepthMask(spawnView)) / 2.0 + 0.5);
                 Vector3 position = vector3 + num * -FezMath.ForwardVector(spawnView);
                 foreach (TrileEmplacement trileEmplacement in Enumerable.Union <TrileEmplacement>((IEnumerable <TrileEmplacement>)thisLevel.InactiveTriles, (IEnumerable <TrileEmplacement>)thisLevel.DestroyedTriles))
                 {
                     if ((double)Vector3.DistanceSquared(trileEmplacement.AsVector, position) < 2.0)
                     {
                         position -= FezMath.ForwardVector(spawnView);
                         break;
                     }
                 }
                 trileInstance = this.ActualInstanceAt(position) ?? this.NearestTrile(vector3, QueryOptions.None, new Viewpoint?(spawnView)).Deep;
             }
         }
         InstanceFace instanceFace = new InstanceFace();
         if (!flag1 || trileInstance == null)
         {
             if (this.StartingPosition != (TrileFace)null)
             {
                 instanceFace.Instance = this.TrileInstanceAt(ref this.StartingPosition.Id);
                 instanceFace.Face     = this.StartingPosition.Face;
             }
             else
             {
                 instanceFace.Face = FezMath.VisibleOrientation(spawnView);
             }
             if (instanceFace.Instance == null)
             {
                 instanceFace.Instance = Enumerable.FirstOrDefault <TrileInstance>((IEnumerable <TrileInstance>)Enumerable.OrderBy <TrileInstance, float>(Enumerable.Where <TrileInstance>((IEnumerable <TrileInstance>) this.Triles.Values, (Func <TrileInstance, bool>)(x => !FezMath.In <CollisionType>(x.GetRotatedFace(FezMath.VisibleOrientation(spawnView)), CollisionType.None, CollisionType.Immaterial, (IEqualityComparer <CollisionType>)CollisionTypeComparer.Default))), (Func <TrileInstance, float>)(x => Math.Abs(FezMath.Dot(x.Center - this.Size / 2f, FezMath.ScreenSpaceMask(spawnView))))));
             }
             trileInstance = instanceFace.Instance;
             spawnView     = FezMath.AsViewpoint(instanceFace.Face);
         }
         this.CameraManager.Constrained        = false;
         this.CameraManager.PanningConstraints = new Vector2?();
         if (trileInstance != null)
         {
             this.GameState.SaveData.Ground = trileInstance.Center;
         }
         this.GameState.SaveData.View      = spawnView;
         this.GameState.SaveData.TimeOfDay = this.TimeManager.CurrentTime.TimeOfDay;
         if (flag2)
         {
             this.PlayerManager.CheckpointGround = (TrileInstance)null;
         }
         this.PlayerManager.RespawnAtCheckpoint();
         if (nullable.HasValue)
         {
             this.PlayerManager.Position = this.PlayerManager.Position * (Vector3.One - FezMath.SideMask(spawnView)) + nullable.Value * FezMath.SideMask(spawnView);
         }
         this.PlayerManager.Action        = ActionType.Idle;
         this.PlayerManager.WallCollision = new MultipleHits <CollisionResult>();
         this.PlayerManager.Ground        = new MultipleHits <TrileInstance>();
         this.PlayerManager.Velocity      = (float)(3.15000009536743 * (double)Math.Sign(this.CollisionManager.GravityFactor) * 0.150000005960464 * 0.0166666675359011) * -Vector3.UnitY;
         this.PhysicsManager.Update((IComplexPhysicsEntity)this.PlayerManager);
         this.PlayerManager.Velocity           = (float)(3.15000009536743 * (double)Math.Sign(this.CollisionManager.GravityFactor) * 0.150000005960464 * 0.0166666675359011) * -Vector3.UnitY;
         this.CameraManager.InterpolatedCenter = this.CameraManager.Center = this.PlayerManager.Position;
         this.OnLevelChanged();
         this.LevelService.OnStart();
         ScriptingHost.Instance.ForceUpdate(new GameTime());
         if (!this.PlayerManager.SpinThroughDoor)
         {
             if (!this.CameraManager.Constrained)
             {
                 this.CameraManager.Center = this.PlayerManager.Position + (float)(4.0 * (this.Descending ? -1.0 : 1.0)) / this.CameraManager.PixelsPerTrixel * Vector3.UnitY;
                 this.CameraManager.SnapInterpolation();
             }
             if (!this.GameState.FarawaySettings.InTransition)
             {
                 this.LevelMaterializer.ForceCull();
             }
         }
         if (this.Name != "HEX_REBUILD" && this.Name != "DRUM" && (this.Name != "VILLAGEVILLE_3D_END_64" && this.Name != "VILLAGEVILLE_3D_END_32"))
         {
             this.GameState.Save();
         }
         GC.Collect(3);
     }
 }
示例#13
0
            public void Update(TimeSpan elapsed)
            {
                this.SinceStateChange += elapsed;
                if (this.SinceStateChange.Ticks >= 0L)
                {
                    this.Lifting = !this.Lifting;
                    if (this.Lifting)
                    {
                        foreach (TrileInstance trileInstance in this.Group.Triles)
                        {
                            trileInstance.PhysicsState.Floating = false;
                            if (!trileInstance.PhysicsState.Puppet)
                            {
                                this.InitialHeight = trileInstance.PhysicsState.Center.Y;
                            }
                        }
                        this.ReachedApex      = false;
                        this.SinceStartedLift = TimeSpan.Zero;
                        this.SinceStateChange = TimeSpan.FromSeconds(-(double)this.Group.GeyserLiftFor);
                    }
                    else
                    {
                        foreach (TrileInstance trileInstance in this.Group.Triles)
                        {
                            trileInstance.PhysicsState.Floating = false;
                        }
                        this.SinceStateChange = TimeSpan.FromSeconds(-(double)this.Group.GeyserPauseFor);
                        IWaiter waiter = Waiters.Interpolate((double)this.Group.GeyserApexHeight / 2.0, (Action <float>)(s => this.heightDelta -= s * 1.25f));
                        waiter.AutoPause   = true;
                        waiter.CustomPause = (Func <bool>)(() => !this.CameraManager.ViewTransitionReached);
                    }
                }
                if (this.Lifting)
                {
                    this.SinceStartedLift += elapsed;
                    double linearStep = this.SinceStartedLift.TotalSeconds / Math.Sqrt((double)this.Group.GeyserApexHeight) * 1.5;
                    float  num        = Easing.EaseInOut(linearStep, EasingType.Quadratic, EasingType.Sine);
                    this.loopEmitter.VolumeFactor = (float)FezMath.Saturate(linearStep);
                    if (!this.ReachedApex && linearStep >= 1.0)
                    {
                        this.ReachedApex   = true;
                        this.ReachedAtTime = (float)this.SinceStateChange.TotalSeconds;
                    }
                    this.heightDelta = !this.ReachedApex ? this.Group.GeyserApexHeight * num : this.Group.GeyserApexHeight + (float)(Math.Sin((this.SinceStateChange.TotalSeconds - (double)this.ReachedAtTime) * 4.0) * 1.5 / 16.0);
                    foreach (TrileInstance trileInstance in this.Group.Triles)
                    {
                        trileInstance.PhysicsState.PushedUp = true;
                        if (this.ReachedApex)
                        {
                            Vector3 center = trileInstance.PhysicsState.Center;
                            trileInstance.PhysicsState.Center   = trileInstance.PhysicsState.Center * FezMath.XZMask + (this.InitialHeight + this.heightDelta) * Vector3.UnitY;
                            trileInstance.PhysicsState.Velocity = trileInstance.PhysicsState.Center - center;
                            trileInstance.PhysicsState.Center   = center;
                        }
                        else
                        {
                            Vector3 center = trileInstance.PhysicsState.Center;
                            trileInstance.PhysicsState.Center   = trileInstance.PhysicsState.Center * FezMath.XZMask + (this.InitialHeight + this.heightDelta) * Vector3.UnitY;
                            trileInstance.PhysicsState.Velocity = trileInstance.PhysicsState.Center - center;
                            trileInstance.PhysicsState.Center   = center;
                        }
                        trileInstance.PhysicsState.Velocity += 0.4725f * (float)elapsed.TotalSeconds * Vector3.Up;
                    }
                }
                else
                {
                    foreach (TrileInstance trileInstance in this.Group.Triles)
                    {
                        trileInstance.PhysicsState.PushedUp = false;
                        if (!trileInstance.PhysicsState.Floating && (double)trileInstance.PhysicsState.Center.Y - (double)this.LevelManager.WaterHeight > 0.0)
                        {
                            trileInstance.PhysicsState.Velocity += 0.4725f * (float)elapsed.TotalSeconds * Vector3.Up / 2f;
                        }
                    }
                    this.loopEmitter.VolumeFactor = this.heightDelta / this.Group.GeyserApexHeight;
                }
                float num1 = (float)((double)this.heightDelta + (double)this.InitialHeight - 1.0) - this.LevelManager.WaterHeight;

                this.TopPlane.Scale    = new Vector3(1f, FezMath.Saturate(num1 + 1f), 1f);
                this.TopPlane.Position = FezMath.XZMask * this.TopPlane.Position + (float)((double)this.LevelManager.WaterHeight + (double)num1 + (1.0 - (double)this.TopPlane.Scale.Y) / 2.0) * Vector3.UnitY;
                this.TopPlane.Visible  = (double)this.TopPlane.Scale.Y > 0.0;
                if ((double)num1 <= 0.0)
                {
                    num1 = 0.0f;
                }
                this.TilePlane.Scale      = new Vector3(1f, num1 / this.TilePlane.Size.Y, 1f);
                this.TilePlane.Position   = FezMath.XZMask * this.TilePlane.Position + (float)((double)this.LevelManager.WaterHeight + (double)num1 / 2.0 - 0.5) * Vector3.UnitY;
                this.TilePlane.Visible    = (double)this.TilePlane.Scale.Y > 0.0;
                this.loopEmitter.Position = this.TopPlane.Position;
            }