Ejemplo n.º 1
0
        protected override async void Run(ETModel.Session session, Actor_GamerReady message)
        {
            try
            {
                Log.Info($"收到准备");
                UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                UIReadyComponent uiReadyComponent = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIReady)?.GetComponent <UIReadyComponent>();

                if (uiRoom == null)
                {
                    return;
                }

                GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();

                Gamer gamer = gamerComponent.Get(message.Uid);
                if (gamer == null)
                {
                    Log.Warning($"{message.Uid}玩家为空");
                    return;
                }
                GamerUIComponent gamerUiComponent = gamer.GetComponent <GamerUIComponent>();
                gamerUiComponent.SetReady();
                uiReadyComponent?.SetReady(message.Uid);

                SoundsHelp.Instance.playSound_ZhunBei();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 2
0
        protected override void Run(Session session, M2C_Gameover message)
        {
            UI             uiRoom             = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            GamerComponent gamerComponent     = uiRoom.GetComponent <GamerComponent>();
            Identity       localGamerIdentity = gamerComponent.LocalGamer.GetComponent <HandCardsComponent>().AccessIdentity;
            Identity       winner             = (Identity)message.Winner;
            UI             uiEndPanel         = UIEndFactory.Create(UIType.UIEnd, uiRoom, winner == localGamerIdentity);
            UIEndComponent uiEndComponent     = uiEndPanel.GetComponent <UIEndComponent>();

            foreach (var gamer in gamerComponent.GetAll())
            {
                gamer.GetComponent <GamerUIComponent>().UpdatePanel();
                gamer.GetComponent <HandCardsComponent>().Hide();
                uiEndComponent.CreateGamerContent(
                    gamer,
                    winner,
                    message.BasePointPerMatch,
                    message.Multiples,
                    message.GamersScore[gamer.UserID]);
            }

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

            uiRoomComponent.Interaction.Gameover();
            uiRoomComponent.ResetMultiples();
        }
        protected override void Run(ETModel.Session session, Actor_Gameover_Ntt message)
        {
            UI                    uiRoom                = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom);
            GamerComponent        gamerComponent        = uiRoom.GetComponent <GamerComponent>();
            Identity              localGamerIdentity    = gamerComponent.LocalGamer.GetComponent <HandCardsComponent>().AccessIdentity;
            UI                    uiEndPanel            = LandlordsEndFactory.Create(UIType.LandlordsEnd, uiRoom, (Identity)message.Winner == localGamerIdentity);
            LandlordsEndComponent landlordsEndComponent = uiEndPanel.GetComponent <LandlordsEndComponent>();

            foreach (GamerScore gamerScore in message.GamersScore)
            {
                Gamer gamer = uiRoom.GetComponent <GamerComponent>().Get(gamerScore.UserID);
                gamer.GetComponent <GamerUIComponent>().UpdatePanel();
                gamer.GetComponent <HandCardsComponent>().Hide();
                landlordsEndComponent.CreateGamerContent(
                    gamer,
                    (Identity)message.Winner,
                    message.BasePointPerMatch,
                    message.Multiples,
                    gamerScore.Score);
            }

            LandlordsRoomComponent landlordsRoomComponent = uiRoom.GetComponent <LandlordsRoomComponent>();

            landlordsRoomComponent.Interaction.Gameover();
            landlordsRoomComponent.ResetMultiples();
        }
Ejemplo n.º 4
0
        protected override void Run(Session session, M2C_AuthorityPlayCard message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.UserID);

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

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

                //显示出牌按钮
                if (gamer.UserID == gamerComponent.LocalGamer.UserID)
                {
                    UIInteractionComponent interaction = uiRoom.GetComponent <UIRoomComponent>().Interaction;
                    interaction.IsFirst = message.IsFirst;
                    interaction.StartPlay();
                }
            }
        }
Ejemplo n.º 5
0
        public void Awake()
        {
            ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>();

            //倒计时
            this.timeText = rc.Get <GameObject>("TimeText").GetComponent <Text>();
            StartTimeDown();

            //4个玩家
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();

            this.gamers = gamerComponent.GetAll();
            plays       = new List <Text>();
            for (int i = 1; i < 5; i++)
            {
                plays.Add(rc.Get <GameObject>("Play" + i).GetComponent <Text>());
            }

            //退出
            this.cancelBtn = rc.Get <GameObject>("CancelBtn").GetComponent <Button>();
            this.sureBtn   = rc.Get <GameObject>("SureBtn").GetComponent <Button>();

            cancelBtn.onClick.Add(OnCancel);
            sureBtn.onClick.Add(OnSure);

            cancelCount = 0;
            SetPlayInfo();

            CommonUtil.SetTextFont(this.GetParent <UI>().GameObject);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 打开手牌并结算
        /// </summary>
        public async ETVoid OpenAllGamerHandCard(CowCowSmallSettlementInfo[] info)
        {
            Dictionary <int, Gamer> gamers = GamerComponent.GetDictAll();

            for (int i = 0; i < info.Length; i++)
            {
                int[] cards = info[i].Cards.ToArray();
                UICowCow_GamerInfoComponent     gic   = gamers[info[i].SeatID].GetComponent <UICowCow_GamerInfoComponent>();
                UICowCow_SSGamerResultComponent ssgrc = gamers[info[i].SeatID].GetComponent <UICowCow_SSGamerResultComponent>();
                gic.ShowCards(cards);
                ssgrc.SetGamerSmallSettlement(info[i]);
            }
            await ETModel.Game.Scene.GetComponent <TimerComponent>().WaitAsync(5000);

            //在此延迟显示小结算
            SmallSettlement.ShowHideSmallSettlement(true);
            for (int i = 0; i < info.Length; i++)
            {
                int[] cards = info[i].Cards.ToArray();
                UICowCow_GamerInfoComponent     gic   = gamers[info[i].SeatID].GetComponent <UICowCow_GamerInfoComponent>();
                UICowCow_SSGamerResultComponent ssgrc = gamers[info[i].SeatID].GetComponent <UICowCow_SSGamerResultComponent>();
                gic.SetStatus(UIGamerStatus.Down);
                gic.SetCoin(info[i].BetCoin.ToString());
            }
        }
Ejemplo n.º 7
0
        public void SetFlowGame(Actor_GameFlow message, GamerComponent gamerComponent)
        {
            Gamer[] gamers = gamerComponent.GetAll();

            for (int i = 0; i < gamers.Length; i++)
            {
                if (gamers[i] == null)
                {
                    continue;
                }
                if (gamers[i].UserID == PlayerInfoComponent.Instance.uid)
                {
                    playerList.Insert(i, winPlayer);
                }
            }

            for (int i = 0; i < gamers.Length; i++)
            {
                Gamer      gamer      = gamers[i];
                GameObject gameObject = this.playerList[i];
                Image      headImage  = gameObject.transform.Find("head").GetComponent <Image>();
                Text       nameText   = gameObject.transform.Find("name").GetComponent <Text>();
                Text       goldText   = gameObject.transform.Find("Text_gold").GetComponent <Text>();

                HeadManager.setHeadSprite(headImage, gamer.PlayerInfo.Icon);
                nameText.text = gamer.PlayerInfo.Name;
                goldText.text = 0 + "";
            }

            winPlayer.transform.Find("hupaiType").GetComponent <Image>().sprite =
                CommonUtil.getSpriteByBundle("image_gameresult", "gameresult_liuju");
        }
Ejemplo n.º 8
0
        public override void Run(int weight, int index)
        {
            try
            {
                UI             ui             = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                GamerComponent gamerComponent = ui.GetComponent <GamerComponent>();
                if (gamerComponent.CurrentPlayUid == PlayerInfoComponent.Instance.uid)
                {
                    Log.Debug("玩家出牌:" + weight + "index:" + index);
                    if (gamerComponent.IsPlayed)
                    {
//                        ToastScript.createToast("拦截多次出牌");
                        return;
                    }

                    if (weight >= 41)
                    {
                        Log.Warning("不能出花牌");
                        return;
                    }
                    gamerComponent.IsPlayed = true;
                    SessionComponent.Instance.Session.Send(new Actor_GamerPlayCard()
                    {
                        weight = weight, index = index
                    });
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 9
0
        public void ShowOperation(int operationType)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();

            Gamer gamer = gamerComponent.Get(PlayerInfoComponent.Instance.uid);
            HandCardsComponent handCardsComponent = gamer.GetComponent <HandCardsComponent>();

            switch (operationType)
            {
            case 0:
                pengBtn.gameObject.SetActive(true);
                handCardsComponent.ShowHandCardCanPeng(CurrentMahjong.weight);

                break;

            case 1:
            case 4:
            case 5:
                gangBtn.gameObject.SetActive(true);
                handCardsComponent.ShowHandCardCanPeng(CurrentMahjong.weight);
                break;

            case 2:
                huBtn.gameObject.SetActive(true);
                break;

            case 3:
                break;
            }

            giveUpBtn.gameObject.SetActive(true);
        }
Ejemplo n.º 10
0
        public override void Dispose()
        {
            if (this.IsDisposed)
            {
                return;
            }
            base.Dispose();

            ReSet();
            res.UnloadBundle(UICowCowAB.CowCow_Prefabs);
            res.UnloadBundle(UICowCowAB.CowCow_Texture);
            smallSettlement?.Dispose();
            bigSettlement?.Dispose();
            gamerComponent?.Dispose();
            chatComponent?.Dispose();
            dissComponent?.Dispose();
            settingComponent?.Dispose();

            smallSettlement  = null;
            bigSettlement    = null;
            gamerComponent   = null;
            chatComponent    = null;
            uiChatVoice      = null;
            dissComponent    = null;
            settingComponent = null;
        }
Ejemplo n.º 11
0
        protected override async void Run(ETModel.Session session, Actor_GamerTrusteeship message)
        {
            try
            {
                Log.Info($"玩家托管:" + message.Uid);

                UI              uiRoom          = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                GamerComponent  gamerComponent  = uiRoom.GetComponent <GamerComponent>();
                UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();
                Gamer           gamer           = gamerComponent.Get(message.Uid);
                if (message.Uid == PlayerInfoComponent.Instance.uid)
                {
                    uiRoomComponent.ShowTrustship();
                }
                else
                {
                    GamerUIComponent gamerUIComponent = gamer.GetComponent <GamerUIComponent>();
                    gamerUIComponent.ShowTrust();
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 12
0
        protected override void Run(ETModel.Session session, Actor_GamerCheat message)
        {
            try
            {
                Log.Debug("收到作弊");

                UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);

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

                Gamer gamer = gamerComponent.Get(PlayerInfoComponent.Instance.uid);

                HandCardsComponent handCardsComponent = gamer.GetComponent <HandCardsComponent>();
                if (handCardsComponent == null)
                {
                    return;
                }
                handCardsComponent.DeleteAllItem(handCardsComponent.CardBottom);

                foreach (var card in message.handCards)
                {
                    card.m_weight = (Consts.MahjongWeight)card.weight;
                }

                handCardsComponent.AddCards(message.handCards);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 13
0
        protected override async void Run(ETModel.Session session, Actor_GameFlow message)
        {
            try
            {
                Log.Info($"收到流局");

                UI              uiRoom          = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                GamerComponent  gamerComponent  = uiRoom.GetComponent <GamerComponent>();
                UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();

                UIGameResultComponent gameResultComponent =
                    Game.Scene.GetComponent <UIComponent>().Create(UIType.UIGameResult).GetComponent <UIGameResultComponent>();

                if (uiRoomComponent.RoomType == 3)
                {
                    gameResultComponent.SetFriendRoom();
                    gameResultComponent.startTimer(5);
                }
                else
                {
                    gameResultComponent.startTimer();
                }
                gameResultComponent.SetFlowGame(message, gamerComponent);
                UIRoomComponent.ISGaming = false;
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 14
0
        protected override void Run(ETModel.Session session, Actor_GameStart_Ntt message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();

            //初始化玩家UI
            foreach (GamerCardNum gamerCardNum in message.GamersCardNum)
            {
                Gamer            gamer   = uiRoom.GetComponent <GamerComponent>().Get(gamerCardNum.UserID);
                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.UserID == gamerComponent.LocalGamer.UserID)
                {
                    //本地玩家添加手牌
                    handCards.AddCards(message.HandCards);
                }
                else
                {
                    //设置其他玩家手牌数
                    handCards.SetHandCardsNum(gamerCardNum.Num);
                }
            }

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

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

            //重置地主牌
            Sprite lordSprite = CardHelper.GetCardSprite("None");

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

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

            //清空选中牌
            uiRoomComponent.Interaction.Clear();
            //设置初始倍率
            uiRoomComponent.SetMultiples(1);
        }
Ejemplo n.º 15
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.º 16
0
        protected override void Run(ETModel.Session session, Actor_AuthorityGrabLandlord_Ntt message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();

            if (message.UserID == gamerComponent.LocalGamer.UserID)
            {
                //显示抢地主交互
                uiRoom.GetComponent <LandlordsRoomComponent>().Interaction.StartGrab();
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 再添加其他玩家
        /// </summary>
        public void AddGamer(GamerInfo info, int posIndex)
        {
            Gamer gamer = GamerComponent.AddGamerUI(info);

            if (gamer != null)
            {
                gamer.AddComponent <UICowCow_GamerInfoComponent, GameObject, GamerInfo, int>(UIRoomGamer, info, posIndex);
                gamer.AddComponent <UICowCow_SSGamerResultComponent, GameObject>(SmallSettlement.SmallBG);
                gamer.AddComponent <UICowCow_BSGamerResultComponent, GameObject>(BigSettlement.BigBG);
            }
        }
Ejemplo n.º 18
0
 public void GamerReady(int[] seatIds)
 {
     for (int i = 0; i < seatIds.Length; i++)
     {
         UICowCow_GamerInfoComponent gc = GamerComponent.Get(seatIds[i]).GetComponent <UICowCow_GamerInfoComponent>();
         if (gc.Status != UIGamerStatus.Ready)
         {
             gc.SetStatus(UIGamerStatus.Ready, UIGamerStatusString.Ready);
         }
     }
 }
Ejemplo n.º 19
0
        protected override async void Run(ETModel.Session session, Actor_GamerGrabCard message)
        {
            try
            {
                Log.Info($"收到抓拍");
                MahjongInfo mahjongInfo = new MahjongInfo()
                {
                    weight = (byte)message.weight, m_weight = (Consts.MahjongWeight)message.weight
                };
                UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                if (uiRoom == null)
                {
                    return;
                }
                GamerComponent  gamerComponent  = uiRoom.GetComponent <GamerComponent>();
                UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();

                Gamer gamer = gamerComponent.Get(message.Uid);
                HandCardsComponent handCardsComponent = gamer.GetComponent <HandCardsComponent>();

                if (PlayerInfoComponent.Instance.uid == message.Uid)
                {
                    handCardsComponent.GrabCard(mahjongInfo);
                }
                else
                {
                    handCardsComponent.GrabOtherCard();
                }

                //当前出牌玩家
                gamerComponent.CurrentPlayUid = message.Uid;
                gamerComponent.IsPlayed       = false;

                //剩下的牌
                uiRoomComponent.SetRestCount();

                //显示黄色bg
                uiRoomComponent.ShowTurn(message.Uid);
                uiRoomComponent.ClosePropmtBtn();

                SoundsHelp.Instance.playSound_MoPai();

                uiRoomComponent.CurrentMahjong = mahjongInfo;

                Gamer currentGamer = gamerComponent.Get(PlayerInfoComponent.Instance.uid);
                HandCardsComponent currentGamerCard = currentGamer.GetComponent <HandCardsComponent>();
                currentGamerCard.CloseHandCardCanPeng();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 20
0
 public override void Run(GameObject a)
 {
     try
     {
         UI             ui             = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
         GamerComponent gamerComponent = ui.GetComponent <GamerComponent>();
     }
     catch (Exception e)
     {
         Log.Error(e);
     }
 }
Ejemplo n.º 21
0
        protected override void Run(Session session, C2M_Trusteeship message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.UserID);

            if (gamer.UserID == ClientComponent.Instance.LocalPlayer.UserID)
            {
                UIInteractionComponent interaction = uiRoom.GetComponent <UIRoomComponent>().Interaction;
                interaction.isTrusteeship = message.isTrusteeship;
            }
        }
        protected override void Run(ETModel.Session session, Actor_Trusteeship_Ntt message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.UserID);

            if (gamer.UserID == ClientComponent.Instance.LocalPlayer.UserID)
            {
                LandlordsInteractionComponent interaction = uiRoom.GetComponent <LandlordsRoomComponent>().Interaction;
                interaction.isTrusteeship = message.isTrusteeship;
            }
        }
Ejemplo n.º 23
0
        public void Awake()
        {
            this.ItemCard = this.GetParent <UI>().GameObject;
            Button         button         = this.ItemCard.GetComponent <Button>();
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();

            this.handCardsComponent = gamerComponent.LocalGamer.GetComponent <HandCardsComponent>();
            button.onClick.RemoveAllListeners();
            button.onClick.Add(() => { OnClick(); });

            CommonUtil.SetTextFont(this.GetParent <UI>().GameObject);
        }
Ejemplo n.º 24
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;
                }
            }
        }
        protected override void Run(Session session, Actor_GamerReady_Ntt message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.UserID);

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

            //本地玩家准备,隐藏准备按钮
            if (gamer.UserID == gamerComponent.LocalGamer.UserID)
            {
                uiRoom.GameObject.Get <GameObject>("ReadyButton").SetActive(false);
            }
        }
Ejemplo n.º 26
0
 /// <summary>
 /// 显示隐藏准备按钮
 /// </summary>
 public void ShowHideReadyButton(bool isShow)
 {
     readyBtn.GetComponent <CanvasGroup>().alpha          = isShow ? 1 : 0;
     readyBtn.GetComponent <CanvasGroup>().blocksRaycasts = isShow;
     if (!isShow)
     {
         //隐藏所有玩家手牌
         Dictionary <int, Gamer> gamers = GamerComponent.GetDictAll();
         foreach (Gamer gamer in gamers.Values)
         {
             gamer.GetComponent <UICowCow_GamerInfoComponent>().ShowHideHandCard(isShow);
         }
     }
 }
Ejemplo n.º 27
0
        protected override void Run(Session session, C2M_GamerReady message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.UserID);

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

            //本地玩家准备,隐藏准备按钮
            if (gamer.UserID == gamerComponent.LocalGamer.UserID)
            {
                uiRoom.GetComponent <UIRoomComponent>().readyButton.SetActive(false);
            }
        }
Ejemplo n.º 28
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;
                }
            }
        }
        public override void Dispose()
        {
            if (this.IsDisposed)
            {
                return;
            }

            base.Dispose();

            //移除连接组件
            Game.Scene.RemoveComponent <SessionComponent>();
            Game.Scene.ModelScene.RemoveComponent <ETModel.SessionComponent>();

            //释放本地玩家对象
            GamerComponent gamerComponent = ETModel.Game.Scene.GetComponent <GamerComponent>();

            if (gamerComponent.MyUser != null)
            {
                gamerComponent.MyUser.Dispose();
                gamerComponent.MyUser = null;
            }

            UIComponent uiComponent = Game.Scene.GetComponent <UIComponent>();

            //游戏关闭,不用回到登录界面
            if (uiComponent == null || uiComponent.IsDisposed)
            {
                return;
            }

            UI uiLogin = uiComponent.Create(UIType.SekiaLogin);

            //uiLogin.GetComponent<SekiaLoginComponent>().("连接断开");

            if (uiComponent.Get(UIType.Moba5V5UI) != null)
            {
                //移除Moba组件
                //切换场景
                uiComponent.Remove(UIType.Moba5V5UI);
            }
            else if (uiComponent.Get(UIType.SekiaLobby) != null)
            {
                uiComponent.Remove(UIType.SekiaLobby);
            }
            else if (uiComponent.Get(UIType.LandlordsRoom) != null)
            {
                uiComponent.Remove(UIType.LandlordsRoom);
            }
        }
Ejemplo n.º 30
0
        protected override void Run(Session session, C2M_GamerGrabLandlordSelect message)
        {
            UI             uiRoom         = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
            GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>();
            Gamer          gamer          = gamerComponent.Get(message.UserID);

            if (gamer != null)
            {
                if (gamer.UserID == gamerComponent.LocalGamer.UserID)
                {
                    uiRoom.GetComponent <UIRoomComponent>().Interaction.EndGrab();
                }
                gamer.GetComponent <GamerUIComponent>().SetGrab(message.IsGrab);
            }
        }