Ejemplo n.º 1
0
        void Update()
        {
            if (LockPauseModule.IsPaused())
            {
                return;
            }

            UpdateState();
        }
Ejemplo n.º 2
0
        private void LateUpdate()
        {
            if (LockPauseModule.IsPaused())
            {
                return;
            }

            if (FollowPlayer)
            {
                //multiple player handling for hmslug
                Vector2 centroid;
                if (PlayerTransforms.Count == 1)
                {
                    centroid = PlayerTransforms[0].position;
                }
                else
                {
                    centroid = Vector2.zero;
                    int validPlayers = 0;
                    foreach (var t in PlayerTransforms)
                    {
                        if (t == null) //skip invalid transforms
                        {
                            continue;
                        }
                        centroid += (Vector2)t.position;
                        validPlayers++;
                    }

                    centroid /= validPlayers;
                }

                //max y dist handling
                float yPos               = transform.position.y - YOffset;
                float yPosToCentroid     = centroid.y - yPos;
                float distYPosToCentroid = Mathf.Abs(yPosToCentroid);
                if (distYPosToCentroid > MaxYDist)
                {
                    yPos += Mathf.Sign(yPosToCentroid) * (distYPosToCentroid - MaxYDist);
                }

                transform.position = new Vector3(centroid.x, yPos + YOffset, transform.position.z);
            }
            else if (MoveTarget.HasValue)
            {
                //move to target
                Vector3 vecToTarget  = MoveTarget.Value - transform.position;
                float   distToTarget = vecToTarget.magnitude;
                if (distToTarget > TargetDistanceThreshold)
                {
                    //move!
                    float moveDistance = Mathf.Min(distToTarget, MoveSpeed * Time.fixedDeltaTime);
                    transform.Translate(moveDistance * vecToTarget.normalized);
                }
            }
        }
Ejemplo n.º 3
0
        private void Update()
        {
            if (LockPauseModule.IsPaused())
            {
                return;
            }

            HandleMovement();
            HandleAttack();
            HandleDeathFall();
        }
Ejemplo n.º 4
0
        private void Update()
        {
            if (LockPauseModule.IsPaused())
            {
                return;
            }

            HandleCriticalInput();
            HandleInvulnerability();
            HandleGrenadeThrow();
        }
Ejemplo n.º 5
0
        private void Update()
        {
            if (LockPauseModule.IsPaused())
            {
                return;
            }

            HandleTargeting();
            HandleMovement();
            HandleAttack();
            HandleDeathGravity();
        }
Ejemplo n.º 6
0
        public override void Update()
        {
            base.Update();

            if (LockPauseModule.IsPaused())
            {
                return;
            }

            TotalTickCount++;

            TimeInState += Time.deltaTime;
            UpdateState();
        }
Ejemplo n.º 7
0
        //TODO STRETCH GOAL: temporary upgrades

        private void Update()
        {
            if (LockPauseModule.IsPaused())
            {
                return;
            }

            if (TimeUntilNextShot > 0)
            {
                TimeUntilNextShot -= Time.deltaTime;
            }

            HandleShooting();
            HandlePivot();
        }
Ejemplo n.º 8
0
        private void FixedUpdate()
        {
            if (LockPauseModule.IsPaused())
            {
                return;
            }

            if (TimeUntilNextJump > 0)
            {
                TimeUntilNextJump -= Time.fixedDeltaTime;
            }


            HandleMovement();
            HandleBounds();
            HandleDeathGravity();
        }
Ejemplo n.º 9
0
        private void LateUpdate()
        {
            if (LockPauseModule.IsPaused())
            {
                return;
            }

            if (!ConfigState.Instance.GetGameplayConfig().BobEffects) //cancel viewbob if disabled
            {
                TargetPosition          = Vector3.zero;
                transform.localPosition = TargetPosition;
                return;
            }

            //set new target

            if (!(MovementComponent.IsMoving || (MovementComponent.IsOnSlope && MovementComponent.Velocity.sqrMagnitude > 0)) ||
                !MovementComponent.IsGrounded ||
                !PlayerController.PlayerInControl)
            {
                TargetPosition = Vector3.zero;
            }
            else if ((transform.localPosition - TargetPosition).magnitude < Threshold)
            {
                float yDirection        = -Mathf.Sign(TargetPosition.y); //bob up and down
                float extraDisplacement = VelocityDisplacementFactor * MovementComponent.Velocity.GetFlatVector().magnitude;
                TargetPosition = new Vector3(0, yDirection * (YDisplacement + Random.Range(-YJitter + extraDisplacement, YJitter + extraDisplacement)), 0);
            }

            //animate toward target
            Vector3 vecToTarget  = TargetPosition - transform.localPosition;
            float   distToTarget = vecToTarget.magnitude;

            if (distToTarget > Threshold)
            {
                //get extra velocity from movement speed
                float   extraVelocity = VelocityFactor * MovementComponent.Velocity.GetFlatVector().magnitude;
                Vector3 dirToTarget   = vecToTarget.normalized;
                float   moveDist      = Mathf.Min(distToTarget, (BaseVelocity + extraVelocity) * Time.deltaTime);
                transform.Translate(moveDist * dirToTarget, Space.Self);
            }
            else if (TargetPosition == Vector3.zero)
            {
                transform.localPosition = Vector3.zero;
            }
        }
Ejemplo n.º 10
0
        //should be fixedupdate, probably
        public override void Update()
        {
            HandleMessages();

            if (Time.timeScale == 0 || LockPauseModule.IsPaused())
            {
                return;
            }

            if (HandleDeath)
            {
                HandleDying();
            }

            if (PlayerInControl && !LockPauseModule.IsInputLocked())
            {
                HandleView();
                HandleInteraction();
                //HandleWeapons();
            }
        }
Ejemplo n.º 11
0
        private void LateUpdate()
        {
            if (LockPauseModule.IsPaused())
            {
                return;
            }

            if (Target != null)
            {
                Elapsed += Time.deltaTime;

                if (Elapsed >= TimeToNext)
                {
                    //change to next
                    if (transform.localEulerAngles.magnitude < Threshold) //we're at zero, so end
                    {
                        Elapsed = 0;
                        transform.localEulerAngles = Vector3.zero;
                        Original = transform.localRotation;
                        Target   = null;
                    }
                    else //we're at target, so try to return to zero
                    {
                        Elapsed    = 0;
                        TimeToNext = TimeToZero;
                        Original   = transform.localRotation;
                        Target     = Quaternion.identity;
                    }
                }
                else
                {
                    //lerp toward target
                    float      ratio    = Elapsed / TimeToNext;
                    Quaternion rotation = Quaternion.Slerp(Original, Target.Value, ratio);
                    transform.localRotation = rotation;
                }
            }
        }
Ejemplo n.º 12
0
        //we may rework this to use an explicit update from PlayerController
        void Update()
        {
            if (Time.timeScale == 0 || LockPauseModule.IsPaused())
            {
                return;
            }

            //HandleDynamicMovement();

            //reset these
            IsMoving        = false;
            IsRunning       = false;
            DidJump         = false;
            DidChangeCrouch = false;

            if (PlayerController.PlayerInControl && !LockPauseModule.IsInputLocked())
            {
                HandleLook();
                if (Clipping)
                {
                    HandleMovement();
                }
            }

            if (Clipping)
            {
                HandleDynamicMovement();
                HandleOutOfBounds();
            }

            HandleNoclip();
            HandleCrouchAnimation();

            HandleAnimation();
            HandleSounds();
        }
Ejemplo n.º 13
0
        private void LateUpdate()
        {
            if (LockPauseModule.IsPaused())
            {
                return;
            }

            if (!ConfigState.Instance.GetGameplayConfig().BobEffects || !WeaponUseMovebob) //cancel viewbob if disabled
            {
                TargetPosition          = Vector3.zero;
                transform.localPosition = TargetPosition;
                return;
            }

            bool isADS = WeaponComponent.IsADS;

            if (isADS && !WasInADS) //ADS hack
            {
                transform.localPosition = Vector3.zero;
                TargetPosition          = Vector3.zero;
                WasInADS = true;
            }

            if (!isADS && WasInADS)
            {
                //reset state but don't change anything!
                WasInADS = false;
            }

            if ((transform.localPosition - TargetPosition).magnitude < Threshold)
            {
                if (!(MovementComponent.IsMoving || (MovementComponent.IsOnSlope && MovementComponent.Velocity.sqrMagnitude > 0)) ||
                    !MovementComponent.IsGrounded)
                {
                    if (TargetLastXSign == -1 || TargetLastXSign == 1)
                    {
                        TargetLastXSign *= -2;
                    }
                    TargetPosition = Vector3.zero;
                }
                //more complex selection logic
                else if (Mathf.Approximately(TargetPosition.y, 0))
                {
                    //move up and to one side
                    //TargetLastXSign *= -1;
                    TargetLastXSign = Math.Sign(TargetLastXSign);
                    TargetPosition  = new Vector3(TargetLastXSign * (XDisplacement + UnityEngine.Random.Range(-XJitter, XJitter)),
                                                  YDisplacement + UnityEngine.Random.Range(-YJitter, YJitter),
                                                  0);
                    if (isADS)
                    {
                        TargetPosition *= ADSDisplacementMultiplier;
                    }
                }
                else
                {
                    //return to center
                    TargetLastXSign *= -1;
                    TargetPosition   = Vector3.zero;
                }
            }

            //animate toward target (same as player movebob I think)
            Vector3 vecToTarget  = TargetPosition - transform.localPosition;
            float   distToTarget = vecToTarget.magnitude;

            if (distToTarget > Threshold)
            {
                //get extra velocity from movement speed
                float   extraVelocity = VelocityFactor * MovementComponent.Velocity.GetFlatVector().magnitude;
                Vector3 dirToTarget   = vecToTarget.normalized;
                float   moveDist      = Mathf.Min(distToTarget, (BaseVelocity + extraVelocity) * Time.deltaTime * (isADS ? ADSVelocityMultiplier : 1));
                transform.Translate(moveDist * dirToTarget, Space.Self);
            }
        }