public ISFSObject GetResultSfsObject() { ISFSObject obj = SFSObject.NewInstance(); if (!IsWinner) { if (IsFail) { obj.PutInt("ResultType", 2); } else if (IsGiveUp) { obj.PutInt("ResultType", 1); } else { obj.PutInt("ResultType", 3); } } else { obj.PutInt("ResultType", 0); obj.PutInt("WinGold", WinGold); } if (Cards != null) { obj.PutIntArray("Cards", Cards); } obj.PutInt("AddGold", AddGold); obj.PutUtfString("Name", NickM); return(obj); }
protected override void OnAllocateCds(object sender, DdzbaseEventArgs args) { //发牌后重置开关 _isRpLeftOne = false; _isRpLeftOneFirst = false; //base.OnAllocateCds(sender,args);---------- var data = args.IsfObjData; var seat = data.GetInt(GlobalConstKey.C_Sit); if (App.GetGameData <GlobalData>().GetSelfSeat != seat || !data.ContainsKey(GlobalConstKey.C_Cards)) { return; } var cards = data.GetIntArray(GlobalConstKey.C_Cards); ResetHdCds(cards); //------------------------end------------------------------------------------------------------------ //判断发牌后是否是自己先行动出牌 if (data.ContainsKey(GlobalConstKey.C_Bkp) && data.GetInt(GlobalConstKey.C_Bkp) == App.GetGameData <GlobalData>().GetSelfSeat) { DisableAllBtns(); if (_lastOutData == null) { _lastOutData = new SFSObject(); } _lastOutData.PutInt(RequestKey.KeySeat, App.GetGameData <GlobalData>().GetSelfSeat); _lastOutData.PutIntArray(RequestKey.KeyCards, new int[] { }); if (HdCdctrlInstance != null) { HdCdctrlInstance.ReSetHandCds(HdCdsListTemp.ToArray(), true); } } else { if (HdCdctrlInstance != null) { HdCdctrlInstance.ReSetHandCds(HdCdsListTemp.ToArray(), true, true); } } }
public override void GetGangData(ISFSObject obj, DVoidSfsObject sendCall) { List <FindGangData> findList = FindCanGang(); //如果不能杠财神,则移除可能是财神的牌 if (_cargs2.ContainsKey(Gangcaishen) && _cargs2.GetUtfString(Gangcaishen) == "0") { foreach (var findGangData in findList) { if (findGangData.cards[0] == Laizi) { findList.Remove(findGangData); break; } } } DVoidInt sendCallArray = index => { YxDebug.Log("发送服务器 杠 " + findList[index].cards); if (findList[index].type != UtilDef.DefInt) { obj.PutInt(RequestKey.KeyType, findList[index].type); } if (findList[index].ttype != UtilDef.DefInt) { obj.PutInt(RequestKeyOther.KeyTType, findList[index].ttype); } if (findList[index].cards != null && findList[index].ttype != MjRequestData.CPG_ZhuaGang) { obj.PutIntArray(RequestKey.KeyCards, findList[index].cards); } else if (findList[index].cards != null && findList[index].ttype == MjRequestData.CPG_ZhuaGang) { obj.PutInt(RequestKey.KeyOpCard, findList[index].cards[0]); } sendCall(obj); }; //如果找到的杠 大于1 if (findList.Count > 1) { YxDebug.Log("通知UI 提示杠选择 " + findList.Count); var lisiCard = findList.Select(t => t.cards).ToList(); //通知UI提示选择 EventDispatch.Dispatch((int)UIEventId.CgChoose, new EventData(lisiCard, sendCallArray, _outPutMahjong)); } else { sendCallArray(0); } }
public void OnShowCard(ISFSObject response) { int seat = response.GetInt(JhRequestConstKey.KeySeat); JhUserInfo player = GetPlayerInfo <JhUserInfo>(seat, true); player.IsShowCards = true; player.Cards = response.GetIntArray("cards"); ISFSObject sendObj = SFSObject.NewInstance(); sendObj.PutInt("Chair", GetLocalSeat(seat)); sendObj.PutIntArray("Cards", player.Cards); SetSfsUserContrl(sendObj); EventObj.SendEvent("PlayersViewEvent", "LiangPai", sendObj); }
public void OnLookCards(ISFSObject response) { LastTime = JhFunc.GetTimeStamp(false); int seat = response.GetInt("seat"); JhUserInfo uinfo = GetPlayerInfo <JhUserInfo>(seat, true); uinfo.IsLook = true; if (SelfSeat == seat) { uinfo.Cards = response.GetIntArray("cards"); } if (response.ContainsKey("gzyz")) { uinfo.IsGzyz = response.GetBool("gzyz"); } ISFSObject sendObj = SFSObject.NewInstance(); sendObj.PutInt("LookChair", GetLocalSeat(seat)); if (SelfSeat == seat) { sendObj.PutIntArray("Cards", uinfo.Cards); } if (SelfSeat == seat && SelfSeat == CurrenPlayer) { sendObj.PutBool("IsCurPlayer", true); SetSfsUserContrl(sendObj); } EventObj.SendEvent("PlayersViewEvent", "Look", sendObj); EventObj.SendEvent("SoundEvent", "PersonSound", new JhSound.SoundData(JhSound.EnAudio.Look, uinfo.SexI)); }
public void OnFapai(ISFSObject data) { RStatus = RoomStatus.FaPai; SingleBet = AnteRate[0]; LastTime = JhFunc.GetTimeStamp(false); BankerSeat = data.GetInt(JhRequestConstKey.KeyBanker); int[] playing = data.GetIntArray(JhRequestConstKey.KeyPlayings); int[] playingChair = new int[playing.Length]; for (int i = 0; i < playing.Length; i++) { playingChair[i] = GetLocalSeat(playing[i]); JhUserInfo uInfo = GetPlayerInfo <JhUserInfo>(playing[i], true); uInfo.IsPlayingGame = true; uInfo.CoinA -= SingleBet; TotalBet += SingleBet; uInfo.AllBeat += SingleBet; } ISFSObject sendObj = SFSObject.NewInstance(); sendObj.PutInt("Banker", GetLocalSeat(BankerSeat)); sendObj.PutIntArray("Playing", playingChair); sendObj.PutInt("ChipValue", SingleBet); sendObj.PutInt("ChipIndex", AnteRate.IndexOf(SingleBet)); sendObj.PutInt("SingleBet", SingleBet); EventObj.SendEvent("PlayersViewEvent", "Fapai", sendObj); SendGameStatusToTableView(); EventObj.SendEvent("SoundEvent", "PlayerEffect", new JhSound.SoundData(JhSound.EnAudio.Card)); }
public ISFSObject GetSfsObject(RoomStatus status) { ISFSObject obj = SFSObject.NewInstance(); if (status <= RoomStatus.CanStart) { obj.PutBool("IsReady", IsReady); } else { obj.PutBool("IsLook", IsLook); obj.PutBool("IsGiveUp", IsGiveUp); obj.PutBool("IsFail", IsFail); obj.PutBool("IsPlaying", IsPlayingGame); obj.PutBool("IsGzyz", IsGzyz); if ((IsLook || IsShowCards) && Cards != null) { obj.PutIntArray("Cards", Cards); } obj.PutInt("AllBeat", AllBeat); } return(obj); }
public void OnGuZhuYiZhi(ISFSObject response) { int gold = response.GetInt("goldinc"); bool isWin = response.GetBool("result"); JhUserInfo biUser = GetPlayerInfo <JhUserInfo>(CurrenPlayer, true); biUser.CoinA -= gold; TotalBet += gold; biUser.IsGzyz = false; List <int> lostList = new List <int>(); if (isWin) { foreach (var userInfo in UserInfoDict) { JhUserInfo jhUser = (JhUserInfo)userInfo.Value; if (jhUser != biUser) { jhUser.IsFail = true; lostList.Add(GetLocalSeat(jhUser.Seat)); } } } else { biUser.IsFail = true; lostList.Add(GetLocalSeat(CurrenPlayer)); } if (response.ContainsKey("fancha")) { ISFSArray arr = response.GetSFSArray("fancha"); for (int i = 0; i < arr.Count; i++) { ISFSObject obj = arr.GetSFSObject(i); int seat = obj.GetInt("seat"); int fancha = obj.GetInt("gold"); JhUserInfo fanUser = GetPlayerInfo <JhUserInfo>(seat, true); fanUser.CoinA += fancha; } } ISFSObject sendObj = SFSObject.NewInstance(); sendObj.PutInt("Chair", GetLocalSeat(CurrenPlayer)); sendObj.PutInt("Gold", gold); sendObj.PutBool("isWin", isWin); sendObj.PutUtfString("Name", biUser.Name); sendObj.PutIntArray("LostList", lostList.ToArray()); //如果存在 反差值的情况 刷新金币 if (response.ContainsKey("fancha")) { //刷新金币 ISFSArray arr = SFSArray.NewInstance(); foreach (var info in UserInfoDict) { JhUserInfo jhInfo = (JhUserInfo)info.Value; if (jhInfo.IsPlaying()) { ISFSObject obj = SFSObject.NewInstance(); obj.PutInt("Chair", GetLocalSeat(jhInfo.Seat)); obj.PutLong("Gold", jhInfo.CoinA); arr.AddSFSObject(obj); } } sendObj.PutSFSArray("FanCha", arr); } EventObj.SendEvent("PlayersViewEvent", "GZYZ", sendObj); EventObj.SendEvent("SoundEvent", "PlayerEffect", new JhSound.SoundData(JhSound.EnAudio.CompareAnimate)); EventObj.SendEvent("TableViewEvent", "Bet", TotalBet); }
protected void SendGameStatusToPlayerView() { ISFSObject sendObj = SFSObject.NewInstance(); ISFSArray sendArray = SFSArray.NewInstance(); foreach (var info in UserInfoDict) { JhUserInfo userInfo = (JhUserInfo)info.Value; if (userInfo != null) { ISFSObject obj = userInfo.GetSfsObject(RStatus); obj.PutInt("Chair", GetLocalSeat(userInfo.Seat)); sendArray.AddSFSObject(obj); } } sendObj.PutBool("isShowTimeTip", CoustemTime > 0); if (RStatus > RoomStatus.CanStart) { sendObj.PutInt("CurChair", GetLocalSeat(CurrenPlayer)); sendObj.PutDouble("CdTime", CdTime); sendObj.PutLong("LastTime", LastTime); if (CurrenPlayer == SelfSeat) { JhUserInfo curUser = GetPlayerInfo <JhUserInfo>(CurrenPlayer, true); if (!curUser.IsGzyz && IsAutoFollow) { sendObj.PutDouble("CdTime", 2.0f); } } JhUserInfo currP = GetPlayerInfo <JhUserInfo>(CurrenPlayer, true); SetCurrenPlayerBeatMinAndMax(currP, sendObj); sendObj.PutInt("Banker", GetLocalSeat(BankerSeat)); if (TotalBet != 0) { ISFSArray betArray = SFSArray.NewInstance(); int ttBet = TotalBet; for (int i = AnteRate.Count - 1; i >= 0; i--) { if (ttBet >= AnteRate[i]) { ISFSObject arrO = SFSObject.NewInstance(); arrO.PutInt("ChipValue", AnteRate[i]); arrO.PutInt("ChipIndex", i); arrO.PutInt("ChipCnt", ttBet / AnteRate[i]); betArray.AddSFSObject(arrO); ttBet = ttBet % AnteRate[i]; } } sendObj.PutSFSArray("ChipList", betArray); } } sendObj.PutSFSArray("Players", sendArray); sendObj.PutIntArray("Antes", AnteRate.ToArray()); sendObj.PutInt("SingleBet", SingleBet); sendObj.PutBool("IsPlaying", RStatus > RoomStatus.CanStart && RStatus != RoomStatus.Over); SetSfsUserContrl(sendObj); EventObj.SendEvent("PlayersViewEvent", "Status", sendObj); }
private void AddMjGroupInfo(ISFSObject data, GameObject bg, ref JpHuManjongGroupInfo groupInfo) { if (groupInfo == null) { groupInfo = Instantiate(JpHumjGroupInfo); groupInfo.gameObject.SetActive(true); groupInfo.gameObject.transform.SetParent(bg.transform); groupInfo.transform.localScale = Vector3.one; Vector3 gpTransform = groupInfo.GetComponent <RectTransform>().localPosition; groupInfo.GetComponent <RectTransform>().localPosition = new Vector3(gpTransform.x, gpTransform.y, 0); } var cards = data.GetIntArray(_keyCards); var tai = data.GetInt(_keyTai); var hua = data.GetInt(_keyHua); var cnt = data.GetInt(_keyCnt); if (cards == null) { return; } var len = cards.Length; if (len < 1) { return; } for (int i = 0; i < len; i++) { groupInfo.AddMjGobCell(cards[i]); if (groupInfo.PosX > _maxWigth)// && i < len - 1 { if (len - (i + 1) > 0) { groupInfo = null; var j = 0; var cdsLeftList = new int[len - (i + 1)]; for (int k = i + 1; k < len; k++) { cdsLeftList[j] = cards[k]; j++; } data.PutIntArray(_keyCards, cdsLeftList); AddMjGroupInfo(data, bg, ref groupInfo); } else { groupInfo.AddInfotextGob(tai, hua, cnt); groupInfo = null; } return; } } groupInfo.AddInfotextGob(tai, hua, cnt); }