Ejemplo n.º 1
0
        public void Run(int WaitSec = GameConfig.Turn_Wait_Server)
        {
            Task SubTask = new Task(() =>
            {
                SpinWait.SpinUntil(() =>
                {
                    return(false);
                }, WaitSec * 1000);

                //【有Bug 风险,用户突然离线】
                var betSession = _GameServer.GetSessions(s => s.GameAttr.UserOpenId == _waitUserOpenId).FirstOrDefault();
                GameManager gm = betSession.GameManager;

                var gi = gm.GetGameBasic();
                //时间到了 还是此用户下注,说明超时,则弃牌
                if (gi.CurBetUserOpenId == gm.UserOpenId)
                {
                    var list = new List <IGameMessage>();

                    //系统主动弃牌
                    gm.PlayerGiveUp();
                    var giveUpMsg = GameMessageHandle.CreateResultPlayerGiveUpMsg(gm.RoomCode,
                                                                                  gm.UserOpenId,
                                                                                  gi.CurBetUserOpenId);
                    list.Add(giveUpMsg);

                    gi = gm.PreNextStep(true);

                    var msg = gm.WaitNextPlayer(gi);
                    if (msg != null)
                    {
                        list.Add(msg);
                    }
                    _GameMessageHandle.Push(list);
                    _GameMessageHandle.Run(_GameServer);
                }
            });

            SubTask.Start();
        }
Ejemplo n.º 2
0
        public void Run(int AfterSec, GameServer GameServer, int weight)
        {
            //洗牌,并获取洗牌结束消息
            var msgList = CreateShuffleEndMessage(weight);


            Task SubTask = new Task(() =>
            {
                // Thread.Sleep(AfterSec * 1000);
                SpinWait.SpinUntil(() =>
                {
                    return(false);
                }, AfterSec * 1000);

                //将洗牌的消息发送出去
                _GameMessageHandle.Push(msgList);
                var r = _GameMessageHandle.Run(GameServer);
                if (r == false)
                {
                    return;
                }

                //EGameInfo gi = null;
                //if (msgList[0] is ResultGameShuffleEnd)
                //{
                //    var rgseMsg = msgList[0] as ResultGameShuffleEnd;
                //    rgseMsg.GameInfo = gi;
                //}
                var gi = _GameManager.GetGameBasic();
                // gi.GameStatus = GameStatus.Playing;
                //gi.GameTurn = GameTurn.FirstTurn;
                //_GameManager.SetGameInfo(gi);

                GameTaskManager.WaitBetUser(GameServer, gi.CurBetUserOpenId);
            });

            SubTask.Start();
        }