Exemplo n.º 1
0
        public bool TriggerDialog(uint dialogId, string customName, Actor otherPlayer, uint actorId, System.Action finishedCallback, System.Action skipedCallback, Task relatedTask)
        {
            //dialogId = 1014;

            DBDialog dbDialog = DBManager.GetInstance().GetDB <DBDialog>();

            DBDialog.DialogInfo dialogInfo = dbDialog.GetDialog(dialogId);

            if (dialogInfo == null)
            {
                GameDebug.LogError("Trigger dialog error, can not find dialog " + dialogId);

                if (finishedCallback != null)
                {
                    finishedCallback();
                }
                return(false);
            }

            if (dialogInfo.mType == DBDialog.EDialogType.IST_DialogBox)
            {
                return(TriggerDialogBox(dialogInfo, customName, otherPlayer, actorId, finishedCallback, skipedCallback, relatedTask));
            }
            else if (dialogInfo.mType == DBDialog.EDialogType.IST_Bubble)
            {
                TriggerBubble(dialogInfo, finishedCallback);
            }

            return(false);
        }
Exemplo n.º 2
0
        void GoToNextBubble(float remainTime, Utils.Timer timer)
        {
            DBDialog.DialogInfo dialogInfo = timer.UserData as DBDialog.DialogInfo;

            if (dialogInfo == null)
            {
                return;
            }

            uint dialogNum         = (uint)dialogInfo.mDialogs.Count;
            uint bubbleDialogIndex = 0;

            if (mBubbleDialogIndexs.TryGetValue(dialogInfo.mId, out bubbleDialogIndex) && bubbleDialogIndex < (dialogNum - 1)) // 对话还没完
            {
                bubbleDialogIndex++;
                mBubbleDialogIndexs[dialogInfo.mId] = bubbleDialogIndex;

                TriggerBubbleImpl(bubbleDialogIndex, dialogInfo);
            }
            else
            {
                if (timer != null)
                {
                    timer.Destroy();
                    timer = null;
                }

                System.Action bubbleFinishedCallback;
                if (mBubbleFinishedCallbacks.TryGetValue(dialogInfo.mId, out bubbleFinishedCallback))
                {
                    if (bubbleFinishedCallback != null)
                    {
                        bubbleFinishedCallback();
                    }
                }

                if (mBubbleDialogInfos.ContainsKey(dialogInfo.mId))
                {
                    mBubbleDialogInfos.Remove(dialogInfo.mId);
                }
                if (mBubbleDialogIndexs.ContainsKey(dialogInfo.mId))
                {
                    mBubbleDialogIndexs.Remove(dialogInfo.mId);
                }
                if (mBubbleFinishedCallbacks.ContainsKey(dialogInfo.mId))
                {
                    mBubbleFinishedCallbacks.Remove(dialogInfo.mId);
                }
                if (mBubbleTimers.ContainsKey(dialogInfo.mId))
                {
                    mBubbleTimers.Remove(dialogInfo.mId);
                }
            }
        }
Exemplo n.º 3
0
        bool TriggerBubbleImpl(uint dialogIndex, DBDialog.DialogInfo dialogInfo)
        {
            if (dialogIndex >= dialogInfo.mDialogs.Count)
            {
                return(false);
            }

            List <uint>     dialogs         = dialogInfo.mDialogs;
            DBDialogContent dbDialogContent = DBManager.GetInstance().GetDB <DBDialogContent>();

            DBDialogContent.DialogContentInfo dialogContentInfo = dbDialogContent.GetDialogContentInfo(dialogs[(int)dialogIndex]);

            Actor actor = null;

            if (dialogContentInfo.mObjectType == DBDialogContent.EDialogObjectType.DOT_Player)
            {
                actor = Game.GetInstance().GetLocalPlayer();
            }
            else if (dialogContentInfo.mObjectType == DBDialogContent.EDialogObjectType.DOT_NPC)
            {
                actor = NpcManager.Instance.GetNpcByNpcId(dialogContentInfo.mObjectParam);
            }
            else if (dialogContentInfo.mObjectType == DBDialogContent.EDialogObjectType.DOT_Monster)
            {
                //List<Actor> actors = InstanceHelper.GetMonstersByMonsterGroupId((int)dialogContentInfo.mObjectParam);
                //if (actors != null && actors.Count > 0)
                //{
                //    actor = actors[0];
                //}
            }
            if (actor == null)
            {
                GameDebug.LogError("TriggerBubble error, actor is null!!!");
                return(false);
            }
            actor.ShowDialogBubble(dialogContentInfo.mWords, (int)dialogContentInfo.mLength);


            Utils.Timer bubbleTimer;
            if (mBubbleTimers.TryGetValue(dialogInfo.mId, out bubbleTimer))
            {
                if (bubbleTimer != null)
                {
                    bubbleTimer.Destroy();
                    bubbleTimer = null;
                }
                mBubbleTimers.Remove(dialogInfo.mId);
            }
            bubbleTimer = new Utils.Timer(1000 * (int)dialogContentInfo.mLength, false, 1000 * dialogContentInfo.mLength, GoToNextBubble, dialogInfo);
            mBubbleTimers.Add(dialogInfo.mId, bubbleTimer);

            return(true);
        }
Exemplo n.º 4
0
        public void Reset()
        {
            mDialogInfo  = null;
            mDialogIndex = 0;

            mRelatedTask = null;

            mBubbleDialogInfos = new Dictionary <uint, DBDialog.DialogInfo>();
            mBubbleDialogInfos.Clear();
            mBubbleDialogIndexs = new Dictionary <uint, uint>();
            mBubbleDialogIndexs.Clear();
            mBubbleFinishedCallbacks = new Dictionary <uint, System.Action>();
            mBubbleFinishedCallbacks.Clear();
            mBubbleTimers = new Dictionary <uint, Utils.Timer>();
            mBubbleTimers.Clear();

            mPlayingVoiceDialogId = 0;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 触发相应的对话框
        /// </summary>
        /// <returns><c>true</c>, if dialog story was triggered, <c>false</c> otherwise.</returns>
        /// <param name="dialogInfo">Dialog info.</param>
        public bool TriggerDialogBox(DBDialog.DialogInfo dialogInfo, string customName, Actor otherPlayer, uint actorId, System.Action finishedCallback, System.Action skipedCallback, Task relatedTask)
        {
            ClearDialog();

            // 是否在系统开放中
            if (SysConfigManager.Instance.IsWaiting() == true)
            {
                GameDebug.LogWarning("DialogManager.TriggerDialogBox SysConfigManager is waiting!!");
                return(false);
            }

            if (dialogInfo != null)
            {
                GameDebug.Log("Trigger dialog box: " + dialogInfo.mId);

                mDialogInfo  = dialogInfo;
                mDialogIndex = 0;

                mCustomName  = customName;
                mOtherPlayer = otherPlayer;
                mActorId     = actorId;

                mFinishedCallback = finishedCallback;
                mSkipedCallback   = skipedCallback;

                mRelatedTask = relatedTask;

                ShowDialogWindow();

                return(true);
            }
            else
            {
                if (finishedCallback != null)
                {
                    finishedCallback();
                }
            }

            return(false);
        }
Exemplo n.º 6
0
        public bool TriggerBubble(DBDialog.DialogInfo dialogInfo, System.Action finishedCallback)
        {
            bool ret = false;

            if (dialogInfo != null)
            {
                //GameDebug.Log("Trigger dialog bubble: " + dialogInfo.mId);

                if (mBubbleDialogInfos.ContainsKey(dialogInfo.mId))
                {
                    mBubbleDialogInfos.Remove(dialogInfo.mId);
                }
                if (mBubbleDialogIndexs.ContainsKey(dialogInfo.mId))
                {
                    mBubbleDialogIndexs.Remove(dialogInfo.mId);
                }
                if (mBubbleFinishedCallbacks.ContainsKey(dialogInfo.mId))
                {
                    mBubbleFinishedCallbacks.Remove(dialogInfo.mId);
                }
                if (mBubbleTimers.ContainsKey(dialogInfo.mId))
                {
                    mBubbleTimers.Remove(dialogInfo.mId);
                }

                mBubbleDialogInfos.Add(dialogInfo.mId, dialogInfo);
                mBubbleDialogIndexs.Add(dialogInfo.mId, 0);
                mBubbleFinishedCallbacks.Add(dialogInfo.mId, finishedCallback);

                ret = TriggerBubbleImpl(0, dialogInfo);
            }

            if (ret == false)
            {
                if (finishedCallback != null)
                {
                    finishedCallback();
                }
            }
            return(ret);
        }
Exemplo n.º 7
0
 public bool TriggerBubble(DBDialog.DialogInfo dialogInfo)
 {
     return(TriggerBubble(dialogInfo, null));
 }
Exemplo n.º 8
0
 public bool TriggerDialogBox(DBDialog.DialogInfo dialogInfo, string customName, Actor otherPlayer, uint actorId = 0)
 {
     return(TriggerDialogBox(dialogInfo, customName, otherPlayer, actorId, null, null, null));
 }
Exemplo n.º 9
0
 public bool TriggerDialogBox(DBDialog.DialogInfo dialogInfo)
 {
     return(TriggerDialogBox(dialogInfo, "", null, 0, null, null, null));
 }