Пример #1
0
        protected override void Run(ETModel.Session session, Actor_Chat message)
        {
            try
            {
                Log.Info("" + "收到表情:");

//                ToastScript.createToast(message.Value);

                UI ui = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIChatShow);
                if (message.ChatType == 1)
                {
                    ui.GetComponent <UIChatShowComponent>().ShowExpressAni(message.Value);
                }
                else if (message.ChatType == 2)
                {
                    ui.GetComponent <UIChatShowComponent>().ShowChatContent(message.Value, message.UId);
                }

                if (message.UId == PlayerInfoComponent.Instance.uid)
                {
                    Game.Scene.GetComponent <UIComponent>().Get(UIType.UIChat).GetComponent <UIChatComponent>().CloseOrOpenChatUI(false);
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Пример #2
0
        protected override void Run(Session session, M2C_AuthorityPlayCard message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.UserID);

            if (gamer != null)
            {
                //重置玩家提示
                gamer.GetComponent <GamerUIComponent>().ResetPrompt();

                //当玩家为先手,清空出牌
                if (message.IsFirst)
                {
                    gamer.GetComponent <HandCardsComponent>().ClearPlayCards();
                }

                //显示出牌按钮
                if (gamer.UserID == gamerComponent.LocalGamer.UserID)
                {
                    UIInteractionComponent interaction = uiRoom.GetComponent <UIRoomComponent>().Interaction;
                    interaction.IsFirst = message.IsFirst;
                    interaction.StartPlay();
                }
            }
        }
Пример #3
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);
            }
        }
        protected override void Run(ETModel.Session session, Actor_AuthorityPlayCard_Ntt message)
        {
            UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom);
            LandlordsRoomComponent room = uiRoom.GetComponent <LandlordsRoomComponent>();
            Gamer gamer = room.GetGamer(message.UserID);

            if (gamer != null)
            {
                //重置玩家提示
                gamer.GetComponent <LandlordsGamerPanelComponent>().ResetPrompt();

                //当玩家为先手,清空出牌
                if (message.IsFirst)
                {
                    gamer.GetComponent <HandCardsComponent>().ClearPlayCards();
                }

                //显示出牌按钮
                if (gamer.UserID == LandlordsRoomComponent.LocalGamer.UserID)
                {
                    LandlordsInteractionComponent interaction = uiRoom.GetComponent <LandlordsRoomComponent>().Interaction;
                    interaction.IsFirst = message.IsFirst;
                    interaction.StartPlay();
                }
            }
        }
Пример #5
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);
            }
        }
Пример #6
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);
            }
        }
        protected override void Run(ETModel.Session session, Actor_Gameover_Ntt message)
        {
            UI                    uiRoom                = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom);
            GamerComponent        gamerComponent        = uiRoom.GetComponent <GamerComponent>();
            Identity              localGamerIdentity    = gamerComponent.LocalGamer.GetComponent <HandCardsComponent>().AccessIdentity;
            UI                    uiEndPanel            = LandlordsEndFactory.Create(UIType.LandlordsEnd, uiRoom, (Identity)message.Winner == localGamerIdentity);
            LandlordsEndComponent landlordsEndComponent = uiEndPanel.GetComponent <LandlordsEndComponent>();

            foreach (GamerScore gamerScore in message.GamersScore)
            {
                Gamer gamer = uiRoom.GetComponent <GamerComponent>().Get(gamerScore.UserID);
                gamer.GetComponent <GamerUIComponent>().UpdatePanel();
                gamer.GetComponent <HandCardsComponent>().Hide();
                landlordsEndComponent.CreateGamerContent(
                    gamer,
                    (Identity)message.Winner,
                    message.BasePointPerMatch,
                    message.Multiples,
                    gamerScore.Score);
            }

            LandlordsRoomComponent landlordsRoomComponent = uiRoom.GetComponent <LandlordsRoomComponent>();

            landlordsRoomComponent.Interaction.Gameover();
            landlordsRoomComponent.ResetMultiples();
        }
        protected override void Run(ETModel.Session session, Actor_GamerPlayCard_Ntt message)
        {
            UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom);
            LandlordsRoomComponent room = uiRoom.GetComponent <LandlordsRoomComponent>();
            Gamer gamer = room.GetGamer(message.UserID);

            if (gamer != null)
            {
                gamer.GetComponent <LandlordsGamerPanelComponent>().ResetPrompt();

                //本地玩家清空选中牌 关闭出牌按钮
                if (gamer.UserID == LandlordsRoomComponent.LocalGamer.UserID)
                {
                    LandlordsInteractionComponent interaction = uiRoom.GetComponent <LandlordsRoomComponent>().Interaction;
                    interaction.Clear();
                    interaction.EndPlay();
                }

                //出牌后更新玩家手牌
                HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>();
                Card[]             Tcards    = new Card[message.Cards.Count];
                for (int i = 0; i < message.Cards.Count; i++)
                {
                    Tcards[i] = message.Cards[i];
                }
                handCards.PopCards(Tcards);
            }
        }
Пример #9
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();
        }
Пример #10
0
        protected override void Run(ETModel.Session session, Actor_GameStart_Ntt message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();

            //初始化玩家UI
            foreach (GamerCardNum gamerCardNum in message.GamersCardNum)
            {
                Gamer            gamer   = uiRoom.GetComponent <GamerComponent>().Get(gamerCardNum.UserID);
                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.HandCards);
                }
                else
                {
                    //设置其他玩家手牌数
                    handCards.SetHandCardsNum(gamerCardNum.Num);
                }
            }

            //显示牌桌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;
            }

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

            //清空选中牌
            uiRoomComponent.Interaction.Clear();
            //设置初始倍率
            uiRoomComponent.SetMultiples(1);
        }
Пример #11
0
        protected override void Run(Session session, M2C_SetLandlord message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.UserID);

            if (gamer != null)
            {
                HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>();
                if (gamer.UserID == gamerComponent.LocalGamer.UserID)
                {
                    //本地玩家添加手牌
                    handCards.AddCards(message.LordCards);
                }
                else
                {
                    //其他玩家设置手牌数
                    handCards.SetHandCardsNum(20);
                }
            }

            foreach (var _gamer in gamerComponent.GetAll())
            {
                HandCardsComponent handCardsComponent = _gamer.GetComponent <HandCardsComponent>();
                GamerUIComponent   gamerUIComponent   = _gamer.GetComponent <GamerUIComponent>();
                if (_gamer.UserID == message.UserID)
                {
                    handCardsComponent.AccessIdentity = Identity.Landlord;
                    gamerUIComponent.SetIdentity(Identity.Landlord);
                }
                else
                {
                    handCardsComponent.AccessIdentity = Identity.Farmer;
                    gamerUIComponent.SetIdentity(Identity.Farmer);
                }
            }

            //重置玩家UI提示
            foreach (var _gamer in gamerComponent.GetAll())
            {
                _gamer.GetComponent <GamerUIComponent>().ResetPrompt();
            }

            //切换地主牌精灵
            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;
            }

            //显示切换游戏模式按钮
            uiRoom.GetComponent <UIRoomComponent>().Interaction.GameStart();
        }
Пример #12
0
        protected override void Run(ETModel.Session session, Actor_AuthorityGrabLandlord_Ntt message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();

            if (message.UserID == gamerComponent.LocalGamer.UserID)
            {
                //显示抢地主交互
                uiRoom.GetComponent <LandlordsRoomComponent>().Interaction.StartGrab();
            }
        }
Пример #13
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);
            }
        }
        protected override void Run(ETModel.Session session, Actor_Trusteeship_Ntt message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.UserID);

            if (gamer.UserID == ClientComponent.Instance.LocalPlayer.UserID)
            {
                LandlordsInteractionComponent interaction = uiRoom.GetComponent <LandlordsRoomComponent>().Interaction;
                interaction.isTrusteeship = message.isTrusteeship;
            }
        }
Пример #15
0
        protected override void Run(Session session, C2M_Trusteeship message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.UserID);

            if (gamer.UserID == ClientComponent.Instance.LocalPlayer.UserID)
            {
                UIInteractionComponent interaction = uiRoom.GetComponent <UIRoomComponent>().Interaction;
                interaction.isTrusteeship = message.isTrusteeship;
            }
        }
Пример #16
0
        protected override void Run(ETModel.Session session, Actor_Trusteeship_Ntt message)
        {
            UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom);
            LandlordsRoomComponent room = uiRoom.GetComponent <LandlordsRoomComponent>();
            Gamer gamer = room.GetGamer(message.UserID);

            if (gamer.UserID == LandlordsRoomComponent.LocalGamer.UserID)
            {
                LandlordsInteractionComponent interaction = uiRoom.GetComponent <LandlordsRoomComponent>().Interaction;
                interaction.isTrusteeship = message.IsTrusteeship;
            }
        }
Пример #17
0
        protected override void Run(ETModel.Session session, Actor_GamerReconnect_Ntt message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();

            foreach (GamerState gamerState in message.GamersState)
            {
                Gamer gamer = gamerComponent.Get(gamerState.UserID);
                HandCardsComponent gamerHandCards = gamer.GetComponent <HandCardsComponent>();
                GamerUIComponent   gamerUI        = gamer.GetComponent <GamerUIComponent>();
                Identity           gamerIdentity  = gamerState.UserIdentity;
                gamerHandCards.AccessIdentity = gamerIdentity;
                gamerUI.SetIdentity(gamerIdentity);
                //初始化出牌
                if (message.UserId == gamer.UserID && gamerIdentity != Identity.None)
                {
                    if (message.Cards != null)
                    {
                        gamerHandCards.PopCards(message.Cards);
                    }
                }
                else if (message.LordCards.count == 0)
                {
                    gamer.GetComponent <GamerUIComponent>().SetGrab(gamerState.State);
                }
            }

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

            //隐藏准备按钮,避免重连时还显示准备按钮
            uiRoom.GameObject.Get <GameObject>("ReadyButton").SetActive(false);
            //设置倍率
            uiRoomComponent.SetMultiples(message.Multiples);
            //当抢完地主时才能显示托管按钮
            if (message.LordCards.count > 0)
            {
                uiRoomComponent.Interaction.GameStart();
            }

            //初始化地主牌
            if (message.LordCards.count > 0)
            {
                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;
                }
            }
        }
Пример #18
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;
                }
            }
        }
Пример #19
0
        protected override void Run(Session session, C2M_GamerReady message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.UserID);

            gamer.GetComponent <GamerUIComponent>().SetReady();

            //本地玩家准备,隐藏准备按钮
            if (gamer.UserID == gamerComponent.LocalGamer.UserID)
            {
                uiRoom.GetComponent <UIRoomComponent>().readyButton.SetActive(false);
            }
        }
Пример #20
0
        protected override void Run(ETModel.Session session, Actor_GamerGrabLandlordSelect_Ntt message)
        {
            UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom);
            LandlordsRoomComponent room = uiRoom.GetComponent <LandlordsRoomComponent>();
            Gamer gamer = room.GetGamer(message.UserID);

            if (gamer != null)
            {
                if (gamer.UserID == LandlordsRoomComponent.LocalGamer.UserID)
                {
                    uiRoom.GetComponent <LandlordsRoomComponent>().Interaction.EndGrab();
                }
                gamer.GetComponent <LandlordsGamerPanelComponent>().SetGrab(message.IsGrab);
            }
        }
Пример #21
0
        protected override void Run(Session session, C2M_GamerGrabLandlordSelect message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.UserID);

            if (gamer != null)
            {
                if (gamer.UserID == gamerComponent.LocalGamer.UserID)
                {
                    uiRoom.GetComponent <UIRoomComponent>().Interaction.EndGrab();
                }
                gamer.GetComponent <GamerUIComponent>().SetGrab(message.IsGrab);
            }
        }
Пример #22
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);
        }
        protected override void Run(ETModel.Session session, Actor_GamerExitRoom_Ntt message)
        {
            UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom);
            LandlordsRoomComponent landlordsRoomComponent = uiRoom.GetComponent <LandlordsRoomComponent>();

            landlordsRoomComponent.RemoveGamer(message.UserID);
        }
Пример #24
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>();
        }
Пример #25
0
        protected override void Run(ETModel.Session session, Actor_GamerDontPlay_Ntt message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.UserID);

            if (gamer != null)
            {
                if (gamer.UserID == gamerComponent.LocalGamer.UserID)
                {
                    uiRoom.GetComponent <LandlordsRoomComponent>().Interaction.EndPlay();
                }
                gamer.GetComponent <HandCardsComponent>().ClearPlayCards();
                gamer.GetComponent <GamerUIComponent>().SetDiscard();
            }
        }
Пример #26
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);
            }
        }
Пример #27
0
        public override void Run(int weight, int index)
        {
            try
            {
                UI             ui             = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                GamerComponent gamerComponent = ui.GetComponent <GamerComponent>();
                if (gamerComponent.CurrentPlayUid == PlayerInfoComponent.Instance.uid)
                {
                    Log.Debug("玩家出牌:" + weight + "index:" + index);
                    if (gamerComponent.IsPlayed)
                    {
//                        ToastScript.createToast("拦截多次出牌");
                        return;
                    }

                    if (weight >= 41)
                    {
                        Log.Warning("不能出花牌");
                        return;
                    }
                    gamerComponent.IsPlayed = true;
                    SessionComponent.Instance.Session.Send(new Actor_GamerPlayCard()
                    {
                        weight = weight, index = index
                    });
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Пример #28
0
        public void ShowOperation(int operationType)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();

            Gamer gamer = gamerComponent.Get(PlayerInfoComponent.Instance.uid);
            HandCardsComponent handCardsComponent = gamer.GetComponent <HandCardsComponent>();

            switch (operationType)
            {
            case 0:
                pengBtn.gameObject.SetActive(true);
                handCardsComponent.ShowHandCardCanPeng(CurrentMahjong.weight);

                break;

            case 1:
            case 4:
            case 5:
                gangBtn.gameObject.SetActive(true);
                handCardsComponent.ShowHandCardCanPeng(CurrentMahjong.weight);
                break;

            case 2:
                huBtn.gameObject.SetActive(true);
                break;

            case 3:
                break;
            }

            giveUpBtn.gameObject.SetActive(true);
        }
Пример #29
0
        /// <summary>
        /// 开始匹配按钮事件
        /// </summary>
        public async void OnStartMatch()
        {
            try
            {
                //发送开始匹配消息
                C2G_StartMatch c2G_StartMatch = new C2G_StartMatch();
                G2C_StartMatch g2C_StartMatch = await SessionWrapComponent.Instance.Session.Call(c2G_StartMatch) as G2C_StartMatch;

                if (g2C_StartMatch.Error == ErrorCode.ERR_UserGoldLessError)
                {
                    Log.Error("余额不足");
                    return;
                }

                //切换到房间界面
                UI room = Game.Scene.GetComponent <UIComponent>().Create(UIType.UIRoom);
                Game.Scene.GetComponent <UIComponent>().Remove(UIType.UILobby);

                //将房间设为匹配状态
                room.GetComponent <UIRoomComponent>().Matching = true;
            }
            catch (Exception e)
            {
                Log.Error(e.ToStr());
            }
        }
Пример #30
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);
            }
        }