private void Live2dClickTigger(GameObject obj)
    {
        EXPRESSIONTRIGERTYPE eType = EXPRESSIONTRIGERTYPE.NO;

        if (obj.name == "Head")
        {
            eType = EXPRESSIONTRIGERTYPE.HEAD;
        }
        else if (obj.name == "Body")
        {
            eType = EXPRESSIONTRIGERTYPE.BODY;
        }
        else
        {
            eType = EXPRESSIONTRIGERTYPE.NORMAL;
        }
        if (_isClick)
        {
            return;
        }
        if (AudioManager.Instance.IsPlayingDubbing)
        {
            return;
        }

        _isClick = true;
        ExpressionInfo expressionInfo = ClientData.GetRandomExpression(_npcId, eType);

        Live2dTigger(eType);
    }
Exemple #2
0
    public void Update(LIVE2DVIEWTYPE viewType)
    {
        if (live2DModel == null)
        {
            Debug.Log("Can not update there is no model data");
            return;
        }

        if (mainMotionManager.isFinished())
        {
            if (viewType == LIVE2DVIEWTYPE.MAINPANLE)
            {
                EXPRESSIONTRIGERTYPE eType          = EXPRESSIONTRIGERTYPE.NORMAL;
                ExpressionInfo       expressionInfo = ClientData.GetRandomExpression(_modelId, eType);
                if (expressionInfo == null)
                {
                    return;
                }
                string  name   = ExpressionList[expressionInfo.Id];
                AMotion motion = expressions[name];

                int no = UnityEngine.Random.Range(0, MotionList.Count);
                StartMotion(L2DConst.MOTION_GROUP_IDLE, no, L2DConst.PRIORITY_IDLE, _loop);
                if (Time.realtimeSinceStartup > _setExpressionTime + _interval)
                {
                    SetExpression(name);
                }
            }
            else
            {
                StartMotion(L2DConst.MOTION_GROUP_IDLE, _currentMontionIndex, L2DConst.PRIORITY_IDLE, _loop);
            }
        }

        //-----------------------------------------------------------------
        live2DModel.loadParam();
        mainMotionManager.updateParam(live2DModel);


        //眨眼睛
        eyeBlink?.updateParam(live2DModel);
        live2DModel.saveParam();

        expressionManager.updateParam(live2DModel);

        if (physics != null)
        {
            physics.updateParam(live2DModel);
        }


        // live2DModel.update();
    }
Exemple #3
0
        public static ExpressionInfo GetRandomExpression(string modelId, EXPRESSIONTRIGERTYPE expressionType)
        {
            int  npcId = 0;
            bool isConversionSuccessful = int.TryParse(modelId, out npcId);

            if (isConversionSuccessful)
            {
                return(GetRandomExpression((npcId / 100) % 10, expressionType));
            }
            else
            {
                return(null);
            }
        }
Exemple #4
0
 public string UnlockDescription; //解锁描述
 public ExpressionInfo(string[] arr)
 {
     //解析数据
     Id                = int.Parse(arr[0]);
     Name              = arr[1];
     Remark            = arr[2];
     ActionId          = int.Parse(arr[3]);
     TriggerType       = (EXPRESSIONTRIGERTYPE)int.Parse(arr[4]);
     Weight            = int.Parse(arr[5]);
     Dialog            = arr[6];
     NpcId             = int.Parse(arr[7]);
     StartTime         = arr[8];
     EndTime           = arr[9];
     LabelId           = arr[10];
     DialogId          = arr[11];
     GiftId            = arr[12];
     DialogName        = arr[13];
     UnlockDescription = arr[14];
 }
Exemple #5
0
 private static bool CheckIsSatisfaction(ExpressionInfo info, EXPRESSIONTRIGERTYPE expressonType, int labelId)
 {
     if (info.TriggerType != expressonType)
     {
         return(false);
     }
     if (!info.IsTimeRange(DateUtil.GetTodayDt()))
     {
         return(false);
     }
     if (labelId > 0)
     {
         if (info.LabelId == labelId.ToString())
         {
             return(GlobalData.DiaryElementModel.IsCanUseElement(int.Parse(info.DialogId)));
         }
         return(false);
     }
     return(true);
 }
Exemple #6
0
        public static List <ExpressionInfo> GetDrawCardExpressionInfos(int NpcId, EXPRESSIONTRIGERTYPE expressionType)
        {
            if (!ExpressionInfoDict.ContainsKey(NpcId))
            {
                return(null);
            }
            ExpressionInfo        expressionInfo = null;
            List <ExpressionInfo> list           = new List <ExpressionInfo>();

            for (int i = 0; i < ExpressionInfoDict[NpcId].Count; i++)
            {
                expressionInfo = ExpressionInfoDict[NpcId][i];
                if (expressionInfo.TriggerType == expressionType
                    )
                {
                    list.Add(expressionInfo);
                }
            }
            return(list);
        }
    /// <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;
        });
    }
Exemple #8
0
        /// <summary>
        /// 根据配置表,获取角色对应触发条件expressonType的随机表情
        /// </summary>
        /// <param name="NpcId"></param>
        /// <param name="expressonType"></param>
        /// <returns></returns>
        public static ExpressionInfo GetRandomExpression(int NpcId, EXPRESSIONTRIGERTYPE expressonType, int labelId = -1)
        {
            ExpressionInfo expressionInfo = null;

            if (!ExpressionInfoDict.ContainsKey(NpcId))
            {
                return(null);
            }

            List <ExpressionInfo> list = new List <ExpressionInfo>();

            for (int i = 0; i < ExpressionInfoDict[NpcId].Count; i++)
            {
                expressionInfo = ExpressionInfoDict[NpcId][i];
                if (CheckIsSatisfaction(expressionInfo, expressonType, labelId))
                //expressionInfo.IsTimeRange(DateUtil.GetTodayDt()))
                {
                    list.Add(expressionInfo);
                }
            }

            return(GetRandomExpression(list));
        }
Exemple #9
0
        /// <summary>
        /// 通过对话ID等到标签ID
        /// </summary>
        /// <param name="NpcId"></param>
        /// <param name="expressonType"></param>
        /// <param name="dialogId"></param>
        /// <returns></returns>
        public static int GetExpressionLabelIdByDialogID(int NpcId, EXPRESSIONTRIGERTYPE expressonType, int dialogId)
        {
            if (!ExpressionInfoDict.ContainsKey(NpcId))
            {
                return(-1);
            }
            ExpressionInfo expressionInfo = null;

            for (int i = 0; i < ExpressionInfoDict[NpcId].Count; i++)
            {
                expressionInfo = ExpressionInfoDict[NpcId][i];
                if (expressionInfo.TriggerType != expressonType)
                {
                    continue;
                }
                if (int.Parse(expressionInfo.DialogId) != dialogId)
                {
                    continue;
                }
                return(int.Parse(expressionInfo.LabelId));
            }
            return(-1);
        }
Exemple #10
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);
        }
    }