示例#1
0
 public void Visit(MusicStmt musicStmt, object[] args)
 {
     kernel.Behave(kernel.FuncCaller.Music(
                       varRefProcessor.Replace(musicStmt.Source),
                       musicStmt.Asset,
                       musicStmt.Loop,
                       musicStmt.FadeIn));
 }
示例#2
0
        public override void Visit(MusicStmt musicStmt, object[] args)
        {
            if (musicStmt.Source != null && !StrVarRefProcessor.IsVariableIncluded(musicStmt.Source))
            {
                CheckContent(musicStmt.Source, ContentType.Music, musicStmt.Location);
            }

            if (musicStmt.Asset != null)
            {
                CheckAsset(musicStmt.Asset, typeof(MusicAsset), musicStmt.Location);
            }

            base.Visit(musicStmt, args);
        }
示例#3
0
        public void Visit(MusicStmt musicStmt, object[] args)
        {
            //检查存在性
            bool srcDefined;

            if (srcDefined = reader.MoveToAttribute("src"))
            {
                musicStmt.Source = reader.Value;
            }

            bool assetDefined;

            if (assetDefined = reader.MoveToAttribute("asset"))
            {
                musicStmt.Asset = reader.Value;
            }

            if (srcDefined && assetDefined)
            {
                kernel.IssueError(ErrorType.BothSrcAndAsset, getCurrentLoc());
            }
            else if (!srcDefined && !assetDefined)
            {
                kernel.IssueError(ErrorType.SrcAndAssetMissed, getCurrentLoc());
            }

            if (reader.MoveToAttribute("loop"))
            {
                musicStmt.Loop = (reader.Value == "true" || reader.Value == "1") ? true : false;
            }

            if (reader.MoveToAttribute("fadeIn"))
            {
                musicStmt.FadeIn = TimeSpan.FromSeconds(double.Parse(reader.Value));
            }
            else
            {
                musicStmt.FadeIn = TimeSpan.Zero;
            }
        }
 public void Visit(MusicStmt musicStmt, object[] args)
 {
     throw new NotImplementedException();
 }
示例#5
0
        private void visitMainContent(ASTNode parent, List <Statement> content)
        {
            bool endWithBr = false;

            while (reader.Read())
            {
                reader.MoveToContent();
                Location location = new Location(file, reader.LineNumber, reader.LinePosition);
                switch (reader.NodeType)
                {
                case XmlNodeType.Text:
                    string   text  = reader.Value;
                    string[] lines = text.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string line in lines)
                    {
                        string trimed = line.Trim();
                        if (trimed.Length == 0)
                        {
                            continue;
                        }

                        if (endWithBr && content.Count > 0 && content[content.Count - 1] is DialogStmt)
                        {
                            DialogStmt dialog = content[content.Count - 1] as DialogStmt;
                            dialog.Text += Environment.NewLine + trimed;
                        }
                        else
                        {
                            DialogStmt dialog = new DialogStmt();
                            dialog.Parent   = parent;
                            dialog.Location = location;

                            dialog.Text = trimed;
                            content.Add(dialog);
                        }
                        endWithBr = false;
                    }
                    break;

                case XmlNodeType.Element:
                    Statement statement = null;
                    switch (dic[reader.Name])
                    {
                    case "br":
                        endWithBr = true;
                        continue;

                    case "expr":
                        statement = new ExpressionStmt();
                        break;

                    case "return":
                        statement = new ReturnStmt();
                        break;

                    case "include":
                        statement = new IncludeStmt();
                        break;

                    case "actor":
                        statement = new ActorStmt();
                        break;

                    case "bg":
                        statement = new BackgroundStmt();
                        break;

                    case "echo":
                        statement = new EchoStmt();
                        break;

                    case "select":
                        statement = new SelectStmt();
                        break;

                    case "selectWithValue":
                        statement = new SelectStmt();
                        break;

                    case "if":
                        statement = new IfStmt();
                        break;

                    case "else":
                        return;

                    case "elseif":
                        return;

                    case "switch":
                        statement = new SwitchStmt();
                        break;

                    case "break":
                        statement = new BreakStmt();
                        break;

                    case "continue":
                        statement = new ContinueStmt();
                        break;

                    case "loop":
                        statement = new LoopStmt();
                        break;

                    case "music":
                        statement = new MusicStmt();
                        break;

                    case "musicStop":
                        statement = new MusicStopStmt();
                        break;

                    case "musicVol":
                        statement = new MusicVolStmt();
                        break;

                    default:
                        statement = new FunctionCallStmt();
                        break;
                    }
                    statement.Parent   = parent;
                    statement.Location = location;
                    statement.Accept(this);
                    content.Add(statement);
                    break;

                case XmlNodeType.EndElement:
                    //reader.Read();  //MainContent结束
                    return;
                }
            }
        }