示例#1
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);
     }
 }
示例#2
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);
   }
 }