Exemplo n.º 1
0
    /// <summary>
    /// 刷新item
    /// </summary>
    /// <param name="args"></param>
    private void OnUpdateItem(params object[] args)
    {
        int                 index = (int)args[0];
        GameObject          obj   = args[1] as GameObject;
        SendGetRoomListInfo data  = mRoomList[index];

        obj.SetActive(true);
        obj.GetComponent <ClubPatternItem>().InitUI(data);
    }
Exemplo n.º 2
0
    /// <summary>
    /// 初始化item
    /// </summary>
    /// <param name="args"></param>
    private void OnInitItem(params object[] args)
    {
        int index = (int)args[0];
        SendGetRoomListInfo data = mRoomList[index];
        GameObject          obj  = NGUITools.AddChild(mScrollView.gameObject, mItem.gameObject);

        obj.SetActive(true);
        obj.GetComponent <ClubPatternItem>().InitUI(data);
        mScrollView.InitItem(index, obj);
    }
Exemplo n.º 3
0
    /// <summary>
    /// 房间信息法神变化
    /// </summary>
    /// <param name="msg"></param>
    private void OnRoomInfoChang(MessageData msg)
    {
        if (mView == null)
        {
            return;
        }
        OnRoomListChange    ack  = msg.Read <OnRoomListChange>();
        SendGetRoomListInfo info = ack.info;
        bool contain             = false;

        if (GamePatternModel.Inst.mRoomList != null && !string.IsNullOrEmpty(info.model))  //更新房间信息,且房间没被解散
        {
            for (int i = 0; i < GamePatternModel.Inst.mRoomList.Count; i++)
            {
                if (GamePatternModel.Inst.mRoomList[i].roomId == info.roomId)
                {
                    contain = true;
                    bool nil = GamePatternModel.Inst.mRoomList[i].nil;
                    GamePatternModel.Inst.mRoomList[i] = info;
                    if (nil == info.nil)                        //有空位还是有空位
                    {
                        mView.UpdateClubPatternWidget(i, info); //刷新一个
                    }
                    else  //空位状态改变
                    {
                        mView.InitClubPatternWidget();//全部刷新
                    }
                    break;
                }
            }
        }

        if (contain)  //更新成功 ,返回
        {
            return;
        }

        if (string.IsNullOrEmpty(info.model))
        {//房间被解散了
            for (int i = 0; i < GamePatternModel.Inst.mRoomList.Count; i++)
            {
                if (GamePatternModel.Inst.mRoomList[i].roomId == info.roomId)
                {
                    GamePatternModel.Inst.mRoomList.Remove(GamePatternModel.Inst.mRoomList[i]);
                    break;
                }
            }
            mView.InitClubPatternWidget();
        }
        else  //新建了一个房间
        {
            GamePatternModel.Inst.mRoomList.Add(info);
            mView.InitClubPatternWidget();
        }
    }
Exemplo n.º 4
0
 public void UpdateClubPatternWidget(int index, SendGetRoomListInfo data)
 {
     //GameObject go = mScrollView.GetChildByIndex(index);
     //if (go!=null) {
     //    mRoomList[index] = data;
     //    ClubPatternItem item = go.GetComponent<ClubPatternItem>();
     //    if (item!=null) {
     //        item.InitUI(data);
     //    }
     //}
 }
Exemplo n.º 5
0
    /// <summary>
    /// 初始化UI
    /// </summary>
    /// <param name="heads"></param>
    /// <param name="rules"></param>
    public void InitUI(SendGetRoomListInfo data)
    {
        mData = data;
        if (data.userInfo != null)
        {
            NGUITools.DestroyChildren(mGrid.transform);
            for (int i = 0; i < data.userInfo.Count; i++)
            {
                GameObject item = Assets.InstantiateChild(mGrid.gameObject, mHeandItem, mScrollView);
                item.gameObject.SetActive(true);
                Assets.LoadIcon(data.userInfo[i].headUrl, (t) =>
                {
                    item.GetComponentInChildren <UITexture>().mainTexture = t;
                });
            }
        }
        mTitle.text         = data.name;
        mState.spriteName   = data.gameStatus == 1 ? "waiting" : "playing";
        mStateBG.spriteName = data.gameStatus == 1 ? "gamestate_bg1" : "gamestate_bg";
        string str = data.rule.baseScore.ToString("f2");

        string[] str1 = str.Split('.');
        if (str1.Length == 2)
        {
            mBaseScoreLabel.text  = str1[0];
            mBaseScoreLabel2.text = "." + str1[1];
        }
        else
        {
            mBaseScoreLabel.text  = str;
            mBaseScoreLabel2.text = "";
        }

        mIntoLabel.text = data.rule.into.ToString();
        if (GamePatternModel.Inst.mCurGameId == eGameType.MaJiang && data.rule.ruleIndexs.Contains(6))
        {
            mThreeSp.gameObject.SetActive(true);
        }
        else
        {
            mThreeSp.gameObject.SetActive(false);
        }
        mGrid.Reposition();
    }
Exemplo n.º 6
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="index"></param>
 public void UpdateClubPatternWidget(int index, SendGetRoomListInfo data)
 {
     mClubWidget.UpdateClubPatternWidget(index, data);
 }