コード例 #1
0
        private void FixedUpdate()
        {
            if (!isOwner)
            {
                return;
            }

            Input.UpdateKeyboard();
            Input.UpdateCombat(ActiveWeapon.HasHeavyAttack);
            if (ActiveWeapon.HasHeavyAttack)
            {
                Input.UpdateHeavyCombat();
            }

            if (!Networker.nv_Dead.Value)
            {
                // If it's Touchdown and the game is in progress or we're the person who scored, then we can move, otherwise, we freeze
                bool td = (Game.Game.Instance.Mode == Game.Game.GameModes.Touchdown && Game.Game.Instance.nv_InProgress.Value) || (Game.Game.Instance.Mode == Game.Game.GameModes.Touchdown && Game.Objects.Ball.Instance.LocalOwner == this);

                if (td)
                {
                    DoLogic();

                    if (moveMotor)
                    {
                        Motor.HandleChecks();
                        Motor.HandleMovement();
                    }
                }
            }

            Animator.HandleAnimations();

            // Regen stamina
            if (!Motor.State.IsSprinting && Game.Objects.Ball.Instance.LocalOwner != this)
            {
                State.Stamina += StaminaRegenSpeed * Time.deltaTime;
            }
            State.Stamina = Mathf.Clamp(State.Stamina, 0, MaxStamina);
        }
コード例 #2
0
        private void Update()
        {
            if (!IsOwner)
            {
                Vector3 aimPos = new Vector3(nv_AimPositionX.Value / 10, nv_AimPositionY.Value / 10, nv_AimPositionZ.Value / 10);
                Controller.AimTarget.position = aimPos;

                Controller.transform.position = Vector3.MoveTowards(Controller.transform.position, ReceivedPosition, 15 * Time.deltaTime);
                //Controller.transform.position = Vector3.Lerp(Controller.transform.position, ReceivedPosition, 10 * Time.deltaTime);
                Controller.transform.localEulerAngles = new Vector3(0, ReceivedPosition.w, 0);//Vector3.Lerp(Controller.transform.localEulerAngles, new Vector3(0, ReceivedPosition.w, 0), 25 * Time.deltaTime);

                Controller.SelectedWeapon = nv_SelectedWeapon.Value;

                // Update our animator
                Animator.HandleAnimations();

                // Set a variable to see if our camera can see the active player
                // We do this here so that we don't do this multiple times in different locations (causing more unnecessary calls)
                CanSeePlayer = PlayerMethods.CanSeeObject(Controller.Motor.Controller.bounds);
            }
            else
            {
                // Set our network object variables
                nv_Stamina.Value = (short)(Controller.State.Stamina * 100); // Keep in mind this is divided by 100

                b1.DrawingWeapon       = Controller.State.DrawingWeapon;
                b1.Aiming              = Controller.State.Aiming;
                nv_ChargedAmount.Value = (short)(Controller.State.ChargedAmount * 100); // Keep in mind this is divided by 100

                b1.Attacking          = Controller.State.Attacking;
                nv_AttackNumber.Value = Controller.State.AttackNumber;

                b1.Reloading            = Controller.State.Reloading;
                nv_SelectedWeapon.Value = Controller.State.SelectedWeapon;

                nv_Pitch.Value        = (short)(Controller.Input.Pitch * 100);
                nv_AimPositionX.Value = (short)(Controller.AimTarget.position.x * 10);
                nv_AimPositionY.Value = (short)(Controller.AimTarget.position.y * 10);
                nv_AimPositionZ.Value = (short)(Controller.AimTarget.position.z * 10);

                b1.IsGrounded  = Controller.Motor.State.IsGrounded;
                b1.IsSprinting = Controller.Motor.State.IsSprinting;
                b3.IsJumpDelay = Controller.Motor.State.IsJumpDelay;

                b1.IsDodging      = Controller.Motor.State.IsDodging;
                b1.DodgeDirection = Controller.Motor.State.DodgeDirection == 1;  // If our dodge direction is 1, we are dodging right ; else we are dodging left

                b2.IsWallSliding = Controller.Motor.State.IsWallSliding;
                //nv_WallHitNormalX.Value = (short)(Controller.Motor.State.WallHitNormal.x * 100);
                //nv_WallHitNormalZ.Value = (short)(Controller.Motor.State.WallHitNormal.z * 100);

                b2.IsWallJumpFrozen = Controller.Motor.State.IsWallJumpFrozen;
                b2.IsWallJumping    = Controller.Motor.State.IsWallJumping;

                b2.IsKnockingBack = Controller.Motor.State.IsKnockingBack;
                b2.IsWallSlammed  = Controller.Motor.State.IsWallSlammed;
                b2.IsPushingBack  = Controller.Motor.State.IsPushingBack;
                b2.IsFlinching    = Controller.Motor.State.IsFlinching;
                b2.IsStunned      = Controller.Motor.State.IsStunned;

                nv_Radius.Value     = (short)(Controller.Motor.Controller.radius * 1000); // Keep in mind this is divided by 1000
                nv_Collidable.Value = Controller.Motor.State.Collidable;

                if (Time.time - lastSentTime > (1f / PositionUpdatesPerSecond))
                {
                    Vector4 position = Controller.transform.position;
                    position.w = Controller.transform.localEulerAngles.y;

                    short moveDirX = (short)(Controller.Motor.State.MoveDirection.x * 1000);
                    short moveDirY = (short)(Controller.Motor.State.MoveDirection.y * 1000);
                    short moveDirZ = (short)(Controller.Motor.State.MoveDirection.z * 1000);

                    short moveSpeed = (short)(Controller.Motor.State.MoveSpeed * 1000);

                    // Set the bool arrays
                    bArray1 = new bool[8]
                    {
                        b1.DrawingWeapon,
                        b1.Aiming,
                        b1.Attacking,
                        b1.Reloading,
                        b1.IsGrounded,
                        b1.IsSprinting,
                        b1.IsDodging,
                        b1.DodgeDirection
                    };
                    bArray2 = new bool[8]
                    {
                        b2.IsWallSliding,
                        b2.IsWallJumpFrozen,
                        b2.IsWallJumping,
                        b2.IsKnockingBack,
                        b2.IsWallSlammed,
                        b2.IsPushingBack,
                        b2.IsFlinching,
                        b2.IsStunned
                    };
                    bArray3 = new bool[8]
                    {
                        b3.IsJumpDelay,
                        b3.fill_1,
                        b3.fill_2,
                        b3.fill_3,
                        b3.fill_4,
                        b3.fill_5,
                        b3.fill_6,
                        b3.fill_7,
                    };

                    InvokeServerRpc("Move_Server", position.x, position.y, position.z, position.w, moveDirX, moveDirY, moveDirZ, moveSpeed, ConvertBoolArrayToByte(bArray1), ConvertBoolArrayToByte(bArray2), ConvertBoolArrayToByte(bArray3), channel: "Unreliable");
                    lastSentTime = Time.time;
                }
            }
        }