protected override void OnQueryHulist(int eventId, EventData evn) { QueryHulistData data = (QueryHulistData)evn.data1; if (null == data) { return; } if (data.Flag == 0) { data.CardsNum = QueryResidueMahjong(data.Cards, data.Laizi); } }
public virtual void OnQueryHulist(ISFSObject data) { //int[] arr = data.GetIntArray("hulist"); var hulist = data.GetSFSArray("hulist"); var intList = new List <int>(); foreach (ISFSObject sfsobj in hulist) { var cds = sfsobj.GetIntArray("cards"); var len = cds.Length; for (int i = 0; i < len; i++) { if (D2MahjongMng.Instance.IsContainMahjongMeKey(cds[i])) { intList.Add(cds[i]); } } } int[] arr = intList.ToArray(); int cardValue = (int)data.GetInt("card"); if (currMahjong == null || currMahjong.MahjongItem.Value != cardValue || mahjongQueryCache.ContainsKey(cardValue)) { return; } mahjongQueryCache.Add(cardValue, FilterCards(arr)); QueryHulistData hulistData = new QueryHulistData((int)MahjongIcon.Flag.Ting, currMahjong.MahjongItem.Value, currMahjong.MahjongItem.MahjongIndex, laizi); hulistData.Cards = mahjongQueryCache[currMahjong.MahjongItem.Value]; if (null != arr || arr.Length > 0) { //任意牌 if (Array.Exists(arr, (a) => { return(a == 0); })) { hulistData.LeaveMahjongCnt = leaveMahjongCnt; } EventDispatch.Dispatch((int)GameEventId.QueryHulist, new EventData(hulistData)); } }
public virtual void Query(ISFSObject obj, DVoidSfsObject sendCall, EventData evn) { currMahjong = (MahjongIcon)evn.data1; if (currMahjong == null) { return; } //向服务器发出请求 if (MahjongIcon.Flag.Ting == currMahjong.CurrFlag && !mahjongQueryCache.ContainsKey(currMahjong.MahjongItem.Value)) { //听的牌,通过服务器查询 obj.PutInt(RequestKey.KeyType, MjRequestData.MJRequestTypeGetHuCards); obj.PutInt("card", currMahjong.MahjongItem.Value); sendCall(obj); } else { //不向服务器发出请求 QueryHulistData hulistData = new QueryHulistData((int)currMahjong.CurrFlag, currMahjong.MahjongItem.Value, currMahjong.MahjongItem.MahjongIndex, laizi); switch (currMahjong.CurrFlag) { case MahjongIcon.Flag.Ting: hulistData.Cards = mahjongQueryCache[currMahjong.MahjongItem.Value]; //任意牌 if (hulistData.Cards.Exists((a) => { return(a == 0); })) { hulistData.LeaveMahjongCnt = leaveMahjongCnt; } EventDispatch.Dispatch((int)GameEventId.QueryHulist, new EventData(hulistData)); break; case MahjongIcon.Flag.Youjin: hulistData.LeaveMahjongCnt = leaveMahjongCnt; EventDispatch.Dispatch((int)GameEventId.QueryHulist, new EventData(hulistData)); break; } } }
public void OnShowHulist(EventData evn) { QueryHulistData data = (QueryHulistData)evn.data1; Transform card = (Transform)evn.data2; if (data == null || card == null || data.Cards.Count == 0) { return; } Bg.SetActive(true); _sgin = data.Laizi; //显示任意牌 if (data.Flag == (int)MahjongIcon.Flag.Youjin || null == data.Cards) { //自适应 窗体大小 SetPnlSize(1); Push(0, transform); HupaiItem item = Pop(0, -1, Grid.transform); item.SetTextNum(data.LeaveMahjongCnt); } else { //自适应 窗体大小 SetPnlSize(data.Cards.Count); //生成牌 Push(data.Cards, transform); //牌值s List <int> values = data.Cards; //牌数量 List <int> numArr = data.CardsNum; ShowHupaiInfo(values, numArr, _sgin); } //窗体位置 SetPnlPosition(card.position); }