private AiStoryInstanceInfo NewAiStoryInstance(string storyId, string _namespace, bool logIfNotFound, params string[] overloadFiles)
        {
            if (!string.IsNullOrEmpty(_namespace))
            {
                storyId = string.Format("{0}:{1}", _namespace, storyId);
            }
            AiStoryInstanceInfo instInfo = GetUnusedAiStoryInstanceInfoFromPool(storyId);

            if (null == instInfo)
            {
                int      ct;
                string[] filePath;
                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(m_Scene.SceneResId, _namespace, filePath);
                StoryInstance instance = StoryConfigManager.Instance.NewStoryInstance(storyId, m_Scene.SceneResId);
                if (instance == null)
                {
                    if (logIfNotFound)
                    {
                        LogSystem.Error("Can't load story config, story:{0} scene:{1} !", storyId, m_Scene.SceneResId);
                    }
                    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)
                            {
                                AiStoryInstanceInfo info = new AiStoryInstanceInfo();
                                info.m_StoryInstance = pair.Value.Clone();
                                info.m_IsUsed        = false;
                                AddAiStoryInstanceInfoToPool(pair.Key, info);
                            }
                        }
                    }
                }
                AiStoryInstanceInfo res = new AiStoryInstanceInfo();
                res.m_StoryInstance = instance;
                res.m_IsUsed        = true;

                AddAiStoryInstanceInfoToPool(storyId, res);
                return(res);
            }
            else
            {
                instInfo.m_IsUsed = true;
                return(instInfo);
            }
        }
Exemplo n.º 2
0
 static public int get_m_IsUsed(IntPtr l)
 {
     try {
         GameFramework.AiStoryInstanceInfo self = (GameFramework.AiStoryInstanceInfo)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.m_IsUsed);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 3
0
 static public int Recycle(IntPtr l)
 {
     try {
         GameFramework.AiStoryInstanceInfo self = (GameFramework.AiStoryInstanceInfo)checkSelf(l);
         self.Recycle();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 4
0
 static public int constructor(IntPtr l)
 {
     try {
         GameFramework.AiStoryInstanceInfo o;
         o = new GameFramework.AiStoryInstanceInfo();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 5
0
 static public int set_m_IsUsed(IntPtr l)
 {
     try {
         GameFramework.AiStoryInstanceInfo self = (GameFramework.AiStoryInstanceInfo)checkSelf(l);
         System.Boolean v;
         checkType(l, 2, out v);
         self.m_IsUsed = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        private void AddAiStoryInstanceInfoToPool(string storyId, AiStoryInstanceInfo info)
        {
            List <AiStoryInstanceInfo> infos;

            if (m_AiStoryInstancePool.TryGetValue(storyId, out infos))
            {
                infos.Add(info);
            }
            else
            {
                infos = new List <AiStoryInstanceInfo>();
                infos.Add(info);
                m_AiStoryInstancePool.Add(storyId, infos);
            }
        }
        public void PreloadAiStory(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);
                }
            }
        }
        private AiStoryInstanceInfo GetUnusedAiStoryInstanceInfoFromPool(string storyId)
        {
            AiStoryInstanceInfo        info = null;
            List <AiStoryInstanceInfo> infos;

            if (m_AiStoryInstancePool.TryGetValue(storyId, out infos))
            {
                int ct = infos.Count;
                for (int ix = 0; ix < ct; ++ix)
                {
                    if (!infos[ix].m_IsUsed)
                    {
                        info = infos[ix];
                        break;
                    }
                }
            }
            return(info);
        }
 public void RecycleAiStoryInstance(AiStoryInstanceInfo info)
 {
     info.m_StoryInstance.Reset();
     info.m_IsUsed = false;
 }
        private AiStoryInstanceInfo NewAiStoryInstance(string storyId, string _namespace, bool logIfNotFound, params string[] overloadFiles)
        {
            if (!string.IsNullOrEmpty(_namespace)) {
                storyId = string.Format("{0}:{1}", _namespace, storyId);
            }
            AiStoryInstanceInfo instInfo = GetUnusedAiStoryInstanceInfoFromPool(storyId);
            if (null == instInfo) {
                int ct;
                string[] filePath;
                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(m_Scene.SceneResId, _namespace, filePath);
                StoryInstance instance = StoryConfigManager.Instance.NewStoryInstance(storyId, m_Scene.SceneResId);
                if (instance == null) {
                    if (logIfNotFound)
                        LogSystem.Error("Can't load story config, story:{0} scene:{1} !", storyId, m_Scene.SceneResId);
                    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) {
                                AiStoryInstanceInfo info = new AiStoryInstanceInfo();
                                info.m_StoryInstance = pair.Value.Clone();
                                info.m_IsUsed = false;
                                AddAiStoryInstanceInfoToPool(pair.Key, info);
                            }
                        }
                    }
                }
                AiStoryInstanceInfo res = new AiStoryInstanceInfo();
                res.m_StoryInstance = instance;
                res.m_IsUsed = true;

                AddAiStoryInstanceInfoToPool(storyId, res);
                return res;
            } else {
                instInfo.m_IsUsed = true;
                return instInfo;
            }
        }
 private void AddAiStoryInstanceInfoToPool(string storyId, AiStoryInstanceInfo info)
 {
     List<AiStoryInstanceInfo> infos;
     if (m_AiStoryInstancePool.TryGetValue(storyId, out infos)) {
         infos.Add(info);
     } else {
         infos = new List<AiStoryInstanceInfo>();
         infos.Add(info);
         m_AiStoryInstancePool.Add(storyId, infos);
     }
 }
 public void RecycleAiStoryInstance(AiStoryInstanceInfo info)
 {
     info.m_StoryInstance.Reset();
     info.m_IsUsed = false;
 }
 public void PreloadAiStory(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);
         }
     }
 }
Exemplo n.º 14
0
        public void Reset()
        {
            m_StateStack.Clear();
            m_AiDatas.Clear();
            if (null != m_AiStoryInstanceInfo) {
                m_AiStoryInstanceInfo.Recycle();
                m_AiStoryInstanceInfo = null;
            }
            m_IsInited = false;

            m_AiLogic = 0;
            m_AiParam = new string[c_MaxAiParamNum];
            m_AiStoryInstanceInfo = null;
            m_Time = 0;
            m_IsInited = false;
            m_leaderID = 0;
            m_HomePos = Vector3.Zero;
            m_Target = 0;
            m_HateTarget = 0;
            m_IsExternalTarget = false;
            m_LastChangeTargetTime = 0;
        }