Esempio n. 1
0
 private bool IsHuggable(TrileInstance instance, IPhysicsEntity entity)
 {
     if (instance != null && instance.Enabled && !instance.Trile.Immaterial && ((!instance.Trile.Thin || instance.Trile.ForceHugging) && (instance != this.PlayerManager.CarriedInstance && instance != this.PlayerManager.PushedInstance)) && (!ActorTypeExtensions.IsBomb(instance.Trile.ActorSettings.Type) && (instance.PhysicsState == null || instance.PhysicsState != entity)))
     {
         return(!FezMath.In <CollisionType>(instance.GetRotatedFace(entity.Background ? FezMath.GetOpposite(this.CameraManager.VisibleOrientation) : this.CameraManager.VisibleOrientation), CollisionType.Immaterial, CollisionType.TopNoStraightLedge, CollisionType.AllSides, (IEqualityComparer <CollisionType>)CollisionTypeComparer.Default));
     }
     else
     {
         return(false);
     }
 }
Esempio n. 2
0
 protected void SyncAnimation(bool isActive)
 {
     if (isActive && this.lastAction != this.PlayerManager.Action)
     {
         AnimatedTexture animation1 = this.PlayerManager.Animation;
         AnimatedTexture animation2 = this.PlayerManager.GetAnimation(this.PlayerManager.Action);
         this.PlayerManager.Animation = animation2;
         animation2.Timing.StartFrame = ActionTypeExtensions.GetStartFrame(this.PlayerManager.Action);
         int endFrame = ActionTypeExtensions.GetEndFrame(this.PlayerManager.Action);
         animation2.Timing.EndFrame = endFrame != -1 ? endFrame : animation2.Timing.InitialEndFrame;
         animation2.Timing.Loop     = ActionTypeExtensions.IsAnimationLooping(this.PlayerManager.Action);
         if ((animation2 != animation1 || !animation2.Timing.Loop) && (this.lastAction != ActionType.Pushing && this.lastAction != ActionType.DropHeavyTrile && this.lastAction != ActionType.DropTrile || this.PlayerManager.Action != ActionType.Grabbing))
         {
             animation2.Timing.Restart();
         }
         if (this.PlayerManager.Action == ActionType.GrabCornerLedge && this.lastAction == ActionType.LowerToCornerLedge)
         {
             animation2.Timing.Step = animation2.Timing.EndStep - 1.0 / 1000.0;
         }
         else if (this.PlayerManager.Action == ActionType.ThrowingHeavy && this.PlayerManager.LastAction == ActionType.CarryHeavyJump)
         {
             animation2.Timing.Step = animation2.Timing.EndStep * (3f / (float)animation2.Timing.EndFrame);
         }
         else if ((this.PlayerManager.Action == ActionType.GrabLedgeFront || this.PlayerManager.Action == ActionType.GrabLedgeBack) && ActionTypeExtensions.IsOnLedge(this.lastAction))
         {
             animation2.Timing.Step = animation2.Timing.EndStep - 1.0 / 1000.0;
         }
         else if (FezMath.In <ActionType>(this.lastAction, ActionType.ToCornerBack, ActionType.ToCornerFront, ActionType.GrabLedgeFront, ActionType.GrabLedgeBack, (IEqualityComparer <ActionType>)ActionTypeComparer.Default) && this.PlayerManager.Action == ActionType.GrabCornerLedge)
         {
             animation2.Timing.Step = animation2.Timing.EndStep - 1.0 / 1000.0;
         }
         else if (this.PlayerManager.Action == ActionType.GrabTombstone && this.PlayerManager.LastAction == ActionType.PivotTombstone)
         {
             animation2.Timing.Step = animation2.Timing.EndStep - 1.0 / 1000.0;
         }
         else if (this.PlayerManager.Action == ActionType.TurnToBell && this.PlayerManager.LastAction == ActionType.HitBell)
         {
             animation2.Timing.Step = animation2.Timing.EndStep - 1.0 / 1000.0;
         }
     }
     this.lastAction = this.PlayerManager.Action;
 }
Esempio n. 3
0
 protected override void TestConditions()
 {
     if (!FezMath.In <ActionType>(this.PlayerManager.Action, ActionType.Sliding, ActionType.GrabCornerLedge, ActionType.Running, ActionType.RunTurnAround, ActionType.Walking, ActionType.Landing, ActionType.WalkingTo, ActionType.GrabTombstone, (IEqualityComparer <ActionType>)ActionTypeComparer.Default) && !this.PlayerManager.Climbing && (!this.PlayerManager.Swimming && !ActionTypeExtensions.IsIdle(this.PlayerManager.Action)) && (this.PlayerManager.Action != ActionType.Falling || !this.PlayerManager.CanDoubleJump) && (this.PlayerManager.Action != ActionType.Grabbing && this.PlayerManager.Action != ActionType.Pushing && !ActionTypeExtensions.IsLookingAround(this.PlayerManager.Action)) || this.InputManager.Jump != FezButtonState.Pressed && (!this.PlayerManager.Grounded && !ActionTypeExtensions.IsOnLedge(this.PlayerManager.Action) || (double)this.PlayerManager.Velocity.Y * (double)Math.Sign(this.CollisionManager.GravityFactor) <= 0.1))
     {
         return;
     }
     this.PlayerManager.PushedInstance = (TrileInstance)null;
     if (this.PlayerManager.CanDoubleJump)
     {
         this.PlayerManager.CanDoubleJump = false;
     }
     if (FezButtonStateExtensions.IsDown(this.InputManager.Down) && (this.PlayerManager.Grounded && this.PlayerManager.Ground.First.GetRotatedFace(FezMath.VisibleOrientation(this.CameraManager.Viewpoint)) == CollisionType.TopOnly || this.PlayerManager.Climbing))
     {
         return;
     }
     if (this.PlayerManager.Action == ActionType.GrabCornerLedge)
     {
         HorizontalDirection horizontalDirection = FezMath.DirectionFromMovement(this.InputManager.Movement.X);
         if (horizontalDirection == HorizontalDirection.None || horizontalDirection == this.PlayerManager.LookingDirection)
         {
             return;
         }
         Vector3 position = this.PlayerManager.Position;
         this.PlayerManager.Position += FezMath.RightVector(this.CameraManager.Viewpoint) * (float)-FezMath.Sign(this.PlayerManager.LookingDirection);
         this.PhysicsManager.DetermineInBackground((IPhysicsEntity)this.PlayerManager, true, false, false);
         this.PlayerManager.Position = position;
     }
     if (this.InputManager.Jump == FezButtonState.Pressed)
     {
         this.sinceJumped  = TimeSpan.Zero;
         this.scheduleJump = true;
     }
     else
     {
         this.DoJump();
     }
     this.PlayerManager.Action = ActionType.Jumping;
 }
Esempio n. 4
0
        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;
            }
        }
Esempio n. 5
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);
     }
 }
Esempio n. 6
0
        private void FollowGomez()
        {
            float num1 = this.CameraManager.PixelsPerTrixel;

            if (this.GameState.FarawaySettings.InTransition && FezMath.AlmostEqual(this.GameState.FarawaySettings.DestinationCrossfadeStep, 1f))
            {
                num1 = MathHelper.Lerp(this.CameraManager.PixelsPerTrixel, this.GameState.FarawaySettings.DestinationPixelsPerTrixel, (float)(((double)this.GameState.FarawaySettings.TransitionStep - 0.875) / 0.125));
            }
            float   num2      = (float)(4.0 * (this.LevelManager.Descending ? -1.0 : 1.0)) / num1;
            Vector3 vector3_1 = new Vector3(this.CameraManager.Center.X, this.PlayerManager.Position.Y + num2, this.CameraManager.Center.Z);
            Vector3 center    = this.CameraManager.Center;

            if (this.CameraManager.StickyCam)
            {
                Vector3 vector3_2 = this.PlayerManager.Position + Vector3.UnitY * num2;
                Vector3 vector3_3 = this.StickyCenter * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) - vector3_2 * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);
                float   val1      = vector3_3.Length() + 1f;
                if (this.InputManager.FreeLook == Vector2.Zero)
                {
                    this.MinimumStickDistance = Math.Min(val1, this.MinimumStickDistance);
                    float viewScale = SettingsManager.GetViewScale(this.GraphicsDevice);
                    if ((double)Math.Abs(vector3_3.X + vector3_3.Z) > (double)this.CameraManager.Radius * 0.400000005960464 / (double)viewScale || (double)Math.Abs(vector3_3.Y) > (double)this.CameraManager.Radius * 0.400000005960464 / (double)this.CameraManager.AspectRatio / (double)viewScale)
                    {
                        this.MinimumStickDistance = 2.5f;
                    }
                    if ((double)this.MinimumStickDistance < 4.0)
                    {
                        this.StickyCenter = Vector3.Lerp(this.StickyCenter, vector3_2, (float)Math.Pow(1.0 / (double)this.MinimumStickDistance, 4.0));
                    }
                }
                vector3_1 = this.StickyCenter;
                if ((double)val1 <= 1.1)
                {
                    this.CameraManager.StickyCam = false;
                }
            }
            else
            {
                if ((double)MathHelper.Clamp(this.PlayerManager.Position.X, center.X - 1.5f, center.X + 1.5f) != (double)this.PlayerManager.Position.X)
                {
                    float num3 = this.PlayerManager.Position.X - center.X;
                    vector3_1.X += num3 - 1.5f * (float)Math.Sign(num3);
                }
                if ((double)MathHelper.Clamp(this.PlayerManager.Position.Z, center.Z - 1.5f, center.Z + 1.5f) != (double)this.PlayerManager.Position.Z)
                {
                    float num3 = this.PlayerManager.Position.Z - this.CameraManager.Center.Z;
                    vector3_1.Z += num3 - 1.5f * (float)Math.Sign(num3);
                }
            }
            if (this.CameraManager.PanningConstraints.HasValue && !this.GameState.InMap)
            {
                Vector3 vector3_2 = FezMath.DepthMask(this.CameraManager.Viewpoint);
                Vector3 vector3_3 = FezMath.SideMask(this.CameraManager.Viewpoint);
                Vector3 vector3_4 = new Vector3(MathHelper.Lerp(this.CameraManager.ConstrainedCenter.X, vector3_1.X, this.CameraManager.PanningConstraints.Value.X), MathHelper.Lerp(this.CameraManager.ConstrainedCenter.Y, vector3_1.Y, this.CameraManager.PanningConstraints.Value.Y), MathHelper.Lerp(this.CameraManager.ConstrainedCenter.Z, vector3_1.Z, this.CameraManager.PanningConstraints.Value.X));
                this.CameraManager.Center = this.CameraManager.Center * vector3_2 + vector3_3 * vector3_4 + Vector3.UnitY * vector3_4;
            }
            else
            {
                if (this.GameState.InMenuCube || this.GameState.InMap || FezMath.In <ActionType>(this.PlayerManager.Action, ActionType.PullUpCornerLedge, ActionType.LowerToCornerLedge, ActionType.Victory, (IEqualityComparer <ActionType>)ActionTypeComparer.Default))
                {
                    return;
                }
                this.CameraManager.Center = vector3_1;
            }
        }
Esempio n. 7
0
 private void InitializePickups()
 {
     this.sinceLevelChanged = 0.0f;
     if (this.LevelManager.TrileSet == null)
     {
         this.initLock.Reset();
         this.PickupStates = (List <PickupState>)null;
         this.initLock.Set();
     }
     else
     {
         this.initLock.Reset();
         if (this.PickupStates != null)
         {
             foreach (PickupState pickupState in this.PickupStates)
             {
                 pickupState.Instance.PhysicsState.ShouldRespawn = false;
             }
         }
         this.PickupStates = new List <PickupState>(Enumerable.Select <TrileInstance, PickupState>(Enumerable.SelectMany <Trile, TrileInstance>(Enumerable.Where <Trile>((IEnumerable <Trile>) this.LevelManager.TrileSet.Triles.Values, (Func <Trile, bool>)(t => ActorTypeExtensions.IsPickable(t.ActorSettings.Type))), (Func <Trile, IEnumerable <TrileInstance> >)(t => (IEnumerable <TrileInstance>)t.Instances)), (Func <TrileInstance, PickupState>)(t => new PickupState(t, this.LevelManager.PickupGroups.ContainsKey(t) ? this.LevelManager.PickupGroups[t] : (TrileGroup)null))));
         foreach (PickupState pickupState in Enumerable.Where <PickupState>((IEnumerable <PickupState>) this.PickupStates, (Func <PickupState, bool>)(x => x.Group != null)))
         {
             int groupId = pickupState.Group.Id;
             pickupState.AttachedAOs = Enumerable.ToArray <ArtObjectInstance>(Enumerable.Where <ArtObjectInstance>((IEnumerable <ArtObjectInstance>) this.LevelMaterializer.LevelArtObjects, (Func <ArtObjectInstance, bool>)(x =>
             {
                 int?local_0 = x.ActorSettings.AttachedGroup;
                 int local_1 = groupId;
                 if (local_0.GetValueOrDefault() == local_1)
                 {
                     return(local_0.HasValue);
                 }
                 else
                 {
                     return(false);
                 }
             })));
             if (pickupState.Group.Triles.Count == 1)
             {
                 pickupState.Group = (TrileGroup)null;
             }
         }
         foreach (TrileInstance instance in Enumerable.Select <PickupState, TrileInstance>(Enumerable.Where <PickupState>((IEnumerable <PickupState>) this.PickupStates, (Func <PickupState, bool>)(x => x.Instance.PhysicsState == null)), (Func <PickupState, TrileInstance>)(x => x.Instance)))
         {
             instance.PhysicsState = new InstancePhysicsState(instance)
             {
                 Ground = new MultipleHits <TrileInstance>()
                 {
                     NearLow = this.LevelManager.ActualInstanceAt(instance.Center - instance.Trile.Size.Y * Vector3.UnitY)
                 }
             }
         }
         ;
         bool flag = this.LevelManager.WaterType == LiquidType.Sewer && !FezMath.In <string>(this.LevelManager.Name, "SEWER_PIVOT", "SEWER_TREASURE_TWO");
         foreach (TrileGroup trileGroup in Enumerable.Distinct <TrileGroup>(Enumerable.Where <TrileGroup>((IEnumerable <TrileGroup>) this.LevelManager.PickupGroups.Values, (Func <TrileGroup, bool>)(g => Enumerable.All <TrileInstance>((IEnumerable <TrileInstance>)g.Triles, (Func <TrileInstance, bool>)(t => !t.PhysicsState.Puppet))))))
         {
             foreach (TrileInstance instance in trileGroup.Triles)
             {
                 instance.PhysicsState.IgnoreCollision = flag;
                 instance.PhysicsState.Center         += 1.0 / 500.0 * FezMath.XZMask;
                 instance.PhysicsState.UpdateInstance();
                 this.LevelManager.UpdateInstance(instance);
                 instance.PhysicsState.Puppet = true;
             }
             trileGroup.Triles[trileGroup.Triles.Count / 2].PhysicsState.Puppet = false;
             trileGroup.InMidAir = true;
         }
         this.PauseGroupOverlaps(true);
         this.DetectBackground();
         this.initLock.Set();
     }
 }