Example #1
0
    public void onEnterGame(int gid, string result)
    {
        WaittingUIHandler.instance.UnShow();
        HallCenterUIHandler.instance.UnShow();

        JsonData list = JsonMapper.ToObject(result);

        for (int i = 0; i < list.Count; i++)
        {
            JsonData   dict = list [i];
            GameObject item = (GameObject)Instantiate(Resources.Load(GameSetting.UIItemPath + "HallItem"), transform.position, Quaternion.identity);
            item.transform.parent     = grid.transform;
            item.transform.localScale = new Vector3(1, 1, 1);
            item.name = "hall" + i.ToString();

            GameHallData itemData = new GameHallData();
            itemData.type = (byte)(i + 1);
            if (gid == 1)
            {
                itemData.bg_name = "ddz_" + itemData.type + "_1";
            }
            else
            {
                itemData.bg_name = "zjh_" + itemData.type + "_1";
            }
            itemData.type        = (int)dict ["id"];
            itemData.playerCount = (int)dict ["players_count"];
            itemData.difen       = float.Parse(dict ["base"].ToString());
            itemData.xianzhi     = float.Parse(dict ["limit"].ToString());

            item.AddComponent <HallItemUIComponent>().setData(itemData);
            UIEventListener.Get(item).onClick = onClickHall;
        }
        grid.Reposition();
    }
Example #2
0
    public void onClickHall(GameObject obj)
    {
        GameHallData data = obj.GetComponent <HallItemUIComponent> ().HallData;

        KBEngine.Event.fireIn("reqEnterHall", new object[] { data.type });
        WaittingUIHandler.instance.Show();
    }
Example #3
0
 public void setData(GameHallData d)
 {
     bg.spriteName = d.bg_name;
     difen.text    = d.difen.ToString();
     xianzhi.text  = d.xianzhi.ToString();
     online.text   = d.playerCount.ToString();
     this.data     = d;
 }