public void CrossFade(string animation, float fadeTime = 0.2f, System.Action complete = null)
        {
            AniAndSound info = ActionConifg.GetAniAndSound(PetName, animation);

            GuLog.Debug("<><BasePlayer>CrossFade Pet:" + PetName + "  Ani:" + animation);
            if (info != null)
            {
                GuLog.Debug("<><BasePlayer>Play Action:" + info.AniName);

                if (animator)
                {
                    animator.CrossFade(info.AniName, fadeTime);
                    if (this.coroutine != null)
                    {
                        this.StopCoroutine(this.coroutine);
                    }
                    this.coroutine = StartCoroutine(WaitAnimationPlayComplete(animation, complete));
                }
                if (!string.IsNullOrEmpty(info.SoundType))
                {
                    this.lastSoundType = info.SoundType;
                    SoundPlayer.GetInstance().PlayRoleSound(info.SoundType);
                }
            }
        }
        public void Play(string strAni)
        {
            if (string.IsNullOrEmpty(PetName) || string.IsNullOrEmpty(strAni))
            {
                return;
            }

            AniAndSound info = ActionConifg.GetAniAndSound(PetName, strAni);

            GuLog.Debug("<><BasePlayer>Play Pet:" + PetName + "  Ani:" + strAni);
            if (info != null)
            {
                GuLog.Debug("<><BasePlayer>Play Action:" + info.AniName);
                if (animator)
                {
                    animator.Play(info.AniName);
                }
                Debug.LogFormat("<><BasePlayer.Play>Sound: {0}, HasModulePageOpened: {1}, InGuideView: {2}",
                                info.SoundType, TopViewHelper.Instance.HasModulePageOpened(), TopViewHelper.Instance.IsInGuideView());
                if (!string.IsNullOrEmpty(info.SoundType) && this.PlayerDataManager.LanguageInitialized() &&
                    (!TopViewHelper.Instance.HasModulePageOpened() || TopViewHelper.Instance.IsInGuideView()))
                {//设置过语言且没有打开任何功能模块,或正在引导才能播放此声音
                    Debug.LogFormat("<><BasePlayer.Play>Sound: {0} ==== Playing", info.SoundType);
                    SoundPlayer.GetInstance().PlayRoleSound(info.SoundType);
                }
            }
        }
Exemple #3
0
 //加载配置数据
 private IEnumerator LoadConfigs()
 {
     yield return(new WaitUntil(() => MissionConifg.IsLoadedOK())); RefreshProgress();
     yield return(new WaitUntil(() => TaskConifg.IsLoadedOK())); RefreshProgress();
     yield return(new WaitUntil(() => ItemConifg.IsLoadedOK())); RefreshProgress();
     yield return(new WaitUntil(() => TreasureBoxConfig.IsLoadedOK())); RefreshProgress();
     yield return(new WaitUntil(() => RoleConifg.IsLoadedOK())); RefreshProgress();
     yield return(new WaitUntil(() => ActionConifg.IsLoadedOK())); RefreshProgress();
     yield return(new WaitUntil(() => SoundConfig.IsLoadedOK())); RefreshProgress();
     yield return(new WaitUntil(() => LevelConifg.IsLoadedOK())); RefreshProgress();
     yield return(new WaitUntil(() => PlayerDataManager.Init())); RefreshProgress();
     Debug.Log("<><MainSceneLoader.LoadConfigs>all configs loaded");
 }
        public void PlayActionSound(string strAni)
        {
            AniAndSound info = ActionConifg.GetAniAndSound(PetName, strAni);

            GuLog.Debug("<><BasePlayer>Play Pet:" + PetName + "  Ani:" + strAni);
            if (info != null)
            {
                Debug.LogFormat("<><BasePlayer.PlayActionSound>Sound: {0}, HasModulePageOpened: {1}, InGuideView: {2}",
                                info.SoundType, TopViewHelper.Instance.HasModulePageOpened(), TopViewHelper.Instance.IsInGuideView());
                if (!string.IsNullOrEmpty(info.SoundType) && (!TopViewHelper.Instance.HasModulePageOpened() || TopViewHelper.Instance.IsInGuideView()))
                {//没有打开任何功能模块,或正在引导才能播放此声音
                    Debug.LogFormat("<><BasePlayer.PlayActionSound>Sound: {0} ==== Playing", info.SoundType);
                    SoundPlayer.GetInstance().PlayRoleSound(info.SoundType);
                }
            }
        }
 public bool IsActionOnPlaying(string strAni)
 {
     if (animator && gameObject.activeInHierarchy)
     {
         AniAndSound info = ActionConifg.GetAniAndSound(PetName, strAni);
         if (info != null)
         {
             AnimatorStateInfo stateinfo = animator.GetCurrentAnimatorStateInfo(0);
             return(stateinfo.IsName(info.AniName));
         }
         else
         {
             GuLog.Info("Not Action:" + strAni + "   in Pet model:" + PetName);
         }
     }
     return(true);
 }
        public float GetAnimationTime(string animationName)
        {
            float       length = 0;
            AniAndSound info   = ActionConifg.GetAniAndSound(PetName, animationName);

            GuLog.Debug("<><BasePlayer>GetAnimationTime Pet:" + PetName + "  Ani:" + animationName);
            if (info != null)
            {
                AnimationClip[] clips = this.animator.runtimeAnimatorController.animationClips;
                foreach (AnimationClip clip in clips)
                {
                    if (clip.name.ToLower().Contains(info.AniName.ToLower()))
                    {
                        length = clip.length;
                        break;
                    }
                }
            }
            return(length);
        }
Exemple #7
0
        /************************************************Unity方法与事件***********************************************/
        protected override void Start()
        {
            base.Start();

            videoPlayer.loopPointReached += (VideoPlayer source) =>
            {
                bMovieEnd = true;
            };

            BuglyUtil.Init();
            videoPlayer.Prepare();
            MissionConifg.LoadMissionConfig();
            propertyConfig.LoadPropertyConfig();
            TaskConifg.LoadTaskData();
            ItemConifg.LoadItemsConfig();
            TreasureBoxConfig.LoadTreasureBoxConfig();
            iconManager.OnlyLoadSelf();
            RoleConifg.LoadRoleConfig();
            LanConfig.LoadLanConfig();
            FontConfig.LoadFontConfig();
            I18NConfig.LoadResConfig();
            AccessoryConfig.LoadAccessoryConfig();
            AwardConfig.LoadAwardConfig();
            ActionConifg.LoadActionConfig();
            LevelConifg.LoadLevelConfig();
            SoundConfig.LoadSoundConfig();
            imageProgress.fillAmount = 0;
            GuLog.Debug("<><Preload>Load Begin!");
            StartCoroutine(StartLoading());
#if CLEAR_DATA
            LocalDataManager.getInstance().deleteAll();
#endif
            mHeartbearActionManager.addEventListener(mUploadFreindHeatbeatAction);
            mHeartbearActionManager.addEventListener(mUploadintakeHeatbeatAction);
            mHeartbeatManager.setHeartbeatListener(() =>
            {
                GuLog.Debug("Preload start do heart beat");
                mHeartbearActionManager.startHeartbeat();
            });
        }