예제 #1
0
        public void UpdateInputs()
        {
            inputHashes = new int[inputs.Length];

            if (inputsDic == null)
            {
                inputsDic = new Dictionary <int, InputItem>(inputs.Length);
            }
            else
            {
                inputsDic.Clear();
            }

            if (enabledInputs == null)
            {
                enabledInputs = new Dictionary <int, bool>(inputs.Length);
            }
            else
            {
                enabledInputs.Clear();
            }

            for (int i = 0; i < inputs.Length; i++)
            {
                int hash = GoldPlayerController.InputNameToHash(inputs[i].ButtonName);
                inputHashes[i] = hash;

                inputsDic.Add(hash, inputs[i]);
                enabledInputs.Add(hash, false);
            }
        }
예제 #2
0
        protected override void OnInitialize()
        {
            // If the camera head is null, complain.
            if (cameraHead == null)
            {
                Debug.LogError($"'{PlayerController.gameObject.name}' needs to have Camera Head assigned in the Camera settings!");
                return;
            }

            if (IsCameraNull)
            {
                Debug.LogError($"'{PlayerController.gameObject.name}' needs to have a Target Camera assigned in the Camera Settings!");
                return;
            }

            lookHash = GoldPlayerController.InputNameToHash(input_Look);
            zoomHash = GoldPlayerController.InputNameToHash(zoomInput);

            originalFieldOfView = CameraFieldOfView;
            zoomFieldOfView     = originalFieldOfView;
            zoomTimer           = zoomOutTime;

            // Lock the cursor, if it should.
            LockCursor(shouldLockCursor);

            // Set the original head rotation to the one on the camera head.
            originalHeadRotation = cameraHead.localRotation;

            // Initialize the FOV kick module.
            fieldOfViewKick.Initialize(PlayerController, PlayerInput);
        }
        /// <summary>
        /// Initializes the audio behaviour.
        /// </summary>
        /// <param name="footstepsSource"></param>
        /// <param name="jumpSource"></param>
        /// <param name="landSource"></param>
        public void Initialize(GoldPlayerController playerController, IGoldInput input, AudioSource footstepsSource, AudioSource jumpSource, AudioSource landSource)
        {
            PlayerController = playerController;
            PlayerInput      = input;

            FootstepsSource = footstepsSource;
            JumpSource      = jumpSource;
            LandSource      = landSource;
        }
예제 #4
0
        internal void Reset()
        {
            // If the controller exists, default the camera head to the one provided on the controller.
            GoldPlayerController controller = GetComponent <GoldPlayerController>();

            if (controller != null && cameraHead == null)
            {
                cameraHead = controller.Camera.CameraHead;
            }
        }
예제 #5
0
        protected virtual void Awake()
        {
#if OBSOLETE
            Debug.LogError(gameObject.name + " has GoldPlayerInteraction attached. It will be removed on build. Please remove this component if you don't intend to use it.", gameObject);
#endif

            interactHash = GoldPlayerController.InputNameToHash(interactInput);

            // Apply the trigger interaction.
            SetTriggerInteraction();
        }
예제 #6
0
        /// <summary>
        /// Sets the player and finds all required components.
        /// </summary>
        private void SetPlayer(GoldPlayerController player)
        {
#if !GOLD_PLAYER_DISABLE_INTERACTION
            // Only get the interaction if the previous set player isn't the new player.
            if (player != null && this.player != player)
            {
                playerInteraction = player.GetComponent <GoldPlayerInteraction>();
            }
#endif
            // Set the player.
            this.player = player;
        }
예제 #7
0
        // Add all actions to the actions dictionary.
        public void UpdateActions()
        {
            if (actions == null)
            {
                return;
            }

            actionsDictionary = new Dictionary <int, InputAction>();
            for (int i = 0; i < actions.Length; i++)
            {
                actionsDictionary.Add(GoldPlayerController.InputNameToHash(actions[i].actionName), actions[i].action);
            }
        }
예제 #8
0
        private void GetStandardComponents()
        {
            // Gets the controller in the editor, usually when the script is added.
            // Avoids a GetComponent in Awake.
            if (controller == null)
            {
                controller = GetComponent <CharacterController>();
            }

            if (playerController == null)
            {
                playerController = GetComponent <GoldPlayerController>();
            }
        }
예제 #9
0
        /// <summary>
        /// Initialize the module.
        /// </summary>
        /// <param name="player">The player controller itself.</param>
        /// <param name="input">Input, if available.</param>
        public void Initialize(GoldPlayerController player, IGoldInput input)
        {
            // If the module has already been initialized, stop here.
            if (HasBeenInitialized)
            {
                return;
            }

            playerController = player;
            if (input != null)
            {
                playerInput = input;
            }

            OnInitialize();

            HasBeenInitialized = true;
        }
예제 #10
0
        private void GetStandardComponents()
        {
            // Get the controller in the editor and cache it.
            if (controller == null)
            {
                controller = GetComponent <CharacterController>();
            }

            if (playerController == null)
            {
                playerController = GetComponent <GoldPlayerController>();
            }

            // Adapt to values if they are changed in play mode.
            if (Application.isPlaying)
            {
                ValidateParameters();
                GetAnimatorHashes();
                UpdateTargetLookAngle();
            }
        }
        private void Reset()
        {
            GoldPlayerController gp = GetComponent <GoldPlayerController>();

#if !GOLD_PLAYER_DISABLE_INTERACTION
            GoldPlayerInteraction gi = GetComponent <GoldPlayerInteraction>();
#endif

            // If the player controller exists, add the input action name from there, otherwise just make it generic.
            actions = new InputSystemItem[]
            {
                new InputSystemItem(gp != null ? gp.Camera.LookInput : "Look", null),
                new InputSystemItem(gp != null ? gp.Movement.MoveInput : "Move", null),
                new InputSystemItem(gp != null ? gp.Movement.JumpInput : "Jump", null),
                new InputSystemItem(gp != null ? gp.Movement.RunInput : "Run", null),
                new InputSystemItem(gp != null ? gp.Movement.CrouchInput : "Crouch", null),
#if !GOLD_PLAYER_DISABLE_INTERACTION
                new InputSystemItem(gi != null ? gi.InteractInput : "Interact", null)
#endif
            };
        }
예제 #12
0
 /// <summary>
 /// Gets a Vector2 input value.
 /// It's much more recommended to cache a hash using <see cref="GoldPlayerController.InputNameToHash"/>
 /// and call <see cref="GetAxisRaw(int)"/> instead.
 /// </summary>
 /// <param name="action"></param>
 /// <returns></returns>
 protected Vector2 GetVector2Input(string action)
 {
     return(GetVector2Input(GoldPlayerController.InputNameToHash(action)));
 }
예제 #13
0
 /// <summary>
 /// Equivalent to Input's GetAxisRaw function.
 /// It's much more recommended to cache a hash using <see cref="GoldPlayerController.InputNameToHash"/>
 /// and call <see cref="GetAxisRaw(int)"/> instead.
 /// </summary>
 /// <param name="axisName">The axis name you want to get.</param>
 protected float GetAxisRaw(string axisName)
 {
     return(GetAxisRaw(GoldPlayerController.InputNameToHash(axisName)));
 }
예제 #14
0
 /// <summary>
 /// Equivalent to Input's GetButtonUp/GetKeyUp function.
 /// It's much more recommended to cache a hash using <see cref="GoldPlayerController.InputNameToHash"/>
 /// and call <see cref="GetButtonUp(int)"/> instead.
 /// </summary>
 /// <param name="buttonName">The button name you want to get.</param>
 protected bool GetButtonUp(string buttonName)
 {
     return(GetButtonUp(GoldPlayerController.InputNameToHash(buttonName)));
 }
예제 #15
0
 public void Initialize(GoldPlayerController player, IGoldInput input)
 {
 }