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();
                }
            }
        }
示例#2
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();
        }
示例#3
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);
                }
            }
        }
示例#4
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(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);
            }
        }
示例#6
0
        public void Start()
        {
            //添加本地玩家
            Player localPlayer = ClientComponent.Instance.LocalPlayer;
            Gamer  localGamer  = EntityFactory.CreateWithId <Gamer, long>(localPlayer.Id, localPlayer.UserID);

            localGamer.AddComponent <GamerUIComponent, UI>(this.GetEntity <UI>());
            GamerComponent gamerComponent = this.GetComponent <GamerComponent>();

            gamerComponent.Add(localGamer);
            gamerComponent.LocalGamer = localGamer;
        }
        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();
        }
        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);
            }
        }
示例#9
0
        protected override void Run(SelectAuthority message)
        {
            UI             uiRoom         = Hotfix.Scene.GetComponent <UIComponent>().Get(UIType.Room);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();

            if (message.PlayerID == gamerComponent.LocalGamer.Id)
            {
                //显示抢地主交互
                uiRoom.GetComponent <UIRoomComponent>().Interaction.StartGrab();
            }
            else
            {
            }
        }
        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);
            }
        }
示例#11
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);
            }
        }
        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;
                }
            }
        }