Пример #1
0
        private IEnumerator ShowModelTask(string name, string motionName, bool motionLoop, string expressionName, Vector3 position, float duration)
        {
            L2DModel model = LoadModel(name);

            if (model == null)
            {
                yield break;
            }

            model.SetActivate(true);
            model.SetEyeBlinkEnabled(false);
            if (expressionName == "")
            {
                model.ClearExpression(true);
            }
            else
            {
                model.SetExpression(expressionName, true);
            }
            model.SetMotion(motionName, motionLoop, true);
            model.SetPosition(position);
            float startTime = Time.time;

            while (Time.time - (startTime + duration) < 0.0f)
            {
                float rate = (Time.time - startTime) / duration;
                model.SetAlpha(Mathf.Lerp(0.0f, 1.0f, rate));
                yield return(null);
            }
            model.SetAlpha(1.0f);
        }
Пример #2
0
    /// <summary>
    /// 触发语音Item语音
    /// </summary>
    /// <param name="info"></param>
    public void Live2dTiggerVoice(CardAwardPreInfo info)
    {
        L2DModel model = _live2DGraphic.GetMainLive2DView.Model;

        _live2DGraphic.GetMainLive2DView.LipSync = true;

        if (info.dialogId == "")
        {
            model.SetExpression(model.ExpressionList[info.expressionId], 2);
            return;
        }
        new AssetLoader().LoadAudio(
            AssetLoader.GetMainPanleDialogById(info.dialogId), //expressionInfo.Dialog),
            (clip, loader) => {
            model.SetExpression(model.ExpressionList[info.expressionId], clip.length + 1);
            AudioManager.Instance.PlayDubbing(clip);
        });
    }
Пример #3
0
 void PlayDialog(string musicId, int expressionId, L2DModel model)
 {
     new AssetLoader().LoadAudio(AssetLoader.GetMainPanleDialogById(musicId), //expressionInfo.Dialog),
                                 (clip, loader) =>
     {
         AudioManager.Instance.PlayDubbing(clip);
         Debug.Log("AudioManager.Instance.PlayDubbing");
         model.SetExpression(model.ExpressionList[expressionId], clip.length + 1);
         isClick = false;
     });
 }
Пример #4
0
    /// <summary>
    /// 触发好感度主机界面摸摸乐语音
    /// </summary>
    /// <param name="eType"></param>
    /// <param name="labelId"></param>
    /// <param name="isSendClick"></param>
    private void Live2dTigger(EXPRESSIONTRIGERTYPE eType, int labelId = -1, bool isSendClick = true)
    {
        L2DModel       model          = _live2DGraphic.GetMainLive2DView.Model;
        ExpressionInfo expressionInfo = ClientData.GetRandomExpression(_npcId, eType, labelId);

        if (expressionInfo == null)
        {
            Debug.Log("expressionInfo == null");
            _isClick = false;
            return;
        }

        if (!model.IsIdle)
        {
            _isClick = false;
            Debug.LogError("model  is busy  ");
            return;
        }

        _live2DGraphic.GetMainLive2DView.LipSync = true;


        if (expressionInfo.Dialog == "")
        {
            Debug.Log("expressionInfo.Dialog == null");
            model.SetExpression(model.ExpressionList[expressionInfo.Id], 2);
            _isClick = false;
            return;
        }

        new AssetLoader().LoadAudio(AssetLoader.GetMainPanleDialogById(expressionInfo.Dialog), //expressionInfo.Dialog),
                                    (clip, loader) =>
        {
            AudioManager.Instance.PlayDubbing(clip);
            Debug.Log("AudioManager.Instance.PlayDubbing");
            model.SetExpression(model.ExpressionList[expressionInfo.Id], clip.length + 1);
            _isClick = false;
        });
    }
Пример #5
0
    /// <summary>
    /// 触发送礼语音
    /// </summary>
    /// <param name="pbId"></param>
    /// <param name="itemId"></param>
    public void Live2dTiggerGiftVoice(int pbId, int itemId)
    {
        L2DModel       model          = _live2DGraphic.GetMainLive2DView.Model;
        ExpressionInfo expressionInfo = ClientData.GetRandomGiftExpression(pbId, itemId);

        if (expressionInfo == null)
        {
            return;
        }
        _live2DGraphic.GetMainLive2DView.LipSync = true;
        model.SetExpression(model.ExpressionList[expressionInfo.Id]);
        if (expressionInfo.Dialog == "")
        {
            return;
        }
        new AssetLoader().LoadAudio(
            AssetLoader.GetMainPanleDialogById(expressionInfo.Dialog), //expressionInfo.Dialog),
            (clip, loader) => { AudioManager.Instance.PlayDubbing(clip); });
    }
Пример #6
0
        public override void Do()
        {
            L2DModel model = GameSystem._Instance._ModelManager.GetActiveModel(_ModelName);

            if (model == null)
            {
                Debug.LogError("[Command_Expression.NotExistActiveModel]" + _ModelName);
                return;
            }

            if (_ExpressionName == "")
            {
                model.ClearExpression(false);
            }
            else
            {
                model.SetExpression(_ExpressionName, false);
            }
        }
Пример #7
0
    private void ChangeRole(int id)
    {
        _isShowLive2d = true;
        _live2dGraphic.Show();
        var live2dName = id.ToString();

        if (_extendCacheVo != null && _extendCacheVo.needDownload)
        {
            var curStep = GuideManager.GetRemoteGuideStep(GuideTypePB.MainGuide);
            if (curStep >= GuideConst.MainLineStep_OnClick_FavorabilityShowMainViewBtn)
            {
                //老号,要读取默认的!
                _live2dGraphic.Hide();

                _live2dGraphic.LoadAnimationById(GlobalData.PlayerModel.PlayerVo.Apparel[0].ToString());
            }
            else
            {
                _live2dGraphic.LoadAnimationById(live2dName);
            }
        }
        else
        {
            //_cacheVo = CacheManager.CheckExtendCache();
            _live2dGraphic.LoadAnimationById(live2dName);
        }

//        Debug.LogError("load!");

        L2DModel model = _live2dGraphic.GetMainLive2DView.Model;

        model.StartMotion(L2DConst.MOTION_GROUP_IDLE, 0, L2DConst.PRIORITY_IDLE, true);
        model.SetExpression(model.ExpressionList[2]);
        model.StartEyeBlink();

        SetLive2dClickSize();

        SdkHelper.PushAgent.PushCreate30DaysNotice();
    }
Пример #8
0
    public void Live2dTigger(EXPRESSIONTRIGERTYPE eType, int labelId = -1, bool isSendClick = true)
    {
        //eType = EXPRESSIONTRIGERTYPE.LOVEDIARY;
        //labelId = 8004;
        L2DModel       model          = _live2dGraphic.GetMainLive2DView.Model;
        ExpressionInfo expressionInfo =
            ClientData.GetRandomExpression(GlobalData.PlayerModel.PlayerVo.NpcId, eType, labelId);

        if (expressionInfo == null)
        {
            Debug.Log("expressionInfo == null");
            isClick = false;
            return;
        }

        if (!model.IsIdle)
        {
            isClick = false;
            Debug.LogError("model  is busy  ");
            return;
        }

        if (isSendClick)
        {
            SendMessage(new Message(MessageConst.CMD_MAIN_ON_LIVE2DCLICK));
        }

        _live2dGraphic.GetMainLive2DView.LipSync = true;


        if (expressionInfo.Dialog == "")
        {
            Debug.Log("expressionInfo.Dialog == null");
            model.SetExpression(model.ExpressionList[expressionInfo.Id], 2);
            isClick = false;
            return;
        }

        string musicId = expressionInfo.Dialog;

        if (labelId != -1)
        {
            if (CacheManager.IsLoveDiaryNeedDown(musicId))
            {
                CacheManager.DownloadLoveDiaryCache(musicId, str =>
                {
                    Debug.LogError("DownloadLoveDiaryCache finish");
                    PlayDialog(musicId, expressionInfo.Id, model);
                }, () =>
                {
                    Debug.LogError("DownloadLoveDiaryCache error");
                    PlayDialog(musicId, expressionInfo.Id, model);
                });
            }
            else
            {
                PlayDialog(musicId, expressionInfo.Id, model);
            }

            //CacheVo cacheVo= CacheManager.CheckLoveDiaryCache(musicId);
            //if (cacheVo != null && cacheVo.needDownload)
            //{
            //    CacheManager.DownloadLoveDiaryCache(musicId, str =>
            //    {
            //        Debug.LogError("DownloadLoveDiaryCache finish");
            //        PlayDialog(musicId, expressionInfo.Id, model);
            //    }, ()=>{
            //        Debug.LogError("DownloadLoveDiaryCache error");
            //        PlayDialog(musicId, expressionInfo.Id, model);
            //    });
            //}
        }
        else
        {
            //new AssetLoader().LoadAudio(AssetLoader.GetMainPanleDialogById(expressionInfo.Dialog), //expressionInfo.Dialog),
            //(clip, loader) =>
            // {
            //     AudioManager.Instance.PlayDubbing(clip);
            //     Debug.Log("AudioManager.Instance.PlayDubbing");
            //    model.SetExpression(model.ExpressionList[expressionInfo.Id], clip.length + 1);
            // isClick = false;
            //});
            PlayDialog(musicId, expressionInfo.Id, model);
        }
    }