Exemplo n.º 1
0
        /// <summary>
        /// 加载配置表
        /// </summary>
        /// <param name="self"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static ChapterCategory GetChapterByName(this GalGameEngineComponent self, string name)
        {
            ChapterCategory res = ConfigComponent.Instance.LoadOneConfig <ChapterCategory>("Config/" + name + "Category.bytes");

            if (res == null)
            {
                Log.Error("加载配置表 " + name + "失败");
            }

            return(res);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 整理章节内容
        /// </summary>
        /// <param name="self"></param>
        /// <returns></returns>
        public static void Order(this ChapterCategory self)
        {
            if (self.IsOrdered)
            {
                return;
            }
            var dict   = self.GetAll();
            var offset = 0;

            for (int i = 0; i < dict.Count; i++)
            {
                var last_index = i + offset - 1;
                if (!dict.ContainsKey(i))
                {
                    if (!dict.ContainsKey(last_index))
                    {
                        offset--;
                    }
                    else
                    {
                        dict[i] = dict[last_index].Clone() as Chapter;
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(dict[i].Command))
                    {
                        dict[i].Command = "ShowMessageWindow";//默认改为对话框
                        if (string.IsNullOrEmpty(dict[i].Arg1))
                        {
                            dict[i].Arg1 = dict[last_index].Arg1;
                        }
                    }
                    dict[i + offset] = dict[i];
                }
            }
            var keys = dict.Keys.ToList();

            keys.Sort();
            for (int i = 0; i < -offset; i++)
            {
                var index = dict.Count - 1 - i;
                dict.Remove(keys[index]);
            }
            self.IsOrdered = true;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 开始播放一段剧情
        /// </summary>
        /// <param name="self"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static async ETTask <bool> PlayChapterByName(this GalGameEngineComponent self, string name, Action <bool> onPlayOver = null)
        {
            if (self.State != GalGameEngineComponent.GalGameEngineState.Ready)
            {
                return(false);
            }
            ChapterCategory category = GetChapterByName(self, name);

            if (category == null)
            {
                return(false);
            }
            self.CurCategory = category;
            self.CurCategory.Order();
            self.StageRoleMap.Clear();
            self.RoleExpressionMap.Clear();
            self.Index      = 0;
            self.OnPlayOver = onPlayOver;
            UIManagerComponent.Instance.OpenWindow <UIGalGameHelper>(UIGalGameHelper.PrefabPath).Coroutine();
            await self.FSM.ChangeState <GalGameEngineRunningState>();

            return(true);
        }
Exemplo n.º 4
0
 public ChapterCategory()
 {
     Instance  = this;
     IsOrdered = false;
 }