コード例 #1
0
        public void AddLobbyChatMessage(Dictionary <string, object> in_jsonMessage)
        {
            BaseState lobbyState = GStateManager.Instance.FindSubState(LobbySubState.STATE_NAME);

            if (lobbyState != null && m_lobbyChatContent == null)
            {
                m_lobbyChatContent = lobbyState.transform.FindDeepChild("lobbyChatContent").gameObject;
            }
            if (m_lobbyChatContent == null)
            {
                return;
            }

            Transform contentTransform = m_lobbyChatContent.transform;

            lock (contentTransform)
            {
                // populate based on the incoming data
                if (contentTransform.childCount >= 30)
                {
                    Destroy(contentTransform.transform.GetChild(0).gameObject);
                }

                ChatCell   tempCell;
                GameObject tempObj;
                Dictionary <string, object> jsonData = in_jsonMessage.ContainsKey("data") ?
                                                       (Dictionary <string, object>)in_jsonMessage["data"] : in_jsonMessage;

                Dictionary <string, object> fromData = (Dictionary <string, object>)jsonData["from"];

                Dictionary <string, object> signalData = jsonData.ContainsKey("signalData") ?
                                                         (Dictionary <string, object>)jsonData["signalData"] : jsonData;
                string profileId = fromData["id"] as string;
                int    rank      = (int)signalData["rank"];

                tempObj = Instantiate(profileId == GCore.Wrapper.Client.ProfileId ? LobbyChatCellYou :                       // is you!
                                      profileId != ChatCell.SYSTEM_MESSAGE ? LobbyChatCellOther : LobbyChatCellSystem,       // A non system meessage?
                                      Vector3.zero, Quaternion.identity, contentTransform);

                tempCell = tempObj.GetComponent <ChatCell>();
                tempCell.Init(fromData["name"] as string, signalData["message"] as string, profileId, fromData.ContainsKey("pic") ? fromData["pic"] as string : null, "", rank);

                GEventManager.TriggerEvent("NEW_LOBBY_CHAT");
            }
        }
コード例 #2
0
        private void addChatMessageToContent(Dictionary <string, object> in_jsonMessage, Transform contentTransform, bool in_lobbyView = false)
        {
            lock (contentTransform)
            {
                // populate based on the incoming data
                if (contentTransform.childCount >= 30)
                {
                    Destroy(contentTransform.transform.GetChild(0).gameObject);
                }

                ChatCell   tempCell;
                GameObject tempObj;
                Dictionary <string, object> jsonData = in_jsonMessage.ContainsKey("data") ?
                                                       (Dictionary <string, object>)in_jsonMessage["data"] : in_jsonMessage;

                Dictionary <string, object> fromData    = (Dictionary <string, object>)jsonData["from"];
                Dictionary <string, object> contentData = (Dictionary <string, object>)jsonData["content"];
                Dictionary <string, object> richData    = contentData.ContainsKey("rich") ? (Dictionary <string, object>)contentData["rich"] : null;

                string profileId        = fromData["id"] as string;
                string lastConnectionId = richData != null?richData.ContainsKey("lastConnectionId") ? richData["lastConnectionId"] as string : "" : "";

                int rank = richData != null?richData.ContainsKey("rank") ? (int)richData["rank"] : 0 : 0;

                tempObj = Instantiate(profileId == GCore.Wrapper.Client.ProfileId ? in_lobbyView ? LobbyChatCellYou : ChatCellYou :                                                   // is you!
                                      profileId != ChatCell.SYSTEM_MESSAGE ? in_lobbyView ? LobbyChatCellOther : ChatCellOther : in_lobbyView ? LobbyChatCellSystem : ChatCellSystem, // A non system meessage?   // haven't done these yet, probably from presence we will do this [TODO]
                                      Vector3.zero, Quaternion.identity, contentTransform);
                tempCell = tempObj.GetComponent <ChatCell>();

                tempCell.Init(fromData["name"] as string, contentData["text"] as string, profileId, fromData.ContainsKey("pic") ? fromData["pic"] as string : null,
                              lastConnectionId,
                              rank,
                              Convert.ToUInt64(jsonData["msgId"]),
                              (int)jsonData["ver"], in_jsonMessage, in_lobbyView);

                if (in_lobbyView)
                {
                    GEventManager.TriggerEvent("NEW_GLOBAL_CHAT");
                }
            }
        }