Пример #1
0
        private void OnTick(object sender, EventArgs e)
        {
            GameplayCamera.ClampPitch(-179, 179);

            if (!PlayerController.ModEnabled)
            {
                if (!_spideySenseOn)
                {
                    return;
                }
                Game.TimeScale = 0;
                _spideySenseOn = false;
                return;
            }

            Game.DisableControlThisFrame(2, Control.SpecialAbility);
            Game.DisableControlThisFrame(2, Control.SpecialAbilityPC);
            Game.DisableControlThisFrame(2, Control.SpecialAbilitySecondary);

            if (Game.IsDisabledControlJustPressed(2, Control.SpecialAbility) ||
                Game.IsDisabledControlJustPressed(2, Control.SpecialAbilityPC))
            {
                _spideySenseOn = !_spideySenseOn;
            }

            if (_spideySenseOn)
            {
                var scroll = Game.GetControlNormal(2, Control.CursorScrollUp);
                //UI.ShowSubtitle(scroll.ToString(CultureInfo.InvariantCulture));
                _timeScale = Maths.Clamp(_timeScale, 0.0001f, 0.2f);
            }

            Game.TimeScale = _spideySenseOn ? _timeScale : 1f;
        }
Пример #2
0
        public void Init()
        {
            //init building pool
            _gameplayCam   = GameObject.FindObjectOfType <GameplayCamera>();
            _gameBoard     = GameObject.FindObjectOfType <GameBoard>();
            _buildHologram = GameObject.Instantiate <BuildHologram>(_buildConfig.buildHologram);

            GameObject pool = GameObject.FindGameObjectWithTag("ScenePool");

            if (!pool)
            {
                Debug.LogError("NO SCENE POOL TRANSFORM FOUND IN SCENE");
            }
            _buildingGenerator = new GenericPooler(pool ? pool.transform : null);
            BuildConfig.BuildableBlueprint[] blueprints = _buildConfig.buildables;
            for (int i = 0; i < blueprints.Length; i++)
            {
                BuildConfig.BuildableBlueprint blueprint = blueprints[i];
                _buildingGenerator.InitPool(blueprint.GetKey(), 10, blueprint.prefab);
            }

            //UI
            _buildViewController = new BuildViewController(this, _inventorySystem, _buildConfig);

            //Build Cam
            //_buildCam = new BuildCam(_buildConfig,_gameplayCam);

            //init currenty build type
            SetBuildType(_buildConfig.startingBuildType);
        }
Пример #3
0
        private async void FB_Explode(float x, float y, float z, int stunTime, int afterTime, float radius)
        {
            int     stunRefTime  = stunTime * 1000;
            int     afterRefTime = afterTime * 1000;
            int     finishTime   = 0;
            Ped     ped          = Game.Player.Character;
            Vector3 pos          = new Vector3(x, y, z);

            PlayParticles(pos);

            float distance = World.GetDistance(ped.Position, pos);

            if (distance <= radius)
            {
                Screen.Effects.Start(ScreenEffect.DontTazemeBro, 0, true);
                GameplayCamera.Shake(CameraShake.Hand, 15f);
                await ped.Task.PlayAnimation(Animation[0], Animation[1], -8f, -8f, -1, AnimationFlags.StayInEndFrame | AnimationFlags.UpperBodyOnly | AnimationFlags.AllowRotation, 8f);

                finishTime = Game.GameTime + stunRefTime;
                while (Game.GameTime < finishTime)
                {
                    Game.Player.DisableFiringThisFrame();
                    await Delay(0);
                }
                ped.Task.ClearAnimation(Animation[0], Animation[1]);
                GameplayCamera.ShakeAmplitude = 10f;
                finishTime = Game.GameTime + afterRefTime;
                while (Game.GameTime < finishTime)
                {
                    await Delay(0);
                }
                GameplayCamera.StopShaking();
                Screen.Effects.Stop(ScreenEffect.DontTazemeBro);
            }
        }
Пример #4
0
        private void RotateGameplayCameraTowardsTarget()
        {
            if (!_lastTarget.HasValue)
            {
                return;
            }

            var dir = _lastTarget.Value - _forwardCamera.Position;

            _yawToTarget   = Geometry.DirectionToRotation(dir).Z;
            _pitchToTarget = Geometry.DirectionToRotation(dir).X;

            Game.Player.Character.Heading = _yawToTarget;

            GameplayCamera.RelativeHeading = 0;
            GameplayCamera.ClampPitch(_pitchToTarget, _pitchToTarget);
            GameplayCamera.RelativePitch   = _pitchToTarget;
            GameplayCameraRotationFiltered = Geometry.DirectionToRotation(dir);

            var deltaPitch = _forwardCamera.Rotation.Z - _yawToTarget;
            var deltaYaw   = _forwardCamera.Rotation.X - _pitchToTarget;
            var minAngle   = 0.01f;

            if (Math.Abs(deltaYaw) < minAngle && Math.Abs(deltaPitch) < minAngle)
            {
                _lastTarget = null;
            }
        }
Пример #5
0
 public BuildCam(BuildConfig buildConfig, GameplayCamera gameplayCam)
 {
     _buildConfig  = buildConfig;
     _buildCamData = _buildConfig._buildCamData;
     _worldLimit   = _buildConfig._buildCamData.worldLimit;
     _gameplayCam  = gameplayCam;
 }
Пример #6
0
 private void CreateItemPreview()
 {
     if (Entity.op_Equality((Entity)this._currentPreview, (Entity)null))
     {
         this.PreviewComplete = false;
         this._currentOffset  = Vector3.get_Zero();
         Prop prop = World.CreateProp(Model.op_Implicit(this._currnetPropHash), (Vector3)null, (Vector3)null, false, false);
         if (Entity.op_Equality((Entity)prop, (Entity)null))
         {
             UI.Notify(string.Format("Failed to load prop, even after request.\nProp Name: {0}", (object)this._currnetPropHash));
             this._resultProp     = (Prop)null;
             this._preview        = false;
             this.PreviewComplete = true;
         }
         else
         {
             ((Entity)prop).set_HasCollision(false);
             this._currentPreview = prop;
             ((Entity)this._currentPreview).set_Alpha(150);
             Database.PlayerPed.get_Weapons().Select((WeaponHash) - 1569615261, true);
             this._resultProp = (Prop)null;
         }
     }
     else
     {
         UiExtended.DisplayHelpTextThisFrame("Press ~INPUT_AIM~ to cancel.\nPress ~INPUT_ATTACK~ to place the item.", true);
         Game.DisableControlThisFrame(2, (Control)25);
         Game.DisableControlThisFrame(2, (Control)24);
         Game.DisableControlThisFrame(2, (Control)257);
         Game.DisableControlThisFrame(2, (Control)152);
         Game.DisableControlThisFrame(2, (Control)153);
         Game.DisableControlThisFrame(2, (Control)44);
         Game.DisableControlThisFrame(2, (Control)27);
         Game.DisableControlThisFrame(2, (Control)172);
         Game.DisableControlThisFrame(2, (Control)173);
         Game.DisableControlThisFrame(2, (Control)21);
         GameExtended.DisableWeaponWheel();
         if (Game.IsDisabledControlPressed(2, (Control)25))
         {
             ((Entity)this._currentPreview).Delete();
             this._currentPreview = this._resultProp = (Prop)null;
             this._preview        = false;
             this.PreviewComplete = true;
             ScriptEventHandler.Instance.UnregisterScript(new EventHandler(this.OnTick));
         }
         else
         {
             Vector3       position      = GameplayCamera.get_Position();
             Vector3       direction     = GameplayCamera.get_Direction();
             RaycastResult raycastResult = World.Raycast(position, Vector3.op_Addition(position, Vector3.op_Multiply(direction, 15f)), (IntersectOptions) - 1, (Entity)Database.PlayerPed);
             Vector3       hitCoords     = ((RaycastResult) ref raycastResult).get_HitCoords();
             if (Vector3.op_Inequality(hitCoords, Vector3.get_Zero()) && (double)((Vector3) ref hitCoords).DistanceTo(Database.PlayerPosition) > 1.5)
             {
                 ItemPreview.DrawScaleForms();
                 float num = Game.IsControlPressed(2, (Control)21) ? 1.5f : 1f;
                 if (Game.IsControlPressed(2, (Control)152))
                 {
                     Vector3    rotation = ((Entity)this._currentPreview).get_Rotation();
                     ref __Null local    = ref rotation.Z;
        public static bool IsOnScreen(this Vector3 vector3)
        {
            Vector3 position    = GameplayCamera.get_Position();
            Vector3 direction   = GameplayCamera.get_Direction();
            float   fieldOfView = GameplayCamera.get_FieldOfView();

            return((double)Vector3.Angle(Vector3.op_Subtraction(vector3, position), direction) < (double)fieldOfView);
        }
Пример #8
0
        public override void OnStart()
        {
            ReduceCounter = new ReduceCounter(15 * 1000);
            ReduceCounter.OnFinishedAsync.Subscribe(_ => ParupunteEnd());
            AddProgressBar(ReduceCounter);
            soundPlayerStart?.Play();

            GameplayCamera.StopShaking();
        }
Пример #9
0
 private void Awake()
 {
     gameCamera = this;
     boundaries = InitializeMission.mission.background.sprite.bounds.size/2;
     center = InitializeMission.mission.background.transform.position;
     camera = GetComponent<Camera>();
     zoomOutSize = camera.orthographicSize;
     posX = InitializeMission.mission.background.transform.position.x + boundaries.x;
     posY = InitializeMission.mission.background.transform.position.y + boundaries.y;
     negX = InitializeMission.mission.background.transform.position.x - boundaries.x;
     negY = InitializeMission.mission.background.transform.position.y - boundaries.y;
 }
    public void Init(HUDController hudController)
    {
        _hudController = hudController;

        PlayerCombatView view = GameObject.Instantiate <PlayerCombatView>(_gameplayResources.playerCombatView);

        _playerCombatController = new PlayerCombatController(view, _gameConfig.playerConfig);
        _playerCombatController.AddListener(GameplayEventType.DAMAGE_TAKEN, OnPlayeDamageTake);

        _gameplayCam      = GameObject.FindObjectOfType <GameplayCamera>();
        _combatCamera     = new CombatCamera(_gameplayCam, _playerCombatController.transform);
        _parentController = GameObject.Instantiate <ParentController>(_gameplayResources.parentController);
        _parentController.Init(_gameConfig.playerConfig);
        _parentController.AddListener(GameplayEventType.DAMAGE_TAKEN, OnParentDamageTaken);
    }
Пример #11
0
    void Start()
    {
        ship           = FindObjectOfType <Ship>();
        gameplayCamera = FindObjectOfType <GameplayCamera>();
        gameplayHUD    = FindObjectOfType <UIGameplayHUD>();

        InitializeLevels();
        currentLvl = 0;
        StartCoroutine(LevelTimer());

        ship.transform.position = lvl1.initialPlayerPos;
        ship.ChangeLevel        = ChangeLevel;
        ship.EndGame            = LoadEndscreen;
        gameplayCamera.UpdateLevelData(lvl1.limitXmin, lvl1.limitXmax);
        gameplayHUD.getlevelTimer = PassLevelTimer;
        gameplayHUD.PauseGame     = PauseGame;
    }
        public void Update(float deltaTime, NViewport vp)
        {
            // 更新输入
            PlayerInput.UpdateInput(deltaTime);
            PreProcessInput(PlayerInput, deltaTime);

            GameplayCamera.UpdateCamera(this, vp.Camera, deltaTime);
            foreach (var camera in CameraModifiers)
            {
                camera.UpdateCamera(this, vp.Camera, deltaTime);
            }
            PlayerMove(deltaTime, vp.Camera);

            Update(deltaTime);

            PlayerInput.ResetInput();
            PressJump = false;
        }
Пример #13
0
            public override bool Tick()
            {
                if (stumbleTimer.Tick())
                {
                    ped.Euphoria.LeanRandom.Start(rnd.Next(500, 1000));
                    ped.Euphoria.BodyBalance.Start();
                }

                if (timer.Tick())
                {
                    GameplayCamera.StopShaking();
                    ped.ResetPedMovementClipset();
                    ped.SetPedIsDrunk(false);
                    ped.ResetConfigFlag(100);
                    Function.Call(Hash._STOP_SCREEN_EFFECT, "DrugsDrivingOut");
                    return(true);
                }

                return(false);
            }
Пример #14
0
    public static Vector3 ScreenToEnvironmentPoint(GameplayCamera cam, Vector3 screenPoint)
    {
        Vector3 environmentPoint = new Vector3();
        Camera  camera           = cam.GetCamera();
        Ray     rayFromMouse     = camera.ScreenPointToRay(screenPoint);
        Vector3 origin           = rayFromMouse.origin;
        Vector3 direction        = rayFromMouse.direction;
        Vector3 end = origin + (direction * cam.GetMaxDistanceFromFocus() * 2);

        environmentPoint = origin;
        ProcessIntersection onIntersect = (result) => {
            environmentPoint = result.GetPosition();
        };
        ShouldContinueRayCast shouldContinue = (result) => {
            return(false);
        };

        IncrementalRaycast(origin, end, onIntersect, shouldContinue);
        return(environmentPoint);
    }
Пример #15
0
    // Token: 0x0600342F RID: 13359 RVA: 0x000D6CF8 File Offset: 0x000D4EF8
    public IEnumerator Start()
    {
        GameplayCamera currentCamera = UI.Cameras.Current;

        currentCamera.ChangeTargetToCurrentCharacter();
        Scenes.Manager.EnableDisabledScenesAtPosition(false);
        currentCamera.UpdateTargetHelperPosition();
        currentCamera.MoveCameraToTargetPosition();
        currentCamera.OffsetController.UpdateOffset(true);
        currentCamera.MoveCameraToTargetInstantly(true);
        yield return(new WaitForFixedUpdate());

        GameSettings.Instance.LoadSettings();
        this.CreateCheckpoint();
        SaveSceneManager.Master.RegisterGameObject(this.m_systemsGameObject);
        SuspensionManager.Register(this);
        if (!this.IsTrial)
        {
            WaitForSaveGameLogic.OnCompletedStatic = (Action)Delegate.Combine(WaitForSaveGameLogic.OnCompletedStatic, new Action(AchievementsLogic.Instance.HandleTrialAchievements));
        }
        yield break;
    }
Пример #16
0
        public void Handle(Chaos mod, String from, IEnumerable <String> rest)
        {
            var player = Game.Player.Character;

            if (player == null)
            {
                return;
            }

            float  amplitude    = 1f;
            string animationSet = "move_m@drunk@moderatedrunk";
            string what         = "drunk";

            if (veryDrunk)
            {
                amplitude    = 5f;
                animationSet = "move_m@drunk@verydrunk";
                what         = "VERY drunk";
                Function.Call(Hash._START_SCREEN_EFFECT, "DrugsDrivingOut", 0, 0);
            }

            var timer        = mod.Timer(what, 20f);
            var stumbleTimer = mod.RandomTimer(2f, 5f);

            if (!WorldExtension.HasAnimationSetLoaded(animationSet))
            {
                WorldExtension.RequestAnimationSet(animationSet);
            }

            GameplayCamera.Shake(CameraShake.Drunk, amplitude);
            player.SetPedIsDrunk(true);
            player.SetConfigFlag(100, true);
            player.SetPedMovementClipset(animationSet);
            mod.AddUniqueTicker(TickerId.Drunk, new DrunkTicker(mod.Rnd, timer, stumbleTimer, player));
            mod.ShowText($"{from} made you {what}!");
        }
Пример #17
0
        /// <summary>
        /// Grapple the player towards the specified vehicle.
        /// </summary>
        /// <param name="vehicle"></param>
        /// <param name="twoHandedAnim"></param>
        /// <param name="elapsedTime"></param>
        /// <param name="initialTargetDirection"></param>
        /// <param name="ropes"></param>
        /// <param name="ropeDeleteDelay"></param>
        /// <returns></returns>
        private bool GrappleToVehicle(Vehicle vehicle, bool twoHandedAnim, float elapsedTime,
                                      Vector3 initialTargetDirection, List <Rope> ropes, ref float ropeDeleteDelay)
        {
            // Two handed web logic...
            ropeDeleteDelay = twoHandedAnim
                ? UpdateRopes1(vehicle, ropes, ropeDeleteDelay)
                : UpdateRopes2(vehicle, ropes, ropeDeleteDelay);

            // Get the target direction direction.
            var targetDirection = vehicle.Position - Profile.LocalUser.Position;

            targetDirection.Normalize();

            // Get the distance while we're at it.
            var targetDistance = Vector3.Distance(Profile.LocalUser.Position, vehicle.Position);

            // The angle of the arc.
            const float angle = 37f;

            // A degree to radians conversion.
            const float degToRad = 0.0174533f;

            // The amount of gravity for the jump.
            const float gravity = 50;

            // Set the player rotation.
            var targetRotation =
                Quaternion.FromToRotation(_helperObj.Quaternion * Vector3.RelativeFront, targetDirection) *
                _helperObj.Quaternion;

            _helperObj.Quaternion = targetRotation;

            // Calculate the speed needed to go from A to B.
            var targetVelocityMag = targetDistance / ((float)Math.Sin(2f * angle * degToRad) / gravity);

            // Extract the x and z of the velocity.
            var acceleration = GetAcceleration(elapsedTime, angle, degToRad, gravity, targetVelocityMag);

            // Set the players velocity and heading.
            Profile.LocalUser.Heading  = (initialTargetDirection * 5).ToHeading();
            Profile.LocalUser.Velocity = acceleration * 25f + vehicle.Velocity;

            // reverse the grapple animation.
            if (Profile.LocalUser.IsPlayingAnimation("weapons@projectile@", "throw_m_fb_stand"))
            {
                Profile.LocalUser.SetAnimationSpeed("weapons@projectile@",
                                                    "throw_m_fb_stand", -1.0f); // set it to -1x the speed.
            }
            // Check if the player has collided with anything,
            // and if so, then break the loop.
            if (Profile.LocalUser.HasCollidedWithAnything)
            {
                // Stop the grapple.
                StopGrapple();

                // If the player is touching the vehicle...
                if (!Profile.LocalUser.IsTouching(vehicle))
                {
                    return(false);
                }

                // Get the collision normal and check to see
                // if we're on a flat surface.
                var collisionNormal = vehicle.GetLastCollisionNormal();
                if (!(Vector3.Dot(collisionNormal, Vector3.WorldUp) > 0.5f))
                {
                    return(false);
                }

                // Now we're going to artificially attach the player
                // to the roof, with a nice little animation.
                Profile.LocalUser.Velocity = vehicle.Velocity;
                vehicle.SetDamage(Profile.LocalUser.Position - vehicle.Position, 3000f, 200f);
                Profile.LocalUser.Task.PlayAnimation("move_fall", "clamber_land_stand",
                                                     8.0f, -4.0f, 750, AnimationFlags.None, 0.0f);
                GameplayCamera.Shake(CameraShake.Jolt, 0.1f);
                OverrideFallHeight(0f);
                return(false);
            }

            // Make sure the player doesn't think he's falling while we update.
            Profile.LocalUser.SetConfigFlag(60, true);
            return(true);
        }
Пример #18
0
 public void ScreenTarget(GameplayCamera cam, Vector3 screenLocation)
 {
     environmentTarget = EnvironmentPhysics.ScreenToEnvironmentPoint(cam, screenLocation);
 }
Пример #19
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();
        }
 public CombatCamera(GameplayCamera gameplayCam, Transform target)
 {
     _target      = target;
     _gameplayCam = gameplayCam;
 }