Example #1
0
 public bool initialize(ICoreInterface coreInterface)
 {
     CoreInterface       = coreInterface;
     ClientInfo.ServerId = CoreInterface.GetLocalServerId();
     ClientInfo.GameType = (int)GameTypes.TianTi;
     return(true);
 }
Example #2
0
 public bool initialize(ICoreInterface coreInterface)
 {
     _CoreInterface       = coreInterface;
     _ClientInfo.ServerId = _CoreInterface.GetLocalServerId();
     _ClientInfo.GameType = (int)_gameType;
     return(true);
 }
Example #3
0
 public bool initialize(ICoreInterface coreInterface)
 {
     CoreInterface       = coreInterface;
     ClientInfo.ServerId = CoreInterface.GetLocalServerId();
     ClientInfo.GameType = (int)GameTypes.YongZheZhanChang;
     ClientInfo.Token    = CoreInterface.GetLocalAddressIPs();
     return(true);
 }
Example #4
0
        /// <summary>
        /// 初始化配置
        /// </summary>
        public bool InitConfig()
        {
            bool     success          = true;
            XElement xml              = null;
            string   fileName         = "";
            string   fullPathFileName = "";
            IEnumerable <XElement> nodes;

            lock (RuntimeData.Mutex)
            {
                try
                {
                    int           open = 0;
                    string        kuaFuUriKeyNamePrefix = null;
                    int           serverId     = CoreInterface.GetLocalServerId();
                    PlatformTypes platfromType = CoreInterface.GetPlatformType();
                    fileName         = string.Format("Config/ThroughService_{0}.xml", platfromType.ToString());
                    fullPathFileName = Global.GameResPath(fileName); //Global.IsolateResPath(fileName);

                    //如果配置文件存在,则读配置文件,否则读默认配置
                    if (File.Exists(fullPathFileName))
                    {
                        xml   = XElement.Load(fullPathFileName);
                        nodes = xml.Elements();

                        foreach (var node in nodes)
                        {
                            int startServer = (int)Global.GetSafeAttributeLong(node, "StartServer");
                            int endServer   = (int)Global.GetSafeAttributeLong(node, "EndServer");
                            if (startServer <= serverId && serverId < endServer)
                            {
                                open = (int)Global.GetSafeAttributeLong(node, "Open");
                                kuaFuUriKeyNamePrefix = Global.GetSafeAttributeStr(node, "ID");
                                break;
                            }
                        }
                    }
                    else
                    {
                        open = 1;
                        kuaFuUriKeyNamePrefix = null;
                    }

                    CoreInterface.SetRuntimeVariable(RuntimeVariableNames.KuaFuGongNeng, open.ToString());
                    CoreInterface.SetRuntimeVariable(RuntimeVariableNames.KuaFuUriKeyNamePrefix, kuaFuUriKeyNamePrefix);

                    string huanYingSiYuanUri   = null;
                    string tianTiUri           = null;
                    string yongZheZhanChangUri = null;
                    //  string moRiJudgeUri = null;
                    // string elementWarUri = null;
                    string kfcopyUri = null;
                    string spreadUri = null;
                    string allyUri   = null;

                    if (open > 0)
                    {
                        string huanYingSiYuanUriKeyName = RuntimeVariableNames.HuanYingSiYuanUri + kuaFuUriKeyNamePrefix;
                        huanYingSiYuanUri = CoreInterface.GetGameConfigStr(huanYingSiYuanUriKeyName, null);

                        //如果数据库没配置,则读默认配置文件
                        if (string.IsNullOrEmpty(huanYingSiYuanUri))
                        {
                            ConfigurationManager.RefreshSection("appSettings");
                            huanYingSiYuanUri = ConfigurationManager.AppSettings.Get(huanYingSiYuanUriKeyName);

                            //如果没有指定后缀的配置,则读默认配置
                            if (string.IsNullOrEmpty(huanYingSiYuanUri))
                            {
                                huanYingSiYuanUri = ConfigurationManager.AppSettings.Get(RuntimeVariableNames.HuanYingSiYuanUri);
                            }
                        }

                        string tianTiUriKeyName = RuntimeVariableNames.TianTiUri + kuaFuUriKeyNamePrefix;
                        tianTiUri = CoreInterface.GetGameConfigStr(tianTiUriKeyName, null);

                        //如果数据库没配置,则读默认配置文件
                        if (string.IsNullOrEmpty(tianTiUri))
                        {
                            ConfigurationManager.RefreshSection("appSettings");
                            tianTiUri = ConfigurationManager.AppSettings.Get(tianTiUriKeyName);

                            //如果没有指定后缀的配置,则读默认配置
                            if (string.IsNullOrEmpty(tianTiUri))
                            {
                                tianTiUri = ConfigurationManager.AppSettings.Get(RuntimeVariableNames.TianTiUri);
                            }
                        }

                        string yongZheZhanChangUriKeyName = RuntimeVariableNames.YongZheZhanChangUri + kuaFuUriKeyNamePrefix;
                        yongZheZhanChangUri = CoreInterface.GetGameConfigStr(yongZheZhanChangUriKeyName, null);

                        //如果数据库没配置,则读默认配置文件
                        if (string.IsNullOrEmpty(yongZheZhanChangUri))
                        {
                            ConfigurationManager.RefreshSection("appSettings");
                            yongZheZhanChangUri = ConfigurationManager.AppSettings.Get(yongZheZhanChangUriKeyName);

                            //如果没有指定后缀的配置,则读默认配置
                            if (string.IsNullOrEmpty(yongZheZhanChangUri))
                            {
                                yongZheZhanChangUri = ConfigurationManager.AppSettings.Get(RuntimeVariableNames.YongZheZhanChangUri);
                            }
                        }

                        /*
                         * string moRiJudgeUriKeyName = RuntimeVariableNames.MoRiJudgeUri + kuaFuUriKeyNamePrefix;
                         * moRiJudgeUri = CoreInterface.GetGameConfigStr(moRiJudgeUriKeyName, null);
                         *
                         * //如果数据库没配置,则读默认配置文件
                         * if (string.IsNullOrEmpty(moRiJudgeUri))
                         * {
                         *  ConfigurationManager.RefreshSection("appSettings");
                         *  moRiJudgeUri = ConfigurationManager.AppSettings.Get(moRiJudgeUriKeyName);
                         *
                         *  //如果没有指定后缀的配置,则读默认配置
                         *  if (string.IsNullOrEmpty(moRiJudgeUri))
                         *  {
                         *      moRiJudgeUri = ConfigurationManager.AppSettings.Get(RuntimeVariableNames.MoRiJudgeUri);
                         *  }
                         * }
                         *
                         * //元素试炼————————————————————————————————————————
                         * string elementWarUriKeyName = RuntimeVariableNames.ElementWarUri + kuaFuUriKeyNamePrefix;
                         * elementWarUri = CoreInterface.GetGameConfigStr(elementWarUriKeyName, null);
                         *
                         * //如果数据库没配置,则读默认配置文件
                         * if (string.IsNullOrEmpty(elementWarUri))
                         * {
                         *  ConfigurationManager.RefreshSection("appSettings");
                         *  elementWarUri = ConfigurationManager.AppSettings.Get(elementWarUriKeyName);
                         *
                         *  //如果没有指定后缀的配置,则读默认配置
                         *  if (string.IsNullOrEmpty(elementWarUri))
                         *  {
                         *      elementWarUri = ConfigurationManager.AppSettings.Get(RuntimeVariableNames.ElementWarUri);
                         *  }
                         * }
                         * */

                        string kfcopyUriKeyName = RuntimeVariableNames.KuaFuCopyUri + kuaFuUriKeyNamePrefix;
                        kfcopyUri = CoreInterface.GetGameConfigStr(kfcopyUriKeyName, null);

                        //如果数据库没配置,则读默认配置文件
                        if (string.IsNullOrEmpty(kfcopyUri))
                        {
                            ConfigurationManager.RefreshSection("appSettings");
                            kfcopyUri = ConfigurationManager.AppSettings.Get(kfcopyUriKeyName);

                            //如果没有指定后缀的配置,则读默认配置
                            if (string.IsNullOrEmpty(kfcopyUri))
                            {
                                kfcopyUri = ConfigurationManager.AppSettings.Get(RuntimeVariableNames.KuaFuCopyUri);
                            }
                        }

                        //
                        string SpreadUriKeyName = RuntimeVariableNames.SpreadUri + kuaFuUriKeyNamePrefix;
                        spreadUri = CoreInterface.GetGameConfigStr(SpreadUriKeyName, null);
                        //如果数据库没配置,则读默认配置文件
                        if (string.IsNullOrEmpty(spreadUri))
                        {
                            ConfigurationManager.RefreshSection("appSettings");
                            spreadUri = ConfigurationManager.AppSettings.Get(SpreadUriKeyName);

                            //如果没有指定后缀的配置,则读默认配置
                            if (string.IsNullOrEmpty(spreadUri))
                            {
                                spreadUri = ConfigurationManager.AppSettings.Get(RuntimeVariableNames.SpreadUri);
                            }
                        }

                        string AllyUriKeyName = RuntimeVariableNames.AllyUri + kuaFuUriKeyNamePrefix;
                        allyUri = CoreInterface.GetGameConfigStr(AllyUriKeyName, null);
                        //如果数据库没配置,则读默认配置文件
                        if (string.IsNullOrEmpty(allyUri))
                        {
                            ConfigurationManager.RefreshSection("appSettings");
                            allyUri = ConfigurationManager.AppSettings.Get(AllyUriKeyName);

                            //如果没有指定后缀的配置,则读默认配置
                            if (string.IsNullOrEmpty(allyUri))
                            {
                                allyUri = ConfigurationManager.AppSettings.Get(RuntimeVariableNames.AllyUri);
                            }
                        }
                    }

                    CoreInterface.SetRuntimeVariable(RuntimeVariableNames.HuanYingSiYuanUri, huanYingSiYuanUri);
                    CoreInterface.SetRuntimeVariable(RuntimeVariableNames.TianTiUri, tianTiUri);
                    CoreInterface.SetRuntimeVariable(RuntimeVariableNames.YongZheZhanChangUri, yongZheZhanChangUri);
                    //CoreInterface.SetRuntimeVariable(RuntimeVariableNames.ElementWarUri, elementWarUri);
                    //CoreInterface.SetRuntimeVariable(RuntimeVariableNames.MoRiJudgeUri, moRiJudgeUri);
                    CoreInterface.SetRuntimeVariable(RuntimeVariableNames.KuaFuCopyUri, kfcopyUri);
                    CoreInterface.SetRuntimeVariable(RuntimeVariableNames.SpreadUri, spreadUri);
                    CoreInterface.SetRuntimeVariable(RuntimeVariableNames.AllyUri, allyUri);
                }
                catch (System.Exception ex)
                {
                    success = false;
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("加载xml配置文件:{0}, 失败。", fileName), ex);
                }
            }

            return(success);
        }