Beispiel #1
0
        public override void Update(GameTime gameTime)
        {
            if (this.EngineState.Loading || this.EngineState.InMap || (this.EngineState.Paused || !FezMath.IsOrthographic(this.CameraManager.Viewpoint)))
            {
                return;
            }
            float num1 = float.MaxValue;

            TombstonesHost.TombstoneState tombstoneState1 = (TombstonesHost.TombstoneState)null;
            foreach (TombstonesHost.TombstoneState tombstoneState2 in this.TrackedStones)
            {
                if (tombstoneState2.Update(gameTime.ElapsedGameTime))
                {
                    float num2 = FezMath.Dot(tombstoneState2.ArtObject.Position, FezMath.ForwardVector(this.CameraManager.Viewpoint));
                    if ((double)num2 < (double)num1)
                    {
                        tombstoneState1 = tombstoneState2;
                        num1            = num2;
                    }
                }
            }
            if (tombstoneState1 != null)
            {
                tombstoneState1.GrabOnto();
            }
            if (!this.SkullRotates)
            {
                return;
            }
            this.RotateSkull();
        }
Beispiel #2
0
 private void TryAssembleCube()
 {
     if (this.AssembleScheduled || this.GameState.SaveData.CollectedParts != 8)
     {
         return;
     }
     this.AssembleScheduled = true;
     Waiters.Wait((Func <bool>)(() =>
     {
         if (!this.GameState.Loading && ActionTypeExtensions.AllowsLookingDirectionChange(this.PlayerManager.Action) && (this.SpeechBubble.Hidden && !this.GameState.ForceTimePaused) && (this.PlayerManager.CanControl && !ActionTypeExtensions.DisallowsRespawn(this.PlayerManager.Action) && (this.CameraManager.ViewTransitionReached && !this.PlayerManager.InDoorTransition)))
         {
             return(this.PlayerManager.CarriedInstance == null);
         }
         else
         {
             return(false);
         }
     }), (Action)(() => Waiters.Wait(0.0, (Action)(() =>
     {
         Vector3 local_0 = FezMath.DepthMask(this.CameraManager.Viewpoint);
         Vector3 local_1 = FezMath.ForwardVector(this.CameraManager.Viewpoint);
         TrileInstance local_3 = new TrileInstance((this.PlayerManager.Position + Vector3.UnitY * (float)(Math.Sin(this.timeAcc.TotalSeconds * 3.14159274101257) * 0.100000001490116 + 2.0) - FezMath.HalfVector) * (Vector3.One - local_0) - local_1 * (this.LevelManager.Size / 2f - local_0 * 2f) + local_0 * this.LevelManager.Size / 2f, Enumerable.Last <Trile>((IEnumerable <Trile>) this.LevelManager.TrileSet.Triles.Values, (Func <Trile, bool>)(x => x.ActorSettings.Type == ActorType.CubeShard)).Id);
         this.LevelManager.RestoreTrile(local_3);
         this.LevelMaterializer.CullInstanceIn(local_3);
         this.PlayerManager.ForcedTreasure = local_3;
         this.PlayerManager.Action = ActionType.FindingTreasure;
         this.AssembleScheduled = false;
     }))));
 }
Beispiel #3
0
        public override void Update(GameTime gameTime)
        {
            if (this.EngineState.Loading || this.EngineState.Paused || (this.GameState.InMap || !FezMath.IsOrthographic(this.CameraManager.Viewpoint)) || !this.CameraManager.ActionRunning)
            {
                return;
            }
            float num1 = float.MaxValue;

            PivotsHost.PivotState pivotState1 = (PivotsHost.PivotState)null;
            foreach (PivotsHost.PivotState pivotState2 in this.TrackedPivots)
            {
                if (pivotState2.Update(gameTime.ElapsedGameTime))
                {
                    float num2 = FezMath.Dot(pivotState2.HandleAo.Position, FezMath.ForwardVector(this.CameraManager.Viewpoint));
                    if ((double)num2 < (double)num1)
                    {
                        pivotState1 = pivotState2;
                        num1        = num2;
                    }
                }
            }
            if (pivotState1 == null)
            {
                return;
            }
            pivotState1.Spin();
        }
Beispiel #4
0
        public override void Update(GameTime gameTime)
        {
            if (this.EngineState.Loading || this.EngineState.InMap || (this.EngineState.Paused || !FezMath.IsOrthographic(this.CameraManager.Viewpoint)))
            {
                return;
            }
            float num1 = float.MaxValue;

            ValvesBoltsTimeswitchesHost.ValveState valveState1 = (ValvesBoltsTimeswitchesHost.ValveState)null;
            foreach (ValvesBoltsTimeswitchesHost.ValveState valveState2 in this.TrackedValves)
            {
                if (valveState2.ArtObject.ActorSettings.ShouldMoveToEnd)
                {
                    valveState2.MoveToEnd();
                }
                if (valveState2.ArtObject.ActorSettings.ShouldMoveToHeight.HasValue)
                {
                    valveState2.MoveToHeight();
                }
                if (valveState2.Update(gameTime.ElapsedGameTime))
                {
                    float num2 = FezMath.Dot(valveState2.ArtObject.Position, FezMath.ForwardVector(this.CameraManager.Viewpoint));
                    if ((double)num2 < (double)num1)
                    {
                        valveState1 = valveState2;
                        num1        = num2;
                    }
                }
            }
            if (valveState1 == null)
            {
                return;
            }
            valveState1.GrabOnto();
        }
Beispiel #5
0
            private void Rotate()
            {
                Vector3 vector3 = this.ArtObject.ActorSettings.RotationCenter;

                if (!this.ArtObject.ActorSettings.OffCenter)
                {
                    vector3 = this.ArtObject.Position;
                }
                Quaternion fromAxisAngle = Quaternion.CreateFromAxisAngle(FezMath.ForwardVector(this.ArtObject.ActorSettings.SpinView), 1.570796f);

                TrileInstance[] trileInstanceArray = this.Triles.ToArray();
                foreach (TrileInstance instance in trileInstanceArray)
                {
                    Vector3 a = Vector3.Transform(instance.Position + FezMath.HalfVector - vector3, fromAxisAngle) + vector3 - FezMath.HalfVector;
                    if (!FezMath.AlmostEqual(a, instance.Position))
                    {
                        this.LevelManager.ClearTrile(instance, true);
                        instance.Position = a;
                    }
                }
                foreach (TrileInstance instance in trileInstanceArray)
                {
                    this.LevelManager.UpdateInstance(instance);
                }
            }
Beispiel #6
0
        public TrileInstance ActualInstanceAt(Vector3 position)
        {
            Vector3          vector3             = FezMath.ForwardVector(this.CameraManager.Viewpoint);
            bool             depthIsZ            = (double)vector3.Z != 0.0;
            bool             flag                = depthIsZ;
            int              forwardSign         = depthIsZ ? (int)vector3.Z : (int)vector3.X;
            Vector3          screenSpacePosition = new Vector3(flag ? position.X : position.Z, position.Y, depthIsZ ? position.Z : position.X);
            TrileEmplacement emplacement         = new TrileEmplacement((int)Math.Floor((double)position.X), (int)Math.Floor((double)position.Y), (int)Math.Floor((double)position.Z));
            float            num = FezMath.Frac(screenSpacePosition.Z);

            LevelManager.QueryResult queryResult;
            TrileInstance            trileInstance = this.OffsetInstanceAt(emplacement, screenSpacePosition, depthIsZ, forwardSign, false, false, QueryOptions.None, out queryResult);

            if (trileInstance != null)
            {
                return(trileInstance);
            }
            if ((double)num >= 0.5)
            {
                return(this.OffsetInstanceAt(emplacement.GetOffset(depthIsZ ? 0 : 1, 0, depthIsZ ? 1 : 0), screenSpacePosition, depthIsZ, forwardSign, false, false, QueryOptions.None, out queryResult));
            }
            else
            {
                return(this.OffsetInstanceAt(emplacement.GetOffset(depthIsZ ? 0 : -1, 0, depthIsZ ? -1 : 0), screenSpacePosition, depthIsZ, forwardSign, false, false, QueryOptions.None, out queryResult));
            }
        }
Beispiel #7
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);
 }
Beispiel #8
0
 public void Rotate(bool clockwise, int turns)
 {
     this.SpinSign = clockwise ? 1 : -1;
     this.Turns    = turns;
     foreach (TrileInstance instance in this.Group.Triles)
     {
         this.LevelMaterializer.UnregisterViewedInstance(instance);
         if (instance.InstanceId == -1)
         {
             this.LevelMaterializer.CullInstanceInNoRegister(instance);
         }
         instance.SkipCulling = true;
     }
     this.LevelMaterializer.CommitBatchesIfNeeded();
     this.RecordStates();
     for (int index = 0; index < this.AttachedArtObjects.Length; ++index)
     {
         this.AttachedAoRotations[index] = this.AttachedArtObjects[index].Rotation;
         this.AttachedAoOrigins[index]   = this.AttachedArtObjects[index].Position;
     }
     this.HeldOnto   = this.Group.Triles.Contains(this.PlayerManager.HeldInstance);
     this.GroundedOn = this.PlayerManager.Grounded && this.TopLayer.Contains(this.PlayerManager.Ground.First);
     if (this.GroundedOn || this.HeldOnto)
     {
         this.PlayerManager.IsOnRotato = true;
     }
     this.OriginalForward        = FezMath.ForwardVector(this.CameraManager.Viewpoint);
     this.OriginalPlayerPosition = this.PlayerManager.Position;
     this.Action = SpinAction.Spinning;
     if (this.sSpin == null)
     {
         return;
     }
     SoundEffectExtensions.EmitAt(this.sSpin, this.Center, false, RandomHelper.Centered(0.100000001490116), false).FadeDistance = 50f;
 }
Beispiel #9
0
 private void ScheduleHit()
 {
     this.wutex2 = (IWaiter)null;
     this.wutex1 = Waiters.Wait(0.25, (Action)(() =>
     {
         Waiters.Wait(0.25, (Action)(() => this.wutex1 = (IWaiter)null));
         this.PlayerManager.Action = ActionType.HitBell;
         this.PlayerManager.Animation.Timing.Restart();
         this.SinceHit = TimeSpan.Zero;
         SoundEffectExtensions.EmitAt(this.sBellHit[(int)(this.CameraManager.Viewpoint - 1)], this.BellAo.Position);
         this.SoundManager.FadeVolume(0.25f, 1f, 2f);
         this.AngularVelocity += new Vector2(-FezMath.Dot(FezMath.ForwardVector(this.CameraManager.Viewpoint), Vector3.UnitZ), FezMath.Dot(FezMath.ForwardVector(this.CameraManager.Viewpoint), Vector3.UnitX)) * 0.075f;
         if (this.Solved)
         {
             return;
         }
         if (this.LastHit != Viewpoint.None && this.LastHit != this.CameraManager.Viewpoint)
         {
             this.Hits[this.CameraManager.Viewpoint] = 0;
         }
         this.LastHit = this.CameraManager.Viewpoint;
         Dictionary <Viewpoint, int> local_1;
         Viewpoint local_2;
         (local_1 = this.Hits)[local_2 = this.CameraManager.Viewpoint] = local_1[local_2] + 1;
         if (!Enumerable.All <KeyValuePair <Viewpoint, int> >((IEnumerable <KeyValuePair <Viewpoint, int> >) this.Hits, (Func <KeyValuePair <Viewpoint, int>, bool>)(kvp => kvp.Value == this.ExpectedHits[kvp.Key])))
         {
             return;
         }
         this.Solved = true;
         this.GameState.SaveData.ThisLevel.InactiveArtObjects.Add(this.BellAo.Id);
         this.LevelService.ResolvePuzzle();
         ServiceHelper.AddComponent((IGameComponent) new GlitchyDespawner(this.Game, this.BellAo, this.OriginalPosition));
     }));
     this.wutex1.AutoPause = true;
 }
Beispiel #10
0
 protected override bool Act(TimeSpan elapsed)
 {
     if (this.PlayerManager.HeldInstance == null)
     {
         this.PlayerManager.Action = ActionType.Idle;
         return(false);
     }
     else
     {
         if (this.PlayerManager.HeldInstance.PhysicsState != null)
         {
             this.camOrigin += this.PlayerManager.HeldInstance.PhysicsState.Velocity;
         }
         Vector3 vector3_1 = FezMath.SideMask(this.CameraManager.Viewpoint);
         Vector3 vector3_2 = FezMath.DepthMask(this.CameraManager.Viewpoint);
         Vector3 vector3_3 = FezMath.ForwardVector(this.CameraManager.Viewpoint);
         this.PlayerManager.Position = this.PlayerManager.Position * vector3_1 + this.PlayerManager.HeldInstance.Center * (Vector3.UnitY + vector3_2) + vector3_3 * (float)-(0.5 + (double)this.PlayerManager.Size.X / 2.0) + this.PlayerManager.HeldInstance.Trile.Size.Y / 2f * Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor);
         this.PlayerManager.Position = this.PlayerManager.Position * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) + this.PlayerManager.HeldInstance.Center * vector3_2 + vector3_3 * -(this.PlayerManager.HeldInstance.TransformedSize / 2f + this.PlayerManager.Size.X * vector3_2 / 4f);
         this.PhysicsManager.HugWalls((IPhysicsEntity)this.PlayerManager, false, false, true);
         Vector3 vector3_4 = this.PlayerManager.Size.Y / 2f * Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor);
         if (!this.CameraManager.StickyCam && !this.CameraManager.Constrained)
         {
             this.CameraManager.Center = Vector3.Lerp(this.camOrigin, this.camOrigin - vector3_4, this.PlayerManager.Animation.Timing.NormalizedStep);
         }
         this.PlayerManager.SplitUpCubeCollectorOffset = vector3_4 * (1f - this.PlayerManager.Animation.Timing.NormalizedStep);
         if (!this.PlayerManager.Animation.Timing.Ended)
         {
             return(true);
         }
         this.PlayerManager.SplitUpCubeCollectorOffset = Vector3.Zero;
         this.PlayerManager.Action = ActionType.GrabLedgeBack;
         return(false);
     }
 }
Beispiel #11
0
        private void FillScreenSpaceTile(Point p, IDictionary <Point, Limit> newLimits)
        {
            Vector3 vector3 = FezMath.ForwardVector(this.CameraManager.Viewpoint);
            bool    flag1   = (double)vector3.Z != 0.0;
            bool    flag2   = flag1;
            int     num1    = flag1 ? (int)vector3.Z : (int)vector3.X;
            float   num2    = (float)(((flag1 ? (double)this.Size.Z : (double)this.Size.X) - 1.0) / 2.0);
            int     num3    = (int)((double)num2 + (double)num1 * (double)num2) + num1;
            Limit   limit   = new Limit()
            {
                Start    = (int)((double)num2 - (double)num1 * (double)num2),
                End      = num3,
                NoOffset = true
            };
            TrileEmplacement key   = new TrileEmplacement(flag2 ? p.X : limit.Start, p.Y, flag1 ? limit.Start : p.X);
            bool             flag3 = true;
            bool             flag4 = false;

            while (flag3)
            {
                TrileInstance trileInstance;
                if (this.Triles.TryGetValue(key, out trileInstance))
                {
                    // ISSUE: explicit reference operation
                    // ISSUE: variable of a reference type
                    Limit& local = @limit;
                    // ISSUE: explicit reference operation
                    int num4 = (^ local).NoOffset & trileInstance.Position == trileInstance.Emplacement.AsVector ? 1 : 0;
                    // ISSUE: explicit reference operation
                    (^ local).NoOffset = num4 != 0;
                    int num5 = flag1 ? key.Z : key.X;
                    if (!flag4)
                    {
                        limit.Start = num5;
                        flag4       = true;
                    }
                    limit.End = num5;
                }
                if (flag1)
                {
                    key.Z += num1;
                    flag3  = key.Z != num3;
                }
                else
                {
                    key.X += num1;
                    flag3  = key.X != num3;
                }
            }
            if (limit.End == num3)
            {
                return;
            }
            if (newLimits.ContainsKey(p))
            {
                newLimits.Remove(p);
            }
            newLimits.Add(p, limit);
        }
Beispiel #12
0
 public void CancelViewTransition()
 {
     this.directionTransition     = (Vector3SplineInterpolation)null;
     this.viewpoint               = this.lastViewpoint;
     this.current                 = this.predefinedViews[this.viewpoint];
     this.current.Direction       = -FezMath.ForwardVector(this.viewpoint);
     this.ViewTransitionCancelled = true;
 }
Beispiel #13
0
        private void AlignMesh(Viewpoint viewpoint)
        {
            float   num = this.CameraManager.Radius / SettingsManager.GetViewScale(this.GraphicsDevice);
            Vector3 interpolatedCenter = this.CameraManager.InterpolatedCenter;
            Vector3 vector1            = FezMath.ForwardVector(viewpoint);
            Vector3 vector2            = FezMath.RightVector(viewpoint);

            this.Meshes[viewpoint].Position = new Vector3(0.0f, interpolatedCenter.Y + num / 2f / this.CameraManager.AspectRatio, 0.0f) + interpolatedCenter * FezMath.Abs(vector2) + this.LevelManager.Size / 2f * FezMath.Abs(vector1) + num * vector1;
        }
Beispiel #14
0
        protected override void Begin()
        {
            if (this.DotManager.Owner == this)
            {
                this.DotManager.Burrow();
            }
            IPlayerManager playerManager = this.PlayerManager;
            Vector3        vector3       = playerManager.Velocity * Vector3.UnitY;

            playerManager.Velocity = vector3;
            this.PlayerManager.LookingDirection = HorizontalDirection.Right;
            this.GameState.SaveData.ThisLevel.InactiveTriles.Add(this.doorBottom.Emplacement);
            this.doorBottom.ActorSettings.Inactive = true;
            TrileEmplacement id1 = this.doorBottom.Emplacement + Vector3.UnitY;

            this.doorTop         = this.LevelManager.TrileInstanceAt(ref id1);
            this.sinceOpened     = TimeSpan.FromSeconds(-1.0);
            this.initialPhi      = this.doorBottom.Phi;
            this.initialPosition = this.doorBottom.Position;
            if (this.doorBottom.Trile.ActorSettings.Type == ActorType.Door)
            {
                ++this.GameState.SaveData.ThisLevel.FilledConditions.LockedDoorCount;
                if (this.doorTop.Trile.ActorSettings.Type == ActorType.Door)
                {
                    ++this.GameState.SaveData.ThisLevel.FilledConditions.LockedDoorCount;
                }
                --this.GameState.SaveData.Keys;
                this.GameState.OnHudElementChanged();
            }
            else
            {
                ++this.GameState.SaveData.ThisLevel.FilledConditions.UnlockedDoorCount;
                if (this.doorTop.Trile.ActorSettings.Type == ActorType.UnlockedDoor)
                {
                    ++this.GameState.SaveData.ThisLevel.FilledConditions.UnlockedDoorCount;
                }
            }
            TrileEmplacement id2 = this.doorBottom.Emplacement + FezMath.ForwardVector(this.CameraManager.Viewpoint);

            this.holeBottom = this.LevelManager.TrileInstanceAt(ref id2);
            TrileEmplacement id3 = this.doorTop.Emplacement + FezMath.ForwardVector(this.CameraManager.Viewpoint);

            this.holeTop    = this.LevelManager.TrileInstanceAt(ref id3);
            id3             = this.doorBottom.Emplacement + FezMath.ForwardVector(this.CameraManager.Viewpoint) * 2f;
            this.tempBottom = this.LevelManager.TrileInstanceAt(ref id3);
            id3             = this.doorTop.Emplacement + FezMath.ForwardVector(this.CameraManager.Viewpoint) * 2f;
            this.tempTop    = this.LevelManager.TrileInstanceAt(ref id3);
            if (this.tempBottom != null)
            {
                this.LevelManager.ClearTrile(this.tempBottom);
            }
            if (this.tempTop != null)
            {
                this.LevelManager.ClearTrile(this.tempTop);
            }
            SoundEffectExtensions.EmitAt(this.turnSound, this.PlayerManager.Position);
        }
Beispiel #15
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);
        }
Beispiel #16
0
 protected override void Begin()
 {
     SoundEffectExtensions.Emit(this.SwooshRight);
     this.originalForward = FezMath.ForwardVector(this.CameraManager.Viewpoint);
     this.CameraManager.ChangeViewpoint(FezMath.GetRotatedView(this.CameraManager.Viewpoint, 2));
     this.PlayerManager.LookingDirection = HorizontalDirection.Right;
     this.PlayerManager.Velocity         = Vector3.Zero;
     this.originalPosition = this.PlayerManager.Position;
     this.distanceToCover  = FezMath.Dot(this.LevelManager.NearestTrile(this.PlayerManager.Ground.First.Center, QueryOptions.None, new Viewpoint?(this.CameraManager.Viewpoint)).Deep.Center - this.originalPosition, this.originalForward);
 }
Beispiel #17
0
        private TrileInstance IsOnLadder(out ClimbingApproach approach)
        {
            Vector3       b              = FezMath.ForwardVector(this.CameraManager.Viewpoint);
            Vector3       vector3        = FezMath.RightVector(this.CameraManager.Viewpoint);
            float         num1           = float.MaxValue;
            bool          flag1          = false;
            TrileInstance trileInstance1 = (TrileInstance)null;
            bool          flag2          = true;

            if (this.currentApproach == ClimbingApproach.None)
            {
                NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.PlayerManager.Center, this.PlayerManager.Background ? QueryOptions.Background : QueryOptions.None);
                flag2 = nearestTriles.Surface != null && nearestTriles.Surface.Trile.ActorSettings.Type == ActorType.Ladder;
            }
            foreach (NearestTriles nearestTriles in this.PlayerManager.AxisCollision.Values)
            {
                if (nearestTriles.Surface != null && this.TestLadderCollision(nearestTriles.Surface, true))
                {
                    TrileInstance trileInstance2 = nearestTriles.Surface;
                    float         num2           = FezMath.Dot(trileInstance2.Position, b);
                    if (flag2 && (double)num2 < (double)num1)
                    {
                        num1           = num2;
                        trileInstance1 = trileInstance2;
                    }
                }
            }
            if (trileInstance1 == null)
            {
                foreach (NearestTriles nearestTriles in this.PlayerManager.AxisCollision.Values)
                {
                    if (nearestTriles.Surface != null && this.TestLadderCollision(nearestTriles.Surface, false))
                    {
                        TrileInstance trileInstance2 = nearestTriles.Surface;
                        float         num2           = FezMath.Dot(trileInstance2.Position, b);
                        if (flag2 && (double)num2 < (double)num1)
                        {
                            flag1          = true;
                            num1           = num2;
                            trileInstance1 = trileInstance2;
                        }
                    }
                }
            }
            if (trileInstance1 != null)
            {
                float num2 = FezMath.Dot(FezMath.AsVector(FezMath.OrientationFromPhi(FezMath.WrapAngle(FezMath.ToPhi(trileInstance1.Trile.ActorSettings.Face) + trileInstance1.Phi))), flag1 ? vector3 : b);
                approach = !flag1 ? ((double)num2 > 0.0 ? ClimbingApproach.Front : ClimbingApproach.Back) : ((double)num2 > 0.0 ? ClimbingApproach.Left : ClimbingApproach.Right);
            }
            else
            {
                approach = ClimbingApproach.None;
            }
            return(trileInstance1);
        }
Beispiel #18
0
            private void StartCrumbling()
            {
                SoundEffectExtensions.EmitAt(this.Host.sCrumble, this.OriginalCenter, RandomHelper.Centered(0.00999999977648258));
                Vector3 vector3_1 = FezMath.SideMask(this.CameraManager.Viewpoint);
                Vector3 vector3_2 = FezMath.ForwardVector(this.CameraManager.Viewpoint);
                bool    flag1     = (double)vector3_1.X != 0.0;
                bool    flag2     = flag1;
                int     num       = flag2 ? (int)vector3_2.Z : (int)vector3_2.X;
                Point   key       = new Point(flag1 ? this.Instance.Emplacement.X : this.Instance.Emplacement.Z, this.Instance.Emplacement.Y);

                this.LevelManager.WaitForScreenInvalidation();
                Limit limit;

                if (this.LevelManager.ScreenSpaceLimits.TryGetValue(key, out limit))
                {
                    limit.End += num;
                    TrileEmplacement id = new TrileEmplacement(flag1 ? key.X : limit.Start, key.Y, flag2 ? limit.Start : key.X);
                    while ((flag2 ? id.Z : id.X) != limit.End)
                    {
                        TrileInstance toRemove = this.LevelManager.TrileInstanceAt(ref id);
                        if (toRemove != null && !toRemove.Hidden && toRemove.Trile.ActorSettings.Type == ActorType.Crumbler)
                        {
                            toRemove.Hidden = true;
                            this.LevelMaterializer.CullInstanceOut(toRemove);
                            this.InstancesToClear.Add(toRemove);
                            ITrixelParticleSystems      particleSystems = this.ParticleSystems;
                            CrumblersHost.CrumblerState crumblerState   = this;
                            Game game = ServiceHelper.Game;
                            TrixelParticleSystem.Settings settings = new TrixelParticleSystem.Settings()
                            {
                                BaseVelocity      = Vector3.Zero,
                                Energy            = 0.1f,
                                ParticleCount     = (int)(20.0 / (double)this.InstancesToClear.Count),
                                GravityModifier   = 0.6f,
                                Crumble           = true,
                                ExplodingInstance = toRemove
                            };
                            TrixelParticleSystem trixelParticleSystem1;
                            TrixelParticleSystem trixelParticleSystem2 = trixelParticleSystem1 = new TrixelParticleSystem(game, settings);
                            crumblerState.System = trixelParticleSystem1;
                            TrixelParticleSystem system = trixelParticleSystem2;
                            particleSystems.Add(system);
                        }
                        if (flag2)
                        {
                            id.Z += num;
                        }
                        else
                        {
                            id.X += num;
                        }
                    }
                }
                Waiters.Wait(1.0, new Action(this.ClearTriles)).AutoPause = true;
            }
Beispiel #19
0
        protected override void DollyZoom()
        {
            float viewScale = SettingsManager.GetViewScale(this.GraphicsDevice);

            if (!this.GameState.InFpsMode)
            {
                base.DollyZoom();
            }
            else
            {
                bool  flag   = FezMath.IsOrthographic(this.viewpoint);
                float amount = (double)this.directionTransition.TotalStep == 0.0 ? 1.0 / 1000.0 : this.directionTransition.TotalStep;
                float num1   = MathHelper.Lerp(flag ? GameCameraManager.FirstPersonFov : 0.0f, flag ? 0.0f : GameCameraManager.FirstPersonFov, amount);
                float num2   = this.radiusBeforeTransition;
                if (this.DollyZoomOut)
                {
                    num2 = this.radiusBeforeTransition + (float)((1.0 - (double)Easing.EaseIn((double)amount, EasingType.Quadratic)) * 15.0);
                }
                float num3 = (float)((double)num2 / (double)this.AspectRatio / (2.0 * Math.Tan((double)num1 / 2.0))) / viewScale;
                if (this.directionTransition.Reached)
                {
                    this.ProjectionTransition = false;
                    if (!flag)
                    {
                        this.predefinedViews[this.lastViewpoint].Direction = -FezMath.ForwardVector(this.lastViewpoint);
                        this.current.Radius = 0.1f;
                    }
                    else
                    {
                        this.current.Radius      = this.radiusBeforeTransition;
                        this.NearPlane           = 0.1f;
                        this.FarPlane            = 500f;
                        this.GameState.InFpsMode = false;
                    }
                    this.FogManager.Density = this.LevelManager.Sky == null ? 0.0f : this.LevelManager.Sky.FogDensity;
                    this.DollyZoomOut       = false;
                    this.RebuildProjection();
                    this.SnapInterpolation();
                }
                else
                {
                    this.FogManager.Density = (this.LevelManager.Sky == null ? 0.0f : this.LevelManager.Sky.FogDensity) * Easing.EaseIn(flag ? 1.0 - (double)amount : (double)amount, EasingType.Quadratic);
                    float num4 = (float)((double)num3 * (flag ? (double)amount : 1.0 - (double)amount) + 0.100000001490116);
                    this.NearPlane   = Math.Max(0.1f, 0.1f + num4 - num2);
                    this.FarPlane    = Math.Max(num4 + this.NearPlane, 499.9f);
                    this.FieldOfView = num1;
                    this.projection  = Matrix.CreatePerspectiveFieldOfView(this.FieldOfView, this.AspectRatio, this.NearPlane, this.FarPlane);
                    this.OnProjectionChanged();
                    this.current.Radius = num4;
                    this.view           = Matrix.CreateLookAt(this.current.Radius * this.current.Direction + this.current.Center, this.current.Center, Vector3.UnitY);
                    this.OnViewChanged();
                }
            }
        }
Beispiel #20
0
        private void PauseGroupOverlaps(bool force)
        {
            if (!force && this.GameState.Loading || (!FezMath.IsOrthographic(this.CameraManager.Viewpoint) || this.LevelManager.PickupGroups.Count == 0))
            {
                return;
            }
            Vector3 b1      = FezMath.ForwardVector(this.CameraManager.Viewpoint);
            Vector3 b2      = FezMath.SideMask(this.CameraManager.Viewpoint);
            Vector3 vector3 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);

            foreach (TrileGroup trileGroup in Enumerable.Distinct <TrileGroup>((IEnumerable <TrileGroup>) this.LevelManager.PickupGroups.Values))
            {
                float num      = float.MaxValue;
                float?nullable = new float?();
                foreach (TrileInstance trileInstance in trileGroup.Triles)
                {
                    num = Math.Min(num, FezMath.Dot(trileInstance.Center, b1));
                    if (!trileInstance.PhysicsState.Puppet)
                    {
                        nullable = new float?(FezMath.Dot(trileInstance.Center, b2));
                    }
                }
                foreach (PickupState pickupState1 in this.PickupStates)
                {
                    if (pickupState1.Group == trileGroup)
                    {
                        TrileInstance trileInstance = pickupState1.Instance;
                        bool          flag          = !FezMath.AlmostEqual(FezMath.Dot(trileInstance.Center, b1), num);
                        trileInstance.PhysicsState.Paused = flag;
                        if (flag)
                        {
                            trileInstance.PhysicsState.Puppet = true;
                            pickupState1.LastMovement         = Vector3.Zero;
                        }
                        else
                        {
                            pickupState1.VisibleOverlapper = (PickupState)null;
                            foreach (PickupState pickupState2 in this.PickupStates)
                            {
                                if (FezMath.AlmostEqual(pickupState2.Instance.Center * vector3, pickupState1.Instance.Center * vector3))
                                {
                                    pickupState2.VisibleOverlapper = pickupState1;
                                }
                            }
                            if (nullable.HasValue && FezMath.AlmostEqual(FezMath.Dot(trileInstance.Center, b2), nullable.Value))
                            {
                                trileInstance.PhysicsState.Puppet = false;
                            }
                        }
                    }
                }
            }
        }
Beispiel #21
0
        private void SpawnDust(TrileInstance instance, float opacity, AnimatedTexture animation, bool onRight, bool onLeft)
        {
            float num1 = (float)((double)instance.Center.Y - (double)instance.TransformedSize.Y / 2.0 * (double)Math.Sign(this.CollisionManager.GravityFactor) + (double)animation.FrameHeight / 32.0 * (double)Math.Sign(this.CollisionManager.GravityFactor));
            float num2 = (float)((double)FezMath.Dot(instance.TransformedSize, FezMath.SideMask(this.CameraManager.Viewpoint)) / 2.0 + (double)animation.FrameWidth / 32.0 * 2.0 / 3.0);

            if (ActorTypeExtensions.IsBomb(instance.Trile.ActorSettings.Type))
            {
                num2 -= 0.25f;
            }
            opacity = 1f;
            Vector3 vector3_1 = FezMath.RightVector(this.CameraManager.Viewpoint);
            Vector3 vector3_2 = FezMath.ForwardVector(this.CameraManager.Viewpoint);
            bool    b         = (double)this.CollisionManager.GravityFactor < 0.0;

            if (onRight)
            {
                BackgroundPlane backgroundPlane;
                this.LevelManager.AddPlane(backgroundPlane = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, animation)
                {
                    OriginalRotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, (float)FezMath.AsNumeric(b) * 3.141593f),
                    Doublesided      = true,
                    Loop             = false,
                    Opacity          = opacity,
                    Timing           =
                    {
                        Step = 0.0f
                    }
                });
                backgroundPlane.Position  = instance.Center * FezMath.XZMask + vector3_1 * num2 + num1 * Vector3.UnitY - vector3_2;
                backgroundPlane.Billboard = true;
            }
            if (!onLeft)
            {
                return;
            }
            BackgroundPlane backgroundPlane1;

            this.LevelManager.AddPlane(backgroundPlane1 = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, animation)
            {
                OriginalRotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 3.141593f) * Quaternion.CreateFromAxisAngle(Vector3.UnitX, (float)FezMath.AsNumeric(b) * 3.141593f),
                Doublesided      = true,
                Loop             = false,
                Opacity          = opacity,
                Timing           =
                {
                    Step = 0.0f
                }
            });
            backgroundPlane1.Position  = instance.Center * FezMath.XZMask - vector3_1 * num2 + num1 * Vector3.UnitY - vector3_2;
            backgroundPlane1.Billboard = true;
        }
Beispiel #22
0
        private void DestroyNeighborhood(TrileInstance instance, BombsHost.BombState state)
        {
            Vector3 vector3_1 = FezMath.SideMask(this.CameraManager.Viewpoint);
            Vector3 vector3_2 = FezMath.ForwardVector(this.CameraManager.Viewpoint);
            bool    flag1     = (double)vector3_1.X != 0.0;
            bool    flag2     = flag1;
            int     num       = flag2 ? (int)vector3_2.Z : (int)vector3_2.X;
            Point   point1    = new Point(flag1 ? instance.Emplacement.X : instance.Emplacement.Z, instance.Emplacement.Y);

            Point[] pointArray = instance.Trile.ActorSettings.Type == ActorType.BigBomb ? BombsHost.BigBombOffsets : BombsHost.SmallBombOffsets;
            this.LevelManager.WaitForScreenInvalidation();
            foreach (Point point2 in pointArray)
            {
                bool  chainsploded = false;
                bool  needsRecull  = false;
                Point key          = new Point(point1.X + point2.X, point1.Y + point2.Y);
                Limit limit;
                if (this.LevelManager.ScreenSpaceLimits.TryGetValue(key, out limit))
                {
                    limit.End += num;
                    TrileEmplacement id = new TrileEmplacement(flag1 ? key.X : limit.Start, key.Y, flag2 ? limit.Start : key.X);
                    while ((flag2 ? id.Z : id.X) != limit.End)
                    {
                        TrileInstance nearestNeighbor = this.LevelManager.TrileInstanceAt(ref id);
                        if (!this.TryExplodeAt(state, nearestNeighbor, ref chainsploded, ref needsRecull))
                        {
                            if (flag2)
                            {
                                id.Z += num;
                            }
                            else
                            {
                                id.X += num;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    if (needsRecull)
                    {
                        this.LevelManager.RecullAt(id);
                        this.TrixelParticleSystems.UnGroundAll();
                    }
                }
            }
        }
Beispiel #23
0
        private bool TestObstruction(TrileInstance trile, float hitDistance, Vector3 hitStart, bool isBlackHole)
        {
            Vector3 b = FezMath.ForwardVector(this.CameraManager.Viewpoint);

            if (this.PlayerManager.Background)
            {
                b *= -1f;
            }
            if (trile != null && trile.Enabled && !trile.Trile.Immaterial && (trile.Trile.ActorSettings.Type != ActorType.Hole || isBlackHole))
            {
                return((double)FezMath.Dot(trile.Emplacement.AsVector + Vector3.One / 2f + b * -0.5f - hitStart, b) <= (double)hitDistance + 0.25);
            }
            else
            {
                return(false);
            }
        }
Beispiel #24
0
        private bool TestObstruction(Vector3 hitStart, float hitDistance)
        {
            Vector3 b       = FezMath.ForwardVector(this.CameraManager.Viewpoint);
            Vector3 vector3 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);

            foreach (TrileInstance trileInstance in (IEnumerable <TrileInstance>) this.LevelManager.Triles.Values)
            {
                if (trileInstance.InstanceId != -1 && (double)((trileInstance.Center - hitStart) * vector3).LengthSquared() < 0.5)
                {
                    Trile trile = trileInstance.Trile;
                    if (trileInstance.Enabled && !trile.Immaterial && !trile.SeeThrough)
                    {
                        return((double)FezMath.Dot(trileInstance.Position + Vector3.One / 2f + b * -0.5f - hitStart, b) <= (double)hitDistance + 0.25);
                    }
                }
            }
            return(false);
        }
Beispiel #25
0
            public void Update()
            {
                Vector3     position    = this.MailboxAo.Position;
                Vector3     center      = this.PlayerManager.Center;
                Vector3     b1          = FezMath.SideMask(this.CameraManager.Viewpoint);
                Vector3     b2          = FezMath.ForwardVector(this.CameraManager.Viewpoint);
                Vector3     vector3     = new Vector3(FezMath.Dot(position, b1), position.Y, 0.0f);
                BoundingBox boundingBox = new BoundingBox(vector3 - new Vector3(0.5f, 0.75f, 0.5f), vector3 + new Vector3(0.5f, 0.75f, 0.5f));
                Vector3     point       = new Vector3(FezMath.Dot(center, b1), center.Y, 0.0f);

                if ((double)FezMath.Dot(center, b2) >= (double)FezMath.Dot(this.MailboxAo.Position, b2) || boundingBox.Contains(point) == ContainmentType.Disjoint || this.InputManager.GrabThrow != FezButtonState.Pressed)
                {
                    return;
                }
                this.GameState.SaveData.ThisLevel.InactiveArtObjects.Add(this.MailboxAo.Id);
                ServiceHelper.AddComponent((IGameComponent) new LetterViewer(ServiceHelper.Game, this.MailboxAo.ActorSettings.TreasureMapName));
                this.GomezService.OnReadMail();
                this.Empty = true;
            }
Beispiel #26
0
        protected override bool Act(TimeSpan elapsed)
        {
            if (this.PlayerManager.HeldInstance.PhysicsState != null)
            {
                this.PlayerManager.Position += this.PlayerManager.HeldInstance.PhysicsState.Velocity;
            }
            if (!this.PlayerManager.Animation.Timing.Ended)
            {
                return(true);
            }
            this.PlayerManager.Action = ActionType.GrabLedgeBack;
            Vector3       vector3_1    = FezMath.SideMask(this.CameraManager.Viewpoint);
            Vector3       vector3_2    = FezMath.DepthMask(this.CameraManager.Viewpoint);
            Vector3       vector3_3    = FezMath.ForwardVector(this.CameraManager.Viewpoint);
            TrileInstance heldInstance = this.PlayerManager.HeldInstance;

            this.PlayerManager.Position = this.PlayerManager.Position * vector3_1 + heldInstance.Center * (Vector3.UnitY + vector3_2) + vector3_3 * (float)-(0.5 + (double)this.PlayerManager.Size.X / 4.0) + Vector3.UnitY * 8f / 16f * (float)Math.Sign(this.CollisionManager.GravityFactor);
            this.PlayerManager.ForceOverlapsDetermination();
            this.PhysicsManager.HugWalls((IPhysicsEntity)this.PlayerManager, false, false, true);
            this.PlayerManager.HeldInstance = this.PlayerManager.AxisCollision[VerticalDirection.Down].Deep;
            return(false);
        }
Beispiel #27
0
 public LongRunningAction Pulse(int id, string textureName)
 {
     // ISSUE: object of a compiler-generated type is created
     // ISSUE: variable of a compiler-generated type
     ArtObjectService.\u003C\u003Ec__DisplayClass12 cDisplayClass12 = new ArtObjectService.\u003C\u003Ec__DisplayClass12();
     // ISSUE: reference to a compiler-generated field
     cDisplayClass12.\u003C\u003E4__this = this;
     // ISSUE: reference to a compiler-generated field
     cDisplayClass12.lightPlane = new BackgroundPlane(this.LevelMaterializer.StaticPlanesMesh, textureName, false)
     {
         Position            = this.LevelManager.ArtObjects[id].Position - FezMath.ForwardVector(this.CameraManager.Viewpoint) * 10f,
         Rotation            = this.CameraManager.Rotation,
         AllowOverbrightness = true,
         LightMap            = true,
         AlwaysOnTop         = true,
         PixelatedLightmap   = true
     };
     // ISSUE: reference to a compiler-generated field
     this.LevelManager.AddPlane(cDisplayClass12.lightPlane);
     // ISSUE: reference to a compiler-generated method
     return(new LongRunningAction(new Func <float, float, bool>(cDisplayClass12.\u003CPulse\u003Eb__11)));
 }
Beispiel #28
0
 protected override void TestConditions()
 {
     switch (this.PlayerManager.Action)
     {
     case ActionType.Jumping:
     case ActionType.Falling:
         if (!FezButtonStateExtensions.IsDown(this.InputManager.Up))
         {
             break;
         }
         FaceOrientation face           = FezMath.VisibleOrientation(this.CameraManager.Viewpoint);
         TrileInstance   trileInstance1 = this.PlayerManager.AxisCollision[VerticalDirection.Up].Deep;
         TrileInstance   trileInstance2 = this.PlayerManager.AxisCollision[VerticalDirection.Down].Deep;
         if (trileInstance1 != null && trileInstance1.GetRotatedFace(face) == CollisionType.AllSides || (trileInstance2 == null || trileInstance2.GetRotatedFace(face) != CollisionType.TopOnly) || BoxCollisionResultExtensions.AnyHit(this.CollisionManager.CollideEdge(trileInstance2.Center, Vector3.Down * (float)Math.Sign(this.CollisionManager.GravityFactor), this.PlayerManager.Size * FezMath.XZMask / 2f, Direction2D.Vertical)))
         {
             break;
         }
         TrileInstance trileInstance3 = this.PlayerManager.AxisCollision[VerticalDirection.Down].Surface;
         if (trileInstance3 != null && ActorTypeExtensions.IsClimbable(trileInstance3.Trile.ActorSettings.Type) || !trileInstance2.Enabled || this.PlayerManager.Action == ActionType.Jumping && (double)((trileInstance2.Center - this.PlayerManager.LeaveGroundPosition) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint)).Length() < 1.25)
         {
             break;
         }
         this.PlayerManager.Action = ActionType.GrabLedgeBack;
         Vector3 vector3_1 = FezMath.DepthMask(this.CameraManager.Viewpoint);
         Vector3 vector3_2 = FezMath.SideMask(this.CameraManager.Viewpoint);
         Vector3 vector3_3 = FezMath.ForwardVector(this.CameraManager.Viewpoint);
         this.PlayerManager.HeldInstance = trileInstance2;
         IPlayerManager playerManager = this.PlayerManager;
         Vector3        vector3_4     = playerManager.Velocity * vector3_2 * 0.5f;
         playerManager.Velocity      = vector3_4;
         this.PlayerManager.Position = this.PlayerManager.Position * vector3_2 + trileInstance2.Center * (Vector3.UnitY + vector3_1) + vector3_3 * -(this.PlayerManager.HeldInstance.TransformedSize / 2f + this.PlayerManager.Size.X * vector3_1 / 4f) + this.PlayerManager.HeldInstance.Trile.Size.Y / 2f * Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor);
         Waiters.Wait(0.1, (Action)(() =>
         {
             SoundEffectExtensions.EmitAt(this.sound, this.PlayerManager.Position);
             this.PlayerManager.Velocity = Vector3.Zero;
         }));
         break;
     }
 }
Beispiel #29
0
        protected void UpdateRotation()
        {
            Quaternion rotation = this.CameraManager.Rotation;

            if (this.oldRotation == rotation && this.oldDirection == this.LookingDirection)
            {
                return;
            }
            this.oldRotation  = rotation;
            this.oldDirection = this.LookingDirection;
            int num = -Math.Sign(FezMath.Dot(this.CameraManager.InverseView.Right, FezMath.Sign(this.Npc.DestinationOffset)));

            if (this.LookingDirection == HorizontalDirection.Left)
            {
                num *= -1;
            }
            if (num != 0)
            {
                rotation *= FezMath.QuaternionFromPhi((float)(3.14159274101257 * ((double)num / 2.0 + 0.5)));
            }
            this.Group.Rotation = rotation;
            if (!FezMath.IsOrthographic(this.CameraManager.Viewpoint))
            {
                return;
            }
            this.InBackground = false;
            Vector3       b             = FezMath.ForwardVector(this.CameraManager.Viewpoint);
            NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.Position, QueryOptions.Simple);
            TrileInstance trileInstance = nearestTriles.Surface ?? nearestTriles.Deep;

            if (trileInstance == null)
            {
                return;
            }
            Vector3 a = trileInstance.Center + trileInstance.TransformedSize / 2f * -b;

            this.InBackground = (double)FezMath.Dot(this.Position, b) > (double)FezMath.Dot(a, b);
        }
Beispiel #30
0
 protected override void TryTalk()
 {
     switch (this.PlayerManager.Action)
     {
     case ActionType.Idle:
     case ActionType.Walking:
     case ActionType.Running:
     case ActionType.Sliding:
         if (this.PlayerManager.Background || !this.SpeechManager.Hidden || this.Npc.ActorType == ActorType.Owl && (this.OwlInvisible || this.CurrentAction == NpcAction.TakeOff || this.CurrentAction == NpcAction.Fly))
         {
             break;
         }
         if (this.Npc.CustomSpeechLine == null)
         {
             if (this.InputManager.CancelTalk != FezButtonState.Pressed)
             {
                 break;
             }
             Vector3     vector3_1   = Vector3.UnitY + (FezMath.SideMask(this.CameraManager.Viewpoint) + FezMath.DepthMask(this.CameraManager.Viewpoint)) * 1.5f;
             BoundingBox boundingBox = new BoundingBox(this.Position - vector3_1, this.Position + vector3_1);
             Vector3     mask        = FezMath.GetMask(FezMath.VisibleAxis(this.CameraManager.Viewpoint));
             Vector3     vector3_2   = FezMath.ForwardVector(this.CameraManager.Viewpoint);
             Ray         ray         = new Ray()
             {
                 Position  = this.PlayerManager.Center * (Vector3.One - mask) - vector3_2 * this.LevelManager.Size,
                 Direction = vector3_2
             };
             float?nullable = boundingBox.Intersects(ray);
             if (!nullable.HasValue || this.TestObstruction(ray.Position, nullable.Value))
             {
                 break;
             }
         }
         this.Talk();
         break;
     }
 }