Esempio n. 1
0
 public override void Update(GameTime gameTime)
 {
     if (this.GameState.Loading)
     {
         return;
     }
     if (FezMath.AlmostEqual(this.PlayerManager.Velocity.Y, 0.0f))
     {
         if (this.eFall != null && !this.eFall.Dead)
         {
             this.eFall.FadeOutAndDie(0.1f);
             this.eFall = (SoundEmitter)null;
         }
     }
     else
     {
         if (this.eFall == null || this.eFall.Dead)
         {
             this.eFall = SoundEffectExtensions.EmitAt(this.sFall, this.PlayerManager.Position, true, 0.0f, 0.0f);
         }
         this.eFall.Position     = this.PlayerManager.Position;
         this.eFall.VolumeFactor = Easing.EaseIn((double)FezMath.Saturate((float)(-(double)this.PlayerManager.Velocity.Y / 0.400000005960464)), EasingType.Quadratic);
     }
     base.Update(gameTime);
 }
Esempio n. 2
0
        public override void Update(GameTime gameTime)
        {
            if (this.ReverseTiming)
            {
                this.sinceStarted -= gameTime.ElapsedGameTime;
                this.sinceStarted -= gameTime.ElapsedGameTime;
            }
            else
            {
                this.sinceStarted += gameTime.ElapsedGameTime;
            }
            float num = Easing.EaseIn(this.sinceStarted.TotalSeconds / 3.0, EasingType.Quartic);

            if (this.HasHorizontalTrails)
            {
                (this.TrailsMesh.Effect as HorizontalTrailsEffect).Timing = (float)this.sinceStarted.TotalSeconds;
            }
            if (!this.FollowCamera)
            {
                this.AdditionalZoom  = (float)FezMath.AsNumeric(this.HasZoomed) + num / 3f;
                this.AdditionalScale = num / 6f;
            }
            if (!this.HasHorizontalTrails && (double)num > 40.0 && !this.Done)
            {
                this.Done = true;
                ServiceHelper.RemoveComponent <StarField>(this);
            }
            if (!this.HasHorizontalTrails || !(this.sinceStarted <= TimeSpan.Zero))
            {
                return;
            }
            this.Enabled      = false;
            this.sinceStarted = TimeSpan.Zero;
        }
Esempio n. 3
0
            private static bool TestFace(ICollection <TrixelEmplacement> subChunk, ICollection <TrixelEmplacement> boxTrixels, Vector3 normal, bool partial, TrixelCluster.Box box, ref int trixelsToRollback)
            {
                Vector3 vector3_1 = FezMath.Abs(normal);
                Vector3 vector2_1 = (double)normal.Z != 0.0 ? Vector3.UnitX : Vector3.UnitZ;
                Vector3 vector2_2 = (double)normal.Z != 0.0 ? Vector3.UnitY : new Vector3(1f, 1f, 0.0f) - vector3_1;
                Vector3 vector3_2 = ((double)Vector3.Dot(normal, Vector3.One) > 0.0 ? box.End.Position : box.Start.Position) * vector3_1;
                int     num1      = (int)Vector3.Dot(box.Start.Position, vector2_1);
                int     num2      = (int)Vector3.Dot(box.End.Position, vector2_1);
                int     num3      = (int)Vector3.Dot(box.Start.Position, vector2_2);
                int     num4      = (int)Vector3.Dot(box.End.Position, vector2_2);

                if (partial)
                {
                    ++num1;
                    --num2;
                }
                for (int index1 = num1; index1 <= num2; ++index1)
                {
                    for (int index2 = num3; index2 <= num4; ++index2)
                    {
                        TrixelEmplacement trixelEmplacement = new TrixelEmplacement((float)index1 * vector2_1 + (float)index2 * vector2_2 + vector3_2);
                        if (!subChunk.Contains(trixelEmplacement))
                        {
                            return(false);
                        }
                        ++trixelsToRollback;
                        boxTrixels.Add(trixelEmplacement);
                    }
                }
                return(true);
            }
Esempio n. 4
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));
            }
        }
Esempio n. 5
0
        private void DoJump()
        {
            bool flag = ActionTypeExtensions.IsClimbingLadder(this.PlayerManager.LastAction) || ActionTypeExtensions.IsClimbingVine(this.PlayerManager.LastAction) || this.PlayerManager.HeldInstance != null;

            if (flag)
            {
                IPlayerManager playerManager = this.PlayerManager;
                Vector3        vector3       = playerManager.Velocity + FezMath.RightVector(this.CameraManager.Viewpoint) * this.InputManager.Movement.X * 0.25f;
                playerManager.Velocity = vector3;
            }
            this.PlayerManager.HeldInstance = (TrileInstance)null;
            if (this.scheduleJump || this.InputManager.Jump == FezButtonState.Pressed)
            {
                SoundEffectExtensions.EmitAt(this.jumpSound, this.PlayerManager.Position);
            }
            float          gravityFactor  = this.CollisionManager.GravityFactor;
            float          num            = (float)((1.32500004768372 + (double)Math.Abs(gravityFactor) * 0.675000011920929) / 2.0) * (float)Math.Sign(gravityFactor);
            IPlayerManager playerManager1 = this.PlayerManager;
            Vector3        vector3_1      = playerManager1.Velocity * FezMath.XZMask;

            playerManager1.Velocity = vector3_1;
            Vector3        vector3_2      = (float)(0.150000005960464 * (double)num * 1.02499997615814 * (flag || this.PlayerManager.Swimming ? 0.774999976158142 : 1.0)) * Vector3.UnitY;
            IPlayerManager playerManager2 = this.PlayerManager;
            Vector3        vector3_3      = playerManager2.Velocity + vector3_2;

            playerManager2.Velocity = vector3_3;
            this.sinceJumped        = TimeSpan.Zero;
            this.GomezService.OnJump();
        }
Esempio n. 6
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();
        }
Esempio n. 7
0
        private void DoLoad(bool dummy)
        {
            this.LevelManager.ChangeLevel(this.NextLevel);
            this.GameState.ScheduleLoadEnd = true;
            this.State = EnterPipe.States.FadeIn;
            Volume volume = Enumerable.FirstOrDefault <Volume>((IEnumerable <Volume>) this.LevelManager.Volumes.Values, (Func <Volume, bool>)(v =>
            {
                int local_0 = v.Id;
                int?local_1 = Enumerable.First <Script>((IEnumerable <Script>) this.LevelManager.Scripts.Values, (Func <Script, bool>)(s => Enumerable.Any <ScriptAction>((IEnumerable <ScriptAction>)s.Actions, (Func <ScriptAction, bool>)(a => a.Operation == "AllowPipeChangeLevel")))).Triggers[0].Object.Identifier;
                if (local_0 == local_1.GetValueOrDefault())
                {
                    return(local_1.HasValue);
                }
                else
                {
                    return(false);
                }
            }));

            if (volume == null)
            {
                throw new InvalidOperationException("Missing pipe volume in destination level!");
            }
            Vector3 a = (volume.From + volume.To) / 2f;

            this.PlayerManager.Action   = ActionType.EnteringPipe;
            this.PlayerManager.Position = a + Vector3.UnitY * 1.25f * (this.Descending ? 1f : -1f);
            this.PlayerManager.Velocity = Vector3.Zero;
            this.PlayerManager.RecordRespawnInformation();
            this.Depth = FezMath.Dot(a, FezMath.DepthMask(this.CameraManager.Viewpoint));
        }
Esempio n. 8
0
        public override void Draw(GameTime gameTime)
        {
            this.sinceStarted += (float)gameTime.ElapsedGameTime.TotalSeconds;
            this.logoAlpha     = (float)(((double)this.sinceStarted - 1.0) / 1.0);
            this.whiteAlpha    = 1f;
            if ((double)this.sinceStarted > 3.0)
            {
                this.logoAlpha = FezMath.Saturate((float)(1.0 - ((double)this.sinceStarted - 3.0) / 0.5));
            }
            if ((double)this.sinceStarted > 3.5)
            {
                this.whiteAlpha = FezMath.Saturate((float)(1.0 - ((double)this.sinceStarted - 4.0) / 0.5));
            }
            this.TRM.DrawFullscreen(new Color(1f, 1f, 1f, this.whiteAlpha));
            Vector2 vector2 = FezMath.Round(new Vector2((float)this.GraphicsDevice.Viewport.Width, (float)this.GraphicsDevice.Viewport.Height) / 2f);

            GraphicsDeviceExtensions.BeginPoint(this.SpriteBatch);
            this.SpriteBatch.Draw(this.PolyLogo, vector2 - FezMath.Round(new Vector2((float)this.PolyLogo.Width, (float)this.PolyLogo.Height) / 2f), new Color(1f, 1f, 1f, this.logoAlpha));
            this.SpriteBatch.End();
            if ((double)this.whiteAlpha != 0.0)
            {
                return;
            }
            ServiceHelper.RemoveComponent <FakeIntro>(this);
        }
Esempio n. 9
0
 public override void Update(GameTime gameTime)
 {
     if (this.GameState.Loading || this.GameState.Paused || (this.GameState.InMap || this.GameState.InMenuCube))
     {
         return;
     }
     this.SinceStarted += (float)gameTime.ElapsedGameTime.TotalSeconds;
     if ((double)this.SinceStarted > 8.0 && (double)this.SinceStarted < 19.0)
     {
         this.SpinSpeed = Easing.EaseIn((double)FezMath.Saturate((float)(((double)this.SinceStarted - 8.0) / 5.0)), EasingType.Sine) * 0.005f;
     }
     else if ((double)this.SinceStarted > 19.0)
     {
         this.SpinSpeed = (float)(0.00499999988824129 + (double)Easing.EaseIn((double)FezMath.Saturate((float)(((double)this.SinceStarted - 19.0) / 20.0)), EasingType.Quadratic) * 0.5);
     }
     if ((double)this.SinceStarted > 33.0 && this.Rings != null)
     {
         this.TrialTimeAccumulator += (float)gameTime.ElapsedGameTime.TotalSeconds;
         this.UpdateRays((float)gameTime.ElapsedGameTime.TotalSeconds);
     }
     if (this.Rings == null)
     {
         return;
     }
     this.Rings[0].Rotation = Quaternion.CreateFromAxisAngle(Vector3.Right, this.SpinSpeed) * this.Rings[0].Rotation;
     this.Rings[1].Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, this.SpinSpeed) * this.Rings[1].Rotation;
     this.Rings[2].Rotation = Quaternion.CreateFromAxisAngle(Vector3.Left, this.SpinSpeed) * this.Rings[2].Rotation;
     this.Rings[3].Rotation = Quaternion.CreateFromAxisAngle(Vector3.Down, this.SpinSpeed) * this.Rings[3].Rotation;
 }
Esempio n. 10
0
        private void RotateViewRight()
        {
            bool flag = this.PlayerManager.Action == ActionType.GrabTombstone;

            if (this.CameraManager.Viewpoint == Viewpoint.Perspective || this.GameState.InMap)
            {
                this.CameraManager.OriginalDirection = Vector3.Transform(this.CameraManager.OriginalDirection, Quaternion.CreateFromAxisAngle(Vector3.Up, 1.570796f));
                if (!this.GameState.InMenuCube && !this.GameState.InMap)
                {
                    this.EmitRight();
                }
            }
            else if (this.CameraManager.ChangeViewpoint(FezMath.GetRotatedView(this.CameraManager.Viewpoint, 1), (flag ? 2f : 1f) * Math.Abs(1f / this.CollisionManager.GravityFactor)) && !flag)
            {
                this.EmitRight();
            }
            if (this.LevelManager.NodeType != LevelNodeType.Lesser || !(this.PlayerManager.AirTime != TimeSpan.Zero))
            {
                return;
            }
            IPlayerManager playerManager = this.PlayerManager;
            Vector3        vector3       = playerManager.Velocity * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);

            playerManager.Velocity = vector3;
        }
Esempio n. 11
0
 private void InitializeShadows()
 {
     if (this.LevelManager.Name == null || this.LevelManager.Sky == null || this.LevelManager.Sky.Shadows == null)
     {
         this.shadowMesh.Texture.Set((Texture)null);
         this.shadowMesh.Enabled = false;
     }
     else
     {
         this.shadowMesh.Enabled  = true;
         this.shadowMesh.Texture  = (Dirtyable <Texture>)((Texture)this.CMProvider.CurrentLevel.Load <Texture2D>("Skies/" + this.LevelManager.Sky.Name + "/" + this.LevelManager.Sky.Shadows));
         this.shadowMesh.Scale    = this.LevelManager.Size + new Vector3(65f, 65f, 65f);
         this.shadowMesh.Position = this.LevelManager.Size / 2f;
         int num1 = 0;
         foreach (Group index in this.axisPerGroup.Keys)
         {
             index.Material = new Material();
             Axis  axis = this.axisPerGroup[index];
             float m11  = FezMath.Dot(this.shadowMesh.Scale, FezMath.GetMask(axis)) / 32f;
             float num2 = this.shadowMesh.Scale.Y / FezMath.Dot(this.shadowMesh.Scale, FezMath.GetMask(axis));
             index.TextureMatrix = (Dirtyable <Matrix?>) new Matrix?(new Matrix(m11, 0.0f, 0.0f, 0.0f, 0.0f, m11 * num2, 0.0f, 0.0f, (float)num1 / 2f, 0.0f, 1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f));
             ++num1;
         }
         this.SineAccumulator = 0.0f;
     }
 }
Esempio n. 12
0
            public bool Update(TimeSpan elapsed)
            {
                this.SinceChanged += elapsed;
                switch (this.State)
                {
                case SpinAction.Idle:
                    Vector3 vector = (this.PlayerManager.Position - this.ArtObject.Position - new Vector3(0.0f, 1f, 0.0f)) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);
                    vector.X += vector.Z;
                    Vector3 vector3 = FezMath.Abs(vector);
                    if (FezMath.AlmostEqual(FezMath.Abs(Vector3.Transform(Vector3.UnitZ, this.ArtObject.Rotation)), FezMath.DepthMask(this.CameraManager.Viewpoint)) && ((double)vector3.X < 0.899999976158142 && (double)vector3.Y < 1.0) && (this.PlayerManager.CarriedInstance == null && this.PlayerManager.Grounded) && (this.PlayerManager.Action != ActionType.GrabTombstone && this.InputManager.GrabThrow == FezButtonState.Pressed && this.PlayerManager.Action != ActionType.ReadingSign))
                    {
                        this.SinceChanged = TimeSpan.Zero;
                        return(true);
                    }
                    else
                    {
                        break;
                    }

                case SpinAction.Spinning:
                    double     num           = FezMath.Saturate(this.SinceChanged.TotalSeconds / 0.75);
                    Quaternion fromAxisAngle = Quaternion.CreateFromAxisAngle(Vector3.UnitY, Easing.EaseIn(num < 0.949999999254942 ? num / 0.949999999254942 : 1.0 + Math.Sin((num - 0.949999999254942) / 0.0500000007450581 * 6.28318548202515 * 2.0) * 0.00999999977648258 * (1.0 - num) / 0.0500000007450581, EasingType.Linear) * 1.570796f * (float)this.SpinSign);
                    this.ArtObject.Rotation     = this.OriginalAoRotation * fromAxisAngle;
                    this.PlayerManager.Position = Vector3.Transform(this.OriginalPlayerPosition - this.ArtObject.Position, fromAxisAngle) + this.ArtObject.Position;
                    if (this.SinceChanged.TotalSeconds >= 0.75)
                    {
                        this.LastViewpoint = FezMath.AsViewpoint(FezMath.OrientationFromDirection(FezMath.MaxClampXZ(Vector3.Transform(Vector3.Forward, this.ArtObject.Rotation))));
                        int count = Enumerable.Count <TombstonesHost.TombstoneState>((IEnumerable <TombstonesHost.TombstoneState>) this.Host.TrackedStones, (Func <TombstonesHost.TombstoneState, bool>)(x => x.LastViewpoint == this.LastViewpoint));
                        this.TombstoneService.UpdateAlignCount(count);
                        if (count > 1)
                        {
                            this.TombstoneService.OnMoreThanOneAligned();
                        }
                        this.Host.StopSkullRotations = count == 4;
                        this.PlayerManager.Action    = ActionType.GrabTombstone;
                        this.PlayerManager.Position += 0.5f * Vector3.UnitY;
                        this.PlayerManager.Velocity  = Vector3.Down;
                        this.PhysicsManager.Update((IComplexPhysicsEntity)this.PlayerManager);
                        this.SinceChanged -= TimeSpan.FromSeconds(0.75);
                        this.State         = SpinAction.Grabbed;
                        break;
                    }
                    else
                    {
                        break;
                    }

                case SpinAction.Grabbed:
                    if (this.PlayerManager.Action != ActionType.GrabTombstone)
                    {
                        this.State = SpinAction.Idle;
                        break;
                    }
                    else
                    {
                        break;
                    }
                }
                return(false);
            }
Esempio n. 13
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();
        }
Esempio n. 14
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);
                }
            }
Esempio n. 15
0
 public override void Initialize()
 {
     base.Initialize();
     this.CameraManager.ViewpointChanged += (Action)(() => this.LevelManager.ScreenInvalidated += (Action)(() =>
     {
         this.PhysicsManager.DetermineOverlaps((IComplexPhysicsEntity)this.PlayerManager);
         if (FezMath.IsOrthographic(this.CameraManager.Viewpoint) && this.CameraManager.LastViewpoint != this.CameraManager.Viewpoint && !this.PlayerManager.HandlesZClamping)
         {
             this.CorrectWallOverlap(true);
             this.PhysicsManager.DetermineInBackground((IPhysicsEntity)this.PlayerManager, !this.PlayerManager.IsOnRotato, true, !this.PlayerManager.Climbing && !this.LevelManager.LowPass);
         }
         this.PhysicsManager.DetermineOverlaps((IComplexPhysicsEntity)this.PlayerManager);
     }));
     this.LevelManager.LevelChanged += (Action)(() => this.LevelManager.ScreenInvalidated += (Action)(() => this.PhysicsManager.HugWalls((IPhysicsEntity)this.PlayerManager, false, false, !this.PlayerManager.Climbing)));
     foreach (SurfaceType key in Util.GetValues <SurfaceType>())
     {
         this.SurfaceHits.Add(key, Enumerable.ToArray <SoundEffect>(Enumerable.Select <string, SoundEffect>(this.CMProvider.GetAllIn("Sounds/Gomez\\Footsteps\\" + (object)key), (Func <string, SoundEffect>)(f => this.CMProvider.Global.Load <SoundEffect>(f)))));
     }
     this.LeftStep  = this.CMProvider.Global.Load <SoundEffect>("Sounds/Gomez\\Footsteps\\Left");
     this.RightStep = this.CMProvider.Global.Load <SoundEffect>("Sounds/Gomez\\Footsteps\\Right");
     this.ScriptingManager.CutsceneSkipped += (Action)(() =>
     {
         while (!this.PlayerManager.CanControl)
         {
             this.PlayerManager.CanControl = true;
         }
     });
 }
Esempio n. 16
0
 private void CorrectWallOverlap(bool overcompensate)
 {
     foreach (PointCollision pointCollision in this.PlayerManager.CornerCollision)
     {
         TrileInstance trileInstance = pointCollision.Instances.Deep;
         if (trileInstance != null && trileInstance != this.PlayerManager.CarriedInstance && trileInstance.GetRotatedFace(this.CameraManager.VisibleOrientation) == CollisionType.AllSides)
         {
             Vector3 vector = (pointCollision.Point - trileInstance.Center + FezMath.Sign(this.PlayerManager.Position - pointCollision.Point) * trileInstance.TransformedSize / 2f) * FezMath.SideMask(this.CameraManager.Viewpoint);
             this.PlayerManager.Position -= vector;
             if (overcompensate)
             {
                 this.PlayerManager.Position -= FezMath.Sign(vector) * (1.0 / 1000.0) * 2f;
             }
             if (!(FezMath.Sign(this.PlayerManager.Velocity) == FezMath.Sign(vector)))
             {
                 break;
             }
             Vector3 vector3_1 = FezMath.Abs(FezMath.Sign(vector));
             this.PlayerManager.Position -= this.PlayerManager.Velocity * vector3_1;
             IPlayerManager playerManager = this.PlayerManager;
             Vector3        vector3_2     = playerManager.Velocity * (Vector3.One - vector3_1);
             playerManager.Velocity = vector3_2;
             break;
         }
     }
 }
Esempio n. 17
0
            private void ForceSpinTo(int initialSpins)
            {
                int num = Math.Abs(initialSpins);

                for (int index1 = 0; index1 < num; ++index1)
                {
                    this.OriginalAoRotation = this.HandleAo.Rotation;
                    this.AttachedTriles.Clear();
                    foreach (TrileInstance instance in this.TopLayer)
                    {
                        this.AddSupportedTrilesOver(instance);
                    }
                    this.OriginalStates = Enumerable.ToArray <Vector4>(Enumerable.Select <TrileInstance, Vector4>(Enumerable.Union <TrileInstance>((IEnumerable <TrileInstance>) this.Group.Triles, (IEnumerable <TrileInstance>) this.AttachedTriles), (Func <TrileInstance, Vector4>)(x => new Vector4(x.Position, x.Phi))));
                    float      angle         = 1.570796f * (float)Math.Sign(initialSpins);
                    Quaternion fromAxisAngle = Quaternion.CreateFromAxisAngle(Vector3.UnitY, angle);
                    Vector3    position      = this.HandleAo.Position;
                    for (int index2 = 0; index2 < this.AttachedArtObjects.Length; ++index2)
                    {
                        this.AttachedAoRotations[index2]         = this.AttachedArtObjects[index2].Rotation;
                        this.AttachedAoOrigins[index2]           = this.AttachedArtObjects[index2].Position;
                        this.AttachedArtObjects[index2].Rotation = this.AttachedAoRotations[index2] * fromAxisAngle;
                        this.AttachedArtObjects[index2].Position = Vector3.Transform(this.AttachedAoOrigins[index2] - position, fromAxisAngle) + position;
                    }
                    for (int index2 = 0; index2 < this.OriginalStates.Length; ++index2)
                    {
                        TrileInstance instance = index2 < this.Group.Triles.Count ? this.Group.Triles[index2] : this.AttachedTriles[index2 - this.Group.Triles.Count];
                        Vector4       vector   = this.OriginalStates[index2];
                        instance.Position = Vector3.Transform(FezMath.XYZ(vector) + new Vector3(0.5f) - position, fromAxisAngle) + position - new Vector3(0.5f);
                        instance.Phi      = FezMath.WrapAngle(vector.W + angle);
                        this.LevelMaterializer.GetTrileMaterializer(instance.Trile).UpdateInstance(instance);
                    }
                    this.RotateTriles();
                }
                this.HandleAo.Rotation = this.HandleAo.Rotation * Quaternion.CreateFromAxisAngle(Vector3.UnitY, 1.570796f * (float)initialSpins);
            }
Esempio n. 18
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);
     }
 }
Esempio n. 19
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();
        }
Esempio n. 20
0
        protected override bool Act(TimeSpan elapsed)
        {
            if (this.PlayerManager.Action != ActionType.LowerToCornerLedge)
            {
                return(false);
            }
            Vector3 vector3_1 = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection);
            float   num       = (float)(4.0 * (this.LevelManager.Descending ? -1.0 : 1.0)) / this.CameraManager.PixelsPerTrixel;
            Vector3 vector3_2 = this.PlayerManager.HeldInstance.Center + (vector3_1 + Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor)) * this.PlayerManager.HeldInstance.TransformedSize / 2f + num * Vector3.UnitY;

            if (!this.CameraManager.StickyCam && !this.CameraManager.Constrained)
            {
                this.CameraManager.Center = Vector3.Lerp(this.camOrigin, vector3_2, this.PlayerManager.Animation.Timing.NormalizedStep);
            }
            this.PlayerManager.Position = this.PlayerManager.HeldInstance.Center + (vector3_1 + Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor)) * this.PlayerManager.HeldInstance.TransformedSize / 2f;
            this.PlayerManager.SplitUpCubeCollectorOffset = (this.playerOrigin - this.PlayerManager.Position) * (1f - this.PlayerManager.Animation.Timing.NormalizedStep);
            if (this.PlayerManager.Animation.Timing.Ended)
            {
                this.PlayerManager.LookingDirection           = FezMath.GetOpposite(this.PlayerManager.LookingDirection);
                this.PlayerManager.SplitUpCubeCollectorOffset = Vector3.Zero;
                this.PlayerManager.Action = ActionType.GrabCornerLedge;
            }
            this.PlayerManager.Animation.Timing.Update(elapsed, 1.25f);
            return(false);
        }
Esempio n. 21
0
 private void ChooseIdle()
 {
     if (NpcActionExtensions.IsSpecialIdle(this.CurrentAction))
     {
         this.CurrentAction = NpcAction.Idle;
     }
     else
     {
         float num1 = RandomHelper.Unit();
         float num2 = (float)(1 + FezMath.AsNumeric(this.CanIdle2) + FezMath.AsNumeric(this.CanIdle3));
         if ((double)num1 < 1.0 / (double)num2)
         {
             this.CurrentAction = NpcAction.Idle;
         }
         else if ((double)num2 > 1.0 && (double)num1 < 2.0 / (double)num2)
         {
             this.CurrentAction = this.CanIdle2 ? NpcAction.Idle2 : NpcAction.Idle3;
         }
         else
         {
             if ((double)num2 <= 2.0 || (double)num1 >= 3.0 / (double)num2)
             {
                 return;
             }
             this.CurrentAction = NpcAction.Idle3;
         }
     }
 }
Esempio n. 22
0
        private void TryAddRay(bool wide, bool midLife)
        {
            Mesh mesh = this.Meshes[FezMath.AsViewpoint(FezMath.OrientationFromPhi((float)RandomHelper.Random.Next(0, 4) * 1.570796f))];

            if (mesh.Groups.Count >= 15)
            {
                return;
            }
            float   num1    = wide ? this.CameraManager.Radius * 2f : this.CameraManager.Radius;
            Vector3 vector3 = RandomHelper.Between(-(double)num1 / 2.0, (double)(num1 / 2f)) * Vector3.UnitX;
            float   num2    = RandomHelper.Between(0.75, 4.0);
            float   num3    = 8f + RandomHelper.Centered(4.0);

            lock (mesh)
            {
                Group local_9 = mesh.AddColoredQuad(new Vector3(0.0f, 0.0f, 0.0f), new Vector3(-num3 - num2, -num3, 0.0f), new Vector3(-num3, -num3, 0.0f), new Vector3(-num2, 0.0f, 0.0f), new Color((int)byte.MaxValue, (int)byte.MaxValue, (int)byte.MaxValue), Color.Black, Color.Black, new Color((int)byte.MaxValue, (int)byte.MaxValue, (int)byte.MaxValue));
                local_9.CustomData = (object)new GodRays.RayCustomData()
                {
                    RandomOpacity   = RandomHelper.Between(0.125, 0.5),
                    Layer           = RandomHelper.Random.Next(0, 4),
                    RandomSpeed     = RandomHelper.Between(0.25, 2.0),
                    AccumulatedTime = (midLife ? TimeSpan.FromSeconds((double)RandomHelper.Between(0.0, 8.0)) : TimeSpan.Zero)
                };
                local_9.Material = new Material()
                {
                    Diffuse = Vector3.Zero
                };
                local_9.Position = vector3;
            }
        }
Esempio n. 23
0
        public override void Draw(GameTime gameTime)
        {
            if (!this.IsActionAllowed(this.PlayerManager.Action) || this.LevelManager.DestinationIsFarAway || this.skipFade)
            {
                return;
            }
            float num = (float)Math.Pow((double)FezMath.Saturate(this.step), this.PlayerManager.SpinThroughDoor ? 2.0 : 3.0);

            if (this.PlayerManager.CarriedInstance != null && !this.PlayerManager.SpinThroughDoor)
            {
                this.trileFadeQuad.Rotation = this.CameraManager.Rotation;
                this.trileFadeQuad.Position = this.PlayerManager.CarriedInstance.Center;
                switch (this.PlayerManager.CarriedInstance.Trile.ActorSettings.Type)
                {
                case ActorType.Bomb:
                case ActorType.BigBomb:
                    this.trileFadeQuad.Scale = new Vector3(0.75f, 1f, 0.75f);
                    break;

                case ActorType.Vase:
                    this.trileFadeQuad.Scale = new Vector3(0.875f, 1f, 0.875f);
                    break;

                default:
                    this.trileFadeQuad.Scale = Vector3.One;
                    break;
                }
                this.trileFadeQuad.Material.Opacity = this.hasFlipped ? 1f - this.step : num;
                GraphicsDeviceExtensions.PrepareStencilRead(this.GraphicsDevice, CompareFunction.Equal, StencilMask.NoSilhouette);
                this.trileFadeQuad.Draw();
                GraphicsDeviceExtensions.PrepareStencilWrite(this.GraphicsDevice, new StencilMask?(StencilMask.None));
            }
            this.fadeOutQuad.Material.Opacity = this.hasFlipped ? 1f - num : num;
            this.fadeOutQuad.Draw();
        }
Esempio n. 24
0
        private static Vector3 SolidCollision(Vector3 normal, TrileInstance instance, Vector3 origin, Vector3 destination, Vector3 impulse, float elasticity)
        {
            Vector3 vector3_1 = instance.TransformedSize / 2f;
            Vector3 vector3_2 = instance.Center + vector3_1 * normal;
            Vector3 vector3_3 = Vector3.Zero;
            Vector3 vector3_4;

            if (instance.PhysicsState != null)
            {
                Vector3 vector3_5 = instance.PhysicsState.Sticky ? FezMath.XZMask : Vector3.One;
                vector3_4 = instance.Center - instance.PhysicsState.Velocity * vector3_5 + vector3_1 * normal;
                vector3_3 = vector3_2 - vector3_4;
            }
            else
            {
                vector3_4 = vector3_2;
            }
            Vector3 a1 = origin - vector3_4;
            Vector3 a2 = destination - vector3_2;

            if ((double)FezMath.AlmostClamp(FezMath.Dot(a1, normal)) < 0.0 || (double)FezMath.AlmostClamp(FezMath.Dot(a2, normal)) > 0.0)
            {
                return(Vector3.Zero);
            }
            Vector3 vector3_6 = FezMath.Abs(normal);

            return((double)elasticity <= 0.0 ? (vector3_2 - destination) * vector3_6 : (vector3_3 - impulse) * vector3_6 * (1f + elasticity));
        }
Esempio n. 25
0
        private void UpdateRays(float elapsedSeconds)
        {
            bool flag = (double)this.PhaseTime > 1.5;

            this.MakeRay();
            if (flag)
            {
                this.MakeRay();
            }
            for (int i = this.RaysMesh.Groups.Count - 1; i >= 0; --i)
            {
                Group            group    = this.RaysMesh.Groups[i];
                DotHost.RayState rayState = group.CustomData as DotHost.RayState;
                rayState.Age          += elapsedSeconds * 0.15f;
                group.Material.Diffuse = Vector3.One * FezMath.Saturate(rayState.Age * 8f);
                group.Scale           *= new Vector3(1.5f, 1f, 1f);
                if ((double)rayState.Age > 1.0)
                {
                    this.RaysMesh.RemoveGroupAt(i);
                }
            }
            this.RaysMesh.AlwaysOnTop       = false;
            this.FlareMesh.Position         = this.RaysMesh.Position = TempleOfLoveHost.HeartCenter;
            this.FlareMesh.Rotation         = this.RaysMesh.Rotation = this.CameraManager.Rotation;
            this.FlareMesh.Material.Opacity = Easing.EaseIn((double)FezMath.Saturate(this.PhaseTime / 2.5f), EasingType.Cubic);
            this.FlareMesh.Scale            = Vector3.One + this.RaysMesh.Scale * Easing.EaseIn(((double)this.PhaseTime - 0.25) / 1.75, EasingType.Decic) * 4f;
        }
Esempio n. 26
0
        protected override bool Act(TimeSpan elapsed)
        {
            Vector3 vector3_1 = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection);
            float   num       = (float)(4.0 * (this.LevelManager.Descending ? -1.0 : 1.0)) / this.CameraManager.PixelsPerTrixel;
            Vector3 vector3_2 = this.PlayerManager.HeldInstance.Center + (-vector3_1 + Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor)) * this.PlayerManager.HeldInstance.TransformedSize / 2f + this.gomezDelta + num * Vector3.UnitY;

            if (!this.CameraManager.StickyCam && !this.CameraManager.Constrained)
            {
                this.CameraManager.Center = Vector3.Lerp(this.camOrigin, vector3_2, this.PlayerManager.Animation.Timing.NormalizedStep);
            }
            this.PlayerManager.SplitUpCubeCollectorOffset = this.gomezDelta * this.PlayerManager.Animation.Timing.NormalizedStep;
            this.PlayerManager.Position = this.PlayerManager.HeldInstance.Center + (-vector3_1 + Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor)) * this.PlayerManager.HeldInstance.TransformedSize / 2f;
            if (this.PlayerManager.Animation.Timing.Ended)
            {
                this.PlayerManager.Position    += this.gomezDelta;
                this.PlayerManager.HeldInstance = (TrileInstance)null;
                this.PlayerManager.SplitUpCubeCollectorOffset = Vector3.Zero;
                this.PhysicsManager.DetermineInBackground((IPhysicsEntity)this.PlayerManager, !this.PlayerManager.IsOnRotato, true, !this.PlayerManager.Climbing);
                this.PlayerManager.Position += 0.5f * Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor);
                IPlayerManager playerManager = this.PlayerManager;
                Vector3        vector3_3     = playerManager.Velocity - Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor);
                playerManager.Velocity = vector3_3;
                this.PhysicsManager.Update((IComplexPhysicsEntity)this.PlayerManager);
                this.PlayerManager.Action = ActionType.Idle;
            }
            return(true);
        }
Esempio n. 27
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;
 }
Esempio n. 28
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;
     }))));
 }
Esempio n. 29
0
        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
            if (!this.IsActionAllowed(this.PlayerManager.Action))
            {
                return;
            }
            if (this.rgbPlanes != null && this.Phase <= GateWarp.Phases.Decelerate)
            {
                GraphicsDeviceExtensions.PrepareStencilRead(this.GraphicsDevice, CompareFunction.Always, StencilMask.None);
                int   num    = 1;
                float amount = 0.01f;
                for (int index = 0; index < 3; ++index)
                {
                    this.rgbPlanes.Groups[index].Material.Diffuse = Vector3.Lerp(this.rgbPlanes.Groups[index].Material.Diffuse, new Vector3(index == 0 ? (float)num : 0.0f, index == 1 ? (float)num : 0.0f, index == 2 ? (float)num : 0.0f), amount);
                    this.rgbPlanes.Groups[index].Material.Opacity = MathHelper.Lerp(this.rgbPlanes.Groups[index].Material.Opacity, (float)num, amount);
                }
                this.rgbPlanes.Draw();
            }
            if (this.Phase != GateWarp.Phases.FadeOut && this.Phase != GateWarp.Phases.FadeIn && this.Phase != GateWarp.Phases.LevelChange)
            {
                return;
            }
            double linearStep = this.SinceStarted.TotalSeconds / 2.25;

            if (this.Phase == GateWarp.Phases.FadeIn)
            {
                linearStep = 1.0 - linearStep;
            }
            float alpha = FezMath.Saturate(Easing.EaseIn(linearStep, EasingType.Cubic));

            GraphicsDeviceExtensions.PrepareStencilRead(this.GraphicsDevice, CompareFunction.Always, StencilMask.None);
            this.TargetRenderer.DrawFullscreen(new Color(0.0f, 0.0f, 0.0f, alpha));
        }
Esempio n. 30
0
        public override void Draw(GameTime gameTime)
        {
            if (this.GameState.Loading)
            {
                return;
            }
            switch (this.ActiveState)
            {
            case DrumSolo.State.ZoomOut:
                float   num     = FezMath.Saturate(this.Time / 6f);
                Vector3 vector3 = EndCutscene32Host.PurpleBlack.ToVector3();
                this.TargetRenderer.DrawFullscreen(new Color(vector3.X, vector3.Y, vector3.Z, 1f - FezMath.Saturate(num * 10f)));
                break;

            case DrumSolo.State.DrumSolo:
            case DrumSolo.State.JumpUp:
                this.StarMesh.Draw();
                this.Flare.Draw();
                break;

            case DrumSolo.State.FezSplash:
                this.GraphicsDevice.Clear(Color.White);
                break;
            }
        }