예제 #1
0
        protected override void Run(ETModel.Session session, Actor_GamerCheat message)
        {
            try
            {
                Log.Debug("收到作弊");

                UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);

                UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();
                GamerComponent  gamerComponent  = uiRoom.GetComponent <GamerComponent>();

                Gamer gamer = gamerComponent.Get(PlayerInfoComponent.Instance.uid);

                HandCardsComponent handCardsComponent = gamer.GetComponent <HandCardsComponent>();
                if (handCardsComponent == null)
                {
                    return;
                }
                handCardsComponent.DeleteAllItem(handCardsComponent.CardBottom);

                foreach (var card in message.handCards)
                {
                    card.m_weight = (Consts.MahjongWeight)card.weight;
                }

                handCardsComponent.AddCards(message.handCards);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #2
0
        protected override void Run(ETModel.Session session, Actor_ShowAnimType message)
        {
            UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);

            if (uiRoom == null)
            {
                return;
            }
            UIRoomComponent roomComponent = uiRoom.GetComponent <UIRoomComponent>();

            Log.Info("显示:" + message.Type);

            try
            {
                switch (message.Type)
                {
                case 1:
                    ToastScript.createToast("扣除服务费:" + message.Count);
                    break;

                case 2:
                case 3:
                    roomComponent.ShowAnim(message.Type);
                    break;

                case 4:
                    break;
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #3
0
        public void Awake()
        {
            ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>();

            this.changeTableBtn = rc.Get <GameObject>("ChangeTableBtn").GetComponent <Button>();
            this.readyBtn       = rc.Get <GameObject>("ReadyBtn").GetComponent <Button>();
            this.weChatBtn      = rc.Get <GameObject>("WeChat").GetComponent <Button>();
            this.roomIdObj      = rc.Get <GameObject>("RoomId");

            this.head         = rc.Get <GameObject>("Head");
            this.readyTimeout = rc.Get <GameObject>("ReadyTimeout");
            this.timeText     = this.readyTimeout.transform.Find("timeText").GetComponent <Text>();

            HeadPanel[0] = head.Get <GameObject>("Bottom");
            HeadPanel[1] = head.Get <GameObject>("Right");
            HeadPanel[2] = head.Get <GameObject>("Top");
            HeadPanel[3] = head.Get <GameObject>("Left");

            this.changeTableBtn.onClick.Add(OnChangeTable);
            this.readyBtn.onClick.Add(OnReady);
            weChatBtn.onClick.Add(OnInviteWeChat);

            CommonUtil.SetTextFont(this.GetParent <UI>().GameObject);

            timeOut = 20;
            SetTimeOut();

            UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);

            this.uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();
        }
예제 #4
0
        protected override async void Run(ETModel.Session session, Actor_GameFlow message)
        {
            try
            {
                Log.Info($"收到流局");

                UI              uiRoom          = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                GamerComponent  gamerComponent  = uiRoom.GetComponent <GamerComponent>();
                UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();

                UIGameResultComponent gameResultComponent =
                    Game.Scene.GetComponent <UIComponent>().Create(UIType.UIGameResult).GetComponent <UIGameResultComponent>();

                if (uiRoomComponent.RoomType == 3)
                {
                    gameResultComponent.SetFriendRoom();
                    gameResultComponent.startTimer(5);
                }
                else
                {
                    gameResultComponent.startTimer();
                }
                gameResultComponent.SetFlowGame(message, gamerComponent);
                UIRoomComponent.ISGaming = false;
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #5
0
        /// <summary>
        /// 玩家出牌
        /// </summary>
        /// <param name="mahjong"></param>
        /// <param name="messageIndex"></param>
        /// <param name="messageWeight"></param>
        public async void PlayCard(MahjongInfo mahjong, int index, GameObject currentItem)
        {
            try
            {
                for (int i = 0; i < handCards.Count; i++)
                {
                    if (handCards[i].weight == mahjong.weight)
                    {
                        GameObject gameObject = this.GetSprite(i);
                        GameObject.Destroy(gameObject);
                        handCards.RemoveAt(i);
                        playCards.Add(mahjong);
                        ItemCards.RemoveAt(i);
                        break;
                    }
                }

                UpdateCards();

                //显示出牌
                GameObject obj  = (GameObject)this.resourcesComponent.GetAsset("Item_Vertical_Card.unity3d", "Item_Vertical_Card");
                GameObject obj2 = (GameObject)this.resourcesComponent.GetAsset("Image_Top_Card.unity3d", "Image_Top_Card");
                this.currentPlayCardObj = GameObject.Instantiate(obj, this.cardDisplay.transform);

                currentPlayCardObj.GetComponent <Image>().sprite = obj2.Get <Sprite>("card_" + mahjong.weight);
                currentPlayCardObj.layer = LayerMask.NameToLayer("UI");

                currentItem = currentPlayCardObj;

                ShowCard(mahjong.weight);

                //出了几张一样的牌
                int playCount = 0;
                foreach (var card in playCards)
                {
                    if (card.weight == mahjong.weight)
                    {
                        playCount++;
                    }
                }
                if (playCount == 3)
                {
                    UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                    UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();
                    uiRoomComponent.tip.SetActive(true);
                    uiRoomComponent.tip.GetComponentInChildren <Image>().sprite = CommonUtil.getSpriteByBundle("Image_Desk_Card", "foursame_tip");
                    await ETModel.Game.Scene.GetComponent <TimerComponent>().WaitAsync(3000);

                    if (this.IsDisposed)
                    {
                        return;
                    }
                    uiRoomComponent?.tip?.SetActive(false);
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #6
0
        protected override void Run(Session session, M2C_Gameover message)
        {
            UI             uiRoom             = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            GamerComponent gamerComponent     = uiRoom.GetComponent <GamerComponent>();
            Identity       localGamerIdentity = gamerComponent.LocalGamer.GetComponent <HandCardsComponent>().AccessIdentity;
            Identity       winner             = (Identity)message.Winner;
            UI             uiEndPanel         = UIEndFactory.Create(UIType.UIEnd, uiRoom, winner == localGamerIdentity);
            UIEndComponent uiEndComponent     = uiEndPanel.GetComponent <UIEndComponent>();

            foreach (var gamer in gamerComponent.GetAll())
            {
                gamer.GetComponent <GamerUIComponent>().UpdatePanel();
                gamer.GetComponent <HandCardsComponent>().Hide();
                uiEndComponent.CreateGamerContent(
                    gamer,
                    winner,
                    message.BasePointPerMatch,
                    message.Multiples,
                    message.GamersScore[gamer.UserID]);
            }

            UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();

            uiRoomComponent.Interaction.Gameover();
            uiRoomComponent.ResetMultiples();
        }
예제 #7
0
        protected override async void Run(ETModel.Session session, Actor_GamerTrusteeship message)
        {
            try
            {
                Log.Info($"玩家托管:" + message.Uid);

                UI              uiRoom          = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                GamerComponent  gamerComponent  = uiRoom.GetComponent <GamerComponent>();
                UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();
                Gamer           gamer           = gamerComponent.Get(message.Uid);
                if (message.Uid == PlayerInfoComponent.Instance.uid)
                {
                    uiRoomComponent.ShowTrustship();
                }
                else
                {
                    GamerUIComponent gamerUIComponent = gamer.GetComponent <GamerUIComponent>();
                    gamerUIComponent.ShowTrust();
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #8
0
        protected override void Run(Session session, M2C_GamerExitRoom message)
        {
            UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();

            uiRoomComponent.RemoveGamer(message.UserID);
        }
예제 #9
0
        protected override void Run(Session session, M2C_GameStart message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();

            //初始化玩家UI
            foreach (var gamer in gamerComponent.GetAll())
            {
                GamerUIComponent gamerUI = gamer.GetComponent <GamerUIComponent>();
                gamerUI.GameStart();

                HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>();
                if (handCards != null)
                {
                    handCards.Reset();
                }
                else
                {
                    handCards = gamer.AddComponent <HandCardsComponent, GameObject>(gamerUI.Panel);
                }

                handCards.Appear();

                if (gamer.UserID == gamerComponent.LocalGamer.UserID)
                {
                    //本地玩家添加手牌
                    handCards.AddCards(message.GamerCards);
                }
                else
                {
                    //设置其他玩家手牌数
                    handCards.SetHandCardsNum(message.GamerCardsNum[gamer.UserID]);
                }
            }

            //显示牌桌UI
            GameObject desk = uiRoom.GameObject.Get <GameObject>("Desk");

            desk.SetActive(true);
            GameObject lordPokers = desk.Get <GameObject>("LordPokers");

            //重置地主牌
            Sprite lordSprite = CardHelper.GetCardSprite("None");

            for (int i = 0; i < lordPokers.transform.childCount; i++)
            {
                lordPokers.transform.GetChild(i).GetComponent <Image>().sprite = lordSprite;
            }

            UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();

            //清空选中牌
            uiRoomComponent.Interaction.Clear();
            //设置初始倍率
            uiRoomComponent.SetMultiples(1);
        }
예제 #10
0
        private async void OnChangeTable()
        {
            UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            UIRoomComponent roomComponent = uiRoom.GetComponent <UIRoomComponent>();

            Log.Debug("换桌:" + roomComponent.RoomType);
            SessionComponent.Instance.Session.Send(new Actor_ChangeTable()
            {
                RoomType = PlayerInfoComponent.Instance.RoomType
            });
            Game.Scene.GetComponent <UIComponent>().Remove(UIType.UIReady);
        }
예제 #11
0
        protected override async void Run(ETModel.Session session, Actor_GamerGrabCard message)
        {
            try
            {
                Log.Info($"收到抓拍");
                MahjongInfo mahjongInfo = new MahjongInfo()
                {
                    weight = (byte)message.weight, m_weight = (Consts.MahjongWeight)message.weight
                };
                UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                if (uiRoom == null)
                {
                    return;
                }
                GamerComponent  gamerComponent  = uiRoom.GetComponent <GamerComponent>();
                UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();

                Gamer gamer = gamerComponent.Get(message.Uid);
                HandCardsComponent handCardsComponent = gamer.GetComponent <HandCardsComponent>();

                if (PlayerInfoComponent.Instance.uid == message.Uid)
                {
                    handCardsComponent.GrabCard(mahjongInfo);
                }
                else
                {
                    handCardsComponent.GrabOtherCard();
                }

                //当前出牌玩家
                gamerComponent.CurrentPlayUid = message.Uid;
                gamerComponent.IsPlayed       = false;

                //剩下的牌
                uiRoomComponent.SetRestCount();

                //显示黄色bg
                uiRoomComponent.ShowTurn(message.Uid);
                uiRoomComponent.ClosePropmtBtn();

                SoundsHelp.Instance.playSound_MoPai();

                uiRoomComponent.CurrentMahjong = mahjongInfo;

                Gamer currentGamer = gamerComponent.Get(PlayerInfoComponent.Instance.uid);
                HandCardsComponent currentGamerCard = currentGamer.GetComponent <HandCardsComponent>();
                currentGamerCard.CloseHandCardCanPeng();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #12
0
        protected override void Run(Session session, M2C_GamerReconnect_ANtt message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();

            uiRoom.GameObject.Get <GameObject>("ReadyButton").SetActive(false);
            foreach (var gamer in gamerComponent.GetAll())
            {
                //初始化玩家身份
                Identity           gamerIdentity  = message.GamersIdentity[gamer.UserID];
                HandCardsComponent gamerHandCards = gamer.GetComponent <HandCardsComponent>();
                GamerUIComponent   gamerUI        = gamer.GetComponent <GamerUIComponent>();
                gamerHandCards.AccessIdentity = gamerIdentity;
                gamerUI.SetIdentity(gamerIdentity);
                //初始化出牌
                if (message.DeskCards.Key == gamer.UserID && gamerIdentity != Identity.None)
                {
                    Card[] deskCards = message.DeskCards.Value;
                    if (deskCards != null)
                    {
                        gamerHandCards.PopCards(deskCards);
                    }
                }
                else if (message.LordCards == null && message.GamerGrabLandlordState.ContainsKey(gamer.UserID))
                {
                    gamer.GetComponent <GamerUIComponent>().SetGrab(message.GamerGrabLandlordState[gamer.UserID]);
                }
            }

            //初始化界面
            UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();

            uiRoomComponent.SetMultiples(message.Multiples);
            //当抢完地主时才能显示托管按钮
            if (message.LordCards != null)
            {
                uiRoomComponent.Interaction.GameStart();
            }

            //初始化地主牌
            if (message.LordCards != null)
            {
                GameObject lordPokers = uiRoom.GameObject.Get <GameObject>("Desk").Get <GameObject>("LordPokers");
                for (int i = 0; i < lordPokers.transform.childCount; i++)
                {
                    Sprite lordCardSprite = CardHelper.GetCardSprite(message.LordCards[i].GetName());
                    lordPokers.transform.GetChild(i).GetComponent <Image>().sprite = lordCardSprite;
                }
            }
        }
예제 #13
0
        protected override async void Run(ETModel.Session session, Actor_GamerJionRoom message)
        {
            try
            {
                Log.Debug("有人加入:");
                UI uiRoom  = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                UI uiReady = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIReady);
                if (uiReady == null)
                {
                    return;
                }
                GamerComponent  gamerComponent = uiRoom.GetComponent <GamerComponent>();
                UIRoomComponent roomComponent  = uiRoom.GetComponent <UIRoomComponent>();

                UIReadyComponent uiReadyComponent = uiReady.GetComponent <UIReadyComponent>();
                Gamer            gamer            = GamerFactory.Create(message.Gamer.UserID, message.Gamer.IsReady, message.Gamer.playerInfo);

                GamerUIComponent gamerUiComponent = gamer.GetComponent <GamerUIComponent>();

                //排序
                int index = message.Gamer.SeatIndex - roomComponent.localGamer.SeatIndex;
                if (index < 0)
                {
                    index += 4;
                }

                //设置准备
                if (uiReadyComponent != null)
                {
                    //                        await gamerUiComponent.GetPlayerInfo();
                    if (gamer?.PlayerInfo != null)
                    {
                        gamerUiComponent?.SetHeadPanel(uiReadyComponent.HeadPanel[index], index);
                        gamerUiComponent?.SetFace(roomComponent.FacePanel[index]);
                        uiReady?.GetComponent <UIReadyComponent>()?.SetPanel(gamer, index);
                        //根据座位的indax添加玩家
                        roomComponent?.AddGamer(gamer, index);
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #14
0
        protected override void Run(Session session, M2C_GamerEnterRoom message)
        {
            UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();
            GamerComponent  gamerComponent  = uiRoom.GetComponent <GamerComponent>();

            //从匹配状态中切换为准备状态
            if (uiRoomComponent.Matching)
            {
                uiRoomComponent.Matching = false;
                GameObject matchPrompt = uiRoom.GameObject.Get <GameObject>("MatchPrompt");
                if (matchPrompt.activeSelf)
                {
                    matchPrompt.SetActive(false);
                    uiRoom.GameObject.Get <GameObject>("ReadyButton").SetActive(true);
                }
            }

            int localGamerIndex = message.Gamers.FindIndex(info => info.UserID == gamerComponent.LocalGamer.UserID);

            //添加未显示玩家
            for (int i = 0; i < message.Gamers.Count; i++)
            {
                GamerInfo gamerInfo = message.Gamers[i];
                if (gamerInfo.UserID == 0)
                {
                    continue;
                }
                if (gamerComponent.Get(gamerInfo.UserID) == null)
                {
                    Gamer gamer = GamerFactory.Create(gamerInfo.UserID, gamerInfo.IsReady);
                    if ((localGamerIndex + 1) % 3 == i)
                    {
                        //玩家在本地玩家右边
                        uiRoomComponent.AddGamer(gamer, 2);
                    }
                    else
                    {
                        //玩家在本地玩家左边
                        uiRoomComponent.AddGamer(gamer, 0);
                    }
                }
            }
        }
예제 #15
0
        protected override async void Run(ETModel.Session session, Actor_GamerBuHua message)
        {
            try
            {
                Log.Info($"收到补花:{message.weight}");
                MahjongInfo mahjongInfo = new MahjongInfo()
                {
                    weight = (byte)message.weight, m_weight = (Consts.MahjongWeight)message.weight
                };
                UI              uiRoom          = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                GamerComponent  gamerComponent  = uiRoom.GetComponent <GamerComponent>();
                UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();

                Gamer              gamer              = gamerComponent.Get(message.Uid);
                GamerUIComponent   gamerUiComponent   = gamer.GetComponent <GamerUIComponent>();
                HandCardsComponent handCardsComponent = gamer.GetComponent <HandCardsComponent>();

                if (PlayerInfoComponent.Instance.uid == message.Uid)
                {
                    handCardsComponent.BuHua(mahjongInfo, true);
                    SoundsHelp.Instance.PlayBuHua(PlayerInfoComponent.Instance.GetPlayerInfo().PlayerSound);
                }
                else
                {
                    handCardsComponent.BuHua(mahjongInfo, false);
                    SoundsHelp.Instance.PlayBuHua(gamer.PlayerInfo.PlayerSound);
                }

                //补花显示
                gamerUiComponent.SetBuHua(message.weight);
                gamerUiComponent.ShowBuHua();

                //剩下的牌
                uiRoomComponent.SetRestCount();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #16
0
        public static void PlayCard(Actor_GamerPlayCard message)
        {
            try
            {
                Log.Info($"收到出牌");
                MahjongInfo mahjongInfo = new MahjongInfo()
                {
                    weight = (byte)message.weight, m_weight = (Consts.MahjongWeight)message.weight
                };

                UI              uiRoom          = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                GamerComponent  gamerComponent  = uiRoom.GetComponent <GamerComponent>();
                UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();

                Gamer gamer = gamerComponent.Get(message.Uid);
                HandCardsComponent handCardsComponent = gamer.GetComponent <HandCardsComponent>();
                HandCardsComponent cardsComponent     = gamerComponent.LocalGamer.GetComponent <HandCardsComponent>();

                if (PlayerInfoComponent.Instance.uid == message.Uid)
                {
                    handCardsComponent.PlayCard(mahjongInfo, message.index, uiRoomComponent.currentItem);
                    SoundsHelp.Instance.PlayCardSound(PlayerInfoComponent.Instance.GetPlayerInfo().PlayerSound, message.weight);
                }
                else
                {
                    handCardsComponent.PlayOtherCard(mahjongInfo, uiRoomComponent.currentItem);
                    SoundsHelp.Instance.PlayCardSound(gamer.PlayerInfo.PlayerSound, message.weight);
                }

                gamerComponent.LastPlayUid = message.Uid;
                SoundsHelp.Instance.playSound_ChuPai();

                uiRoomComponent.CurrentMahjong = mahjongInfo;
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #17
0
        protected override async void Run(ETModel.Session session, Actor_GamerCanOperation message)
        {
            try
            {
                Log.Info($"收到有人能够碰刚:" + JsonHelper.ToJson(message));

                UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();
                GamerComponent  gamerComponent  = uiRoom.GetComponent <GamerComponent>();

                if (message.Uid == gamerComponent.LocalGamer.UserID)
                {
                    uiRoomComponent.ShowOperation(message.OperationType);
                }

                //显示黄色bg
//                uiRoomComponent.ShowTurn(message.Uid);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #18
0
        protected override async void Run(ETModel.Session session, Actor_GamerChangeGold message)
        {
            try
            {
                Log.Info($"收到改变金币:" + message.Uid + "GoldAmount," + message.GoldAmount);
                UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                if (uiRoom == null)
                {
                    Log.Warning("uiroom  null");
                    return;
                }

                UIRoomComponent    uiRoomComponent    = uiRoom.GetComponent <UIRoomComponent>();
                GamerComponent     gamerComponent     = uiRoom.GetComponent <GamerComponent>();
                Gamer              gamer              = gamerComponent.Get(message.Uid);
                HandCardsComponent handCardsComponent = gamer.GetComponent <HandCardsComponent>();
                handCardsComponent.ChangeGold(message.GoldAmount);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #19
0
        protected override async void Run(ETModel.Session session, Actor_GamerExitRoom message)
        {
            try
            {
                Log.Info($"收到退出");
                UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);

                if (uiRoom == null)
                {
                    return;
                }
//                UI uiReady = Game.Scene.GetComponent<UIComponent>().Get(UIType.UIReady);

                GamerComponent  gamerComponent  = uiRoom.GetComponent <GamerComponent>();
                UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();

//                UIReadyComponent uiReadyComponent = uiReady.GetComponent<UIReadyComponent>();

                if (gamerComponent.LocalGamer.UserID == message.Uid)
                {
                    CommonUtil.ShowUI(UIType.UIMain);
                    GameUtil.Back2Main();
                }
                else
                {
                    Gamer gamer = gamerComponent.Get(message.Uid);
                    gamer?.GetComponent <GamerUIComponent>()?.ResetReadyPanel();
                    uiRoomComponent.RemoveGamer(message.Uid);
                }

                SoundsHelp.Instance.playSound_LiKai();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #20
0
        public void Update()
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Log.Info("第三方返回:" + PlatformHelper.isThirdSDKQuit());

                if (PlatformHelper.isThirdSDKQuit())
                {
                    PlatformHelper.thirdSDKQuit("AnroidCallBack", "", "");
                }
                else
                {
                    // 不在游戏内,退出整个游戏
                    if (Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom) == null)
                    {
                        UICommonPanelComponent script = UICommonPanelComponent.showCommonPanel("通知", "是否退出游戏?");
                        script.setOnClickOkEvent(() =>
                        {
                            Application.Quit();
                        });

                        script.setOnClickCloseEvent(() =>
                        {
                            Game.Scene.GetComponent <UIComponent>().Remove(UIType.UICommonPanel);
                        });

                        script.getTextObj().alignment = TextAnchor.MiddleCenter;
                    }
                    // 在游戏内,退回到主界面
                    else
                    {
                        UIRoomComponent.OnExit();
                    }
                }
            }
        }
예제 #21
0
        protected override async void Run(ETModel.Session session, Actor_GamerHuPai message)
        {
            try
            {
                Log.Info($"收到胡:");
                UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                if (uiRoom == null)
                {
                    return;
                }

                GamerComponent     gamerComponent     = uiRoom.GetComponent <GamerComponent>();
                UIRoomComponent    uiRoomComponent    = uiRoom.GetComponent <UIRoomComponent>();
                Gamer              gamer              = gamerComponent.Get(message.Uid);
                HandCardsComponent handCardsComponent = gamer.GetComponent <HandCardsComponent>();

                SoundsHelp.Instance.PlayHuSound(gamer.PlayerInfo.PlayerSound);

                if (PlayerInfoComponent.Instance.uid == message.Uid)
                {
                    SoundsHelp.Instance.playSound_Win();
                }
                else
                {
                    SoundsHelp.Instance.playSound_Fail();
                }

                if (message.IsZiMo)
                {
                    handCardsComponent.ShowOperateAnimAsync((int)GamerOpearteType.zimo);
                }
                else
                {
                    handCardsComponent.ShowOperateAnimAsync((int)GamerOpearteType.Hu);
                }

                uiRoomComponent.exitBtn.gameObject.SetActive(false);

                await ETModel.Game.Scene.GetComponent <TimerComponent>().WaitAsync(1500);

                uiRoomComponent.exitBtn.gameObject.SetActive(true);
                if (gamerComponent.GetGamerCount() < 4)
                {
                    return;
                }

                UIGameResultComponent gameResultComponent =
                    Game.Scene.GetComponent <UIComponent>().Create(UIType.UIGameResult).GetComponent <UIGameResultComponent>();

                RoomConfig roomConfig;
                if (uiRoomComponent.RoomType == 3)
                {
                    roomConfig = uiRoomComponent.RoomConfig;
                    gameResultComponent.SetFriendRoom();
                    gameResultComponent.startTimer(5);
                }
                else
                {
                    roomConfig = ConfigHelp.Get <RoomConfig>(uiRoomComponent.RoomType);
                    gameResultComponent.startTimer(20);
                }
                gameResultComponent.setData(message, gamerComponent, roomConfig.Multiples);
                UIRoomComponent.ISGaming = false;
                uiRoomComponent.ClosePropmtBtn();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #22
0
        public void Awake(GameObject panel, int index, int seatIndex)
        {
            this.Panel              = panel;
            this.Index              = index;
            SeatIndex               = seatIndex;
            this.CardBottom         = panel.Get <GameObject>("CardBottom");
            this.cardBottonPosition = this.CardBottom.transform.localPosition;
            this.showCard           = panel.Get <GameObject>("ShowCard");
            this.cardDisplay        = panel.Get <GameObject>("CardDisplay");
            this.directionObj       = panel.Get <GameObject>("Direction");
            this.pengObj            = panel.Get <GameObject>("Peng");
            this.bg          = panel.Get <GameObject>("Bg");
            this.changeMoney = panel.Get <GameObject>("ChangeMoney");
            this.faceImage   = panel.Get <GameObject>("FaceImage").GetComponent <Image>();
            this.faceImageGe = panel.Get <GameObject>("FaceImageGe").GetComponent <Image>();
            Image image = this.directionObj.GetComponent <Image>();

            //花牌显示
            this.faceCard = panel.Get <GameObject>("FaceCard");
            this.prompt   = panel.Get <GameObject>("Prompt");

            faceCard.GetComponent <Button>().onClick.Add(() =>
            {
                UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();
                uiRoomComponent.faceCardObj.SetActive(true);
            });
            switch (index)
            {
            case 0:
                PrefabName = "Image_Bottom_Card";
                ItemName   = "Item_Bottom_Card";
                postionX   = 78;
                postionY   = 0;
                Direction  = "bottom";
                break;

            case 1:
                PrefabName   = "Image_Right_Card";
                ItemName     = "Item_Right_Card";
                postionX     = 0;
                postionY     = -34;
                grabPostionX = 0;
                grabPostionY = 51;
                Direction    = "right";
                break;

            case 2:
                PrefabName   = "Image_Top_Card";
                ItemName     = "Item_Top_Card";
                postionX     = 47;
                postionY     = 0;
                grabPostionX = -70;
                grabPostionY = 0;
                Direction    = "card";
                break;

            case 3:
                PrefabName   = "Image_Left_Card";
                ItemName     = "Item_Left_Card";
                postionX     = 0;
                postionY     = -34;
                grabPostionX = 0;
                grabPostionY = -457;
                Direction    = "left";
                break;
            }

            //设置东南西北
            switch (seatIndex)
            {
            case 0:
                image.sprite = CommonUtil.getSpriteByBundle("Image_Desk_Card", "desk_dong");
                break;

            case 1:
                image.sprite = CommonUtil.getSpriteByBundle("Image_Desk_Card", "desk_nan");
                break;

            case 2:
                image.sprite = CommonUtil.getSpriteByBundle("Image_Desk_Card", "desk_xi");
                break;

            case 3:
                image.sprite = CommonUtil.getSpriteByBundle("Image_Desk_Card", "desk_bei");
                break;
            }

            //Load AB
            this.resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
            this.resourcesComponent.LoadBundle($"{PrefabName}.unity3d");
            this.resourcesComponent.LoadBundle($"{ItemName}.unity3d");
            this.resourcesComponent.LoadBundle($"Item_Horizontal_Card.unity3d");
            this.resourcesComponent.LoadBundle($"Item_Vertical_Card.unity3d");

            this.prefabObj = (GameObject)this.resourcesComponent.GetAsset($"{this.PrefabName}.unity3d", this.PrefabName);
            this.itemObj   = (GameObject)this.resourcesComponent.GetAsset($"{this.ItemName}.unity3d", this.ItemName);
        }
예제 #23
0
        /// <summary>
        /// 抓牌
        /// </summary>
        /// <param name="mahjong"></param>
        public async void GrabCard(MahjongInfo mahjong)
        {
            GameObject cardSprite = this.CreateCardSprite($"{Direction}_" + mahjong.weight, 0, 0);

            SetPosition(cardSprite, (handCards.Count) * postionX + 30, 0);

            //查询插入的index
            int index = -1;

            for (int i = 0; i < handCards.Count - 1; i++)
            {
                if (mahjong.m_weight < handCards[0].m_weight)
                {
                    index = -1;
                    break;
                }

                if (mahjong.m_weight >= handCards[handCards.Count - 1].m_weight)
                {
                    index = handCards.Count - 1;
                    break;
                }

                MahjongInfo mahjongInfo1 = this.handCards[i];
                MahjongInfo mahjongInfo2 = this.handCards[i + 1];
                if (mahjongInfo1.m_weight <= mahjong.m_weight && mahjongInfo2.m_weight > mahjong.m_weight)
                {
                    index = i;
                    break;
                }
            }

            index++;
            handCards.Insert(index, mahjong);
            ItemCards.Insert(index, cardSprite);

            //大于index的item本身的index需要加1
            for (int i = 0; i < ItemCards.Count; i++)
            {
                if (i > index)
                {
                    ItemCards[i].GetComponent <ItemCardScipt>().index = i;
                }
            }

            //设置item
            cardSprite.GetComponent <ItemCardScipt>().weight = mahjong.weight;
            cardSprite.GetComponent <ItemCardScipt>().index  = index;

            //添加点击事件
            Button cardBtn = cardSprite.GetComponent <Button>();

            cardBtn.onClick.RemoveAllListeners();
//            cardBtn.onClick.Add(() =>
//            {
//                if (IsSelect)
//                {
//
//                }
//                else
//                {
//                    IsSelect = true;
//                    Vector3 localPosition = this._rectTransform.localPosition;
//                    this._rectTransform.localPosition = new Vector3(localPosition.x, localPosition.y + 20, localPosition.z);
//                }
//            })

            grabIndex = index;



            //第4张显示门清提示
            if (playCards.Count == 3)
            {
                UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();
                uiRoomComponent.tip.SetActive(true);
                uiRoomComponent.tip.GetComponentInChildren <Image>().sprite = CommonUtil.getSpriteByBundle("Image_Desk_Card", "menqing_tip");
                await ETModel.Game.Scene.GetComponent <TimerComponent>().WaitAsync(3000);

                if (this.IsDisposed)
                {
                    return;
                }
                uiRoomComponent?.tip?.SetActive(false);
            }
        }
예제 #24
0
        public static async void StartGame(Actor_StartGame message, bool isReconnect)
        {
            Log.Debug($"收到开始");

            try
            {
                UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);

                if (uiRoom == null)
                {
                    uiRoom = Game.Scene.GetComponent <UIComponent>().Create(UIType.UIRoom);
                }

                Game.Scene.GetComponent <UIComponent>().Remove(UIType.UIReady);
                Game.Scene.GetComponent <UIComponent>().Remove(UIType.UIGameResult);
                GamerComponent  gamerComponent  = uiRoom.GetComponent <GamerComponent>();
                UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();
                UIRoomComponent.ISGaming = true;
                uiRoomComponent.ContinueGamer();
                //好友房设置将退出变成解散
                if (UIRoomComponent.IsFriendRoom)
                {
                    uiRoomComponent.SetFriendSetting(PlayerInfoComponent.Instance.uid);
                    uiRoomComponent.SetCurrentJuCount(message.CurrentJuCount);
                }
                //先掷骰子
                if (!isReconnect)
                {
                    uiRoomComponent.exitBtn.interactable = false;
                    uiRoomComponent.players.SetActive(true);
                    GameObject DiceAnim   = uiRoomComponent.dice.Get <GameObject>("DiceAnim");
                    GameObject DiceBottom = uiRoomComponent.dice.Get <GameObject>("DiceBottom");
                    Image      Dice1      = DiceBottom.transform.Find("Dice1").GetComponent <Image>();
                    Image      Dice2      = DiceBottom.transform.Find("Dice2").GetComponent <Image>();
                    DiceAnim.SetActive(true);
                    SoundsHelp.Instance.playSound_ShaiZi();
                    await ETModel.Game.Scene.GetComponent <TimerComponent>().WaitAsync(2000);

                    DiceAnim.SetActive(false);
                    DiceBottom.SetActive(true);
                    int number1 = RandomHelper.RandomNumber(1, 7);
                    Dice1.sprite = CommonUtil.getSpriteByBundle("Image_Dice", "num_" + number1);
                    int number2 = RandomHelper.RandomNumber(1, 7);
                    Dice2.sprite = CommonUtil.getSpriteByBundle("Image_Dice", "num_" + number2);
                    await ETModel.Game.Scene.GetComponent <TimerComponent>().WaitAsync(1000);


                    //发牌动画

                    List <MahjongInfo> myCard = null;
                    foreach (var gameData in message.GamerDatas)
                    {
                        foreach (var mahjong in gameData.handCards)
                        {
                            mahjong.m_weight = (Consts.MahjongWeight)mahjong.weight;
                        }

                        foreach (var mahjong in gameData.faceCards)
                        {
                            mahjong.m_weight = (Consts.MahjongWeight)mahjong.weight;
                        }

                        foreach (var gamer in gamerComponent.GetAll())
                        {
                            if (gamer.UserID != gameData.UserID)
                            {
                                continue;
                            }
//                            if (gamer.UserID == PlayerInfoComponent.Instance.uid)
//                            {
//                                myCard = new List<MahjongInfo>(gameData.handCards);
//                            }
                            gamer.gameData = gameData;
                            GamerUIComponent gamerUi = gamer.GetComponent <GamerUIComponent>();
                            gamerUi.GameStart();

                            gamer.IsBanker = gameData.IsBanker;
                            HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>();
                            if (handCards != null)
                            {
                                handCards.Reset();
                            }
                            else
                            {
                                handCards = gamer.AddComponent <HandCardsComponent, GameObject, int, int>(gamerUi.Panel, gamerUi.Index, gameData.SeatIndex);
                            }

                            handCards.myCard = new List <MahjongInfo>(gameData.handCards);
                        }
                    }

                    for (int i = 0; i < 4; i++)
                    {
                        foreach (var gamer in gamerComponent.GetAll())
                        {
                            HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>();

                            if (PlayerInfoComponent.Instance.uid == gamer.UserID)
                            {
                                handCards.StartDealCardAnim(true);
                            }
                            else
                            {
                                handCards.StartDealCardAnim(false);
                            }
                            await ETModel.Game.Scene.GetComponent <TimerComponent>().WaitAsync(400);
                        }
                    }

                    //自己的牌翻一下
                    foreach (var gamer in gamerComponent.GetAll())
                    {
                        if (gamer.UserID == PlayerInfoComponent.Instance.uid)
                        {
                            HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>();
                            handCards.FanPai();
                        }
                    }
                    await ETModel.Game.Scene.GetComponent <TimerComponent>().WaitAsync(500);

                    DiceBottom.SetActive(false);
                }

                uiRoomComponent.StartGame(message.restCount);
                uiRoomComponent.exitBtn.interactable = true;
                // uiRoomComponent.SetRoomType(message.RoomType);

                foreach (var gameData in message.GamerDatas)
                {
                    foreach (var mahjong in gameData.handCards)
                    {
                        mahjong.m_weight = (Consts.MahjongWeight)mahjong.weight;
                    }

                    foreach (var mahjong in gameData.faceCards)
                    {
                        mahjong.m_weight = (Consts.MahjongWeight)mahjong.weight;
                    }

                    foreach (var gamer in gamerComponent.GetAll())
                    {
                        if (gamer.UserID != gameData.UserID)
                        {
                            continue;
                        }

                        GamerUIComponent gamerUi = gamer.GetComponent <GamerUIComponent>();
                        gamerUi.GameStart();
                        HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>();
                        if (handCards != null)
                        {
                            handCards.Reset();
                        }
                        else
                        {
                            handCards = gamer.AddComponent <HandCardsComponent, GameObject, int, int>(gamerUi.Panel, gamerUi.Index, gameData.SeatIndex);
                        }

                        //设置庄家
                        gamer.IsBanker = gameData.IsBanker;
                        gamerUi.SetZhuang();

                        //当前出牌玩家
                        if (gamer.IsBanker)
                        {
                            gamerComponent.CurrentPlayUid = gamer.UserID;
                        }

                        if (gamer.UserID == gamerComponent.LocalGamer.UserID)
                        {
                            //本地玩家添加手牌
                            uiRoomComponent.SetTreasureTime(gameData.OnlineSeconds);
                            handCards.AddCards(gameData.handCards);
                            handCards.ShowBg();
                        }
                        else
                        {
                            handCards.AddOtherCards(gamer.IsBanker);
                        }

                        handCards.SetFaceCards(gameData.faceCards);
                        foreach (var card in gameData.faceCards)
                        {
                            gamerUi.SetBuHua(card.weight);
                        }
                    }
                }

                //时间倒计时
                foreach (var gamer in gamerComponent.GetAll())
                {
                    if (gamer.IsBanker)
                    {
                        uiRoomComponent.ShowTurn(gamer.UserID);
                    }
                }

                uiRoom.GameObject.SetActive(true);
                UIRoomComponent.ISGaming = true;

                uiRoomComponent?.tip?.SetActive(true);
                uiRoomComponent.tip.GetComponentInChildren <Image>().sprite = CommonUtil.getSpriteByBundle("Image_Desk_Card", "shangji_tip");
                await ETModel.Game.Scene.GetComponent <TimerComponent>().WaitAsync(3000);

                if (uiRoomComponent != null)
                {
                    if (uiRoomComponent.tip != null)
                    {
                        uiRoomComponent?.tip?.SetActive(false);
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #25
0
        protected override async void Run(ETModel.Session session, Actor_GamerReconnet message)
        {
            try
            {
                Log.Info($"断线重连:");
                SoundsHelp.Instance.IsOpenSound(false);

                GameObject mask = GameObject.Instantiate(CommonUtil.getGameObjByBundle("Image_Desk_Card", "RoomMask"), GameObject.Find("Global/UI/CommonCanvas").transform);

                //进入
                List <GamerInfo> Gamers = new List <GamerInfo>();
                foreach (var item in message.Gamers)
                {
                    GamerInfo gamerInfo = new GamerInfo();
                    gamerInfo.UserID     = item.UserID;
                    gamerInfo.SeatIndex  = item.SeatIndex;
                    gamerInfo.IsReady    = true;
                    gamerInfo.playerInfo = item.playerInfo;
                    Gamers.Add(gamerInfo);

                    //将出的牌加入到手牌中
                    item.handCards.AddRange(item.playCards);

                    foreach (var card in item.pengCards)
                    {
                        item.handCards.Add(card);
                        item.handCards.Add(card);
                    }

                    foreach (var card in item.gangCards)
                    {
                        item.handCards.Add(card);
                        item.handCards.Add(card);
                        item.handCards.Add(card);
                    }

                    Logic_NJMJ.getInstance().SortMahjong(item.handCards);

                    Log.Info($"{item.UserID} 手牌:{item.handCards.Count}");
                }

                Actor_GamerEnterRoom actorGamerEnterRoom = new Actor_GamerEnterRoom()
                {
                    Gamers   = Gamers,
                    RoomType = message.RoomType,
                };
                if (message.RoomType == 3)
                {
                    actorGamerEnterRoom.RoomId       = message.RoomId;
                    actorGamerEnterRoom.MasterUserId = message.MasterUserId;
                    actorGamerEnterRoom.JuCount      = message.JuCount;
                    actorGamerEnterRoom.Multiples    = message.Multiples;
                }
                await Actor_GamerEnterRoomHandler.GamerEnterRoom(actorGamerEnterRoom);

                //开始游戏
                var actorStartGame = new Actor_StartGame();
                actorStartGame.GamerDatas = message.Gamers;
                actorStartGame.restCount  = message.RestCount;
                actorStartGame.RoomType   = message.RoomType;
                if (actorStartGame.RoomType == 3)
                {
                    actorStartGame.CurrentJuCount = message.CurrentJuCount;
                }

                Actor_StartGameHandler.StartGame(actorStartGame, true);

                //碰刚
                foreach (var item in message.Gamers)
                {
                    for (int i = 0; i < item.pengCards.Count; i++)
                    {
                        MahjongInfo          card           = item.pengCards[i];
                        Actor_GamerOperation gamerOperation = new Actor_GamerOperation();
                        gamerOperation.Uid           = item.UserID;
                        gamerOperation.weight        = card.weight;
                        gamerOperation.OperationType = 0;
                        gamerOperation.OperatedUid   = item.OperatedPengUserIds[i];
                        Actor_GamerOperateHandler.GamerOperation(gamerOperation, true);
                    }

                    for (int i = 0; i < item.gangCards.Count; i++)
                    {
                        MahjongInfo          card = item.gangCards[i];
                        long                 operatedGangUserIds = item.OperatedGangUserIds[i];
                        Actor_GamerOperation gamerOperation      = new Actor_GamerOperation();
                        gamerOperation.Uid           = item.UserID;
                        gamerOperation.weight        = card.weight;
                        gamerOperation.OperationType = 1;
                        gamerOperation.OperatedUid   = operatedGangUserIds;

                        if (operatedGangUserIds == 0)
                        {
                            gamerOperation.OperationType = 4;
                        }
                        Actor_GamerOperateHandler.GamerOperation(gamerOperation, true);
                    }
                }

                //打牌
                foreach (var item in message.Gamers)
                {
                    Log.Debug($"{item.UserID} 重连出牌");
                    for (int i = 0; i < item.playCards.Count; i++)
                    {
                        MahjongInfo         card     = item.playCards[i];
                        int                 index    = Logic_NJMJ.getInstance().GetIndex(item.handCards, card);
                        Actor_GamerPlayCard playCard = new Actor_GamerPlayCard();
                        playCard.Uid    = item.UserID;
                        playCard.weight = card.weight;
                        playCard.index  = index;
//                        await ETModel.Game.Scene.GetComponent<TimerComponent>().WaitAsync(100);
                        Actor_GamerPlayCardHandler.PlayCard(playCard);
//                        item.handCards.RemoveAt(index);
                    }
                }

                //托管恢复
                UI              uiRoom          = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                GamerComponent  gamerComponent  = uiRoom.GetComponent <GamerComponent>();
                UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();
                foreach (var item in message.Gamers)
                {
                    if (item.IsTrusteeship)
                    {
                        if (item.UserID == PlayerInfoComponent.Instance.uid)
                        {
                            uiRoomComponent.ShowTrustship();
                        }
                        else
                        {
                            GamerUIComponent gamerUIComponent = gamerComponent.Get(item.UserID).GetComponent <GamerUIComponent>();
                            gamerUIComponent.ShowTrust();
                        }
                    }
                }

                await ETModel.Game.Scene.GetComponent <TimerComponent>().WaitAsync(3000);

                int openSound = PlayerPrefs.GetInt("isOpenSound", 1);
                SoundsHelp.Instance.IsOpenSound(openSound == 1);
                GameObject.Destroy(mask);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #26
0
        //        public async Task GetPlayerInfo()
//        {
//            tokenSource = new CancellationTokenSource();
//            try
//            {
//                Gamer gamer = this.GetParent<Gamer>();
//                Log.Debug("请求gamer信息:" + gamer.UserID);
//                G2C_PlayerInfo playerInfo = (G2C_PlayerInfo)await SessionComponent.Instance.Session.Call(new C2G_PlayerInfo() { uid = gamer.UserID }, tokenSource.Token);
//                gamer.PlayerInfo = playerInfo.PlayerInfo;
//            }
//            catch (Exception e)
//            {
//                Log.Error(e);
//                tokenSource.Cancel();
//            }
//        }

        /// <summary>
        /// 设置准备界面
        /// </summary>
        /// <param name="gameObject"></param>
        public void SetHeadPanel(GameObject gameObject, int index)
        {
            try
            {
                if (gameObject == null)
                {
                    return;
                }

                Index = index;
                Gamer gamer = this.GetParent <Gamer>();
                this.readyHead = gameObject.Get <GameObject>("Image").GetComponent <Image>();
                this.readyName = gameObject.Get <GameObject>("Name").GetComponent <Text>();
                this.readyText = gameObject.Get <GameObject>("Text").GetComponent <Text>();
                this.vip       = gameObject.Get <GameObject>("vip");
                PlayerInfo playerInfo = gamer.PlayerInfo;

                if (readyName == null)
                {
                    return;
                }
                readyName.text = playerInfo.Name + "";
                HeadManager.setHeadSprite(readyHead, playerInfo.Icon);

                if (gamer.IsReady)
                {
                    gameObject.transform.Find("Text").GetComponent <Text>().text = "已准备";
                }
                else
                {
                    readyText.text = "";
                }

                if (GameUtil.isVIP(playerInfo))
                {
                    vip.transform.localScale = Vector3.one;
                }
                else
                {
                    vip.transform.localScale = Vector3.zero;
                }

                #region 准备界面信息框
                // if(Index != 0)
                {
                    this.headReadyInfo = gameObject.Get <GameObject>("HeadInfo");
                    Image kickOffImage     = this.headReadyInfo.Get <GameObject>("KickOffImage").GetComponent <Image>();
                    Text  uidReadyText     = this.headReadyInfo.Get <GameObject>("Uid").GetComponent <Text>();
                    Text  shenglvReadyText = this.headReadyInfo.Get <GameObject>("Shenglv").GetComponent <Text>();
                    Text  jinbiReadyText   = this.headReadyInfo.Get <GameObject>("Jinbi").GetComponent <Text>();
                    this.headReadyInfo.SetActive(false);
                    this.headReadyInfo.GetComponentInParent <Button>().onClick.RemoveAllListeners();
                    this.headReadyInfo.GetComponentInParent <Button>().onClick.Add(() =>
                    {
                        if (this.headReadyInfo.activeSelf)
                        {
                            this.headReadyInfo.SetActive(false);
                        }
                        else
                        {
                            this.headReadyInfo.SetActive(true);
                        }
                    });
                    uidReadyText.text = playerInfo.Name;


                    UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                    this.uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();
                    if (UIRoomComponent.IsFriendRoom)
                    {
                        shenglvReadyText.text = $"积 分:<color=#FFF089FF>{playerInfo.Score}</color>";
                    }
                    else
                    {
                        shenglvReadyText.text = $"金 币:<color=#FFF089FF>{playerInfo.GoldNum}</color>";
                    }

                    float i;
                    if (playerInfo.TotalGameCount == 0)
                    {
                        i = 0;
                    }
                    else
                    {
                        i = GameUtil.GetWinRate(playerInfo.TotalGameCount, playerInfo.WinGameCount);
                    }
                    jinbiReadyText.text = $"胜 率:<color=#FFF089FF>{i}%</color>";

                    //踢人

                    if (uiRoomComponent.masterUserId != 0 && uiRoomComponent.masterUserId == PlayerInfoComponent.Instance.uid && Index != 0)
                    {
                        kickOffImage.gameObject.SetActive(true);
                    }
                    else
                    {
                        kickOffImage.gameObject.SetActive(false);
                    }

                    kickOffImage.gameObject.GetComponent <Button>().onClick.Add(() =>
                    {
                        SessionComponent.Instance.Session.Send(new Actor_GamerKickOff()
                        {
                            KickedUserId = gamer.UserID
                        });
                    });
                }



                #endregion
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #27
0
        public static void GamerOperation(Actor_GamerOperation message, bool isReconnect)
        {
            try
            {
                Log.Info($"收到有人碰杠胡");
                UI                 uiRoom             = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                GamerComponent     gamerComponent     = uiRoom.GetComponent <GamerComponent>();
                UIRoomComponent    uiRoomComponent    = uiRoom.GetComponent <UIRoomComponent>();
                Gamer              gamer              = gamerComponent.Get(message.Uid);
                HandCardsComponent handCardsComponent = gamer.GetComponent <HandCardsComponent>();
                uiRoomComponent.ClosePropmtBtn();
                uiRoomComponent.ShowTurn(message.Uid);
                MahjongInfo mahjongInfo = new MahjongInfo()
                {
                    weight = (byte)message.weight, m_weight = (Consts.MahjongWeight)message.weight
                };

                if (message.OperationType == 0)
                {
                    SoundsHelp.Instance.PlayPeng(PlayerInfoComponent.Instance.GetPlayerInfo().PlayerSound);
                }
                else
                {
                    SoundsHelp.Instance.PlayGang(PlayerInfoComponent.Instance.GetPlayerInfo().PlayerSound);
                }

                if (PlayerInfoComponent.Instance.uid == message.Uid)
                {
                    if (message.OperationType == 0)
                    {
                        gamerComponent.CurrentPlayUid = message.Uid;
                        gamerComponent.IsPlayed       = false;
                    }

                    //碰刚
                    if (message.OperationType == 5)
                    {
                        handCardsComponent.SetPengGang(message.OperationType, mahjongInfo, message.OperatedUid);
                    }
                    else
                    {
                        handCardsComponent.SetPeng(message.OperationType, mahjongInfo, message.OperatedUid, isReconnect);
                    }
                    //隐藏碰杠
                    handCardsComponent.CloseHandCardCanPeng();
                }
                else
                {
                    //碰刚
                    if (message.OperationType == 5)
                    {
                        handCardsComponent.SetOtherPengGang(message.OperationType, mahjongInfo, message.OperatedUid, message.Uid);
                    }
                    else
                    {
                        handCardsComponent.SetOtherPeng(message.OperationType, mahjongInfo, message.OperatedUid, message.Uid);
                    }
                }
                //显示碰刚动画
                handCardsComponent.ShowOperateAnimAsync(message.OperationType);


                if (isReconnect)
                {
                    return;
                }
                //碰和碰刚删除出的牌
                if (message.OperationType == 0 || message.OperationType == 1)
                {
                    Gamer currentGamer = gamerComponent.Get(gamerComponent.LastPlayUid);
                    HandCardsComponent currentCards = currentGamer.GetComponent <HandCardsComponent>();

                    GameObject.Destroy(currentCards.currentPlayCardObj);
                    currentCards.cardDisplayObjs.Remove(currentCards.currentPlayCardObj);
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #28
0
        public static async Task GamerEnterRoom(Actor_GamerEnterRoom message)
        {
            try
            {
                //玩家还在结算画面
                if (Game.Scene.GetComponent <UIComponent>().Get(UIType.UIGameResult) != null || UIRoomComponent.ISGaming)
                {
                    return;
                }

                Log.Info($"收到玩家进入");
                //第一次进入创建UIRoom
                if (Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom) == null)
                {
                    CommonUtil.ShowUI(UIType.UIRoom);
                    Game.Scene.GetComponent <UIComponent>().Remove(UIType.UIMain);
                    Game.Scene.GetComponent <UIComponent>().Remove(UIType.UICreateFriendRoom);
                    Game.Scene.GetComponent <UIComponent>().Remove(UIType.UIJoinRoom);
                }

                if (Game.Scene.GetComponent <UIComponent>().Get(UIType.UIReady) == null)
                {
                    CommonUtil.ShowUI(UIType.UIReady);
                }
                UINetLoadingComponent.closeNetLoading();
                UI              uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                UI              uiReady        = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIReady);
                GamerComponent  gamerComponent = uiRoom.GetComponent <GamerComponent>();
                UIRoomComponent roomComponent  = uiRoom.GetComponent <UIRoomComponent>();
                roomComponent.ContinueGamer();
                roomComponent.enterRoomMsg = message;
                roomComponent.SetRoomType(message.RoomType, message.Multiples);
                Gamer[] gamers = gamerComponent.GetAll();

                //清空座位
                for (int i = 0; i < gamers.Length; i++)
                {
                    if (gamers[i] == null)
                    {
                        continue;
                    }

                    if (gamers[i].UserID != 0)
                    {
                        Log.Debug("删除gamer");
                        roomComponent.RemoveGamer(gamers[i].UserID);
                    }
                }

                GamerInfo localGamer = null;
                for (int i = 0; i < message.Gamers.Count; i++)
                {
                    if (message.Gamers[i].UserID == PlayerInfoComponent.Instance.uid)
                    {
                        localGamer = message.Gamers[i];
                        gamerComponent.LocalGamer = GamerFactory.Create(localGamer.UserID, localGamer.IsReady, localGamer.playerInfo);
                        break;
                    }
                }

                if (localGamer == null)
                {
                    return;
                }

                roomComponent.localGamer = localGamer;

                //好友房处理
                if (message.RoomType == 3)
                {
                    UIRoomComponent.IsFriendRoom = true;
                    roomComponent.JuCount        = message.JuCount;
                    uiReady?.GetComponent <UIReadyComponent>()?.ClosePropt();
                    uiReady?.GetComponent <UIReadyComponent>()?.SetFriendRoom(true);
                    uiReady?.GetComponent <UIReadyComponent>()?.ShowWeChat(message.RoomId.ToString());
                    roomComponent.RoomConfig.Multiples = message.Multiples;
                    roomComponent.SetFriendSetting(message.MasterUserId);

                    if (message.CurrentJuCount > 0)
                    {
                        uiReady?.GetComponent <UIReadyComponent>()?.CloseBtn();
                        roomComponent.exitBtn.interactable = false;
                    }
                }
                else
                {
                    uiReady?.GetComponent <UIReadyComponent>()?.SetFriendRoom(false);
                    UIRoomComponent.IsFriendRoom = false;
                }

                for (int i = 0; i < message.Gamers.Count; i++)
                {
                    GamerInfo gamerInfo = message.Gamers[i];
                    Gamer     gamer;
                    if (gamerInfo.UserID == localGamer.UserID)
                    {
                        gamer = gamerComponent.LocalGamer;
                    }
                    else
                    {
                        gamer = GamerFactory.Create(gamerInfo.UserID, gamerInfo.IsReady, gamerInfo.playerInfo);
                    }

                    UIReadyComponent uiReadyComponent = uiReady.GetComponent <UIReadyComponent>();
                    GamerUIComponent gamerUiComponent = gamer.GetComponent <GamerUIComponent>();

                    //排序
                    int index = gamerInfo.SeatIndex - localGamer.SeatIndex;
                    if (index < 0)
                    {
                        index += 4;
                    }

                    //设置准备
                    if (uiReadyComponent != null)
                    {
                        if (gamer?.PlayerInfo != null)
                        {
                            gamerUiComponent?.SetHeadPanel(uiReadyComponent.HeadPanel[index], index);
                            gamerUiComponent?.SetFace(roomComponent.FacePanel[index]);
                            uiReady?.GetComponent <UIReadyComponent>()?.SetPanel(gamer, index);
                            //根据座位的indax添加玩家
                            roomComponent?.AddGamer(gamer, index);
                        }
                    }
                }

                SoundsHelp.Instance.playSound_JinRu();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }