static public int constructor(IntPtr l)
 {
     try {
         GameFramework.HomePath o;
         o = new GameFramework.HomePath();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 2
0
        public void LoadAiStory(string _namespace, string file)
        {
            string filePath = HomePath.GetAbsolutePath(FilePathDefine_Server.C_DslPath + file);

            StoryConfigManager.Instance.LoadStories(m_Scene.SceneResId, _namespace, filePath);
            Dictionary <string, StoryInstance> stories = StoryConfigManager.Instance.GetStories(filePath);

            if (null != stories)
            {
                foreach (KeyValuePair <string, StoryInstance> pair in stories)
                {
                    AiStoryInstanceInfo info = new AiStoryInstanceInfo();
                    info.m_StoryInstance = pair.Value.Clone();
                    info.m_IsUsed        = false;
                    AddAiStoryInstanceInfoToPool(pair.Key, info);
                }
            }
        }
        public bool LoadFromBinary(string file)
        {
            long        t1     = TimeUtility.GetElapsedTimeUs();
            bool        result = true;
            BinaryTable table  = new BinaryTable();

            table.Load(HomePath.GetAbsolutePath(file));
            long t2 = TimeUtility.GetElapsedTimeUs();

            long t3 = TimeUtility.GetElapsedTimeUs();

            for (int index = 0; index < table.Records.Count; ++index)
            {
                try {
                    TData data = new TData();
                    bool  ret  = data.ReadFromBinary(table, index);
                    if (ret && !m_DataContainer.ContainsKey(data.GetId()))
                    {
                        m_DataContainer.Add(data.GetId(), data);
                    }
                    else
                    {
                        string info = string.Format("DataTempalteMgr.CollectDataFromBinary collectData Row:{0} failed in {1}!", index, file);
                        LogSystem.Error(info);
                        Helper.LogCallStack(true);
                        result = false;
                    }
                } catch (System.Exception ex) {
                    LogSystem.Error("CollectData failed. file:{0} rowIndex:{1}\nException:{2}\n{3}", file, index, ex.Message, ex.StackTrace);
                }
            }
            long t4 = TimeUtility.GetElapsedTimeUs();

            LogSystem.Info("binary load {0} parse {1}, file {2}", t2 - t1, t4 - t3, file);
            return(result);
        }
Ejemplo n.º 4
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)
            {
                string[] filePath;
                if (overloadFiles.Length <= 0)
                {
                    TableConfig.UserScript cfg = TableConfig.UserScriptProvider.Instance.GetUserScript(storyId);
                    if (null != cfg)
                    {
                        filePath    = new string[1];
                        filePath[0] = HomePath.GetAbsolutePath(FilePathDefine_Server.C_DslPath + cfg.DslFile);
                    }
                    else
                    {
                        if (logIfNotFound)
                        {
                            LogSystem.Error("Can't find story config, story:{0} !", storyId);
                        }
                        return(null);
                    }
                }
                else
                {
                    int ct = overloadFiles.Length;
                    filePath = new string[ct];
                    for (int i = 0; i < ct; i++)
                    {
                        filePath[i] = HomePath.GetAbsolutePath(FilePathDefine_Server.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} !", storyId);
                    }
                    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
            {
                return(instance);
            }
        }