public IEnumerator <float> GetCardBuZhangTask() { while (mBuzhangLogic.BuzhangQueue.Count > 0) { int card = mBuzhangLogic.BuzhangQueue.Dequeue(); //在墙中移除 DataCenter.LeaveMahjongCnt--; Game.MahjongGroups.PopMahFromCurrWall(1); //添加到手牌中 int chair = mBuzhangLogic.BuZhangChair; Game.MahjongGroups.MahjongHandWall[chair].GetInMahjong(chair == 0 ? card : 0); yield return(DataCenter.Config.TimeBuzhangAniDelay); //移除手牌中的 Game.MahjongGroups.MahjongHandWall[chair].RemoveMahjong(card); //添加到胡牌中 Game.MahjongGroups.MahjongOther[chair].GetInMahjong(card); MahjongUtility.PlayPlayerSound(DataCenter.CurrOpChair, "buhua"); yield return(DataCenter.Config.TimeBuzhangAniDelay); } OnGetCard(); GameCenter.Shortcuts.SwitchCombination.Close((int)GameSwitchType.HasBuzhang); if (GameCenter.Shortcuts.SwitchCombination.IsOpen((int)GameSwitchType.AiAgency)) { yield return(Config.TimeTingPutCardWait); GameCenter.Network.C2S.ThrowoutCard(DataCenter.GetInMahjong); } if (DataCenter.CurrOpChair == 0) { //重新展示听提示 var tingList = DataCenter.Players[0].TingList; GameCenter.Shortcuts.MahjongQuery.ShowQueryTip(tingList); } }
public void OnReconnect_Wmbbmj(ISFSObject data) { OnReconnect(data); var arr = data.TryGetIntArray("caipiao"); if (arr != null) { var panel = GameCenter.Hud.GetPanel <PanelPlayersInfo>(); var go = GameUtils.GetAssets <GameObject>("Caipiao"); var sprite = go.GetComponent <Image>().sprite; var tempArr = new int[arr.Length]; for (int i = 0; i < arr.Length; i++) { var chair = MahjongUtility.GetChair(i); panel[chair].SetHeadOtherImage(arr[i] > 0, sprite); tempArr[chair] = arr[i]; } var throwoutCard = GameCenter.Network.GetGameResponseLogic <GameLogic_ThrowoutCard>(); throwoutCard.SetCaipiaoChairs(tempArr); var flag = throwoutCard.SetCaipiaoState(); if (flag) { var handWall = Game.MahjongGroups.MahjongHandWall[0]; var item = handWall.GetLastMj(); var playerHand = handWall.GetMahHandComponent <MahPlayerHand>(); playerHand.SetMahjongNormalState(item); } } }
public void PlaySaiziAnimation(byte val1, System.Action action = null) { Glass.gameObject.SetActive(false); Saizi3.gameObject.SetActive(true); MahjongUtility.PlayEnvironmentSound("saizi"); StartCoroutine(SaiziOneAnimation(val1, 0.7f, action)); }
/// <summary> /// 出牌事件 /// </summary> protected void ThrowCardClickEvent(Transform mahjong) { //如果允许当前用户出牌 if (PlayerHand.HasToken) { var temp = mahjong.GetComponent <MahjongContainer>(); PlayerHand.ChooseMj = temp; //花牌不允许打出 if (temp.MahjongCard.Value >= (int)MahjongValue.ChunF) { return; } if (temp.Lock) { return; } if (null != mPutOutFunc && mPutOutFunc(temp)) { return; } bool flag = MahjongUtility.MahjongFlagCheck(temp.Value); //赖子牌是否允许打出 if (flag && !GameCenter.DataCenter.Config.AllowLaiziPut) { return; } PlayerHand.HasToken = false; //通知网络 发送出牌消息 GameCenter.Network.C2S.ThrowoutCard(temp.Value); } }
private IEnumerator <float> HandcardCtrlTask() { if (mArgs.HuType != NetworkProtocol.MJReqTypeLastCd && !GameUtils.CheckStopTask()) { yield return(Config.TimePushCardInterval); var huChair = new List <int>(); var group = Game.MahjongGroups; for (int i = 0; i < mArgs.HuSeats.Count; i++) { int chair = MahjongUtility.GetChair(mArgs.HuSeats[i]); group.MahjongHandWall[chair].GameResultRota(Config.TimeHuAniInterval); huChair.Add(chair); } yield return(Config.TimePushCardInterval); for (int i = 0; i < group.MahjongHandWall.Length; i++) { if (!huChair.Contains(i)) { group.MahjongHandWall[i].GameResultRota(Config.TimeHuAniInterval); } } } }
protected virtual void OnDrag(Vector2 delta) { if (!GameCenter.Scene.HandMahTouchEnable) { return; } if (ForbidDrag) { return; } if (mDragClone == null) { //克隆出一个新的麻将 mDragClone = GameCenter.Scene.MahjongCtrl.PopMahjong(gameObject.GetComponent <MahjongContainer>().Value); mDragClone.transform.SetParent(transform.parent); mDragClone.transform.position = transform.position; mDragClone.transform.rotation = transform.rotation; mDragClone.transform.localScale = transform.localScale; MahjongUtility.ChangeLayer(mDragClone.transform, transform.gameObject.layer); mDragClone.GetComponent <MahjongContainer>().RemoveMahjongScript(); mRecordMahjongPos = transform.position; } var handCarmera = GameCenter.Scene.MahjongCamera.HandCamera; //物体的屏幕坐标 Vector3 screenPos = handCarmera.WorldToScreenPoint(mDragClone.transform.position); #if (UNITY_ANDROID || UNITY_IPHONE) && !UNITY_EDITOR Vector3 mousePos = Input.touches[0].position; #else Vector3 mousePos = Input.mousePosition; #endif mousePos.z = screenPos.z; Vector3 worldPos = handCarmera.ScreenToWorldPoint(mousePos); mDragClone.transform.position = new Vector3(worldPos.x, worldPos.y, worldPos.z); }
public void OnReconnect_Qdjt(ISFSObject data) { //更新牌 UpdateMahjongGroup(); //更新牌桌 UpdateMahjongTable(); MahjongQueryHuTip(); //开启允许托管权限 GameCenter.Shortcuts.SwitchCombination.Open((int)GameSwitchType.PowerAiAgency); MahjongUserInfo userInfo; var groups = GameCenter.Scene.MahjongGroups; var panel = GameCenter.Hud.GetPanel <PanelOtherHuTip>(); for (int i = 0; i < DataCenter.MaxPlayerCount; i++) { userInfo = DataCenter.Players[i]; int[] liangCards = userInfo.ExtData.Get <VarIntArray>("liangdaoCards"); if (liangCards == null || liangCards.Length < 1) { continue; } groups.MahjongHandWall[i].SetHandCardState(HandcardStateTyps.TingAndShowCard, liangCards); //UI显示胡牌 var chair = MahjongUtility.GetChair(userInfo.Seat); panel.Open(liangCards, chair); } //设置手牌状态 SetReconectCardState(); }
public void OnGetInBuZhang(ISFSObject data) { mBuZhangChair = MahjongUtility.GetChair(data); mGetCardBuzhangQueue.Enqueue(data.GetInt(RequestKey.KeyOpCard)); GameCenter.Shortcuts.SwitchCombination.Open((int)GameSwitchType.HasBuzhang); //Game.MahjongGroups.PlayerToken = false; }
public void Play(List <HeadTextItem> list) { HeadTextItem obj; //获取数据 if (null == mData) { for (int i = 0; i < Datas.Length; i++) { if (Datas[i].Amount == list.Count) { mData = Datas[i]; } } } for (int i = 0; i < list.Count; i++) { obj = list[i]; var item = MahjongUtility.GetYxGameData().GetPlayerInfoItem <PlayerInfoItem>(i); obj.ExSetParent(item.transform); obj.transform.SetAsFirstSibling(); obj.GetComponent <RectTransform>().anchoredPosition3D = mData.GetPosition(i); var rect = item.GetComponent <RectTransform>(); var v3 = rect.anchoredPosition3D; } }
public void OnItemClick() { var db = GameCenter.DataCenter; if (db.Players.SearchPlayer(data => data.UserId == Player.Info.UserId)) { YxMessageBox.Show(new YxMessageBoxData() { Msg = "玩家已经在房间了!", IsTopShow = true, BtnStyle = YxMessageBox.MiddleBtnStyle }); return; } if (db.MaxPlayerCount == db.Players.CurrPlayerCount) { YxMessageBox.Show(new YxMessageBoxData() { Msg = "房间已满!", IsTopShow = true, BtnStyle = YxMessageBox.MiddleBtnStyle }); return; } var apiInfo = new Dictionary <string, object>() { { "bundleID", Application.bundleIdentifier }, { "inviteId", Player.Info.UserId }, { "roomId", db.Room.RoomID } }; MahjongUtility.SendAction("mahjongwm.inviteWmFriends", apiInfo, data => { }); }
public void OnFenzhang_Dbsmj(ISFSObject data) { if (data.ContainsKey("cards")) { var value = 0; int chair = 0; DataCenter.Game.FenzhangFlag = true; int[] cardsBySeat = data.GetIntArray("cards"); for (int i = 0; i < cardsBySeat.Length; i++) { chair = MahjongUtility.GetChair(i); value = cardsBySeat[i]; if (value > 0) { Game.MahjongGroups.CurrGetMahjongWall.PopMahjong(); var temp = Game.MahjongCtrl.PopMahjong(value); if (temp != null) { var mahjong = temp.GetComponent <MahjongContainer>(); mahjong.Laizi = MahjongUtility.MahjongFlagCheck(value); Game.MahjongGroups.MahjongOther[chair].GetInMahjong(mahjong); } } DataCenter.Players[chair].FenzhangCard = value; } //隐藏箭头 Game.TableManager.HideOutcardFlag(); } }
public void OnFenzhang(ISFSObject data) { if (data.ContainsKey("cards")) { DataCenter.Game.FenzhangFlag = true; var arr = data.GetSFSArray("cards"); DataCenter.LeaveMahjongCnt -= arr.Count; for (int i = 0; i < arr.Count; i++) { var obj = arr.GetSFSObject(i); if (obj != null) { var value = obj.GetInt("card"); var chair = MahjongUtility.GetChair(obj.GetInt("seat")); if (value > 0) { Game.MahjongGroups.CurrGetMahjongWall.PopMahjong(); var temp = Game.MahjongCtrl.PopMahjong(value); if (temp != null) { var mahjong = temp.GetComponent <MahjongContainer>(); mahjong.Laizi = MahjongUtility.MahjongFlagCheck(value); Game.MahjongGroups.MahjongOther[chair].GetInMahjong(mahjong); } } DataCenter.Players[chair].FenzhangCard = value; } } //隐藏箭头 Game.TableManager.HideOutcardFlag(); } }
private IEnumerator <float> ZimoTask_Bbmj() { if (!GameUtils.CheckStopTask()) { yield return(Config.TimeHuAniInterval); var huCard = mArgs.HuCard; var huChair = MahjongUtility.GetChair(mArgs.HuSeats[0]); //如果本家自摸,移除本家自摸的牌 if (huChair == 0) { Game.MahjongGroups.PlayerHand.PopMahjong(); } //游金了之后,抓到白板胡,叫白燕白 if (huCard == 87 && DataCenter.Players[huChair].IsAuto) { MahjongUtility.PlayPlayerSound(huChair, "baiyanbai"); GameCenter.Scene.PlayPlayerEffect(huChair, PoolObjectType.hu); } else { MahjongUtility.PlayOperateEffect(huChair, PoolObjectType.hu); } SetHuCard(huChair, huCard).Laizi = MahjongUtility.MahjongFlagCheck(huCard); } }
/// <summary> /// 根据本地座位号取数据 /// </summary> /// <param name="chair">本地座位号</param> /// <returns></returns> public MahjongUserInfo this[int chair] { get { var dic = MahjongUtility.GetYxGameData().UserInfoDict; if (dic.ContainsKey(chair)) { return(dic[chair] as MahjongUserInfo); } else { if (!GameCenter.GameProcess.IsCurrState <StateGameReady>()) { var info = GetUserInfoFormBackup(chair); if (info == null) { var oldData = MahjongUtility.GetYxGameData().GetLastGamePlayerInfo(chair); if (null != oldData) { return(oldData as MahjongUserInfo); } } return(info); } } return(null); } }
private string PlaySeat(int seat) { int chair = MahjongUtility.GetChair(seat); var count = GameCenter.DataCenter.MaxPlayerCount; if (count == 2) { return("对家"); } else if (count == 3) { if (chair == 1) { return("上家"); } else { return("下家"); } } else if (count == 4) { switch (chair) { case 1: return("上家"); case 2: return("对家"); case 3: return("下家"); } } return(""); }
public void Open(List <int> list) { base.Open(); //显示item UIBigCardItem item = null; for (int i = 0; i < list.Count; i++) { if (mItemList.Count - 1 >= i) { item = mItemList[i]; } else { item = Instantiate(Prefab); item.transform.ExSetParent(Group); item.ExLocalRotation(new Vector3(0, 0, 180)); mItemList.Add(item); } item.SetCard(list[i]); } //调整布局 Vector2 v2 = Bg.sizeDelta; int rowNum = (int)System.Math.Ceiling((list.Count / 6f)); float y = 111 * rowNum + 160; Bg.sizeDelta = new Vector2(v2.x, y); if (DataCenter.Game.BaoCard == 0) { //中码声音 MahjongUtility.PlayEnvironmentSound("biyou"); } }
//解散房间 public void OnDismissRoom(int dismissType) { var network = GameCenter.Network; network.OnRequestC2S((sfs) => { var dataCenter = GameCenter.DataCenter; if (dataCenter.IsGamePlaying) { sfs.PutUtfString("cmd", "dismiss"); sfs.PutInt(RequestKey.KeyType, dismissType); network.SendRequest("hup", sfs); } else { if (dataCenter.OneselfData.IsOwner) { network.SendRequest("dissolve", sfs); } else { MahjongUtility.ReturnToHall(); } } return(null); }); }
public void LogicAction() { int currChair = DataCenter.CurrOpChair; Game.MahjongGroups.Do((groups) => { groups.OnClearFlagMahjong(); if (DataCenter.CurrOpChair == 0) { UserContorl.ClearSelectCard(); } groups.MahjongHandWall[currChair].ThrowOut(mData.ThrowoutCard); var item = groups.MahjongThrow[currChair].GetInMahjong(mData.ThrowoutCard); Game.TableManager.ShowOutcardFlag(item); }); MahjongUtility.PlayMahjongSound(currChair, mData.ThrowoutCard); //金币房时 玩家选择听牌时,如果时间到了系统自动出牌, 恢复为正常出牌状态 if (DataCenter.Room.RoomType == MahRoomType.YuLe) { var playerHand = Game.MahjongGroups.PlayerHand.GetMahHandComponent <MahPlayerHand>(); if (playerHand.CurrState == HandcardStateTyps.ChooseNiuTing || playerHand.CurrState == HandcardStateTyps.ChooseTingCard) { playerHand.SetHandCardState(HandcardStateTyps.Normal); } } }
public void OnResponseCpg_Bbmj(ISFSObject data) { CpgLogic(data); switch (mData.CpgType) { case EnGroupType.Chi: MahjongUtility.PlayOperateEffect(DataCenter.CurrOpChair, PoolObjectType.chi); break; case EnGroupType.Peng: MahjongUtility.PlayOperateEffect(DataCenter.CurrOpChair, PoolObjectType.peng); break; default: string soundName = "gang"; if (mData.CpgType == EnGroupType.MingGang) { soundName = "minggang"; } else if (mData.CpgType == EnGroupType.AnGang) { soundName = "angang"; } MahjongUtility.PlayPlayerSound(mData.CurrOpChair, soundName); MahjongUtility.PlayOperateEffect(mData.CurrOpChair, PoolObjectType.gang); MahjongUtility.PlayEnvironmentEffect(mData.CurrOpChair, PoolObjectType.longjuanfeng); PlayScoreEffect(data); break; } }
/// <summary> /// 返回大厅 /// </summary> public void OnReturnRoomClick() { var db = GameCenter.DataCenter; if (db.Room.RoomType == MahRoomType.YuLe) { //娱乐房,一局结束后允许返回大厅 if (GameCenter.GameProcess.IsCurrState <StateGamePlaying>()) { YxMessageBox.Show("游戏中不能返回大厅!"); return; } } else { if (db.IsGamePlaying) { YxMessageBox.Show("游戏中不能返回大厅!"); return; } } YxMessageBox.Show("是否要返回大厅?", null, (box, btnName) => { if (btnName.Equals(YxMessageBox.BtnLeft)) { MahjongUtility.QuitGame(); } }, false, YxMessageBox.LeftBtnStyle | YxMessageBox.RightBtnStyle); }
private List <int[]> FindCanChi() { var dataCenter = GameCenter.DataCenter; var findList = new List <int[]>(); int outcard = dataCenter.ThrowoutCard; int laizi = dataCenter.Game.LaiziCard; List <int> cards = dataCenter.OneselfData.HardCards; MahjongUtility.SortMahjong(cards); Dictionary <int, int> dic = GetCardAmount(cards); if (dic.ContainsKey(outcard - 1) && outcard - 1 != laizi) { if (dic.ContainsKey(outcard - 2) && outcard - 2 != laizi) { findList.Add(new[] { outcard - 2, outcard - 1 }); } if (dic.ContainsKey(outcard + 1) && outcard + 1 != laizi) { findList.Add(new[] { outcard - 1, outcard + 1 }); } } if (dic.ContainsKey(outcard + 1) && dic.ContainsKey(outcard + 2) && outcard + 1 != laizi && outcard + 2 != laizi) { findList.Add(new[] { outcard + 1, outcard + 2 }); } return(findList); }
public IEnumerator <float> BuZhangAnimation() { BuZhangData buData; while (mBuZhangQueue.Count > 0) { buData = mBuZhangQueue.Dequeue(); //移除手牌中的 Game.MahjongGroups.MahjongHandWall[buData.chair].RemoveMahjong(buData.BuZhangCards); //添加到胡牌中 Game.MahjongGroups.MahjongOther[buData.chair].GetInMahjong(buData.BuZhangCards); yield return(DataCenter.Config.TimeBuzhangAniDelay); //在墙中移除 DataCenter.LeaveMahjongCnt -= buData.BuZhangCards.Length; Game.MahjongGroups.PopMahFromCurrWall(buData.BuZhangCards.Length); //添加到手牌中 Game.MahjongGroups.MahjongHandWall[buData.chair].GetInMahjongWithRoat(buData.Cards); MahjongUtility.PlayPlayerSound(buData.chair, "buhua"); //补张的牌 添加到手牌中 if (buData.chair == 0) { //移除花牌 DataCenter.Players.RemoveHandCardData(0, buData.BuZhangCards); //添加新牌 DataCenter.Players.AddHandCardData(0, buData.Cards); //重新展示听提示 var tingList = DataCenter.Players[0].TingList; GameCenter.Shortcuts.MahjongQuery.ShowQueryTip(tingList); } yield return(DataCenter.Config.TimeBuzhangAniDelay); } }
private IEnumerator TimeUpdata(Action callBack = null) { while (Time >= 0) { yield return(new WaitForSeconds(1)); Time--; var db = GameCenter.DataCenter; if (db.CurrOpChair == 0 && GameCenter.GameProcess.IsCurrState <StateGamePlaying>()) { if (Time <= 3 && Time >= 1) { MahjongUtility.PlayEnvironmentSound("clock"); if (MahjongUtility.ShakeCtrl == (int)CtrlSwitchType.Open && db.Config.MobileShake) { #if UNITY_ANDROID || UNITY_IOS Handheld.Vibrate(); #endif } } if (Time == 0) { Time = -1; MahjongUtility.PlayEnvironmentSound("naozhong"); } } } if (callBack != null) { callBack(); } }
/// <summary> /// 标记打出的单张牌 /// </summary> public void OnFlagMahjong(int card) { for (int i = 0; i < MahjongThrow.Length; i++) { MahjongThrow[i].SignItemByValueGreen(card); } MahjongUtility.PlayEnvironmentSound("get"); }
/// <summary> /// 更新玩家出牌方位, 改变当前用户倒计时以及东西南北 /// </summary> public void ChangeDirection(int currOpSeat, int oldOpSeat) { MahjongGroups.PlayerToken = 0 == MahjongUtility.GetChair(currOpSeat); if (currOpSeat != oldOpSeat) { TableManager.SwitchDirection(currOpSeat); TableManager.StartTimer(GameCenter.DataCenter.Config.TimeOutcard); } }
/// <summary> /// 玩家进入 /// </summary> private void OnOtherPlayerJoinRoom(ISFSObject data) { var user = data.GetSFSObject(RequestKey.KeyUser); GameCenter.EventHandle.Dispatch((int)UIEventProtocol.PlayerJoin, new PlayerInfoArgs() { Chair = MahjongUtility.GetChair(user) }); }
protected void OnPengCard(int value) { for (int i = 0; i < PlayerHand.Count; i++) { if (PlayerHand[i].Value == value && !MahjongUtility.MahjongFlagCheck(value)) { SetJue(PlayerHand[i], true); } } }
private float bili = 0.159f; //屏幕比例,点击这以下无声音 void Update() { if (Input.GetMouseButtonDown(0)) { if (Input.mousePosition.y / Screen.height > bili) { MahjongUtility.PlayEnvironmentSound("uiclick"); } } }
/// <summary> /// 总战绩截图分享 /// </summary> public void OnshareResultScreen() { MahjongUtility.DoScreenShot(this, new Rect(0, 0, Screen.width, Screen.height), imageUrl => { if (Application.platform == RuntimePlatform.Android) { imageUrl = "file://" + imageUrl; } GameUtils.WeChatShareGameResult(imageUrl); }); }
public void OnBuZhang(ISFSObject data) { var buData = new BuZhangData() { chair = MahjongUtility.GetChair(data), BuZhangCards = data.GetIntArray("buZhangCard"), Cards = data.GetIntArray(RequestKey.KeyCards), }; mBuZhangQueue.Enqueue(buData); }