コード例 #1
0
        private void FrontFlip()
        {
            if (!Profile.FlipAfterWebPull)
            {
                return;
            }
            Profile.LocalUser.Task.ClearAllImmediately();
            Profile.LocalUser.SetConfigFlag(60, false);
            var t = 0.1f;

            while (t > 0f)
            {
                t -= Game.LastFrameTime;
                Profile.LocalUser.Velocity = Vector3.WorldUp * 15f;
                Script.Yield();
            }
            Profile.LocalUser.Task.Skydive();
            Profile.LocalUser.Task.PlayAnimation("swimming@swim", "recover_back_to_idle", 2.0f, -2.0f, 1150,
                                                 AnimationFlags.AllowRotation, 0.0f);
            t = 0.7f;
            while (t > 0 && Profile.LocalUser.HeightAboveGround > 1.25f)
            {
                Profile.LocalUser.HasCollision = false;
                t -= Time.DeltaTime;
                Game.SetControlNormal(2, Control.ParachutePitchUpDown, -1f);
                Script.Yield();
            }
            Profile.LocalUser.HasCollision = true;
            WebZip.OverrideFallHeight(float.MaxValue);
        }
コード例 #2
0
        private void UpdateClimbing(Vector3 surfacePosition, Vector3 surfaceNormal)
        {
            // Create the attachmentObject.
            var attachmentObject = World.CreateProp("w_pi_pistol", surfacePosition, false, false);

            attachmentObject.PositionNoOffset = surfacePosition;
            attachmentObject.HasCollision     = false;
            attachmentObject.FreezePosition   = true;
            attachmentObject.Quaternion       = Maths.LookRotation(Vector3.WorldUp, surfaceNormal);
            attachmentObject.Alpha            = 0;
            // attachmentObject.Alpha = 0;

            // Attach the player to the attachment object.
            Profile.LocalUser.Task.ClearAllImmediately();
            Profile.LocalUser.AttachTo(attachmentObject, 0, new Vector3(0, 0, 1), Vector3.Zero);
            Profile.LocalUser.Task.PlayAnimation("move_crouch_proto", "idle_intro", 8.0f, -1, AnimationFlags.Loop);

            // Delay for the control.
            GameWaiter.Wait(10);

            // Create camera.
            var camDirection  = Vector3.Zero;
            var moveDirection = Vector3.Zero;
            //var camSpawn = attachmentObject.GetOffsetInWorldCoords(new Vector3(0, -2, 1));
            //var cam = World.CreateCamera(camSpawn, Vector3.Zero, 60);
            //cam.Direction = attachmentObject.Position - cam.Position;
            //cam.TransitionIn(100);

            //var pivot = World.CreateProp("w_pi_pistol", attachmentObject.Position, false, false);
            //pivot.FreezePosition = true;
            //pivot.IsVisible = false;
            //pivot.Quaternion = attachmentObject.Quaternion;

            //// Camera rotation.
            //var xRotation = 0f;
            //var yRotation = 45f;

            // flags.
            var cancelClimb = false;
            var idleTimer   = 0f;

            while (!cancelClimb)
            {
                // Override the enabled controls.
                SetActiveControls();

                GameplayCamera.ClampPitch(-90, 90);

                // Rotate the wall cam.
                //RotateCam(cam, pivot, attachmentObject, ref xRotation, ref yRotation);

                // Get the movement vector.
                var movement = GetMovementVector();

                // Move the player attachment.
                Move(/*cam, */ surfaceNormal, attachmentObject, ref camDirection, ref moveDirection, movement);

                // Play the player movement animations.
                DoMovementAnimations(attachmentObject, movement.Length(), ref idleTimer);

                // Start a new surface ray.
                var surfaceRay = WorldProbe.StartShapeTestRay(attachmentObject.Position + attachmentObject.UpVector,
                                                              attachmentObject.Position - attachmentObject.UpVector,
                                                              ShapeTestFlags.IntersectMap, attachmentObject);

                // Handle the ejection keys.
                HandleEject(ref cancelClimb, attachmentObject);

                // Make sure the result is not empty.
                var result = surfaceRay.GetResult();
                if (!result.Hit)
                {
                    DetachPlayer(attachmentObject);
                    GameWaiter.Wait(10);
                    if (Game.IsDisabledControlPressed(2, Control.Sprint))
                    {
                        Profile.LocalUser.HasCollision     = false;
                        Profile.LocalUser.IsCollisionProof = true;
                        Profile.LocalUser.SetConfigFlag(60, false);
                        Profile.LocalUser.Task.Skydive();
                        Profile.LocalUser.Task.PlayAnimation("swimming@swim", "recover_back_to_idle",
                                                             2.0f, -2.0f, 1150, AnimationFlags.AllowRotation, 0.0f);
                        Profile.LocalUser.Velocity = Vector3.WorldUp * 25f;
                        WebZip.OverrideFallHeight(float.MaxValue);
                        var t = 0.1f;
                        while (t > 0f)
                        {
                            t -= Game.LastFrameTime;
                            Profile.LocalUser.HasCollision = false;
                            Script.Yield();
                        }
                        Profile.LocalUser.HasCollision     = true;
                        Profile.LocalUser.IsCollisionProof = false;
                    }
                    else
                    {
                        Profile.LocalUser.Task.Climb();
                        WebZip.OverrideFallHeight(0f);
                    }
                    break;
                }

                // Set the surface position.
                surfacePosition = result.EndCoords;

                // Check the surface normal.
                if (surfaceNormal != result.SurfaceNormal)
                {
                    // If the surface normal has changed, then change immediately rotation the player
                    // to match the normal.
                    surfaceNormal = result.SurfaceNormal;
                    Move(/*cam, */ surfaceNormal, attachmentObject, ref camDirection, ref moveDirection, movement,
                         false);
                }

                attachmentObject.PositionNoOffset = surfacePosition;

                Script.Yield();
            }

            // Destroy the camera.
            //Utilities.DestroyAllCameras();

            // Delte the camera pivot.
            //pivot.Delete();
        }