Exemplo n.º 1
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);
            }
Exemplo n.º 2
0
            public void Update(TimeSpan elapsed)
            {
                if (!this.Enabled || this.Path.NeedsTrigger)
                {
                    return;
                }
                if (this.justStarted)
                {
                    this.originalViewpoint       = this.CameraManager.Viewpoint;
                    this.originalCenter          = this.CameraManager.Center;
                    this.originalDirection       = this.CameraManager.Direction;
                    this.originalPixelsPerTrixel = this.CameraManager.PixelsPerTrixel;
                    this.originalRadius          = this.CameraManager.Radius;
                    bool perspective = (this.Nodes[0].CustomData as CameraNodeData).Perspective;
                    if (this.Path.InTransition)
                    {
                        this.nodeIndex = 1;
                        this.Nodes.Insert(0, new PathSegment()
                        {
                            Destination = this.originalCenter,
                            Orientation = Quaternion.Inverse(this.CameraManager.Rotation),
                            CustomData  = (ICloneable) new CameraNodeData()
                            {
                                PixelsPerTrixel = (int)this.originalPixelsPerTrixel,
                                Perspective     = perspective
                            }
                        });
                    }
                    if (this.Path.OutTransition)
                    {
                        this.Nodes.Add(new PathSegment()
                        {
                            Destination = this.originalCenter,
                            Orientation = Quaternion.Inverse(this.CameraManager.Rotation),
                            CustomData  = (ICloneable) new CameraNodeData()
                            {
                                PixelsPerTrixel = (int)this.originalPixelsPerTrixel,
                                Perspective     = perspective
                            }
                        });
                    }
                    if (this.Nodes.Count < 2)
                    {
                        this.EndPath();
                        return;
                    }
                    else
                    {
                        CameraNodeData cameraNodeData = this.Nodes[0].CustomData as CameraNodeData;
                        this.firstNodeViewpoint = FezMath.AsViewpoint(FezMath.OrientationFromDirection(FezMath.MaxClampXZ(Vector3.Transform(Vector3.Forward, this.Nodes[0].Orientation))));
                        this.CameraManager.ChangeViewpoint(cameraNodeData.Perspective ? Viewpoint.Perspective : this.firstNodeViewpoint);
                        if (cameraNodeData.Perspective)
                        {
                            this.CameraManager.Radius = 1.0 / 1000.0;
                        }
                        if (cameraNodeData.PixelsPerTrixel != 0 && (double)this.CameraManager.PixelsPerTrixel != (double)cameraNodeData.PixelsPerTrixel)
                        {
                            this.CameraManager.PixelsPerTrixel = (float)cameraNodeData.PixelsPerTrixel;
                        }
                        this.StartNewSegment();
                        this.justStarted = false;
                    }
                }
                if (this.CameraManager.ActionRunning)
                {
                    this.sinceSegmentStarted += elapsed;
                }
                if (this.sinceSegmentStarted >= this.CurrentNode.Duration + this.CurrentNode.WaitTimeOnFinish)
                {
                    this.ChangeSegment();
                }
                if (!this.Enabled || this.Path.NeedsTrigger)
                {
                    return;
                }
                float       num1         = (float)FezMath.Saturate(this.sinceSegmentStarted.TotalSeconds / this.CurrentNode.Duration.TotalSeconds);
                float       amount       = (double)this.CurrentNode.Deceleration != 0.0 || (double)this.CurrentNode.Acceleration != 0.0 ? ((double)this.CurrentNode.Acceleration != 0.0 ? ((double)this.CurrentNode.Deceleration != 0.0 ? Easing.EaseInOut((double)num1, EasingType.Sine, this.CurrentNode.Acceleration, EasingType.Sine, this.CurrentNode.Deceleration) : Easing.Ease((double)num1, this.CurrentNode.Acceleration, EasingType.Quadratic)) : Easing.Ease((double)num1, -this.CurrentNode.Deceleration, EasingType.Quadratic)) : num1;
                PathSegment pathSegment1 = this.Nodes[Math.Max(this.nodeIndex - 1, 0)];
                PathSegment currentNode  = this.CurrentNode;
                Vector3     vector3_1;
                Quaternion  quat;

                if (this.Path.IsSpline)
                {
                    PathSegment pathSegment2 = this.Nodes[Math.Max(this.nodeIndex - 2, 0)];
                    PathSegment pathSegment3 = this.Nodes[Math.Min(this.nodeIndex + 1, this.Nodes.Count - 1)];
                    vector3_1 = Vector3.CatmullRom(pathSegment2.Destination, pathSegment1.Destination, currentNode.Destination, pathSegment3.Destination, amount);
                    quat      = Quaternion.Slerp(pathSegment1.Orientation, currentNode.Orientation, amount);
                }
                else
                {
                    vector3_1 = Vector3.Lerp(pathSegment1.Destination, currentNode.Destination, amount);
                    quat      = Quaternion.Slerp(pathSegment1.Orientation, currentNode.Orientation, amount);
                }
                float num2 = MathHelper.Lerp(pathSegment1.JitterFactor, currentNode.JitterFactor, amount);

                if ((double)num2 > 0.0)
                {
                    vector3_1 += new Vector3(RandomHelper.Centered((double)num2) * 0.5f, RandomHelper.Centered((double)num2) * 0.5f, RandomHelper.Centered((double)num2) * 0.5f);
                }
                Vector3        vector3_2       = Vector3.Transform(Vector3.Forward, quat);
                CameraNodeData cameraNodeData1 = pathSegment1.CustomData as CameraNodeData;
                CameraNodeData cameraNodeData2 = currentNode.CustomData as CameraNodeData;

                if (!cameraNodeData2.Perspective)
                {
                    this.CameraManager.PixelsPerTrixel = MathHelper.Lerp(cameraNodeData1.PixelsPerTrixel == 0 ? this.originalPixelsPerTrixel : (float)cameraNodeData1.PixelsPerTrixel, cameraNodeData2.PixelsPerTrixel == 0 ? this.originalPixelsPerTrixel : (float)cameraNodeData2.PixelsPerTrixel, amount);
                }
                Viewpoint view = cameraNodeData2.Perspective ? Viewpoint.Perspective : this.firstNodeViewpoint;

                if (view != this.CameraManager.Viewpoint)
                {
                    if (view == Viewpoint.Perspective)
                    {
                        this.CameraManager.Radius = 1.0 / 1000.0;
                    }
                    this.CameraManager.ChangeViewpoint(view);
                }
                this.CameraManager.Center    = vector3_1;
                this.CameraManager.Direction = vector3_2;
                if (!cameraNodeData2.Perspective)
                {
                    return;
                }
                if (this.nodeIndex == 1)
                {
                    this.CameraManager.Radius = MathHelper.Lerp(this.originalRadius, 1.0 / 1000.0, amount);
                }
                else if (this.nodeIndex == this.Nodes.Count - 1)
                {
                    this.CameraManager.Radius = MathHelper.Lerp(1.0 / 1000.0, this.originalRadius, amount);
                }
                else
                {
                    this.CameraManager.Radius = 1.0 / 1000.0;
                }
            }
Exemplo n.º 3
0
            public TombstoneState(TombstonesHost host, ArtObjectInstance ao)
            {
                ServiceHelper.InjectServices((object)this);
                this.Host      = host;
                this.ArtObject = ao;
                int num1;

                if (this.GameState.SaveData.ThisLevel.PivotRotations.TryGetValue(this.ArtObject.Id, out num1) && num1 != 0)
                {
                    int num2 = Math.Abs(num1);
                    for (int index = 0; index < num2; ++index)
                    {
                        this.OriginalAoRotation  = this.ArtObject.Rotation;
                        this.ArtObject.Rotation *= Quaternion.CreateFromAxisAngle(Vector3.UnitY, 1.570796f * (float)Math.Sign(num1));
                    }
                }
                this.LastViewpoint = FezMath.AsViewpoint(FezMath.OrientationFromDirection(FezMath.MaxClampXZ(Vector3.Transform(Vector3.Forward, this.ArtObject.Rotation))));
            }