// Called automatically by Unity when the script is first added to a gameobject or is reset from the context menu.
        void Reset()
        {
            meleeWeapon = GetComponentInChildren <MeleeWeapon>();

            Transform footStepSource = transform.Find("FootstepSource");

            if (footStepSource != null)
            {
                footstepPlayer = footStepSource.GetComponent <RandomAudioPlayer>();
            }

            Transform hurtSource = transform.Find("HurtSource");

            if (hurtSource != null)
            {
                hurtAudioPlayer = hurtSource.GetComponent <RandomAudioPlayer>();
            }

            Transform landingSource = transform.Find("LandingSource");

            if (landingSource != null)
            {
                landingPlayer = landingSource.GetComponent <RandomAudioPlayer>();
            }
        }
Пример #2
0
        void AudioInit()
        {
            Transform audioSource = transform.Find("AudioSources");

            if (audioSource == null)
            {
                return;
            }

            Transform footStepSource = audioSource.Find("FootstepSource");

            if (footStepSource != null)
            {
                footstepPlayer = footStepSource.GetComponent <RandomAudioPlayer>();
            }

            Transform hurtSource = audioSource.Find("HurtSource");

            if (hurtSource != null)
            {
                hurtAudioPlayer = hurtSource.GetComponent <RandomAudioPlayer>();
            }

            Transform landingSource = audioSource.Find("LandingSource");

            if (landingSource != null)
            {
                landingPlayer = landingSource.GetComponent <RandomAudioPlayer>();
            }

            Transform emoteLanding = audioSource.Find("EmoteLanding");

            if (emoteLanding != null)
            {
                emoteLandingPlayer = emoteLanding.GetComponent <RandomAudioPlayer>();
            }

            Transform emoteDeath = audioSource.Find("EmoteDeath");

            if (emoteDeath != null)
            {
                emoteDeathPlayer = emoteDeath.GetComponent <RandomAudioPlayer>();
            }

            Transform emoteAttack = audioSource.Find("EmoteAttack");

            if (emoteAttack != null)
            {
                emoteAttackPlayer = emoteAttack.GetComponent <RandomAudioPlayer>();
            }

            Transform emoteJump = audioSource.Find("EmoteJump");

            if (emoteJump != null)
            {
                emoteJumpPlayer = emoteJump.GetComponent <RandomAudioPlayer>();
            }
        }
Пример #3
0
        public void TriggerAttack()
        {
            _currentAttack = Random.Range(1, 3) == 1 ? BasicAttack : ClawAttack;

            CurrentAttackAudio = _currentAttack == BasicAttack ? AttackAudio : ClawAttackAudio;

            Controller.animator.SetTrigger(_currentAttack);
            AttackBegin();
        }
Пример #4
0
        // Called automatically by Unity when the script is first added to a gameobject or is reset from the context menu.
        void Reset()
        {
            meleeWeapon = GetComponentInChildren <MeleeWeapon>();

            Transform footStepSource = transform.Find("FootstepSource");

            if (footStepSource != null)
            {
                footstepPlayer = footStepSource.GetComponent <RandomAudioPlayer>();
            }

            Transform hurtSource = transform.Find("HurtSource");

            if (hurtSource != null)
            {
                hurtAudioPlayer = hurtSource.GetComponent <RandomAudioPlayer>();
            }

            Transform landingSource = transform.Find("LandingSource");

            if (landingSource != null)
            {
                landingPlayer = landingSource.GetComponent <RandomAudioPlayer>();
            }

            cameraSettings = FindObjectOfType <CameraSettings>();

            if (cameraSettings != null)
            {
                if (cameraSettings.follow == null)
                {
                    cameraSettings.follow = transform;
                }

                if (cameraSettings.lookAt == null)
                {
                    cameraSettings.follow = transform.Find("HeadTarget");
                }
            }
        }
Пример #5
0
        // Called automatically by Unity when the script is first added to a gameobject or is reset from the context menu.
        //当脚本首次添加到游戏对象或从上下文菜单重置时,由Unity自动调用。
        void Reset()
        {
            meleeWeapon = GetComponentInChildren <MeleeWeapon>();        //获取武器

            Transform footStepSource = transform.Find("FootstepSource"); //获取行走资源

            if (footStepSource != null)                                  //根据玩家不同的状态播放不同的音频
            {
                footstepPlayer = footStepSource.GetComponent <RandomAudioPlayer>();
            }

            Transform hurtSource = transform.Find("HurtSource");

            if (hurtSource != null)
            {
                hurtAudioPlayer = hurtSource.GetComponent <RandomAudioPlayer>();
            }

            Transform landingSource = transform.Find("LandingSource");

            if (landingSource != null)
            {
                landingPlayer = landingSource.GetComponent <RandomAudioPlayer>();
            }

            cameraSettings = FindObjectOfType <CameraSettings>(); //初始化相机设置

            if (cameraSettings != null)                           //根据跟随状态还是注视状态调整相机的位置
            {
                if (cameraSettings.follow == null)
                {
                    cameraSettings.follow = transform;
                }

                if (cameraSettings.lookAt == null)
                {
                    cameraSettings.follow = transform.Find("HeadTarget");
                }
            }
        }