private static FlexibleConfiguration.Abstractions.IConfigurationRoot CompileFromConfigurationSources(OktaClientConfiguration apiClientConfiguration = null)
        {
            string configurationFileRoot = Directory.GetCurrentDirectory();

            var homeOktaYamlLocation = HomePath.Resolve("~", ".okta", "okta.yaml");

            var applicationAppSettingsLocation = Path.Combine(configurationFileRoot ?? string.Empty, "appsettings.json");
            var applicationOktaYamlLocation    = Path.Combine(configurationFileRoot ?? string.Empty, "okta.yaml");

            var configBuilder = new ConfigurationBuilder()
                                .AddYamlFile(homeOktaYamlLocation, optional: true)
                                .AddJsonFile(applicationAppSettingsLocation, optional: true)
                                .AddYamlFile(applicationOktaYamlLocation, optional: true)
                                .AddEnvironmentVariables("okta", "_", root: "okta")
                                .AddObject(apiClientConfiguration, root: "okta:client");

            return(configBuilder.Build());
        }
Exemple #2
0
        private void PreloadNewSkillInstance(int skillId)
        {
            SkillLogicData skillData = SkillConfigProvider.Instance.ExtractData(SkillConfigType.SCT_SKILL, skillId) as SkillLogicData;

            if (null != skillData)
            {
                string filePath = HomePath.GetAbsolutePath(FilePathDefine_Client.C_SkillDslPath + skillData.SkillDataFile);
                SkillConfigManager.Instance.LoadSkillIfNotExist(skillId, filePath);
                SkillInstance inst = SkillConfigManager.Instance.NewSkillInstance(skillId);
                if (inst != null)
                {
                    SkillInstanceInfo res = new SkillInstanceInfo();
                    res.m_SkillId       = skillId;
                    res.m_SkillInstance = inst;
                    res.m_IsUsed        = true;
                    AddSkillInstanceInfoToPool(skillId, res);
                    RecycleSkillInstance(res);
                }
            }
        }
        private SkillInstanceInfo NewSkillInstance(int skillId)
        {
            SkillInstanceInfo instInfo = GetUnusedSkillInstanceInfoFromPool(skillId);

            if (null == instInfo)
            {
                SkillLogicData skillData = SkillConfigProvider.Instance.ExtractData(SkillConfigType.SCT_SKILL, skillId) as SkillLogicData;
                if (null != skillData)
                {
                    string filePath = HomePath.GetAbsolutePath(FilePathDefine_Server.C_SkillDslPath + skillData.SkillDataFile);
                    SkillConfigManager.Instance.LoadSkillIfNotExist(skillId, filePath);
                    SkillInstance inst = SkillConfigManager.Instance.NewSkillInstance(skillId);

                    if (null != inst)
                    {
                        SkillInstanceInfo res = new SkillInstanceInfo();
                        res.m_SkillId       = skillId;
                        res.m_SkillInstance = inst;
                        res.m_IsUsed        = true;

                        AddSkillInstanceInfoToPool(skillId, res);
                        return(res);
                    }
                    else
                    {
                        LogSystem.Error("Can't find skill dsl or skill dsl error, skill:{0} !", skillId);
                        return(null);
                    }
                }
                else
                {
                    LogSystem.Error("Can't find skill config, skill:{0} !", skillId);
                    return(null);
                }
            }
            else
            {
                instInfo.m_IsUsed = true;
                return(instInfo);
            }
        }
Exemple #4
0
        protected override void Init()
        {
            string json = HomePath.ReadGpuProfilesJsonFile();

            if (!string.IsNullOrEmpty(json))
            {
                GpuProfilesJsonDb data = VirtualRoot.JsonSerializer.Deserialize <GpuProfilesJsonDb>(json);
                if (data != null)
                {
                    _data = data;
                }
                else
                {
                    Save();
                }
            }
            else
            {
                Save();
            }
        }
Exemple #5
0
        public void PreLoadAllSkills()
        {
            MyDictionary <int, object> datacont = SkillConfigProvider.Instance.skillLogicDataMgr.GetData();

            foreach (KeyValuePair <int, object> pair in datacont)
            {
                int            id        = pair.Key;
                SkillLogicData skillData = pair.Value as SkillLogicData;

                string filePath = HomePath.GetAbsolutePath(FilePathDefine_Client.C_SkillDslPath + skillData.SkillDataFile);
                if (!String.IsNullOrEmpty(filePath))
                {
                    if (File.Exists(filePath))
                    {
                        for (int i = 0; i < 5; i++)
                        {
                            PreloadNewSkillInstance(id);
                        }
                    }
                }
            }
        }
Exemple #6
0
        private static OktaClientConfiguration GetConfigurationOrDefault(OktaClientConfiguration apiClientConfiguration = null)
        {
            string configurationFileRoot = Directory.GetCurrentDirectory();

            var homeOktaYamlLocation = HomePath.Resolve("~", ".okta", "okta.yaml");

            var applicationAppSettingsLocation = Path.Combine(configurationFileRoot ?? string.Empty, "appsettings.json");
            var applicationOktaYamlLocation    = Path.Combine(configurationFileRoot ?? string.Empty, "okta.yaml");

            var configBuilder = new ConfigurationBuilder()
                                .AddYamlFile(homeOktaYamlLocation, optional: true)
                                .AddJsonFile(applicationAppSettingsLocation, optional: true)
                                .AddYamlFile(applicationOktaYamlLocation, optional: true)
                                .AddEnvironmentVariables("okta", "_", root: "okta")
                                .AddObject(apiClientConfiguration, root: "okta:client");

            var compiledConfig = new OktaClientConfiguration();

            configBuilder.Build().GetSection("okta").GetSection("client").Bind(compiledConfig);

            return(compiledConfig);
        }
Exemple #7
0
        public void Init()
        {
            ArkCrossEngine.RoleInfo ri = ArkCrossEngine.LobbyClient.Instance.CurrentRole;
            if (ri != null)
            {
                Data_PlayerConfig cg = PlayerConfigProvider.Instance.GetPlayerConfigById(ri.HeroId);
                if (cg != null)
                {
                    herostr = cg.m_Portrait;
                }
                heroname = ri.Nickname;
            }
            m_StoryInfos.Clear();
            DBC dlgCfg = new DBC();

            if (dlgCfg.Load(HomePath.GetAbsolutePath(FilePathDefine_Client.C_DialogConfig)))
            {
                for (int index = 0; index < dlgCfg.RowNum; index++)
                {
                    DBC_Row node = dlgCfg.GetRowByIndex(index);
                    if (null != node)
                    {
                        StoryDlgInfo info = new StoryDlgInfo();
                        info.ID           = DBCUtil.ExtractNumeric <int>(node, "Id", 0, true);
                        info.StoryName    = DBCUtil.ExtractString(node, "StoryName", "", true);
                        info.DlgType      = (StoryDlgPanel.StoryDlgType)DBCUtil.ExtractNumeric <int>(node, "DlgType", 0, true);
                        info.IntervalTime = DBCUtil.ExtractNumeric <float>(node, "IntervalTime", 1.0f, true);
                        info.StoryItems   = BuildStoryItems(info.StoryName);
                        if (!m_StoryInfos.ContainsKey(info.ID))
                        {
                            m_StoryInfos.Add(info.ID, info);
                        }
                    }
                }
            }
        }
Exemple #8
0
    private void LoadEditedSkills(int targetId)
    {
        PlayerPrefs.SetInt("TargetId", targetId);
        PlayerPrefs.Save();

        SaveEditedSkills(HomePath.GetAbsolutePath("../../../edit_skills_bak.txt"));
        CopyTableAndDslFiles();

        PluginFramework.LoadTableConfig();
        PredefinedSkill.Instance.ReBuild();
        GfxSkillSystem.Instance.Reset();
        GfxSkillSystem.Instance.ClearSkillInstancePool();
        SkillSystem.SkillConfigManager.Instance.Clear();

        GameObject actor  = GameObject.Find("Editor_ActorRecord");
        GameObject skills = GameObject.Find("Editor_SkillRecords");

        if (null != actor && null != skills)
        {
            ActorRecord  actorRecord  = actor.GetComponent <ActorRecord>();
            SkillRecords skillRecords = skills.GetComponent <SkillRecords>();
            if (null != actorRecord && null != skillRecords)
            {
                List <int> args    = new List <int>();
                int        actorId = actorRecord.id;
                if (actorRecord.skill0 > 0)
                {
                    args.Add(actorRecord.skill0);
                }
                if (actorRecord.skill1 > 0)
                {
                    args.Add(actorRecord.skill1);
                }
                if (actorRecord.skill2 > 0)
                {
                    args.Add(actorRecord.skill2);
                }
                if (actorRecord.skill3 > 0)
                {
                    args.Add(actorRecord.skill3);
                }
                if (actorRecord.skill4 > 0)
                {
                    args.Add(actorRecord.skill4);
                }
                if (actorRecord.skill5 > 0)
                {
                    args.Add(actorRecord.skill5);
                }
                if (actorRecord.skill6 > 0)
                {
                    args.Add(actorRecord.skill6);
                }
                if (actorRecord.skill7 > 0)
                {
                    args.Add(actorRecord.skill7);
                }
                if (actorRecord.skill8 > 0)
                {
                    args.Add(actorRecord.skill8);
                }

                RebuildVisualSkillInfo(actorId);

                bool isValid = true;
                if (string.IsNullOrEmpty(actorRecord.avatar))
                {
                    Debug.LogErrorFormat("actor avatar is empty !!!");
                    isValid = false;
                }
                foreach (int skillId in args)
                {
                    CheckEditedSkill(skillId, skillRecords.records, ref isValid);
                }
                if (isValid)
                {
                    TableConfig.Actor actorInfo = TableConfig.ActorProvider.Instance.GetActor(actorId);
                    if (null == actorInfo)
                    {
                        actorInfo    = new TableConfig.Actor();
                        actorInfo.id = actorId;
                        TableConfig.ActorProvider.Instance.ActorMgr.GetData().Add(actorId, actorInfo);
                    }
                    actorRecord.CopyTo(actorInfo);

                    foreach (SkillRecords.SkillRecord record in skillRecords.records)
                    {
                        TableConfig.Skill skillInfo = TableConfig.SkillProvider.Instance.GetSkill(record.id);
                        if (null == skillInfo)
                        {
                            skillInfo    = new TableConfig.Skill();
                            skillInfo.id = record.id;
                            TableConfig.SkillProvider.Instance.SkillMgr.GetData().Add(record.id, skillInfo);
                        }
                        record.CopyTo(skillInfo);
                    }

                    if (args.Count > 1)
                    {
                        GfxStorySystem.Instance.SendMessage("reload", actorId, targetId, BoxedValue.From(args));
                    }
                }
            }

            UnityEditor.EditorUtility.DisplayDialog("提示", "编辑英雄与技能加载完毕", "ok");
        }
    }
Exemple #9
0
    private void NewEditedSkills()
    {
        if (UnityEditor.EditorUtility.DisplayDialog("关键信息", "加载或创建英雄技能数据将覆盖正在编辑的数据,继续吗?(如果之前的数据没有保存到表格文件里,请利用剪贴板拷到表格文件!)", "我确定要继续", "不要继续,我还没保存呢"))
        {
            SaveEditedSkills(HomePath.GetAbsolutePath("../../../edit_skills_bak.txt"));

            PluginFramework.LoadTableConfig();
            PredefinedSkill.Instance.ReBuild();
            GfxSkillSystem.Instance.Reset();
            GfxSkillSystem.Instance.ClearSkillInstancePool();
            SkillSystem.SkillConfigManager.Instance.Clear();

            GameObject actor  = GameObject.Find("Editor_ActorRecord");
            GameObject skills = GameObject.Find("Editor_SkillRecords");
            if (null != actor && null != skills)
            {
                ActorRecord  actorRecord  = actor.GetComponent <ActorRecord>();
                SkillRecords skillRecords = skills.GetComponent <SkillRecords>();
                if (null != actorRecord && null != skillRecords)
                {
                    int        skillCount = 0;
                    List <int> skillIds   = new List <int>();
                    if (actorRecord.skill0 > 0)
                    {
                        ++skillCount; skillIds.Add(actorRecord.skill0);
                    }
                    if (actorRecord.skill1 > 0)
                    {
                        ++skillCount; skillIds.Add(actorRecord.skill1);
                    }
                    if (actorRecord.skill2 > 0)
                    {
                        ++skillCount; skillIds.Add(actorRecord.skill2);
                    }
                    if (actorRecord.skill3 > 0)
                    {
                        ++skillCount; skillIds.Add(actorRecord.skill3);
                    }
                    if (actorRecord.skill4 > 0)
                    {
                        ++skillCount; skillIds.Add(actorRecord.skill4);
                    }
                    if (actorRecord.skill5 > 0)
                    {
                        ++skillCount; skillIds.Add(actorRecord.skill5);
                    }
                    if (actorRecord.skill6 > 0)
                    {
                        ++skillCount; skillIds.Add(actorRecord.skill6);
                    }
                    if (actorRecord.skill7 > 0)
                    {
                        ++skillCount; skillIds.Add(actorRecord.skill7);
                    }
                    if (actorRecord.skill8 > 0)
                    {
                        ++skillCount; skillIds.Add(actorRecord.skill8);
                    }

                    RebuildVisualSkillInfo(actorRecord.id);

                    skillRecords.records.Clear();
                    for (int i = 0; i < skillCount; ++i)
                    {
                        AddViewedSkill(skillIds[i], skillRecords.records);
                    }
                }
            }
        }

        UnityEditor.EditorUtility.DisplayDialog("提示", "技能数据加载/创建完毕", "ok");
    }
Exemple #10
0
    private void LoadViewedSkills(object[] fargs)
    {
        if (null != fargs && fargs.Length == 2)
        {
            int actorId  = (int)fargs[0];
            int targetId = (int)fargs[1];

            PlayerPrefs.SetInt("ActorId", actorId);
            PlayerPrefs.SetInt("TargetId", targetId);
            PlayerPrefs.Save();

            if (UnityEditor.EditorUtility.DisplayDialog("关键信息", "从文件加载数据将同时覆盖正在编辑的数据,继续吗?(如果之前的数据没有保存到表格文件里,请利用剪贴板拷到表格文件!)", "我确定要继续", "不要继续,我还没保存呢"))
            {
                SaveEditedSkills(HomePath.GetAbsolutePath("../../../edit_skills_bak.txt"));
                CopyTableAndDslFiles();
                m_CameraController.OnLevelWasLoaded(null);
                PluginFramework.LoadTableConfig();
                PredefinedSkill.Instance.ReBuild();
                GfxSkillSystem.Instance.Reset();
                GfxSkillSystem.Instance.ClearSkillInstancePool();
                SkillSystem.SkillConfigManager.Instance.Clear();

                GameObject actor  = GameObject.Find("Editor_ActorRecord");
                GameObject skills = GameObject.Find("Editor_SkillRecords");
                if (null != actor && null != skills)
                {
                    ActorRecord  actorRecord  = actor.GetComponent <ActorRecord>();
                    SkillRecords skillRecords = skills.GetComponent <SkillRecords>();
                    if (null != actorRecord && null != skillRecords)
                    {
                        TableConfig.Actor actorInfo = TableConfig.ActorProvider.Instance.GetActor(actorId);
                        if (null != actorInfo)
                        {
                            List <int> args = new List <int>();
                            if (actorInfo.skill0 > 0)
                            {
                                args.Add(actorInfo.skill0);
                            }
                            if (actorInfo.skill1 > 0)
                            {
                                args.Add(actorInfo.skill1);
                            }
                            if (actorInfo.skill2 > 0)
                            {
                                args.Add(actorInfo.skill2);
                            }
                            if (actorInfo.skill3 > 0)
                            {
                                args.Add(actorInfo.skill3);
                            }
                            if (actorInfo.skill4 > 0)
                            {
                                args.Add(actorInfo.skill4);
                            }
                            if (actorInfo.skill5 > 0)
                            {
                                args.Add(actorInfo.skill5);
                            }
                            if (actorInfo.skill6 > 0)
                            {
                                args.Add(actorInfo.skill6);
                            }
                            if (actorInfo.skill7 > 0)
                            {
                                args.Add(actorInfo.skill7);
                            }
                            if (actorInfo.skill8 > 0)
                            {
                                args.Add(actorInfo.skill8);
                            }

                            RebuildVisualSkillInfo(actorId);

                            actorRecord.CopyFrom(actorInfo);

                            skillRecords.records.Clear();
                            foreach (int skillId in args)
                            {
                                AddViewedSkill(skillId, skillRecords.records);
                            }

                            GfxStorySystem.Instance.SendMessage("reload", actorId, targetId, BoxedValue.From(args));
                        }
                    }
                }

                UnityEditor.EditorUtility.DisplayDialog("提示", "从文件加载英雄与技能完毕", "ok");
            }
        }
    }
Exemple #11
0
        private StoryInstance NewStoryInstance(string storyId, string _namespace, bool logIfNotFound, params string[] overloadFiles)
        {
            if (!string.IsNullOrEmpty(_namespace))
            {
                storyId = string.Format("{0}:{1}", _namespace, storyId);
            }
            StoryInstance instance = GetStoryInstance(storyId);

            if (null == instance)
            {
                TableConfig.Level cfg = TableConfig.LevelProvider.Instance.GetLevel(m_SceneId);
                if (null != cfg)
                {
                    string[] filePath;
                    if (overloadFiles.Length <= 0)
                    {
                        int ct1 = cfg.SceneDslFile.Count;
                        int ct2 = cfg.ClientDslFile.Count;
                        filePath = new string[ct1 + ct2];
                        for (int i = 0; i < ct1; i++)
                        {
                            filePath[i] = HomePath.GetAbsolutePath(FilePathDefine_Client.C_DslPath + cfg.SceneDslFile[i]);
                        }
                        for (int i = 0; i < ct2; i++)
                        {
                            filePath[ct1 + i] = HomePath.GetAbsolutePath(FilePathDefine_Client.C_DslPath + cfg.ClientDslFile[i]);
                        }
                    }
                    else
                    {
                        int ct = overloadFiles.Length;
                        filePath = new string[ct];
                        for (int i = 0; i < ct; i++)
                        {
                            filePath[i] = HomePath.GetAbsolutePath(FilePathDefine_Client.C_DslPath + overloadFiles[i]);
                        }
                    }
                    StoryConfigManager.Instance.LoadStories(0, _namespace, filePath);
                    instance = StoryConfigManager.Instance.NewStoryInstance(storyId, 0);
                    if (instance == null)
                    {
                        if (logIfNotFound)
                        {
                            LogSystem.Error("Can't load story config, story:{0} scene:{1} !", storyId, m_SceneId);
                        }
                        return(null);
                    }
                    for (int ix = 0; ix < filePath.Length; ++ix)
                    {
                        Dictionary <string, StoryInstance> stories = StoryConfigManager.Instance.GetStories(filePath[ix]);
                        if (null != stories)
                        {
                            foreach (KeyValuePair <string, StoryInstance> pair in stories)
                            {
                                if (pair.Key != storyId)
                                {
                                    AddStoryInstance(pair.Key, pair.Value.Clone());
                                }
                            }
                        }
                    }
                    AddStoryInstance(storyId, instance);
                    return(instance);
                }
                else
                {
                    if (logIfNotFound)
                    {
                        LogSystem.Error("Can't find story config, story:{0} scene:{1} !", storyId, m_SceneId);
                    }
                    return(null);
                }
            }
            else
            {
                return(instance);
            }
        }
Exemple #12
0
        private List <StoryDlgItem> BuildStoryItems(string storyName)
        {
            DBC    storyItems = new DBC();
            string str        = String.Format("{0}{1}.txt", FilePathDefine_Client.C_DialogPath, storyName.Trim());

            if (storyItems.Load(HomePath.GetAbsolutePath(str)))
            {
                List <StoryDlgItem> itemList = new List <StoryDlgItem>();
                for (int index = 0; index < storyItems.RowNum; index++)
                {
                    DBC_Row node = storyItems.GetRowByIndex(index);
                    if (null != node)
                    {
                        StoryDlgItem item = new StoryDlgItem();
                        item.Number       = DBCUtil.ExtractNumeric <int>(node, "Number", 0, true);
                        item.UnitId       = DBCUtil.ExtractNumeric <int>(node, "UnitId", -1, false);
                        item.IntervalTime = DBCUtil.ExtractNumeric <float>(node, "IntervalTime", 0f, false);
                        item.SpeakerName  = DBCUtil.ExtractString(node, "SpeakerName", "", true);
                        if (item.SpeakerName.Contains("player"))
                        {
                            item.SpeakerName = item.SpeakerName.Replace("player", heroname);
                        }
                        item.ImageLeftAtlas = DBCUtil.ExtractString(node, "ImageLeftAtlas", "", false);
                        item.ImageLeft      = DBCUtil.ExtractString(node, "ImageLeft", "", true);
                        if (item.ImageLeft.Contains("player"))
                        {
                            item.ImageLeft = item.ImageLeft.Replace("player", herostr);
                        }
                        item.ImageLeftBig    = string.Format("{0}_big", item.ImageLeft);
                        item.ImageLeftSmall  = string.Format("{0}_small", item.ImageLeft);
                        item.ImageRightAtlas = DBCUtil.ExtractString(node, "ImageRightAtlas", "", false);
                        item.ImageRight      = DBCUtil.ExtractString(node, "ImageRight", "", true);
                        if (item.ImageRight.Contains("player"))
                        {
                            item.ImageRight = item.ImageRight.Replace("player", herostr);
                        }
                        item.ImageRightBig   = string.Format("{0}_big", item.ImageRight);
                        item.ImageRightSmall = string.Format("{0}_small", item.ImageRight);
                        item.Words           = DBCUtil.ExtractString(node, "Words", "", true);
                        if (item.Words.Contains("player"))
                        {
                            item.Words = item.Words.Replace("player", heroname);
                        }
                        item.TextureAnimationPath = DBCUtil.ExtractString(node, "TexturePath", "", false);
                        //TweenPos
                        item.FromOffsetBottom = DBCUtil.ExtractNumeric <float>(node, "FromOffsetBottom", 0, false);
                        item.FromOffsetLeft   = DBCUtil.ExtractNumeric <float>(node, "FromOffsetLeft", 0, false);
                        item.ToOffsetBottom   = DBCUtil.ExtractNumeric <float>(node, "ToOffsetBottom", 0, false);
                        item.ToOffsetLeft     = DBCUtil.ExtractNumeric <float>(node, "ToOffsetLeft", 0, false);
                        item.TweenPosDelay    = DBCUtil.ExtractNumeric <float>(node, "TweenPosDelay", 0, false);
                        item.TweenPosDuration = DBCUtil.ExtractNumeric <float>(node, "TweenPosDuration", 0, false);
                        //TweenScale
                        item.FromScale          = DBCUtil.ExtractNumeric <float>(node, "FromScale", 1, false);
                        item.ToScale            = DBCUtil.ExtractNumeric <float>(node, "ToScale", 1, false);
                        item.TweenScaleDelay    = DBCUtil.ExtractNumeric <float>(node, "TweenScaleDelay", 0, false);
                        item.TweenScaleDuration = DBCUtil.ExtractNumeric <float>(node, "TweenScaleDuration", 0, false);
                        //TweenAlpha
                        item.FromAlpha          = DBCUtil.ExtractNumeric <float>(node, "FromAlpha", 1, false);
                        item.ToAlpha            = DBCUtil.ExtractNumeric <float>(node, "ToAlpha", 1, false);
                        item.TweenAlphaDelay    = DBCUtil.ExtractNumeric <float>(node, "TweenAlphaDelay", 0, false);
                        item.TweenAlphaDuration = DBCUtil.ExtractNumeric <float>(node, "TweenAlphaDuration", 0, false);
                        //显示字的速度
                        item.WordDuration = DBCUtil.ExtractNumeric <float>(node, "WordDuration", 0, false);

                        itemList.Add(item);
                    }
                }
                return(itemList);
            }
            return(null);
        }
        private void Init(string[] args)
        {
            m_NameHandleCallback = this.OnNameHandleChanged;
            m_MsgCallback        = this.OnMessage;
            m_MsgResultCallback  = this.OnMessageResultCallback;
            m_CmdCallback        = this.OnCommand;
            m_LogHandler         = this.OnCenterLog;
            CenterClientApi.SetCenterLogHandler(m_LogHandler);
            CenterClientApi.Init("roomserver", args.Length, args, m_NameHandleCallback, m_MsgCallback, m_MsgResultCallback, m_CmdCallback);

            Console.WriteLine("begin init roomserver...");
            HomePath.InitHomePath();

            bool ret = LogSys.Init("./config/logconfig.xml");

            System.Diagnostics.Debug.Assert(ret);

            m_LastTickTimeForSend  = TimeUtility.GetLocalMilliseconds();
            m_LastSendRoomInfoTime = m_LastTickTimeForSend;
            m_IsContinueRegister   = true;
            m_Channel = new PBChannel(BigworldAndRoomServerMessageEnum2Type.Query, BigworldAndRoomServerMessageEnum2Type.Query);
            m_Channel.DefaultServiceName = "Lobby";
            m_LobbyConnector             = new Connector(m_Channel);

            m_ServerIp   = "127.0.0.1";
            m_ServerPort = 9528;

            InitConfig();

            GlobalVariables.Instance.IsClient = false;

            string key = "防君子不防小人";

            byte[] xor = Encoding.UTF8.GetBytes(key);

            ResourceReadProxy.OnReadAsArray = ((string filePath) => {
                byte[] buffer = null;
                try {
                    buffer = File.ReadAllBytes(filePath);
                } catch (Exception e) {
                    LogSys.Log(LOG_TYPE.ERROR, "Exception:{0}\n{1}", e.Message, e.StackTrace);
                    return(null);
                }
                return(buffer);
            });
            LogSystem.OnOutput += (Log_Type type, string msg) => {
                switch (type)
                {
                case Log_Type.LT_Debug:
                    LogSys.Log(LOG_TYPE.DEBUG, msg);
                    break;

                case Log_Type.LT_Info:
                    LogSys.Log(LOG_TYPE.INFO, msg);
                    break;

                case Log_Type.LT_Warn:
                    LogSys.Log(LOG_TYPE.WARN, msg);
                    break;

                case Log_Type.LT_Error:
                case Log_Type.LT_Assert:
                    LogSys.Log(LOG_TYPE.ERROR, msg);
                    break;
                }
            };

            LoadData();
            LogSys.Log(LOG_TYPE.DEBUG, "room server init ip: {0}  port: {1}", m_ServerIp, m_ServerPort);

            uint tick_interval = 33;

            m_RoomMgr = new RoomManager(1280, c_ThreadCount, c_PerThreadRoomCount, tick_interval, m_LobbyConnector);
            m_RoomMgr.Init(m_RoomServerName);
            IOManager.Instance.Init((int)m_ServerPort);
            m_RoomMgr.StartRoomThread();
            SceneLogicViewManager.Instance.Init();

            ServerStorySystem.StaticInit();
            GameFramework.GmCommands.GmStorySystem.StaticInit();

            m_Channel.Register <Msg_LR_ReplyRegisterRoomServer>(HandleReplyRegisterRoomServer);
            m_RoomMgr.RegisterMsgHandler(m_Channel);

            LogSys.Log(LOG_TYPE.DEBUG, "room server init ok.");
        }
Exemple #14
0
        private void Init(string[] args)
        {
            m_NameHandleCallback = this.OnNameHandleChanged;
            m_MsgCallback        = this.OnMessage;
            m_CmdCallback        = this.OnCommand;
            m_MsgResultCallback  = this.OnMessageResult;
            CenterClientApi.Init("roomserver", args.Length, args, m_NameHandleCallback, m_MsgCallback, m_MsgResultCallback, m_CmdCallback);

            Console.WriteLine("begin init roomserver...");
            HomePath.InitHomePath();

            bool ret = LogSys.Init("./config/logconfig.xml");

            System.Diagnostics.Debug.Assert(ret);

            last_tick_time_          = TimeUtility.GetServerMilliseconds();
            last_send_roominfo_time_ = last_tick_time_;
            is_continue_register_    = true;
            channel_ = new PBChannel(MessageMapping.Query, MessageMapping.Query);
            channel_.DefaultServiceName = "Lobby";
            lobby_connector_            = new Connector(channel_);

            server_ip_   = "127.0.0.1";
            server_port_ = 9528;

            StringBuilder sb = new StringBuilder(256);

            if (CenterClientApi.GetConfig("name", sb, 256))
            {
                room_server_name_ = sb.ToString();
            }
            if (CenterClientApi.GetConfig("ServerIp", sb, 256))
            {
                server_ip_ = sb.ToString();
            }
            if (CenterClientApi.GetConfig("ServerPort", sb, 256))
            {
                server_port_ = uint.Parse(sb.ToString());
            }
            if (CenterClientApi.GetConfig("Debug", sb, 256))
            {
                int debug = int.Parse(sb.ToString());
                if (debug != 0)
                {
                    GlobalVariables.Instance.IsDebug = true;
                }
            }

            GlobalVariables.Instance.IsClient = false;

            FileReaderProxy.RegisterReadFileHandler((string filePath) =>
            {
                byte[] buffer = null;
                try
                {
                    buffer = File.ReadAllBytes(filePath);
                }
                catch (Exception e)
                {
                    LogSys.Log(LOG_TYPE.ERROR, "Exception:{0}\n{1}", e.Message, e.StackTrace);
                    return(null);
                }
                return(buffer);
            }, (string filepath) => { return(File.Exists(filepath)); });
            LogSystem.OnOutput += (Log_Type type, string msg) =>
            {
                switch (type)
                {
                case Log_Type.LT_Debug:
                    LogSys.Log(LOG_TYPE.DEBUG, msg);
                    break;

                case Log_Type.LT_Info:
                    LogSys.Log(LOG_TYPE.INFO, msg);
                    break;

                case Log_Type.LT_Warn:
                    LogSys.Log(LOG_TYPE.WARN, msg);
                    break;

                case Log_Type.LT_Error:
                case Log_Type.LT_Assert:
                    LogSys.Log(LOG_TYPE.ERROR, msg);
                    break;
                }
            };

            LoadData();

            LogSys.Log(LOG_TYPE.DEBUG, "room server init ip: {0}  port: {1}", server_ip_, server_port_);

            ret = Serialize.Init();
            if (!ret)
            {
                LogSys.Log(LOG_TYPE.DEBUG, "Serialize init error !!!");
            }
            else
            {
                LogSys.Log(LOG_TYPE.DEBUG, "Serialize init OK.");
            }

            thread_count_          = 16;
            per_thread_room_count_ = 20;
            uint tick_interval = 50;

            room_mgr_ = new RoomManager(thread_count_, per_thread_room_count_,
                                        tick_interval, lobby_connector_);
            room_mgr_.Init();
            IOManager.Instance.Init((int)server_port_);
            room_mgr_.StartRoomThread();
            AiViewManager.Instance.Init();
            SceneLogicViewManager.Instance.Init();
            ImpactViewManager.Instance.Init();

            ServerSkillSystem.StaticInit();
            ServerStorySystem.StaticInit();
            DashFire.GmCommands.GmStorySystem.StaticInit();

            channel_.Register <Msg_LR_ReplyRegisterRoomServer>(HandleReplyRegisterRoomServer);
            room_mgr_.RegisterMsgHandler(channel_);

            LogSys.Log(LOG_TYPE.DEBUG, "room server init ok.");
        }