예제 #1
0
        /// <summary>
        /// 获取等待排队的配置
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="defVal"></param>
        /// <returns></returns>
        private string GetWaitingConfig(string paramName)
        {
            WaitingConfig waitingConfig = null;

            lock (_PlatConfigWaitingDict)
            {
                if (!_PlatConfigWaitingDict.TryGetValue(GameManager.ServerId, out waitingConfig))
                {
                    //如果指定的服务器不存在,则选择默认的,默认的为0
                    _PlatConfigWaitingDict.TryGetValue(0, out waitingConfig);
                }
            }
            //如果不为空
            if (waitingConfig != null)
            {
                if (paramName.Equals(PlatConfigNames.UserWaitConfig))
                {
                    return(waitingConfig.UserWaitConfig);
                }
                if (paramName.Equals(PlatConfigNames.VipWaitConfig))
                {
                    return(waitingConfig.VIPWaitConfig);
                }
                if (paramName.Equals(PlatConfigNames.LoginAllowVipExp))
                {
                    return(waitingConfig.LoginAllow_VIPExp.ToString());
                }
            }
            //上面三个都不满足,返回NULL
            return(null);
        }
예제 #2
0
        private string GetWaitingConfig(string paramName)
        {
            WaitingConfig waitingConfig = null;

            lock (this._PlatConfigWaitingDict)
            {
                if (!this._PlatConfigWaitingDict.TryGetValue(GameManager.ServerId, out waitingConfig))
                {
                    this._PlatConfigWaitingDict.TryGetValue(0, out waitingConfig);
                }
            }
            if (waitingConfig != null)
            {
                if (paramName.Equals("userwaitconfig"))
                {
                    return(waitingConfig.UserWaitConfig);
                }
                if (paramName.Equals("vipwaitconfig"))
                {
                    return(waitingConfig.VIPWaitConfig);
                }
                if (paramName.Equals("loginallow_vipexp"))
                {
                    return(waitingConfig.LoginAllow_VIPExp.ToString());
                }
            }
            return(null);
        }
예제 #3
0
        /// <summary>
        /// 加载排队配置,每个区的排队配置组成一个类 WatingConfig,字典的key为serverID
        /// </summary>
        /// <param name="xml"></param>
        private void LoadWaitingConfig(XElement xml, Dictionary <int, WaitingConfig> waitingDict)
        {
            lock (waitingDict)
            {
                try
                {
                    XElement xmlEle = null;
                    //加载Waiting
                    xmlEle = Global.GetSafeXElement(xml, "Waiting");
                    IEnumerable <XElement> waitingNodes = xmlEle.Elements();
                    foreach (var xmlNode in waitingNodes)
                    {
                        WaitingConfig waitingConfig = new WaitingConfig();
                        string        severID       = (string)Global.GetSafeAttributeStr(xmlNode, "ID");
                        waitingConfig.SeverID = Convert.ToInt32(severID);
                        int[] NeedWaitNumberArr = Global.GetSafeAttributeIntArray(xmlNode, "NeedWaitNumber", 2);
                        waitingConfig.NormalNeedWaitNumber = NeedWaitNumberArr[0];
                        waitingConfig.VIPNeedWaitNumber    = NeedWaitNumberArr[1];
                        int[] MaxNumber = Global.GetSafeAttributeIntArray(xmlNode, "MaxNumber", 2);
                        waitingConfig.NormalMaxNumber = MaxNumber[0];
                        waitingConfig.VIPMaxNumber    = MaxNumber[1];
                        int[] WaitingMaxNumber = Global.GetSafeAttributeIntArray(xmlNode, "WaitingMaxNumber", 2);
                        waitingConfig.NormalWaitingMaxNumber = WaitingMaxNumber[0];
                        waitingConfig.VIPWaitingMaxNumber    = WaitingMaxNumber[1];
                        int[] EnterMinInt = Global.GetSafeAttributeIntArray(xmlNode, "EnterMinInt", 2);
                        waitingConfig.NormalEnterMinInt = EnterMinInt[0];
                        waitingConfig.VIPEnterMinInt    = EnterMinInt[1];
                        int[] AllowMSecs = Global.GetSafeAttributeIntArray(xmlNode, "AllowMSecs", 2);
                        waitingConfig.NormalAllowMSecs = AllowMSecs[0];
                        waitingConfig.VIPAllowMSecs    = AllowMSecs[1];
                        int[] LogoutAllowMSecs = Global.GetSafeAttributeIntArray(xmlNode, "LogoutAllowMSecs", 2);
                        waitingConfig.NormalLogoutAllowMSecs = LogoutAllowMSecs[0];
                        waitingConfig.VIPLogoutAllowMSecs    = LogoutAllowMSecs[1];
                        waitingConfig.VipExp = Convert.ToInt32((string)Global.GetSafeAttributeStr(xmlNode, "vipexp"));
                        //添加到等待配置字典
                        waitingDict.Add(waitingConfig.SeverID, waitingConfig);
                    }

                    //如果waiting配置项没有配置默认项(0),或者没有waiting项没有内容,也抛出异常
                    if (!waitingDict.ContainsKey(0))
                    {
                        throw new Exception(string.Format("配置文件 {0} 可能没有配置 {1} 项或者没有默认配置项,请正确配置后重新加载文件。", fileName, "waiting"));
                    }
                }
                catch (Exception e)
                {
                    throw new Exception(string.Format("加载系统配置参数配置文件:{0}, 失败。{1} 节点配置错误!! !  {2}", fileName, "Waiting", e.ToString()));
                }
            }
        }