示例#1
0
 public override void Update(GameTime gameTime)
 {
     if (this.rotatedFrom.HasValue && (double)this.CameraManager.ViewTransitionStep >= 0.6)
     {
         int distance = FezMath.GetDistance(this.CameraManager.Viewpoint, this.rotatedFrom.Value);
         if (Math.Abs(distance) % 2 == 0)
         {
             this.PlayerManager.Background = !this.PlayerManager.Background;
             this.PlayerManager.Action     = ActionTypeExtensions.FacesBack(this.PlayerManager.Action) ? ActionType.GrabLedgeFront : ActionType.GrabLedgeBack;
         }
         else
         {
             if (ActionTypeExtensions.FacesBack(this.PlayerManager.Action))
             {
                 this.PlayerManager.LookingDirection = Math.Sign(distance) > 0 ? HorizontalDirection.Left : HorizontalDirection.Right;
             }
             else
             {
                 this.PlayerManager.LookingDirection = Math.Sign(distance) > 0 ? HorizontalDirection.Right : HorizontalDirection.Left;
             }
             this.PlayerManager.Action     = ActionType.GrabCornerLedge;
             this.PlayerManager.Position  += this.PlayerManager.Size.Z / 4f * FezMath.ForwardVector(this.rotatedFrom.Value);
             this.PlayerManager.Background = false;
         }
         this.SyncAnimation(true);
         this.rotatedFrom = new Viewpoint?();
     }
     base.Update(gameTime);
 }
示例#2
0
 private void RotateTo(Viewpoint view)
 {
     if (Math.Abs(FezMath.GetDistance(this.CameraManager.Viewpoint, view)) > 1)
     {
         this.EmitRight();
     }
     this.CameraManager.ChangeViewpoint(view);
 }
示例#3
0
        public virtual bool ChangeViewpoint(Viewpoint newViewpoint, float speedFactor)
        {
            bool flag = FezMath.IsOrthographic(newViewpoint) != FezMath.IsOrthographic(this.viewpoint);

            if (flag && this.ProjectionTransition)
            {
                return(false);
            }
            this.ProjectionTransition   = flag && (double)speedFactor > 0.0;
            this.radiusBeforeTransition = FezMath.IsOrthographic(this.viewpoint) ? this.current.Radius : this.predefinedViews[this.lastViewpoint].Radius;
            if ((double)speedFactor > 0.0)
            {
                float num = (float)((double)(Math.Abs(FezMath.GetDistance(newViewpoint, this.Viewpoint)) - 1) / 2.0 + 1.0);
                if (newViewpoint == Viewpoint.Perspective || this.Viewpoint == Viewpoint.Perspective)
                {
                    num = 1f;
                }
                Vector3 from = this.current.Direction;
                Vector3 to   = this.predefinedViews[newViewpoint].Direction;
                this.directionTransition = new Vector3SplineInterpolation(TimeSpan.FromSeconds((double)DefaultCameraManager.TransitionSpeed * (double)num * (double)speedFactor), new Vector3[3]
                {
                    from,
                    DefaultCameraManager.GetIntemediateVector(from, to),
                    to
                });
                this.directionTransition.Start();
            }
            if (FezMath.IsOrthographic(this.viewpoint))
            {
                this.current.Direction = -FezMath.ForwardVector(this.viewpoint);
                this.current.Radius    = this.DefaultViewableWidth;
            }
            this.olderViewpoint = this.lastViewpoint;
            this.lastViewpoint  = this.viewpoint;
            this.viewpoint      = newViewpoint;
            Vector3 center = this.Center;

            this.current        = this.predefinedViews[newViewpoint];
            this.current.Center = center;
            if (this.lastViewpoint != Viewpoint.None)
            {
                this.PreViewpointChanged();
                if (!this.ViewTransitionCancelled)
                {
                    this.ViewpointChanged();
                }
            }
            if ((double)speedFactor == 0.0 && !this.ViewTransitionCancelled)
            {
                this.RebuildView();
            }
            bool transitionCancelled = this.ViewTransitionCancelled;

            this.ViewTransitionCancelled = false;
            return(!transitionCancelled);
        }
示例#4
0
 public override void Update(GameTime gameTime)
 {
     if (this.rotatedFrom.HasValue && (double)this.CameraManager.ViewTransitionStep >= 0.6)
     {
         int distance = FezMath.GetDistance(this.CameraManager.Viewpoint, this.rotatedFrom.Value);
         if (Math.Abs(distance) % 2 == 0)
         {
             this.PlayerManager.LookingDirection = FezMath.GetOpposite(this.PlayerManager.LookingDirection);
         }
         else
         {
             if (this.PlayerManager.LookingDirection == HorizontalDirection.Right)
             {
                 this.PlayerManager.Action = Math.Sign(distance) > 0 ? ActionType.GrabLedgeBack : ActionType.GrabLedgeFront;
             }
             else
             {
                 this.PlayerManager.Action = Math.Sign(distance) > 0 ? ActionType.GrabLedgeFront : ActionType.GrabLedgeBack;
             }
             if (this.PlayerManager.Action == ActionType.GrabLedgeBack)
             {
                 this.PlayerManager.Position -= this.PlayerManager.Size.Z / 4f * FezMath.ForwardVector(this.CameraManager.Viewpoint);
                 this.CorrectWallOverlap(true);
                 this.PlayerManager.Background = false;
             }
             else
             {
                 this.PlayerManager.Position  += this.PlayerManager.Size.Z / 4f * FezMath.ForwardVector(this.CameraManager.Viewpoint);
                 this.PlayerManager.Background = true;
             }
         }
         this.SyncAnimation(this.IsActionAllowed(this.PlayerManager.Action));
         this.rotatedFrom = new Viewpoint?();
     }
     if (ActionTypeExtensions.IsOnLedge(this.PlayerManager.Action))
     {
         if (this.PlayerManager.HeldInstance == null)
         {
             this.PlayerManager.Action = ActionType.Idle;
         }
         else if (this.PlayerManager.HeldInstance.PhysicsState != null && (double)Math.Abs(FezMath.Dot(this.PlayerManager.HeldInstance.PhysicsState.Velocity, Vector3.One)) > 0.5)
         {
             this.PlayerManager.Velocity     = this.PlayerManager.HeldInstance.PhysicsState.Velocity;
             this.PlayerManager.HeldInstance = (TrileInstance)null;
             this.PlayerManager.Action       = ActionType.Jumping;
         }
     }
     base.Update(gameTime);
 }
示例#5
0
 private void CheckForPattern()
 {
     if (!this.Enabled || this.GameState.Loading)
     {
         return;
     }
     this.Input.Add(FezMath.GetDistance(this.CameraManager.Viewpoint, this.CameraManager.LastViewpoint) == 1 ? VibrationMotor.LeftLow : VibrationMotor.RightHigh);
     if (this.Input.Count > 16)
     {
         this.Input.RemoveAt(0);
     }
     if (!PatternTester.Test((IList <VibrationMotor>) this.Input, this.ArtObject.ActorSettings.VibrationPattern))
     {
         return;
     }
     this.Input.Clear();
     this.Enabled = false;
     Waiters.Wait((Func <bool>)(() => this.CameraManager.ViewTransitionReached), new Action(this.Solve));
 }
示例#6
0
 public void TrySpin()
 {
     if (this.State != SpinAction.Grabbed)
     {
         return;
     }
     if (this.PlayerManager.Action != ActionType.GrabTombstone)
     {
         this.State = SpinAction.Idle;
     }
     else
     {
         if (!this.PlayerManager.Animation.Timing.Ended || this.CameraManager.Viewpoint == Viewpoint.Perspective || this.CameraManager.LastViewpoint == this.CameraManager.Viewpoint)
         {
             return;
         }
         this.SpinSign = FezMath.GetDistance(this.CameraManager.LastViewpoint, this.CameraManager.Viewpoint);
         if (this.SpinSign == 1)
         {
             SoundEffectExtensions.EmitAt(this.Host.TurnRight, this.ArtObject.Position);
         }
         else
         {
             SoundEffectExtensions.EmitAt(this.Host.TurnLeft, this.ArtObject.Position);
         }
         int num;
         if (!this.GameState.SaveData.ThisLevel.PivotRotations.TryGetValue(this.ArtObject.Id, out num))
         {
             this.GameState.SaveData.ThisLevel.PivotRotations.Add(this.ArtObject.Id, this.SpinSign);
         }
         else
         {
             this.GameState.SaveData.ThisLevel.PivotRotations[this.ArtObject.Id] = num + this.SpinSign;
         }
         this.PlayerManager.Position = this.PlayerManager.Position * FezMath.ScreenSpaceMask(this.CameraManager.LastViewpoint) + this.ArtObject.Position * FezMath.DepthMask(this.CameraManager.LastViewpoint) + -FezMath.ForwardVector(this.CameraManager.LastViewpoint);
         this.OriginalPlayerPosition = this.PlayerManager.Position;
         this.OriginalAoRotation     = this.ArtObject.Rotation;
         this.SinceChanged           = TimeSpan.Zero;
         this.State = SpinAction.Spinning;
         this.PlayerManager.Action = ActionType.PivotTombstone;
     }
 }
示例#7
0
        private void ChangeApproach()
        {
            if (!this.IsActionAllowed(this.PlayerManager.Action) || !FezMath.IsOrthographic(this.CameraManager.Viewpoint) || (this.CameraManager.Viewpoint == this.CameraManager.LastViewpoint || this.PlayerManager.IsOnRotato))
            {
                return;
            }
            int num = (int)(this.currentApproach + FezMath.GetDistance(this.CameraManager.Viewpoint, this.CameraManager.LastViewpoint));

            if (num > 4)
            {
                num -= 4;
            }
            if (num < 1)
            {
                num += 4;
            }
            this.currentApproach = (ClimbingApproach)num;
            this.RefreshPlayerAction(true);
            this.shouldSyncAnimationHalfway = true;
        }
示例#8
0
 public void TrySpin()
 {
     if (this.State != SpinAction.Grabbed)
     {
         return;
     }
     if (this.PlayerManager.Action != ActionType.GrabTombstone)
     {
         this.State = SpinAction.Idle;
     }
     else
     {
         if (!this.PlayerManager.Animation.Timing.Ended || this.CameraManager.Viewpoint == Viewpoint.Perspective || this.CameraManager.LastViewpoint == this.CameraManager.Viewpoint)
         {
             return;
         }
         this.SpinSign = FezMath.GetDistance(this.CameraManager.LastViewpoint, this.CameraManager.Viewpoint);
         if (this.IsBolt)
         {
             Vector3     vector3_1 = new Vector3(2f);
             Vector3     vector3_2 = this.ArtObject.Position + this.CenterOffset;
             BoundingBox box       = new BoundingBox(vector3_2 - vector3_1, vector3_2 + vector3_1);
             foreach (ArtObjectInstance artObjectInstance in (IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values)
             {
                 if (artObjectInstance.ArtObject.ActorType == ActorType.BoltNutBottom && this.SpinSign == -1)
                 {
                     Vector3 vector3_3 = artObjectInstance.ArtObject.Size / 2f + Vector3.Up / 32f;
                     if (new BoundingBox(artObjectInstance.Position - vector3_3, artObjectInstance.Position + vector3_3).Intersects(box))
                     {
                         this.CameraManager.CancelViewTransition();
                         return;
                     }
                 }
                 else if (artObjectInstance.ArtObject.ActorType == ActorType.BoltNutTop && this.SpinSign == 1)
                 {
                     Vector3 vector3_3 = artObjectInstance.Position + Vector3.Up * 3.5f;
                     Vector3 vector3_4 = artObjectInstance.ArtObject.Size / 2f + Vector3.Up / 32f;
                     if (new BoundingBox(vector3_3 - vector3_4, vector3_3 + vector3_4).Intersects(box))
                     {
                         this.CameraManager.CancelViewTransition();
                         return;
                     }
                 }
             }
         }
         if (this.IsTimeswitch && this.SpinSign == -1)
         {
             this.CameraManager.CancelViewTransition();
         }
         else
         {
             if (this.IsBolt)
             {
                 if (this.SpinSign == 1)
                 {
                     SoundEffectExtensions.EmitAt(this.Host.BoltScrew, this.ArtObject.Position);
                 }
                 else
                 {
                     SoundEffectExtensions.EmitAt(this.Host.BoltUnscrew, this.ArtObject.Position);
                 }
             }
             else if (this.IsTimeswitch)
             {
                 SoundEffectExtensions.EmitAt(this.Host.TimeSwitchWind, this.ArtObject.Position);
             }
             else if (this.SpinSign == 1)
             {
                 SoundEffectExtensions.EmitAt(this.Host.ValveScrew, this.ArtObject.Position);
             }
             else
             {
                 SoundEffectExtensions.EmitAt(this.Host.ValveUnscrew, this.ArtObject.Position);
             }
             int num;
             if (!this.GameState.SaveData.ThisLevel.PivotRotations.TryGetValue(this.ArtObject.Id, out num))
             {
                 this.GameState.SaveData.ThisLevel.PivotRotations.Add(this.ArtObject.Id, this.SpinSign);
             }
             else
             {
                 this.GameState.SaveData.ThisLevel.PivotRotations[this.ArtObject.Id] = num + this.SpinSign;
             }
             Viewpoint lastViewpoint = this.CameraManager.LastViewpoint;
             Vector3   vector3_1     = FezMath.ScreenSpaceMask(lastViewpoint);
             Vector3   vector3_2     = FezMath.ForwardVector(lastViewpoint);
             Vector3   vector3_3     = FezMath.DepthMask(lastViewpoint);
             Vector3   vector3_4     = (this.ArtObject.Position + this.CenterOffset) * vector3_3;
             this.OriginalPlayerPosition = this.PlayerManager.Position = this.PlayerManager.Position * vector3_1 + vector3_3 * vector3_4 - vector3_2 * 2f;
             this.OriginalAoRotation     = this.ArtObject.Rotation;
             this.OriginalAoPosition     = this.IsTimeswitch ? this.TimeswitchScrewAo.Position : this.ArtObject.Position;
             if (this.IsTimeswitch)
             {
                 this.OriginalScrewRotation = this.TimeswitchScrewAo.Rotation;
             }
             if (this.AttachedGroup != null)
             {
                 this.OriginalGroupTrilePositions = Enumerable.ToArray <Vector3>(Enumerable.Select <TrileInstance, Vector3>((IEnumerable <TrileInstance>) this.AttachedGroup.Triles, (Func <TrileInstance, Vector3>)(x => x.Position)));
             }
             this.SinceChanged         = TimeSpan.Zero;
             this.State                = SpinAction.Spinning;
             this.PlayerManager.Action = ActionType.PivotTombstone;
             if (this.IsTimeswitch)
             {
                 if (this.SpinSign != 1 || (double)this.ScrewHeight > 0.0)
                 {
                     return;
                 }
                 this.TimeswitchService.OnScrewedOut(this.ArtObject.Id);
             }
             else if (this.SpinSign == -1)
             {
                 this.ValveService.OnUnscrew(this.ArtObject.Id);
             }
             else
             {
                 this.ValveService.OnScrew(this.ArtObject.Id);
             }
         }
     }
 }
示例#9
0
        public void AlterTransition(Viewpoint newTo)
        {
            Viewpoint rotatedView = FezMath.GetRotatedView(FezMath.AsViewpoint(FezMath.OrientationFromDirection(this.directionTransition.Points[0])), FezMath.GetDistance(FezMath.AsViewpoint(FezMath.OrientationFromDirection(this.directionTransition.Points[2])), newTo));
            Vector3   from        = this.predefinedViews[rotatedView].Direction;
            Vector3   to          = this.predefinedViews[newTo].Direction;

            this.directionTransition.Points[0] = from;
            this.directionTransition.Points[1] = DefaultCameraManager.GetIntemediateVector(from, to);
            this.directionTransition.Points[2] = to;
            this.current       = this.predefinedViews[newTo];
            this.lastViewpoint = rotatedView;
            this.viewpoint     = newTo;
        }