当前位置: 首页>>代码示例>>C#>>正文


C# Chapter.setChapterPath方法代码示例

本文整理汇总了C#中Chapter.setChapterPath方法的典型用法代码示例。如果您正苦于以下问题:C# Chapter.setChapterPath方法的具体用法?C# Chapter.setChapterPath怎么用?C# Chapter.setChapterPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Chapter的用法示例。


在下文中一共展示了Chapter.setChapterPath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: loadChapterData

    /**
     * Loads the script data from the given XML file
     *
     * @param filename
     *            Name of the XML file containing the script
     * @param validate
     *            distinguish between if the load is made in editor or engine
     * @return The script stored as game data
     */
    public static Chapter loadChapterData(InputStreamCreator isCreator, string fileName, List<Incidence> incidences)
    {
        // Create the chapter
        Chapter currentChapter = new Chapter();
        bool chapterFound = false;
        if (Loader.adventureData != null)
        {
            foreach (Chapter chapter in adventureData.getChapters())
            {
                if (chapter != null && chapter.getChapterPath() != null && chapter.getChapterPath().Equals(fileName))
                {
                    currentChapter = chapter;
                    chapterFound = true;
                    break;

                }
                else if (chapter != null && chapter.getChapterPath() == null)
                {

                    currentChapter = chapter;
                    chapterFound = true;
                    currentChapter.setChapterPath("chapter1.xml");
                    break;

                }
            }

        }
        if (!chapterFound)
        {

            string chapterIS = null;

            //if (zipFile!=null){
            chapterIS = isCreator.buildInputStream(fileName);
            currentChapter.setChapterPath(fileName);

            //} else{
            // Then fileName is an absolutePath
            //string chapterPath = fileName.substring( Math.max (fileName.lastIndexOf( '\\' ), fileName.lastIndexOf( '/' ) ), fileName.length( ));
            //currentChapter.setName( chapterPath );
            //try {
            //	chapterIS = new FileInputStream( fileName );
            //} catch (FileNotFoundException e) {
            //e.printStackTrace();
            //	incidences.add( Incidence.createChapterIncidence( TextConstants.getText( "Error.LoadData.IO" ), fileName ) );
            //}
            //}

            // Open the file and load the data
            try
            {
                if (chapterIS != null)
                {
                    // Set the chapter handler
                    ChapterHandler chapterParser = new ChapterHandler(isCreator, currentChapter);

                    //factory.setValidating(false);

                    //SAXParser saxParser = factory.newSAXParser();

                    //// Parse the data and close the data
                    //saxParser.parse(chapterIS, chapterParser);
                    //chapterIS.close();
                    chapterParser.Parse(chapterIS);
                }

            }
            catch (Exception e) { Debug.LogError(e); }
            //catch (ParserConfigurationException e)
            //{
            //    incidences.add(Incidence.createChapterIncidence(Language.GetText("Error.LoadData.SAX"), fileName, e));
            //}
            //catch (SAXException e)
            //{
            //    incidences.add(Incidence.createChapterIncidence(Language.GetText("Error.LoadData.SAX"), fileName, e));
            //}
            //catch (IOException e)
            //{
            //    incidences.add(Incidence.createChapterIncidence(Language.GetText("Error.LoadData.IO"), fileName, e));
            //}
        }
        //Debug.Log(currentChapter);
        return currentChapter;
    }
开发者ID:Synpheros,项目名称:eAdventure4Unity,代码行数:94,代码来源:Loader.cs

示例2: Parse


//.........这里部分代码省略.........
                        uri = tmpString;
                    }

                    adventureData.addArrow(type, uri);
                }
            }

            XmlElement mode = (XmlElement) configuration.SelectSingleNode ("mode");
            if (mode != null)
            {
                tmpString = mode.GetAttribute ("playerTransparent");
                if (!string.IsNullOrEmpty(tmpString)){
                    adventureData.setPlayerMode (tmpString.Equals ("yes") ? DescriptorData.MODE_PLAYER_1STPERSON : DescriptorData.MODE_PLAYER_3RDPERSON);
                }
            }

            XmlElement graphics = (XmlElement) configuration.SelectSingleNode ("graphics");
            if (graphics != null)
            {
                tmpString = graphics.GetAttribute ("playerTransparent");
                if (!string.IsNullOrEmpty(tmpString)){
                    switch (tmpString) {
                    case "windowed":    adventureData.setGraphicConfig(DescriptorData.GRAPHICS_WINDOWED); break;
                    case "fullscreen":  adventureData.setGraphicConfig(DescriptorData.GRAPHICS_FULLSCREEN); break;
                    case "blackbkg":    adventureData.setGraphicConfig(DescriptorData.GRAPHICS_BLACKBKG); break;
                    }
                }
            }
        }

        if (contents != null) {
            Chapter currentChapter;

            XmlNodeList chapters = contents.SelectNodes ("chapter");
            foreach (XmlElement chapter in chapters) {
                currentChapter = new Chapter ();

                string chapterPath = "";
                tmpString = chapter.GetAttribute ("path");
                if (!string.IsNullOrEmpty(tmpString)){
                    chapterPath = tmpString;
                }
                currentChapter.setChapterPath(directory + chapterPath);

                ChapterHandler_ chapterParser = new ChapterHandler_(currentChapter);
                chapterParser.Parse (directory + chapterPath);

                title = (XmlElement) chapter.SelectSingleNode ("title");
                if (title != null) {
                    tmpString = title.InnerText;

                    if (!string.IsNullOrEmpty(tmpString))
                    {
                        currentChapter.setTitle (tmpString);
                    }
                }

                description = (XmlElement) chapter.SelectSingleNode ("description");
                if (description != null) {
                    tmpString = title.InnerText;

                    if (!string.IsNullOrEmpty(tmpString))
                    {
                        currentChapter.setDescription (tmpString);
                    }
                }

                XmlElement adaptation = (XmlElement) chapter.SelectSingleNode ("adaptation-configuration");
                if (adaptation != null) {
                    tmpString = adaptation.GetAttribute ("path");
                    if (!string.IsNullOrEmpty (tmpString)) {
                        string adaptationName = tmpString;
                        // delete the path's characteristics
                        adaptationName = adaptationName.Substring (adaptationName.IndexOf ("/") + 1);
                        adaptationName = adaptationName.Substring (0, adaptationName.IndexOf ("."));
                        currentChapter.setAdaptationName (adaptationName);
                    }
                }

                XmlElement assestment = (XmlElement) chapter.SelectSingleNode ("assessment-configuration");
                if (adaptation != null) {
                    tmpString = adaptation.GetAttribute ("path");
                    if (!string.IsNullOrEmpty (tmpString)) {
                        string assessmentName = tmpString;
                        // delete the path's characteristics
                        assessmentName = assessmentName.Substring(assessmentName.IndexOf("/") + 1);
                        assessmentName = assessmentName.Substring(0, assessmentName.IndexOf("."));
                        currentChapter.setAssessmentName(assessmentName);
                    }
                }

                adventureData.addChapter (currentChapter);
            }
        }

        /*if (qName.EndsWith("automatic-commentaries"))
        {
            adventureData.setCommentaries(true);
        }*/
    }
开发者ID:Synpheros,项目名称:eAdventure4Unity,代码行数:101,代码来源:AdventureHandler_.cs

示例3: startElement


//.........这里部分代码省略.........
                    }
                    else if (entry.Value.ToString().Equals("fullscreen"))
                    {
                        adventureData.setGraphicConfig(DescriptorData.GRAPHICS_FULLSCREEN);
                    }
                    else if (entry.Value.ToString().Equals("blackbkg"))
                    {
                        adventureData.setGraphicConfig(DescriptorData.GRAPHICS_BLACKBKG);
                    }
                }
            }
        }

        // If reading the contents tag, switch to the chapters mode
        else if (qName.Equals("contents"))
        {
            reading = READING_CHAPTER;
        }

        // If reading the contents of a chapter, create a new one to store the data
        else if (qName.Equals("chapter"))
        {
            // Create the chapter
            currentChapter = new Chapter();

            // Search and store the path of the file
            string chapterPath = null;
            foreach (KeyValuePair<string, string> entry in attrs)
                if (entry.Key.Equals("path"))
                    chapterPath = entry.Value.ToString();

            if (chapterPath != null)
            {
                currentChapter.setChapterPath(chapterPath);
            }
            else
                currentChapter.setChapterPath("");

            // Open the file and load the data
            try
            {
                // Set the chapter handler
                // ChapterHandler chapterParser = new ChapterHandler(isCreator, currentChapter);
                ChapterHandler_ chapterParser = new ChapterHandler_(currentChapter);
                Debug.Log(currentChapter.getBooks().Count);
                //// Create a new factory
                //SAXParserFactory factory = SAXParserFactory.newInstance();
                ////factory.setValidating( validate );
                //factory.setValidating(false);
                //SAXParser saxParser = factory.newSAXParser();

                //// Set the input stream with the file
                //InputStream chapterIS = isCreator.buildInputStream(chapterPath);

                //// Parse the data and close the data
                //saxParser.parse(chapterIS, chapterParser);
                //chapterIS.close();
                string chapterIS = isCreator.buildInputStream(chapterPath);
                chapterParser.Parse(chapterIS);

            }
            catch (Exception e) { Debug.LogError(e); }
            //catch (ParserConfigurationException e)
            //{
            //    incidences.add(Incidence.createChapterIncidence(Language.GetText("Error.LoadData.SAX"), chapterPath, e));
            //}
开发者ID:Synpheros,项目名称:eAdventure4Unity,代码行数:67,代码来源:AdventureHandler.cs


注:本文中的Chapter.setChapterPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。