Пример #1
0
        protected override void Run(GamerEnter message)
        {
            UI             uiRoom         = Hotfix.Scene.GetComponent <UIComponent>().Get(UIType.Room);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();

            //隐藏匹配提示
            GameObject matchPrompt = uiRoom.GameObject.Get <GameObject>("MatchPrompt");

            if (matchPrompt.activeSelf)
            {
                matchPrompt.SetActive(false);
                uiRoom.GameObject.Get <GameObject>("ReadyButton").SetActive(true);
            }

            //添加未显示玩家
            for (int i = 0; i < message.GamersInfo.Length; i++)
            {
                GamerInfo info = message.GamersInfo[i];
                if (gamerComponent.Get(info.PlayerID) == null)
                {
                    Gamer gamer = EntityFactory.CreateWithId <Gamer, long>(info.PlayerID, info.UserID);
                    gamer.IsReady = info.IsReady;
                    gamer.AddComponent <GamerUIComponent, UI>(uiRoom);
                    gamerComponent.Add(gamer);
                }
            }
        }
        protected override void Run(AuthorityPlayCard message)
        {
            UI             uiRoom         = Hotfix.Scene.GetComponent <UIComponent>().Get(UIType.Room);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.PlayerID);

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

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

                //显示出牌按钮
                if (gamer.Id == gamerComponent.LocalGamer.Id)
                {
                    InteractionComponent interaction = uiRoom.GetComponent <UIRoomComponent>().Interaction;
                    interaction.IsFirst = message.IsFirst;
                    interaction.StartPlay();
                }
            }
        }
Пример #3
0
        protected override void Run(GamerReenter message)
        {
            UI             uiRoom         = Hotfix.Scene.GetComponent <UIComponent>().Get(UIType.Room);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.PastID);

            if (gamer != null)
            {
                gamer.Id = message.NewID;
                gamerComponent.Replace(message.PastID, gamer);
            }
        }
Пример #4
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();
        }
Пример #5
0
        protected override void Run(PlayerReady message)
        {
            UI             uiRoom         = Hotfix.Scene.GetComponent <UIComponent>().Get(UIType.Room);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.PlayerID);

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

            //本地玩家准备,隐藏准备按钮
            if (gamer.Id == gamerComponent.LocalGamer.Id)
            {
                uiRoom.GameObject.Get <GameObject>("ReadyButton").SetActive(false);
            }
        }
        protected override void Run(GrabLordSelect message)
        {
            UI             uiRoom         = Hotfix.Scene.GetComponent <UIComponent>().Get(UIType.Room);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.PlayerID);

            if (gamer != null)
            {
                if (gamer.Id == gamerComponent.LocalGamer.Id)
                {
                    uiRoom.GetComponent <UIRoomComponent>().Interaction.EndGrab();
                }
                gamer.GetComponent <GamerUIComponent>().SetGrab(message.IsGrab);
            }
        }
Пример #7
0
        protected override void Run(Discard message)
        {
            UI             uiRoom         = Hotfix.Scene.GetComponent <UIComponent>().Get(UIType.Room);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.PlayerID);

            if (gamer != null)
            {
                if (gamer.Id == gamerComponent.LocalGamer.Id)
                {
                    uiRoom.GetComponent <UIRoomComponent>().Interaction.EndPlay();
                }
                gamer.GetComponent <HandCardsComponent>().ClearPlayCards();
                gamer.GetComponent <GamerUIComponent>().SetDiscard();
            }
        }
        protected override void Run(GamerPlayCards message)
        {
            UI             uiRoom         = Hotfix.Scene.GetComponent <UIComponent>().Get(UIType.Room);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.PlayerID);

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

                if (gamer.Id == gamerComponent.LocalGamer.Id)
                {
                    InteractionComponent interaction = uiRoom.GetComponent <UIRoomComponent>().Interaction;
                    interaction.Clear();
                    interaction.EndPlay();
                }

                HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>();
                handCards.PopCards(message.Cards);
            }
        }