示例#1
0
        /// <summary> 获取玩家 </summary>
        /// <param name="userid">当前用户玩家Id</param>
        /// <param name="rivalcamp">对手阵营</param>
        /// <param name="time"></param>
        private ASObject PlayerMatching(Int64 userid, int rivalcamp, int time)
        {
            var flag  = true;
            var token = new CancellationTokenSource();
            var task  = new Task(() => SpinWait.SpinUntil(() =>
            {
                if (!flag)
                {
                    token.Cancel();
                    return(true);
                }
                flag = IsGetRival(userid, rivalcamp);
                return(false);
            }, time), token.Token);

            task.Start();
            task.ContinueWith(m =>
            {
                if (!Variable.OnlinePlayer.ContainsKey(userid))
                {
                    return;
                }
                var session = Variable.OnlinePlayer[userid];
                PUSH_GATE_RESULT.GetInstance().CommandStart(session);
                token.Cancel();
            }, token.Token);
            return(new ASObject(Common.GetInstance().BuildData((int)ResultType.SUCCESS)));
        }
示例#2
0
        /// <summary> 破坏城门时间到后返回破坏城门结果 </summary>
        /// <param name="session">session</param>
        /// <param name="playerdata">玩家活动数据</param>
        private ASObject ThreadGateResult(Int64 userid, SiegePlayer playerdata)
        {
            playerdata.ismatching = false;
            var token = new CancellationTokenSource();
            var task  = new Task(() => SpinWait.SpinUntil(() => false, Variable.Activity.Siege.BaseData.GateTime), token.Token);

            task.Start();
            task.ContinueWith(m =>
            {
                if (!Variable.OnlinePlayer.ContainsKey(userid))
                {
                    return;
                }
                var session = Variable.OnlinePlayer[userid];
                PUSH_GATE_RESULT.GetInstance().CommandStart(session);
                token.Cancel();
            },
                              token.Token);
            return(new ASObject(Common.GetInstance().BuildData((int)ResultType.SUCCESS)));
        }
示例#3
0
 /// <summary>PUSH_GATE_RESULT单体模式</summary>
 public static PUSH_GATE_RESULT GetInstance()
 {
     return(ObjInstance ?? (ObjInstance = new PUSH_GATE_RESULT()));
 }