Exemplo n.º 1
0
        /// <summary>
        /// 发送谈话,等待时间后,返回收到的回答
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="waitms"></param>
        /// <returns></returns>
        public static List <string> TalkToAll(string msg, int waitms = 3000, int maxCount = 0)
        {
            msg = msg.Replace("\r\n", "").Replace("\n", "");
            int    id         = requestID;
            string requestMsg = string.Format("{0}#{1}#{2}", id, "0", msg);

            try
            {
                Notify(NotifyTalkTopic, requestMsg);
            }
            catch (Exception ex)
            { return(new List <string>()); }
            var waititem = new TalkItem(id, maxCount);

            lock (talkrequestslocker)
            {
                talkrequests.Add(waititem.RequestID, waititem);
            }
            waititem.MRE.WaitOne(waitms);
            lock (talkrequestslocker)
            {
                if (talkrequests.ContainsKey(id))
                {
                    var item = talkrequests[id];
                    talkrequests.Remove(id);
                    return(item.Response);
                }
                else
                {
                    return(new List <string>());
                }
            }
        }
Exemplo n.º 2
0
    void NormalCallBack(GameObject cell, int index)
    {
        TalkItem talkItem = cell.GetComponent <TalkItem>();

        if (index % 2 != 0)
        {
            ToolsManager.SetActive(talkItem.headLeft.gameObject, true);
            ToolsManager.SetActive(talkItem.textLeft.gameObject, true);
            talkItem.textLeft.text = index.ToString() + "世界终究在我脚下";
        }
        else
        {
            ToolsManager.SetActive(talkItem.headRight.gameObject, true);
            ToolsManager.SetActive(talkItem.textRight.gameObject, true);
            talkItem.textRight.text = index.ToString() + "世界终究在我脚下";
        }
    }