예제 #1
0
        protected override void Run(GameStart message)
        {
            UI             uiRoom         = Hotfix.Scene.GetComponent <UIComponent>().Get(UIType.Room);
            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.Id == gamerComponent.LocalGamer.Id)
                {
                    //本地玩家添加手牌
                    handCards.AddCards(message.GamerCards);
                }
                else
                {
                    //设置其他玩家手牌数
                    handCards.SetHandCardsNum(message.GamerCardsNum[gamer.Id]);
                }
            }

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

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

            //重置地主牌
            Sprite lordSprite = Resources.Load <GameObject>("UI").Get <GameObject>("Atlas").Get <Sprite>("None");

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

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

            //清空选中牌
            uiRoom.GetComponent <UIRoomComponent>().Interaction.Clear();
            //设置初始倍率
            uiRoomComponent.SetMultiples(1);
        }
예제 #2
0
        protected override void Run(SelectLord message)
        {
            UI             uiRoom         = Hotfix.Scene.GetComponent <UIComponent>().Get(UIType.Room);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.PlayerID);

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

            foreach (var _gamer in gamerComponent.GetAll())
            {
                if (_gamer.Id == message.PlayerID)
                {
                    _gamer.GetComponent <HandCardsComponent>().AccessIdentity = Identity.Landlord;
                    _gamer.GetComponent <GamerUIComponent>().SetIdentity(Identity.Landlord);
                }
                else
                {
                    _gamer.GetComponent <HandCardsComponent>().AccessIdentity = Identity.Farmer;
                    _gamer.GetComponent <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 = Resources.Load <GameObject>("UI").Get <GameObject>("Atlas").Get <Sprite>(message.LordCards[i].GetName());
                lordPokers.transform.GetChild(i).GetComponent <Image>().sprite = lordCardSprite;
            }

            //显示切换游戏模式按钮
            uiRoom.GetComponent <UIRoomComponent>().Interaction.GameStart();
        }