Example #1
0
        public override void OnFrame(int tick, float timePass)
        {
            base.OnFrame(tick, timePass);

            if (evtItem != null && evtItem.RunningState == TalkEventItem.TalkEventState.Running)
            {
                evtItem.OnFrame(tick);
                if (evtItem.RunningState == TalkEventItem.TalkEventState.Finish)
                {
                    interactBlock = evtItem.GetResult();
                    if (interactBlock is SceneQuestSay)
                    {
                        SetupQuestItem();
                    }
                    else if (interactBlock == null)
                    {
                        answerList.Clear();
                        var block = new SceneQuestAnswer(this, EventId, eventLevel, "结束", 999, 999);
                        AddBlockAnswer(block);
                    }
                }
                Invalidate();
            }

            if (colorWord != null)
            {
                colorWord.OnFrame(tick, this);
            }
        }
Example #2
0
        public static SceneQuestBlock GetQuestData(Control c, int eventId, int level, string name)
        {
            Dictionary <int, SceneQuestBlock> levelCachDict = new Dictionary <int, SceneQuestBlock>();//存下每一深度的最后节点
            SceneQuestBlock root = null;
            StreamReader    sr   = new StreamReader(DataLoader.Read("SceneQuest", String.Format("{0}.txt", name)));
            string          line;
            int             lineCount = 0;

            while ((line = sr.ReadLine()) != null)
            {
                lineCount++;
                int             lineDepth = GetStringDepth(ref line);
                char            type      = line[0];
                string          script    = line.Substring(1);
                SceneQuestBlock data;
                switch (type)
                {
                case 's': data = new SceneQuestSay(c, eventId, level, script, lineDepth, lineCount); break;

                case 'a': data = new SceneQuestAnswer(c, eventId, level, script, lineDepth, lineCount); break;

                case 'e': data = new SceneQuestEvent(c, eventId, level, script, lineDepth, lineCount); break;

                case 'r': data = new SceneQuestRollItem(c, eventId, level, script, lineDepth, lineCount); break;

                default: throw new Exception(string.Format("GetQuestData unknown type {0} {1}", name, lineCount));
                }

                levelCachDict[data.Depth] = data;
                if (root == null)
                {
                    root = data;
                }
                else
                {
                    levelCachDict[data.Depth - 1].Children.Add(data);
                }
            }
            sr.Close();

            return(root);
        }