/// <summary> /// 添加游戏桌子 /// </summary> /// <param name="deskNum">最大桌子数量</param> /// <param name="playerNumPerDesk">当前游戏人数</param> /// <param name="deskMaxPlyerCount">桌子上可以承载的人数</param> public void AddDesk(ushort deskNum, byte playerNumPerDesk, byte deskMaxPlyerCount = 4) { AssetBundle bundle = AssetBundleManager.GetAssetBundle(GameDefine.HallAssetbundleName); if (bundle == null) { return; } string PrefabName = CCsvDataManager.Instance.GameUIDataMgr.GetGameUIPrefabName("MatchTable", GameMain.hall_.GameBaseObj.GetGameType()); GameObject asset = (GameObject)bundle.LoadAsset <GameObject>(PrefabName + playerNumPerDesk); if (asset == null) { return; } foreach (Transform child in m_Scroll.content) { Destroy(child.gameObject); } m_dictIndexDesks.Clear(); Transform tfm; RoomDeskInfo deskInfo; for (ushort i = 1; i <= deskNum; i++) { GameObject obj = Instantiate(asset); obj.transform.SetParent(m_Scroll.content, false); obj.name = i.ToString("d2"); deskInfo = new RoomDeskInfo(); deskInfo.deskTfm = obj.transform.Find("ImageBG"); m_dictIndexDesks[i] = deskInfo; deskInfo.deskTfm.Find("Image_table/TextNum").GetComponent <Text>().text = obj.name; for (sbyte j = 0; j < playerNumPerDesk; j++) { tfm = deskInfo.deskTfm.Find("Image_player_" + (j + 1)); ushort desk = i; sbyte sit = j; tfm.Find("Button_seat").GetComponent <Button>().onClick.AddListener(() => { OnClickSit(desk, sit); }); } } m_nDeskNum = deskNum; m_bUpdateDesk = true; }
bool HandleRoomInfo(uint _msgType, UMessage _ms) { if (m_nDeskNum == 0) { return(false); } ushort size = _ms.ReaduShort(); m_bDeskComplete = (_ms.ReadByte() == 1); HashSet <byte> playerSit = new HashSet <byte>(); for (int i = 0; i < size; i++) { uint deskId = _ms.ReadUInt(); RoomDeskInfo di = m_dictIndexDesks[deskId]; di.m_bInited = true; playerSit.Clear(); int playerNum = m_ChairList.Count; for (byte k = 0; k < playerNum; k++) { playerSit.Add(k); } byte num = _ms.ReadByte(); for (int j = 0; j < num; j++) { byte sit = _ms.ReadByte(); uint userId = _ms.ReadUInt(); int faceId = _ms.ReadInt(); string url = _ms.ReadString(); string name = _ms.ReadString(); di.ShowPlayer(sit, true, name, url, userId, faceId); playerSit.Remove(sit); } foreach (byte sit in playerSit) { di.ShowPlayer(sit, false); } } return(true); }
void CheckDeskInView(bool send) { if (m_bUpdateDesk) { return; } float pos = (1f - m_Scroll.verticalScrollbar.value) * (1f - m_fScreenHRatio); float posEnd = pos + m_fScreenHRatio; uint begin = (uint)(pos / m_fDeskHRatio); begin = begin * m_nDeskNumPerRow + 1; uint end = (uint)(posEnd / m_fDeskHRatio); end = (end + 1) * m_nDeskNumPerRow; if (end > m_nDeskNum) { end = m_nDeskNum; } if (send) { DebugLog.LogWarning("Inview:" + begin + "-" + end); ushort start = 0; ushort stop = 0; for (uint i = begin; i <= end; i++) { RoomDeskInfo di = m_dictIndexDesks[i]; if (!di.m_bInited) { if (start == 0) { start = (ushort)i; } } else if (start != 0) { stop = (ushort)(i - 1); } } if (stop == 0) { stop = (ushort)end; } if (start != 0) { UMessage msg = new UMessage((uint)GameCity.EMSG_ENUM.CrazyCityMsg_CM_UPDATEBEFOREHANDROOMINFO); msg.Add((byte)GameMain.hall_.GameBaseObj.GetGameType()); msg.Add(GameMain.hall_.CurRoomIndex); msg.Add(start); msg.Add((ushort)(stop - start + 1)); HallMain.SendMsgToRoomSer(msg); DebugLog.Log("Request desk info:" + start + "-" + stop + "level:" + GameMain.hall_.CurRoomIndex); } } else { foreach (var di in m_dictIndexDesks) { di.Value.Show(di.Key >= begin && di.Key <= end); } } }