Beispiel #1
0
    public void onClickButtonHandler(GameObject obj)
    {
        CareerRoomRecord temp = new CareerRoomRecord();

        foreach (CareerRoomRecord room in CareerRooms)
        {
            if (obj.name == room.RoomId.ToString())
            {
                temp = room;
            }
        }

        OpenRoomInfo(temp);
    }
Beispiel #2
0
    public void OpenRoomInfo(CareerRoomRecord room)
    {
        Transform RoomInfo = transform.Find("RoomInfo");

        RoomInfo.gameObject.SetActive(true);
        RoomInfo.Find("Top/Title").GetComponent <Text> ().text       = room.Name;
        RoomInfo.Find("Time").GetComponent <Text> ().text            = ConvertStringToDateTime((int)room.BeginTime).ToString() + " ~ " + ConvertStringToDateTime((int)room.EndTime).ToString();
        RoomInfo.Find("Totalhands/Text").GetComponent <Text> ().text = room.PlayedHands.ToString() + "/" + room.Hands.ToString();
        if (room.Items.Count > 0)
        {
            RoomInfo.Find("MVP/Text").GetComponent <Text> ().text = room.Items [0].Name;
        }
        RoomInfo.Find("Roomfee/Text").GetComponent <Text> ().text = room.IsShare?"Shared":"Individual";
        RoomInfo.Find("Betsize/Text").GetComponent <Text> ().text = room.MinBet.ToString() + "-" + room.MaxBet.ToString();

        Transform Content = RoomInfo.Find("PlayerList/List/Viewport/Content");

        float top    = 0;
        float height = 105 * room.Items.Count;

        if (height < 860)
        {
            height = 860;
        }

        Content.GetComponent <RectTransform> ().sizeDelta     = new Vector2(Content.GetComponent <RectTransform> ().sizeDelta.x, height);
        Content.GetComponent <RectTransform> ().localPosition = new Vector3(0, -height / 2, 0);

        top = height / 2;

        for (int i = 0; i < room.Items.Count; i++)
        {
            GameObject CareerPlayer = Instantiate(m_CareerPlayer) as GameObject;

            CareerPlayer.transform.Find("Name").GetComponent <Text> ().text = room.Items[i].Name;
            if (i < 3)
            {
                CareerPlayer.transform.Find("ST").gameObject.SetActive(true);
                CareerPlayer.transform.Find("ST").GetComponent <Image>().sprite = Resources.Load("Image/Lobby/" + i + "st", typeof(Sprite)) as Sprite;
            }

            if (room.Items[i].Uid == Common.Uid)
            {
                CareerPlayer.transform.Find("Mine").gameObject.SetActive(true);
            }

            UICircle avatar = (UICircle)Instantiate(LobbyController.PrefabAvatar);
            avatar.transform.SetParent(CareerPlayer.transform.Find("Avatar"));
            avatar.transform.localPosition = new Vector3();
            avatar.transform.localScale    = new Vector3(1, 1, 1);
            avatar.GetComponent <RectTransform> ().sizeDelta = new Vector2(68, 68);
            StartCoroutine(Common.Load(avatar, room.Items[i].Avatar));

            string typestr = "";
            if (room.Items[i].Score >= 0)
            {
                typestr = "win";
            }
            else
            {
                typestr = "lost";
            }
            string amount = Mathf.Abs(room.Items[i].Score).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/Lobby/" + typestr + amount[c], typeof(Sprite)) as Sprite;
                t.transform.SetParent(CareerPlayer.transform.Find("Amount"));
                t.transform.GetComponent <RectTransform> ().sizeDelta = new Vector2(22, 29);
                t.transform.localPosition = new Vector3(left, 0, 0);
                left = left - 20;

                if (c == 0)
                {
                    GameObject icon = new GameObject();
                    icon.AddComponent <Image> ();
                    icon.GetComponent <Image>().sprite = Resources.Load("Image/Lobby/" + typestr + "icon", typeof(Sprite)) as Sprite;
                    icon.transform.SetParent(CareerPlayer.transform.Find("Amount"));
                    icon.transform.GetComponent <RectTransform> ().sizeDelta = new Vector2(22, 29);
                    icon.transform.localPosition = new Vector3(left, 0, 0);
                }
            }

            CareerPlayer.transform.SetParent(Content);
            CareerPlayer.GetComponent <RectTransform> ().localScale    = new Vector3(1, 1, 1);
            CareerPlayer.GetComponent <RectTransform> ().localPosition = new Vector3(0, top, 0);
            top -= 105;
        }
    }