コード例 #1
0
ファイル: SocketGameRoom.cs プロジェクト: iuvei/newClient
 private void OnDissmissVoteSyn(PacketBase msg)
 {
     if (msg.code == 0)
     {
         DissmissVoteSyn response = NetSerilizer.DeSerialize <DissmissVoteSyn>(msg.data);
         MjData          player   = Game.MJMgr.MjData[response.position];
         Action <bool>   callback = (ok) => {
             DoDissmissVoteSyn(ok);
         };
         Game.DialogMgr.PushDialog(UIDialog.DoubleBtnDialog, player.player.nickName + "申请解散房间", "提示", callback);
     }
 }
コード例 #2
0
ファイル: SoundManager.cs プロジェクト: iuvei/newClient
    private SoundsFiles GetSoundsFiles(int position)
    {
        MjData data = Game.MJMgr.MjData[position];

        if (data.player.sex == 1)
        {
            return(man);
        }
        else
        {
            return(female);
        }
    }
コード例 #3
0
ファイル: PlayPage.cs プロジェクト: gitshuaidong/MJ
    void SetupUI(params object[] args)
    {
        detail.HangUp_UIItem.gameObject.SetActive(Game.MJMgr.HangUp);
        detail.VoiceButton_Button.gameObject.SetActive(RoomMgr.IsVipRoom());
        detail.HostedButton_Button.gameObject.SetActive(RoomMgr.IsNormalRoom());

        if (RoomMgr.IsVipRoom())
        {
            detail.DismissButton_Button.gameObject.SetActive(true);
            detail.GameRoundButton_Button.gameObject.SetActive(true);
            int quanNum   = RoomMgr.GetQuanNum();
            int totalQuan = RoomMgr.GetTotalQuan();
            detail.GameRoundText_Text.text = string.Format("{0}/{1}{2}", quanNum, totalQuan, RoomMgr.IsVip2Room()?"局":"圈");

            bool isWaitting = Game.Instance.state == GameState.Waitting;
            detail.WXButton_Button.gameObject.SetActive(isWaitting);
        }
        else
        {
            detail.GameRoundButton_Button.gameObject.SetActive(false);
            detail.DismissButton_Button.gameObject.SetActive(false);
            detail.WXButton_Button.gameObject.SetActive(false);
        }

        OnUpdateCtrlPanel();

        foreach (PlayerSub sub in players)
        {
            sub.gameObject.SetActive(false);
        }

        for (int i = 0; i < Game.MJMgr.MjData.Length; i++)
        {
            int    position = i;
            MjData data     = Game.MJMgr.MjData[position];
            if (null != data.player)
            {
                int index = Game.MJMgr.GetIndexByPosition(position);
                players[index].SetValue(data);
            }
        }

        //MJPlayer self = Game.MJMgr.MyPlayer;
        //MjData selfData = Game.MJMgr.MjData[self.postion];
        //Player selfPlayer = selfData.player;
        //bool isReady = null != selfPlayer && selfPlayer.isReady;
        //detail.StartButton_Button.gameObject.SetActive(!isReady);
        //detail.StartButton_Button.gameObject.SetActive(false);
        //detail.ReadyCancelButton_Button.gameObject.SetActive(false);
        //detail.ReadyButton_Button.gameObject.SetActive(false);
    }
コード例 #4
0
ファイル: SettleRoundDialog.cs プロジェクト: iuvei/newClient
    void SetupSub(RoundAccountSub sub, GameOperPlayerSettle settle, int huCard = -1)
    {
        MJPlayer mjPlayer = Game.MJMgr.GetPlayerByPosition(settle.position);
        MjData   data     = Game.MJMgr.MjData[settle.position];

        sub.detail.Name_Text.text = data.player.nickName;
        sub.detail.ID_Text.text   = "ID:" + data.player.playerId;
        if (settle.fanNum > 0)
        {
            sub.detail.Fan_TextMeshProUGUI.text = string.Format("+{0}分", settle.fanNum);
        }
        else
        {
            sub.detail.Fan_TextMeshProUGUI.text = string.Format("{0}分", settle.fanNum);
        }
        Game.MJMgr.MjData[settle.position].player.coin  = settle.coin;
        Game.MJMgr.MjData[settle.position].player.score = settle.score;

        //sub.detail.ResultType_Text.text = settle.resultType.ToString();

        string fans = "";

        foreach (string fan in settle.fanDetail)
        {
            //if (fan.Contains("庄家")) continue;
            fans += fan.Trim() + " ";
        }
        sub.detail.TingInfo_Text.text = fans;

        bool IsMakers = Game.MJMgr.MakersPosition == settle.position;

        sub.detail.ZhuangFlag_Image.gameObject.SetActive(IsMakers);

        foreach (int card in mjPlayer.tableCardLayout.TableCards)
        {
            SpawnCard(sub.detail.TableCards_GridLayoutGroup.transform, card);
        }

        foreach (int card in settle.handcard)
        {
            SpawnCard(sub.detail.Handcards_GridLayoutGroup.transform, card);
        }

        if (huCard > 0)
        {
            SpawnCard(sub.detail.Handcards_GridLayoutGroup.transform, huCard);
        }
    }
コード例 #5
0
ファイル: PlayerSub.cs プロジェクト: gitshuaidong/MJ
    public void SetValue(MjData data)
    {
        this.data = data;

        Player player = data.player;

        if (player != null)
        {
            gameObject.SetActive(true);
            //detail.Ready_Text.text = player.isReady ? "" : "未准备";

            if (player.offline)
            {
                detail.AwayFlag_Image.gameObject.SetActive(false);
                detail.OfflineFlag_Image.gameObject.SetActive(true);
            }
            else
            {
                detail.AwayFlag_Image.gameObject.SetActive(player.leave);
                detail.OfflineFlag_Image.gameObject.SetActive(false);
            }

            //players[p.index].detail.Zhuang_Text.gameObject.SetActive(Game.MJMgr.makersIndex == p.playerInfo.Index);
            detail.Ting_Image.gameObject.SetActive(player.ting);
            bool IsMakers = Game.MJMgr.MakersPosition == player.position;
            detail.Zhuang_Image.gameObject.SetActive(IsMakers);

            //detail.Icon_Image.sprite = Game.IconMgr.GetFace(player.headImg);
            Game.IconMgr.SetFace(detail.Icon_Image, player.headImg);

            detail.Name_Text.text = player.nickName;
            if (RoomMgr.IsVipRoom() || RoomMgr.IsSingeRoom())
            {
                detail.Coins_Text.text = player.score.ToString();
            }
            else
            {
                detail.Coins_Text.text = player.coin.ToString();
            }
            detail.TalkingFlag_Image.gameObject.SetActive(showVoice);
            detail.WordRoot_Text.gameObject.SetActive(showWord);
            detail.MoodRoot_UIItem.gameObject.SetActive(showMood);

            bool isActivePlayer = Game.MJMgr.ActivePosition == player.position;
            //
            if (null == eff)
            {
                eff = Game.PoolManager.EffectPool.Spawn("FrameEffect");
                eff.transform.SetParent(this.transform);
                eff.transform.localPosition = Vector3.zero;
                eff.transform.localScale    = Vector3.one;
            }
            eff.SetActive(isActivePlayer);
        }
        else
        {
            gameObject.SetActive(false);


            //players[p.index].detail.Coins_Text.text = "100";
            //players[p.index].detail.Ready_Text.text = "";
            //players[p.index].detail.OfflineFlag_Text.text = "";
        }
    }
コード例 #6
0
ファイル: SocketGame.cs プロジェクト: gitshuaidong/MJ
    //int[] wins = new int[] {
    //    MJUtils.HU_BaoZhongBao,
    //    MJUtils.HU_DaiLou,
    //    MJUtils.HU_GuaDaFeng,
    //    MJUtils.HU_HongZhong,
    //    MJUtils.HU_Hu,
    //    MJUtils.HU_KaiPaiZha,
    //    MJUtils.HU_MoBao
    //};
    //void _OnGameOperPlayerHuSyn(GameOperPlayerHuSyn data)
    //{
    //    string huInfo = GetHuStr(data.resultType);
    //    string winInfo = GetHuStr(data.winType);
    //    Debug.LogFormat("===HuSyn:{0}[炮:{1}] card:{2} bao:[{3}] Hu:{4}/Win:{5}", (data.position < 0) ? "流局" : strs[data.position], (data.paoPosition < 0) ? "无" : strs[data.paoPosition], GetCardStr(data.card), GetCardStr(data.bao), huInfo, winInfo);

    //    RoomMgr.huSyn = data;

    //    if (RoomMgr.huSyn.resultType != MJUtils.HU_LiuJu)
    //    {
    //        MJPlayer player = Game.MJMgr.GetPlayerByPosition(data.position);
    //        MjData pData = Game.MJMgr.MjData[data.position];

    //        bool zimo = (data.paoPosition == -1 || data.paoPosition == data.position);

    //        List<GameOperPlayerSettle> list = data.detail;
    //        foreach (GameOperPlayerSettle s in list)
    //        {
    //            Debug.LogFormat("===OnGameOperPlayerHuSyn:{0} fanNum:{1} handcard:[{2}]", strs[s.position], s.fanNum, ToStr(s.handcard));

    //            if (s.position == data.position)
    //            {
    //                player.handCardLayout.Refresh(s.handcard);
    //            }
    //        }

    //        if (zimo)
    //        {
    //            Game.SoundManager.PlayEffect(27);
    //            Game.SoundManager.PlayZimo(data.position);
    //            player.DragCard(data.card, true);
    //        }
    //        else
    //        {
    //            if (-1 != data.paoPosition)
    //            {
    //                Game.SoundManager.PlayEffect(28);
    //                MJPlayer paoPlayer = Game.MJMgr.GetPlayerByPosition(data.paoPosition);
    //                GameObject eff = Game.PoolManager.EffectPool.Spawn("shandian_EF");
    //                eff.transform.position = Game.MJMgr.LastDropCard.transform.position;
    //                Game.PoolManager.EffectPool.Despawn(eff, 2);
    //            }

    //            Game.SoundManager.PlayHu(data.position);
    //            player.handCardLayout.DragCard(data.card, Game.MJMgr.LastDropCard.gameObject);
    //        }

    //        Game.MaterialManager.TurnOnHandCard();
    //        player.handCardLayout.PlayHu();

    //        PlayHuEffect(data.position);

    //        bool isMy = player.index == 0;
    //        if (isMy)
    //        {
    //            Game.SoundManager.PlayWin();
    //        }
    //        else
    //        {
    //            if (data.paoPosition != -1)
    //            {
    //                MJPlayer paoPplayer = Game.MJMgr.GetPlayerByPosition(data.paoPosition);
    //                isMy = paoPplayer.index == 0;
    //                if (isMy)
    //                {
    //                    Game.SoundManager.PlayLose();
    //                }
    //            }
    //        }
    //    }
    //    else
    //    {
    //        Game.SoundManager.PlayFall();
    //    }

    //    if (!data.skipHuSettle)
    //    {
    //        Game.Delay(3, () =>
    //        {
    //            Game.SoundManager.PlaySettleSound();
    //            Game.DialogMgr.PushDialog(UIDialog.SettleRoundDialog);
    //            IsBusy = false;
    //        });
    //    }
    //}

    void OnGameOperPlayerHuSyn(GameOperPlayerHuSyn data)
    {
        string huInfo  = GetHuStr(data.resultType);
        string winInfo = GetHuStr(data.winType);

        Debug.LogFormat("===HuSyn:{0}[炮:{1}] card:{2} bao:[{3}] Hu:{4}/Win:{5}", (data.position < 0) ? "流局" : strs[data.position], (data.paoPosition < 0) ? "无" : strs[data.paoPosition], GetCardStr(data.card), GetCardStr(data.bao), huInfo, winInfo);

        RoomMgr.huSyn = data;

        if (RoomMgr.huSyn.resultType == MJUtils.HU_LiuJu)
        {
            Game.SoundManager.PlayFall();
            if (!data.skipHuSettle)
            {
                Game.Delay(3, () =>
                {
                    Game.SoundManager.PlaySettleSound();
                    Game.DialogMgr.PushDialog(UIDialog.SettleRoundDialog);
                });
            }
            return;
        }

        MJPlayer player = Game.MJMgr.GetPlayerByPosition(data.position);
        MjData   pData  = Game.MJMgr.MjData[data.position];
        List <GameOperPlayerSettle> list = data.detail;

        foreach (GameOperPlayerSettle s in list)
        {
            Debug.LogFormat("===OnGameOperPlayerHuSyn:{0} fanNum:{1} handcard:[{2}]", strs[s.position], s.fanNum, ToStr(s.handcard));

            if (s.position == data.position)
            {
                player.handCardLayout.Refresh(s.handcard);
            }
            ////////////////////////
            if (!RoomMgr.IsSingeRoom())
            {
                if (!RoomMgr.IsVipRoom())
                {
                    if (Game.MJMgr.MjData[s.position].player.coin + s.fanNum * Game.Instance.baseScore < 0)
                    {
                        Game.MJMgr.MjData[s.position].player.coin = 0;
                    }
                    else
                    {
                        Game.MJMgr.MjData[s.position].player.coin += s.fanNum * Game.Instance.baseScore;
                    }
                }
                else
                {
                    Game.MJMgr.MjData[s.position].player.score += s.fanNum;
                }
                EventDispatcher.DispatchEvent(MessageCommand.MJ_UpdatePlayPage);
            }
            ////////////////////////
        }

        bool zimo = (data.paoPosition == -1 || data.paoPosition == data.position);

        if (zimo)
        {
            PlayZimoHu(player, data);
        }
        else
        {
            bool isPao = false;
            if (-1 != data.paoPosition)
            {
                Game.SoundManager.PlayEffect(28);
                MJPlayer   paoPlayer = Game.MJMgr.GetPlayerByPosition(data.paoPosition);
                GameObject eff       = Game.PoolManager.EffectPool.Spawn("shandian_EF");
                eff.transform.position = Game.MJMgr.LastDropCard.transform.position;
                Game.PoolManager.EffectPool.Despawn(eff, 5);

                isPao = paoPlayer.index == 0;
            }

            Game.Delay(1, () =>
            {
                bool isWin = player.index == 0;
                if (isWin)
                {
                    Game.SoundManager.PlayWin();
                }
                else if (isPao)
                {
                    Game.SoundManager.PlayLose();
                }

                PlayHu(player, data);
            });
        }
    }
コード例 #7
0
    public void PlayDropCard(int card, bool isMy)
    {
        IsBusy = true;
        MjData data = Game.MJMgr.MjData[position];

        Game.SoundManager.PlayCardSound(position, card);

        Transform dropCLTrans = player.dropCardLayout.transform;
        int       childCount  = dropCLTrans.childCount;

        if (isMy)
        {
            if (null == Game.MJMgr.MyDropMJEntity)
            {
                player.handCardLayout.DropCard(card);
            }
            else
            {
                player.handCardLayout.DropCard();
            }

            Game.MJMgr.MyDropMJEntity = null;
            //player.handCardLayout.Sort();
        }
        else
        {
            //int position = Game.MJMgr.GetPositionByIndex(player.index);

            //MjData data = Game.MJMgr.MjData[position];
            //if (data.player.ting)
            //{
            //    int Count = player.handCardLayout.HandCards.Count;
            //    player.handCardLayout.RemoveCardAt(Count);
            //}
            //else
            {
                int count = player.handCardLayout.HandCards.Count;
                if (data.player.ting)
                {
                    player.handCardLayout.RemoveCardAt(count - 1);
                }
                else
                {
                    int index = UnityEngine.Random.Range(2, count);
                    player.handCardLayout.RemoveCardAt(index);
                }
            }

            //player.HandCards.RemoveAt(index);
            // TODO  这里需要做细节
        }

        anim.gameObject.SetActive(true);

        Vector3 toPos  = player.dropCardLayout.GetLocalPos(childCount);
        Vector3 endPos = dropCLTrans.TransformPoint(toPos);

        hand.transform.position = endPos;

        GameObject child = Game.PoolManager.CardPool.Spawn(card.ToString());

        Game.MJMgr.LastDropCard      = child.GetComponent <MJEntity>();
        Game.MJMgr.LastDropCard.Card = card;

        Transform cardTrans = child.transform;

        cardTrans.SetParent(handMJRoot);
        cardTrans.localPosition = Vector3.zero;
        cardTrans.localRotation = Quaternion.identity;
        cardTrans.localScale    = Vector3.one;

        if (UnityEngine.Random.Range(0f, 1f) < 0.8f)
        {
            anim.Play("Drop");
            handAnima.OnDropCallback = () =>
            {
                Game.SoundManager.PlayDropCard();
                Game.MJMgr.targetFlag.gameObject.SetActive(true);
                Game.MJMgr.targetFlag.position = hand.transform.position;

                player.dropCardLayout.AddCard(card, child);
                //hand.SetActive(false);
                player.handCardLayout.LineUp(isMy);
                IsBusy = false;
            };
            //Game.Delay(0.13f, () =>{
            //});
        }
        else
        {
            anim.Play("Drop1");
            handAnima.OnDropSoundCallback = () =>
            {
                Game.SoundManager.PlayDropCard();
            };

            handAnima.OnDropCallback = () =>
            {
                Game.MJMgr.targetFlag.gameObject.SetActive(true);
                Game.MJMgr.targetFlag.position = hand.transform.position;

                player.dropCardLayout.AddCard(card, child);
                //hand.SetActive(false);
                player.handCardLayout.LineUp(isMy);
                IsBusy = false;
            };
            //Game.Delay(0.25f, () => {

            //});
        }
    }