Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
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;
                }
            }
        }
Ejemplo n.º 3
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;
                }
            }
        }