Esempio n. 1
0
        protected override void Run(Gameover message)
        {
            UI             uiRoom             = Hotfix.Scene.GetComponent <UIComponent>().Get(UIType.Room);
            GamerComponent gamerComponent     = uiRoom.GetComponent <GamerComponent>();
            Identity       localGamerIdentity = gamerComponent.LocalGamer.GetComponent <HandCardsComponent>().AccessIdentity;
            UI             uiEndPanel         = UIEndFactory.Create(Hotfix.Scene, UIType.EndPanel, uiRoom, message.Winner == localGamerIdentity);
            UIEndComponent endComponent       = uiEndPanel.GetComponent <UIEndComponent>();

            uiRoom.Add(uiEndPanel);

            foreach (var gamer in gamerComponent.GetAll())
            {
                gamer.GetComponent <GamerUIComponent>().UpdateInfo();
                gamer.GetComponent <HandCardsComponent>().Hide();
                endComponent.CreateGamerContent(
                    gamer,
                    message.Winner,
                    message.BasePointPerMatch,
                    message.Multiples,
                    message.GamersScore[gamer.Id]);
            }

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

            uiRoomComponent.Interaction.Gameover();
            uiRoomComponent.ResetMultiples();
        }
Esempio n. 2
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);
        }
        protected override void Run(GamerReconnect message)
        {
            UI             uiRoom         = Hotfix.Scene.GetComponent <UIComponent>().Get(UIType.Room);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();

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

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

            uiRoomComponent.SetMultiples(message.Multiples);
            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 = Resources.Load <GameObject>("UI").Get <GameObject>("Atlas").Get <Sprite>(message.LordCards[i].GetName());
                    lordPokers.transform.GetChild(i).GetComponent <Image>().sprite = lordCardSprite;
                }
            }
        }