Пример #1
0
    private void InitTalk()
    {
        if (mTalkID < 0)
        {
            return;
        }
        if (!DataManager.NpcTalkTable.ContainsKey(mTalkID))
        {
            return;
        }

        NpcTalkTableItem item = DataManager.NpcTalkTable[mTalkID] as NpcTalkTableItem;

        if (!string.IsNullOrEmpty(item.talk1))
        {
            mNormalTalks = item.talk1.Split(new char[] { '|' });
        }
        if (!string.IsNullOrEmpty(item.talk2))
        {
            mFightingTalks = item.talk2.Split(new char[] { '|' });
        }

        mTalkTime  = item.Interval;
        mContinued = item.Continued;
        mInterval  = item.Interval;
    }
Пример #2
0
    private void UpdateTalk(uint elapsed)
    {
        if (mTalkID < 0)
        {
            return;
        }

        if (this.IsDead())
        {
            return;
        }

        mTalkTime -= (int)elapsed;
        if (mTalkTime <= 0)
        {
            if (DataManager.NpcTalkTable.ContainsKey(mTalkID))
            {
                NpcTalkTableItem item = DataManager.NpcTalkTable[mTalkID] as NpcTalkTableItem;

                string talk_str = item.talk1;
                if (this.IsFighting())
                {
                    talk_str = item.talk2;
                }

                if (string.IsNullOrEmpty(talk_str))
                {
                    return;
                }
                string[] talks = talk_str.Split(new char[] { '|' });

                if (talks.Length <= 0)
                {
                    return;
                }

                int idx = Random.Range(0, talks.Length);

                ShowTalk(talks[idx], item.Continued * 1000);

                mTalkTime = item.Interval * 1000 + item.Continued * 1000;
            }
        }
    }