public void UpdateSelfInfo() { transform.Find("SelfInfo/ID").GetComponent <Text> ().text = Common.Uid.ToString(); transform.Find("SelfInfo/Name").GetComponent <Text> ().text = Common.FB_name; float width = Common.DiamondAmount.ToString().Length * 12 + 45; float left = (640 - width) / 2; transform.Find("SelfInfo/Diamonds/Icon").gameObject.SetActive(true); m_DiaAmount.gameObject.SetActive(true); m_DiaAmount.text = Common.ToCarryNum((int)Common.DiamondAmount); transform.Find("SelfInfo/Diamonds/Icon").localPosition = new Vector3(left, 0, 0); m_DiaAmount.transform.localPosition = new Vector3(left + 45, 0, 0); if (string.IsNullOrEmpty(Common.FB_avatar)) { m_Avatar.UseDefAvatar(); } else { StartCoroutine(Common.Load(m_Avatar, Common.FB_avatar)); } }
public void ShowResultInfo(bool hasAni = false) { List <Vector3> poslist = new List <Vector3> (); poslist.Add(new Vector3(0, 286, 0)); poslist.Add(new Vector3(0, 54, 0)); poslist.Add(new Vector3(0, -165, 0)); poslist.Add(new Vector3(0, -386, 0)); List <int> Seats = new List <int> (); foreach (KeyValuePair <int, CSeatResult> pair in Common.CSeatResults) { Seats.Add(pair.Key); } Seats.Sort(); int index = 0; foreach (int seatid in Seats) { CSeatResult hInfo = Common.CSeatResults[seatid]; GameObject PreInfoObj = (GameObject)Instantiate(m_GameController.m_PrefabPreInfo); PreInfoObj.transform.SetParent(Layer.Find("PreInfoCom")); if (hasAni) { PreInfoObj.transform.localPosition = new Vector3(0, -720, 0); } UICircle avatar = (UICircle)Instantiate(m_GameController.m_PrefabAvatar); avatar.transform.SetParent(PreInfoObj.transform.Find("Avatar")); avatar.GetComponent <RectTransform> ().sizeDelta = new Vector2(); avatar.transform.localPosition = new Vector3(); avatar.GetComponent <RectTransform> ().sizeDelta = new Vector2(60, 60); if (string.IsNullOrEmpty(hInfo.Avatar)) { avatar.UseDefAvatar(); } else { StartCoroutine(Common.Load(avatar, hInfo.Avatar)); } if (seatid == 0) { PreInfoObj.transform.Find("BBorder").gameObject.SetActive(true); PreInfoObj.transform.Find("BName").GetComponent <Text> ().text = hInfo.Name; } else { PreInfoObj.transform.Find("PBorder").gameObject.SetActive(true); PreInfoObj.transform.Find("PName").GetComponent <Text> ().text = hInfo.Name; } for (int i = 0; i < hInfo.Pres.Count; i++) { RepeatedField <uint> pInfo = hInfo.Pres [i]; for (int o = 0; o < pInfo.Count; o++) { Transform Poker = PreInfoObj.transform.Find("Hand" + i + "/Poker" + o); Image image = Poker.GetComponent <Image>(); image.sprite = Resources.Load("Image/Poker/" + pInfo[o], typeof(Sprite)) as Sprite; } } Transform number = PreInfoObj.transform.Find("Amount"); string typestr = ""; if (hInfo.Win < 0) { typestr = "lost"; } else { typestr = "win"; } string amount = Mathf.Abs(hInfo.Win).ToString(); float left = 0; for (int c = amount.Length - 1; c >= 0; c--) { GameObject t = new GameObject(); t.AddComponent <Image> (); t.GetComponent <Image>().sprite = Resources.Load("Image/Game/" + typestr + amount[c], typeof(Sprite)) as Sprite; t.transform.SetParent(number); t.transform.GetComponent <RectTransform> ().sizeDelta = new Vector2(20, 24); t.transform.localPosition = new Vector3(left, 0, 0); left = left - 18; if (c == 0) { GameObject icon = new GameObject(); icon.AddComponent <Image> (); icon.GetComponent <Image>().sprite = Resources.Load("Image/Game/" + typestr + "icon", typeof(Sprite)) as Sprite; icon.transform.SetParent(number); icon.transform.GetComponent <RectTransform> ().sizeDelta = new Vector2(20, 24); icon.transform.localPosition = new Vector3(left, 0, 0); } } float right = number.localPosition.x - 18 * amount.Length; if (hInfo.autowin) { PreInfoObj.transform.Find("GetLucky").gameObject.SetActive(true); PreInfoObj.transform.Find("GetLucky").localPosition = new Vector3(right, PreInfoObj.transform.Find("GetLucky").localPosition.y, 0); } if (hInfo.foul) { PreInfoObj.transform.Find("Foul").gameObject.SetActive(true); PreInfoObj.transform.Find("Foul").localPosition = new Vector3(right, PreInfoObj.transform.Find("GetLucky").localPosition.y, 0); } if (hasAni) { PreInfoObj.transform.DOLocalMoveY(poslist [index].y, 0.25f).SetDelay((index + 1) * 0.17f); } else { PreInfoObj.transform.localPosition = poslist [index]; } PreInfoObj.transform.localScale = new Vector3(1, 1, 1); index++; } }
public void UpdatePlayerUI() { Layer.Find("TipsNoPlayers").gameObject.SetActive(false); //LetPlay & AutoBanker if (m_GameController.m_SelfSeatID == 0 && m_StateManage.GetCulState() == STATE.STATE_SEAT) { ShowAutoBanker(); UpdateAutoBanker(); if (m_GameController.GetTablePlayersCount() <= 1) { Layer.Find("TipsNoPlayers").gameObject.SetActive(true); } } else { HideAutoBanker(); } if (m_GameController.m_SelfSeatID > 0 && m_StateManage.GetCulState() == STATE.STATE_SEAT) { Layer.Find("TipsWaitStart").gameObject.SetActive(true); } else { Layer.Find("TipsWaitStart").gameObject.SetActive(false); } //Tips if (m_GameController.m_SelfSeatID == -1) { Layer.Find("TipsPick").gameObject.SetActive(true); } else { Layer.Find("TipsPick").gameObject.SetActive(false); } //HandUI for (int i = 0; i < Layer.Find("SeatCom").childCount; i++) { Debug.Log("Seat==========" + i); Transform SeatObj = Layer.Find("SeatCom").GetChild(i); PlayerInfo player = m_GameController.GetPlayerInfoForSeatID(i); if (player != null) { SeatObj.Find("AddSeat").gameObject.SetActive(false); SeatObj.Find("Name").GetComponent <Text> ().text = player.Name; SeatObj.Find("Name").gameObject.SetActive(true); SeatObj.Find("Border").gameObject.SetActive(true); SeatObj.Find("Avatar").gameObject.SetActive(true); SeatObj.Find("Tips").gameObject.SetActive(false); SeatObj.Find("Amount").GetComponent <Text> ().text = Common.ToCarryNum(player.Score); SeatObj.Find("Amount").gameObject.SetActive(true); UICircle avatar = (UICircle)Instantiate(m_GameController.m_PrefabAvatar); avatar.transform.SetParent(SeatObj.Find("Avatar")); avatar.transform.localPosition = new Vector3(); avatar.GetComponent <RectTransform> ().sizeDelta = new Vector2(90, 90); if (!string.IsNullOrEmpty(player.FB_avatar)) { StartCoroutine(Common.Load(avatar, player.FB_avatar)); } else { avatar.UseDefAvatar(); } } else { SeatObj.Find("Amount").GetComponent <Text> ().text = ""; SeatObj.Find("Amount").gameObject.SetActive(false); SeatObj.Find("Name").GetComponent <Text> ().text = ""; SeatObj.Find("Name").gameObject.SetActive(false); SeatObj.Find("Border").gameObject.SetActive(false); for (int c = SeatObj.Find("Avatar").childCount - 1; c >= 0; c--) { Destroy(SeatObj.Find("Avatar").GetChild(c).gameObject); } if (m_GameController.m_SelfSeatID >= 0) { SeatObj.Find("Tips").gameObject.SetActive(false); SeatObj.Find("AddSeat").gameObject.SetActive(false); } else { SeatObj.Find("Tips").gameObject.SetActive(true); SeatObj.Find("AddSeat").gameObject.SetActive(true); } } } }
public void ShowPlayerList(List <Msg.ScoreboardItem> slist, int mode) { CLearPlayerList(); ClearObList(); Transform layer = GameObject.Find("Canvas").transform.Find("PlayersListLayer"); if (mode == 0) { layer.Find("Close").gameObject.SetActive(true); layer.Find("Observer").gameObject.SetActive(true); layer.Find("OK").gameObject.SetActive(false); } else { layer.Find("Close").gameObject.SetActive(false); layer.Find("Observer").gameObject.SetActive(false); layer.Find("OK").gameObject.SetActive(true); } layer.gameObject.SetActive(true); //string BeginTime = "2018-2-27 11:11"; //string EndTime = "Now"; string Hands = (Common.CPlayed_hands + 1) + " / " + Common.CHands; string Mvp = ""; if (slist.Count > 0) { Mvp = slist [0].Name; } string Roomfee = ""; if (Common.CIs_share) { Roomfee = "Shared"; } { Roomfee = "Individual"; } string Betsize = Common.ToCarryNum((int)Common.CMin_bet) + "-" + Common.ToCarryNum((int)Common.CMax_bet); //layer.Find ("Date/Time").GetComponent<Text> ().text = BeginTime + " ~ " + EndTime; layer.Find("Totalhands/Text").GetComponent <Text> ().text = Hands; layer.Find("MVP/Text").GetComponent <Text> ().text = Mvp; layer.Find("Roomfee/Text").GetComponent <Text> ().text = Roomfee; layer.Find("Betsize/Text").GetComponent <Text> ().text = Betsize; if (slist.Count > 4) { layer.Find("TablePlayers/Viewport/Content").GetComponent <RectTransform> ().sizeDelta = new Vector2(0, 100 * slist.Count); float height = layer.Find("TablePlayers/Viewport/Content").GetComponent <RectTransform> ().sizeDelta.y; float left = layer.Find("TablePlayers/Viewport/Content").GetComponent <RectTransform> ().localPosition.x; layer.Find("TablePlayers/Viewport/Content").GetComponent <RectTransform> ().localPosition = new Vector3(left, -height / 2, 0); } float y = (layer.Find("TablePlayers/Viewport/Content").GetComponent <RectTransform> ().sizeDelta.y / 2) - 3; //player list for (int i = 0; i < slist.Count; i++) { GameObject pinfo = (GameObject)Instantiate(m_GameController.m_PrefabTPlayer); pinfo.transform.SetParent(layer.Find("TablePlayers/Viewport/Content")); pinfo.transform.localPosition = new Vector3(0, y, 0); pinfo.transform.localScale = new Vector3(1, 1, 1); pinfo.transform.Find("Name").GetComponent <Text> ().text = slist [i].Name; UICircle avatar = (UICircle)Instantiate(m_GameController.m_PrefabAvatar); avatar.transform.SetParent(pinfo.transform.Find("Avatar")); avatar.transform.localPosition = new Vector3(); avatar.GetComponent <RectTransform> ().sizeDelta = new Vector2(65, 65); if (string.IsNullOrEmpty(slist [i].Avatar)) { avatar.UseDefAvatar(); } else { StartCoroutine(Common.Load(avatar, slist [i].Avatar)); } string typestr = ""; if (slist [i].Score < 0) { typestr = "lost"; } else { typestr = "win"; } float left = 0; GameObject icon = new GameObject(); icon.AddComponent <Image> (); icon.GetComponent <Image>().sprite = Resources.Load("Image/Game/" + typestr + "icon", typeof(Sprite)) as Sprite; icon.transform.SetParent(pinfo.transform.Find("Amount")); icon.transform.GetComponent <RectTransform> ().sizeDelta = new Vector2(20, 24); icon.transform.localPosition = new Vector3(left, 0, 0); left = left + 18; string amount = Mathf.Abs(slist [i].Score).ToString(); for (int c = 0; c < amount.Length; c++) { GameObject t = new GameObject(); t.AddComponent <Image> (); t.GetComponent <Image>().sprite = Resources.Load("Image/Game/" + typestr + amount[c], typeof(Sprite)) as Sprite; t.transform.SetParent(pinfo.transform.Find("Amount")); t.transform.GetComponent <RectTransform> ().sizeDelta = new Vector2(20, 24); t.transform.localPosition = new Vector3(left, 0, 0); left = left + 18; } y -= 100; } //Ob list if (mode == 0) { List <PlayerInfo> oblist = new List <PlayerInfo>(); foreach (PlayerInfo p in Common.CPlayers) { if (p.SeatID == -1) { oblist.Add(p); } } Transform ObContent = layer.Find("Observer/ObList/Viewport/Content"); Vector3 oblistsize = layer.Find("Observer/ObList").GetComponent <RectTransform> ().sizeDelta; if (oblist.Count > 5) { ObContent.GetComponent <RectTransform> ().sizeDelta = new Vector2(95 * oblist.Count - oblistsize.x, oblistsize.y); ObContent.GetComponent <RectTransform> ().localPosition = new Vector3(0, 0, 0); } float obleft = 37; foreach (PlayerInfo p in oblist) { GameObject obinfo = (GameObject)Instantiate(m_GameController.m_PrefabObInfo); obinfo.transform.SetParent(ObContent); obinfo.transform.localPosition = new Vector3(obleft, 0, 0); obinfo.transform.localScale = new Vector3(1, 1, 1); UICircle avatar = (UICircle)Instantiate(m_GameController.m_PrefabAvatar); avatar.transform.SetParent(obinfo.transform.Find("Avatar")); avatar.transform.localPosition = new Vector3(); avatar.GetComponent <RectTransform> ().sizeDelta = new Vector2(68, 68); if (string.IsNullOrEmpty(p.FB_avatar)) { avatar.UseDefAvatar(); } else { StartCoroutine(Common.Load(avatar, p.FB_avatar)); } obleft += (70 + 24); } } }