/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is a object tag, create the new object (with its id) if (qName.Equals("barrier")) { int x = 0, y = 0, width = 0, height = 0; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("width")) { width = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("height")) { height = int.Parse(entry.Value.ToString()); } } barrier = new Barrier(generateId(), x, y, width, height); } // If it is a condition tag, create new conditions and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } } // If it is reading an effect or a condition, spread the call if (subParsing != SUBPARSING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); } }
/* * (non-Javadoc) * * @see conversationaleditor.xmlparser.ConversationParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is a "graph-conversation" we pick the name, so we can build the conversation later if (qName.Equals("graph-conversation")) { // Store the name conversationName = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("id")) { conversationName = entry.Value.ToString(); } } graphNodes = new List <ConversationNode>(); nodeLinks = new List <List <int> >(); } // If it is a node, create a new node else if (qName.Equals("dialogue-node") || qName.Equals("option-node")) { // Create the node depending of the tag editorX = editorY = int.MinValue; if (qName.Equals("dialogue-node")) { foreach (KeyValuePair <string, string> entry in attrs) { //If there is a "waitUserInteraction" attribute, store if the lines will wait until user interacts if (entry.Key.Equals("keepShowing")) { if (entry.Value.ToString().Equals("yes")) { keepShowingDialogue = true; } else { keepShowingDialogue = false; } } //If there is a "editor-x" and "editor-y" attributes if (entry.Key.Equals("editor-x")) { editorX = Mathf.Max(0, int.Parse(entry.Value.ToString())); } else if (entry.Key.Equals("editor-y")) { editorY = Mathf.Max(0, int.Parse(entry.Value.ToString())); } } currentNode = new DialogueConversationNode(keepShowingDialogue); if (editorX > int.MinValue) { currentNode.setEditorX(editorX); } if (editorY > int.MinValue) { currentNode.setEditorY(editorY); } } if (qName.Equals("option-node")) { foreach (KeyValuePair <string, string> entry in attrs) { //If there is a "random" attribute, store if the options will be random if (entry.Key.Equals("random")) { if (entry.Value.ToString().Equals("yes")) { random = true; } else { random = false; } } else //If there is a "keepShowing" attribute, keep the previous conversation line showing if (entry.Key.Equals("keepShowing")) { if (entry.Value.ToString().Equals("yes")) { keepShowing = true; } else { keepShowing = false; } } else //If there is a "showUserOption" attribute, identify if show the user response at option node if (entry.Key.Equals("showUserOption")) { if (entry.Value.ToString().Equals("yes")) { showUserOption = true; } else { showUserOption = false; } } else //If there is a "showUserOption" attribute, identify if show the user response at option node if (entry.Key.Equals("preListening")) { if (entry.Value.ToString().Equals("yes")) { preListening = true; } else { preListening = false; } } else //If there is a "x" and "y" attributes with the position where the option node has to be painted, if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } else if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } //If there is a "editor-x" and "editor-y" attributes if (entry.Key.Equals("editor-x")) { editorX = Mathf.Max(0, int.Parse(entry.Value.ToString())); } else if (entry.Key.Equals("editor-y")) { editorY = Mathf.Max(0, int.Parse(entry.Value.ToString())); } } currentNode = new OptionConversationNode(random, keepShowing, showUserOption, preListening, x, y); if (editorX > int.MinValue) { currentNode.setEditorX(editorX); } if (editorY > int.MinValue) { currentNode.setEditorY(editorY); } } // Create a new vector for the links of the current node currentLinks = new List <int>(); } // If it is a non-player character line, store the character name and audio path (if present) else if (qName.Equals("speak-char")) { // Set default name to "NPC" characterName = "NPC"; audioPath = ""; foreach (KeyValuePair <string, string> entry in attrs) { // If there is a "idTarget" attribute, store it if (entry.Key.Equals("idTarget")) { characterName = entry.Value.ToString(); } // If there is a "uri" attribute, store it as audio path if (entry.Key.Equals("uri")) { audioPath = entry.Value.ToString(); } // If there is a "synthesize" attribute, store its value if (entry.Key.Equals("synthesize")) { string response = entry.Value.ToString(); if (response.Equals("yes")) { synthesizerVoice = true; } else { synthesizerVoice = false; } } // If there is a "keepShowing" attribute, store its value if (entry.Key.Equals("keepShowing")) { string response = entry.Value.ToString(); if (response.Equals("yes")) { keepShowingLine = true; } else { keepShowingLine = false; } } } } // If it is a player character line, store the audio path (if present) else if (qName.Equals("speak-player")) { audioPath = ""; foreach (KeyValuePair <string, string> entry in attrs) { // If there is a "uri" attribute, store it as audio path if (entry.Key.Equals("uri")) { audioPath = entry.Value.ToString(); } // If there is a "synthesize" attribute, store its value if (entry.Key.Equals("synthesize")) { string response = entry.Value.ToString(); if (response.Equals("yes")) { synthesizerVoice = true; } else { synthesizerVoice = false; } } // If there is a "keepShowing" attribute, store its value if (entry.Key.Equals("keepShowing")) { string response = entry.Value.ToString(); if (response.Equals("yes")) { keepShowingLine = true; } else { keepShowingLine = false; } } } } // If it is a node to a child, store the number of the child node else if (qName.Equals("child")) { // Look for the index of the link, and add it foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("nodeindex")) { // Get the child node index, and store it int childIndex = int.Parse(entry.Value.ToString()); currentLinks.Add(childIndex); } } } // If it is an effect tag else if (qName.Equals("effect")) { // Create the new effects, and the subparser currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; }// If it is a condition tag, create new conditions and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } } // If we are subparsing an effect, spread the call if (subParsing == SUBPARSING_EFFECT || subParsing == SUBPARSING_CONDITION) { subParser.startElement(namespaceURI, sName, qName, attrs); endElement(namespaceURI, sName, qName); } }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is a object tag, create the new object (with its id) if (qName.Equals("active-area")) { int x = 0, y = 0, width = 0, height = 0; string id = null; bool rectangular = true; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("rectangular")) { rectangular = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("width")) { width = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("height")) { height = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("id")) { id = entry.Value.ToString(); } if (entry.Key.Equals("hasInfluenceArea")) { hasInfluence = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("influenceX")) { influenceX = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("influenceY")) { influenceY = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("influenceWidth")) { influenceWidth = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("influenceHeight")) { influenceHeight = int.Parse(entry.Value.ToString()); } } activeArea = new ActiveArea((id == null ? generateId() : id), rectangular, x, y, width, height); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); activeArea.setInfluenceArea(influenceArea); } descriptions = new List <Description>(); activeArea.setDescriptions(descriptions); } else if (qName.Equals("point")) { if (activeArea != null) { int x = 0, y = 0; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } } Vector2 point = new Vector2(x, y); activeArea.addVector2(point); } } // If it is a description tag, create the new description (with its id) else if (qName.Equals("description")) { description = new Description(); subParser = new DescriptionsSubParser(description, chapter); subParsing = SUBPARSING_DESCRIPTION; } else if (qName.Equals("actions")) { subParser = new ActionsSubParser(chapter, activeArea); subParsing = SUBPARSING_ACTIONS; } // If it is a condition tag, create new conditions and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // If it is a effect tag, create new effects and switch the state else if (qName.Equals("effect")) { subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } } // If it is reading an effect or a condition, spread the call if (subParsing != SUBPARSING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); } }
public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { // If no element is being subparsed, check if we must subparse something if (subParsing == NONE) { //Parse eAdventure attributes if (qName.Equals("eAdventure")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("adaptProfile")) { chapter.setAdaptationName(entry.Value.ToString()); } if (entry.Key.Equals("assessProfile")) { chapter.setAssessmentName(entry.Value.ToString()); } } } // Subparse scene else if (qName.Equals("scene")) { subParser = new SceneSubParser(chapter); subParsing = SCENE; } // Subparse slidescene else if (qName.Equals("slidescene") || qName.Equals("videoscene")) { subParser = new CutsceneSubParser(chapter); subParsing = CUTSCENE; } // Subparse book else if (qName.Equals("book")) { subParser = new BookSubParser(chapter); subParsing = BOOK; } // Subparse object else if (qName.Equals("object")) { subParser = new ItemSubParser(chapter); subParsing = OBJECT; } // Subparse player else if (qName.Equals("player")) { subParser = new PlayerSubParser(chapter); subParsing = PLAYER; } // Subparse character else if (qName.Equals("character")) { subParser = new CharacterSubParser(chapter); subParsing = CHARACTER; } // Subparse conversacion (tree conversation) else if (qName.Equals("tree-conversation")) { subParser = new TreeConversationSubParser(chapter); subParsing = CONVERSATION; } // Subparse conversation (graph conversation) else if (qName.Equals("graph-conversation")) { subParser = new GraphConversationSubParser(chapter); subParsing = CONVERSATION; } // Subparse timer else if (qName.Equals("timer")) { subParser = new TimerSubParser(chapter); subParsing = TIMER; } // Subparse global-state else if (qName.Equals("global-state")) { string id = null; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("id")) { id = entry.Value.ToString(); } } currentGlobalState = new GlobalState(id); currentString = string.Empty; chapter.addGlobalState(currentGlobalState); subParser = new ConditionSubParser(currentGlobalState, chapter); subParsing = GLOBAL_STATE; } // Subparse macro else if (qName.Equals("macro")) { string id = null; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("id")) { id = entry.Value.ToString(); } } currentMacro = new Macro(id); currentString = string.Empty; chapter.addMacro(currentMacro); subParser = new EffectSubParser(currentMacro, chapter); subParsing = MACRO; } // Subparse atrezzo object else if (qName.Equals("atrezzoobject")) { subParser = new AtrezzoSubParser(chapter); subParsing = ATREZZO; }// Subparse assessment profile else if (qName.Equals("assessment")) { subParser = new AssessmentSubParser(chapter); subParsing = ASSESSMENT; }// Subparse adaptation profile else if (qName.Equals("adaptation")) { subParser = new AdaptationSubParser(chapter); subParsing = ADAPTATION; } } // If an element is being subparsed, spread the call if (subParsing != NONE) { //try { subParser.startElement(namespaceURI, sName, qName, attrs); //} catch (Exception e) { Debug.LogError(e); }{ // System.out.println("Marihuanhell es muy malo pero hemos capturado la excepción"); //e.printStackTrace(); //} } }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.XmlAttribute) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is an examine, use or grab tag, create new conditions and effects if (qName.Equals("examine") || qName.Equals("grab") || qName.Equals("use") || qName.Equals("talk-to")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("needsGoTo")) { currentNeedsGoTo = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("keepDistance")) { currentKeepDistance = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("not-effects")) { activateNotEffects = entry.Value.ToString().Equals("yes"); } } currentConditions = new Conditions(); currentEffects = new Effects(); currentNotEffects = new Effects(); currentClickEffects = new Effects(); currentDocumentation = null; reading = READING_ACTION; } // If it is an use-with or give-to tag, create new conditions and effects, and store the idTarget else if (qName.Equals("use-with") || qName.Equals("give-to") || qName.Equals("drag-to")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { currentIdTarget = entry.Value.ToString(); } if (entry.Key.Equals("needsGoTo")) { currentNeedsGoTo = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("keepDistance")) { currentKeepDistance = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("not-effects")) { activateNotEffects = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("click-effects")) { activateClickEffects = entry.Value.ToString().Equals("yes"); } } currentConditions = new Conditions(); currentEffects = new Effects(); currentNotEffects = new Effects(); currentClickEffects = new Effects(); currentDocumentation = null; reading = READING_ACTION; } else if (qName.Equals("custom") || qName.Equals("custom-interact")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { currentIdTarget = entry.Value.ToString(); } if (entry.Key.Equals("name")) { currentName = entry.Value.ToString(); } if (entry.Key.Equals("needsGoTo")) { currentNeedsGoTo = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("keepDistance")) { currentKeepDistance = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("not-effects")) { activateNotEffects = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("click-effects")) { activateClickEffects = entry.Value.ToString().Equals("yes"); } } currentConditions = new Conditions(); currentEffects = new Effects(); currentNotEffects = new Effects(); currentClickEffects = new Effects(); currentDocumentation = null; if (qName.Equals("custom")) { currentCustomAction = new CustomAction(Action.CUSTOM); } else { currentCustomAction = new CustomAction(Action.CUSTOM_INTERACT); } reading = READING_ACTION; } // If it is a resources tag, create the new resources and switch the state else if (qName.Equals("resources")) { currentResources = new ResourcesUni(); foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("name")) { currentResources.setName(entry.Value.ToString()); } } reading = READING_RESOURCES; } // If it is an asset tag, read it and add it to the current resources else if (qName.Equals("asset")) { string type = ""; string path = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("type")) { type = entry.Value.ToString(); } if (entry.Key.Equals("uri")) { path = entry.Value.ToString(); } } // If the asset is not an special one // if( !AssetsController.isAssetSpecial( path ) ) currentResources.addAsset(type, path); } // If it is a condition tag, create new conditions and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // If it is a effect tag, create new effects and switch the state else if (qName.Equals("effect")) { subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a not-effect tag, create new effects and switch the state else if (qName.Equals("not-effect")) { subParser = new EffectSubParser(currentNotEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a click-effect tag, create new effects and switch the state else if (qName.Equals("click-effect")) { subParser = new EffectSubParser(currentClickEffects, chapter); subParsing = SUBPARSING_EFFECT; } } // If it is reading an effect or a condition, spread the call if (subParsing != SUBPARSING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); } }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is a object tag, create the new object (with its id) if (qName.Equals("atrezzoobject")) { string atrezzoId = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("id")) { atrezzoId = entry.Value.ToString(); } } atrezzo = new Atrezzo(atrezzoId); descriptions = new List <Description>(); atrezzo.setDescriptions(descriptions); } // If it is a resources tag, create the new resources and switch the state else if (qName.Equals("resources")) { currentResources = new ResourcesUni(); foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("name")) { currentResources.setName(entry.Value.ToString()); } } reading = READING_RESOURCES; } // If it is an asset tag, read it and add it to the current resources else if (qName.Equals("asset")) { string type = ""; string path = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("type")) { type = entry.Value.ToString(); } if (entry.Key.Equals("uri")) { path = entry.Value.ToString(); } } // If the asset is not an special one // if( !AssetsController.isAssetSpecial( path ) ) currentResources.addAsset(type, path); } // If it is a description tag, create the new description (with its id) else if (qName.Equals("description")) { description = new Description(); subParser = new DescriptionsSubParser(description, chapter); subParsing = SUBPARSING_DESCRIPTION; } // If it is a condition tag, create new conditions and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // If it is a effect tag, create new effects and switch the state else if (qName.Equals("effect")) { subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } } // If it is reading an effect or a condition, spread the call if (subParsing != SUBPARSING_NONE) { //string id = this.atrezzo.getId( ); subParser.startElement(namespaceURI, sName, qName, attrs); } }
public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { // If no element is being subparsed // Debug.Log(namespaceURI + " " + sName + " " + qName + "\nAttrs:\n" + CollectionPrinter.PrintCollection(attrs)); if (subParsing == SUBPARSING_NONE) { // If it is a object tag, create the new parsedObject (with its id) if (qName.Equals("object")) { string parsedObjectId = ""; bool returnsWhenDragged = true; //Two lines added:v1.4 Item.BehaviourType behaviour = Item.BehaviourType.NORMAL; long resourceTransition = 0; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("id")) { parsedObjectId = entry.Value.ToString(); } if (entry.Key.Equals("returnsWhenDragged")) { returnsWhenDragged = (entry.Value.ToString().Equals("yes") ? true : false); } if (entry.Key.Equals("behaviour")) { if (entry.Value.ToString().Equals("normal")) { behaviour = Item.BehaviourType.NORMAL; } else if (entry.Value.ToString().Equals("atrezzo")) { behaviour = Item.BehaviourType.ATREZZO; } else if (entry.Value.ToString().Equals("first-action")) { behaviour = Item.BehaviourType.FIRST_ACTION; } } if (entry.Key.Equals("resources-transition-time")) { resourceTransition = long.Parse(entry.Value.ToString()); } } parsedObject = new Item(parsedObjectId); parsedObject.setReturnsWhenDragged(returnsWhenDragged); parsedObject.setResourcesTransitionTime(resourceTransition); parsedObject.setBehaviour(behaviour); descriptions = new List <Description>(); parsedObject.setDescriptions(descriptions); } // If it is a resources tag, create the new resources and switch the state else if (qName.Equals("resources")) { currentResources = new ResourcesUni(); foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("name")) { currentResources.setName(entry.Value.ToString()); } } reading = READING_RESOURCES; //Debug.Log("RESOURCES, PARSUJE: " + parsedObject); } // If it is an asset tag, read it and add it to the current resources else if (qName.Equals("asset")) { string type = ""; string path = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("type")) { type = entry.Value.ToString(); } if (entry.Key.Equals("uri")) { path = entry.Value.ToString(); } } // If the asset is not an special one // if( !AssetsController.isAssetSpecial( path ) ) currentResources.addAsset(type, path); } // If it is a description tag, create the new description (with its id) else if (qName.Equals("description")) { description = new Description(); subParser = new DescriptionsSubParser(description, chapter); subParsing = SUBPARSING_DESCRIPTION; } else if (qName.Equals("actions")) { subParser = new ActionsSubParser(chapter, parsedObject); subParsing = SUBPARSING_ACTIONS; } // If it is a condition tag, create new conditions and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // If it is a effect tag, create new effects and switch the state else if (qName.Equals("effect")) { subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } } // If it is reading an effect or a condition, spread the call if (subParsing != SUBPARSING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); } }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.loader.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is a book tag, store the id of the book if (qName.Equals("book")) { string bookId = ""; string xPrevious = "", xNext = "", yPrevious = "", yNext = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("id")) { bookId = entry.Value.ToString(); } else if (entry.Key.Equals("xPreviousPage")) { xPrevious = entry.Value.ToString(); } else if (entry.Key.Equals("xNextPage")) { xNext = entry.Value.ToString(); } else if (entry.Key.Equals("yPreviousPage")) { yPrevious = entry.Value.ToString(); } else if (entry.Key.Equals("yNextPage")) { yNext = entry.Value.ToString(); } } book = new Book(bookId); if (xPrevious != "" && yPrevious != "") { try { int x = int.Parse(xPrevious); int y = int.Parse(yPrevious); book.setPreviousPageVector2(new Vector2(x, y)); } catch (Exception e) { // Number in XML is wrong -> Do nothing } } if (xNext != "" && yNext != "") { try { int x = int.Parse(xNext); int y = int.Parse(yNext); book.setNextPageVector2(new Vector2(x, y)); } catch (Exception e) { // Number in XML is wrong -> Do nothing } } } // If it is a resources tag, create the new resources else if (qName.Equals("resources")) { currentResources = new ResourcesUni(); foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("name")) { currentResources.setName(entry.Value.ToString()); } } } // If it is a documentation tag, hold the documentation in the book else if (qName.Equals("documentation")) { currentstring = string.Empty; } // If it is a condition tag, create a new subparser else if (qName.Equals("condition")) { currentConditions = new Conditions(); conditionSubParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // If it is an asset tag, read it and add it to the current resources else if (qName.Equals("asset")) { string type = ""; string path = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("type")) { type = entry.Value.ToString(); } if (entry.Key.Equals("uri")) { path = entry.Value.ToString(); } } currentResources.addAsset(type, path); } else if (qName.Equals("text")) { book.setType(Book.TYPE_PARAGRAPHS); } else if (qName.Equals("pages")) { book.setType(Book.TYPE_PAGES); } else if (qName.Equals("page")) { string uri = ""; int type = BookPage.TYPE_URL; int margin = 0; int marginEnd = 0; int marginTop = 0; int marginBottom = 0; bool scrollable = false; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("uri")) { uri = entry.Value.ToString(); } if (entry.Key.Equals("type")) { if (entry.Value.ToString().Equals("resource")) { type = BookPage.TYPE_RESOURCE; } if (entry.Value.ToString().Equals("image")) { type = BookPage.TYPE_IMAGE; } } if (entry.Key.Equals("scrollable")) { if (entry.Value.ToString().Equals("yes")) { scrollable = true; } } if (entry.Key.Equals("margin")) { try { margin = int.Parse(entry.Value.ToString()); } catch (Exception e) { Debug.LogError(e); } } if (entry.Key.Equals("marginEnd")) { try { marginEnd = int.Parse(entry.Value.ToString()); } catch (Exception e) { Debug.LogError(e); } } if (entry.Key.Equals("marginTop")) { try { marginTop = int.Parse(entry.Value.ToString()); } catch (Exception e) { Debug.LogError(e); } } if (entry.Key.Equals("marginBottom")) { try { marginBottom = int.Parse(entry.Value.ToString()); } catch (Exception e) { Debug.LogError(e); } } } book.addPage(uri, type, margin, marginEnd, marginTop, marginBottom, scrollable); } // If it is a title or bullet tag, store the previous text in the book else if (qName.Equals("title") || qName.Equals("bullet")) { // Add the new text paragraph if (currentstring != null && currentstring.ToString().Trim().Replace("\t", "").Replace("\n", "").Length > 0) { book.addParagraph(new BookParagraph(BookParagraph.TEXT, currentstring.ToString().Trim().Replace("\t", ""))); } currentstring = string.Empty; } // If it is an image tag, store the image in the book else if (qName.Equals("img")) { // Add the new text paragraph if (currentstring.ToString().Trim().Replace("\t", "").Replace("\n", "").Length > 0) { book.addParagraph(new BookParagraph(BookParagraph.TEXT, currentstring.ToString().Trim().Replace("\t", ""))); currentstring = string.Empty; } string path = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("src")) { path = entry.Value.ToString(); } } // Add the new image paragraph book.addParagraph(new BookParagraph(BookParagraph.IMAGE, path)); } } // If a condition is being subparsed, spread the call if (subParsing == SUBPARSING_CONDITION) { conditionSubParser.startElement(namespaceURI, sName, qName, attrs); } }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { Debug.Log("START: " + sName + " " + qName + " sub:" + subParsing + ", reading: " + reading); // If no element is being parsed if (subParsing == SUBPARSING_NONE) { // If it is a scene tag, create a new scene with its id if (qName.Equals("scene")) { string sceneId = ""; bool initialScene = false; int playerLayer = -1; float playerScale = 1.0f; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("id")) { sceneId = entry.Value.ToString(); } if (entry.Key.Equals("start")) { initialScene = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("playerLayer")) { playerLayer = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("playerScale")) { playerScale = float.Parse(entry.Value.ToString(), CultureInfo.InvariantCulture); } } scene = new Scene(sceneId); scene.setPlayerLayer(playerLayer); scene.setPlayerScale(playerScale); if (initialScene) { chapter.setTargetId(sceneId); } } // If it is a resources tag, create the new resources else if (qName.Equals("resources")) { currentResources = new ResourcesUni(); foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("name")) { currentResources.setName(entry.Value.ToString()); } } reading = READING_RESOURCES; } // If it is an asset tag, read it and add it to the current resources else if (qName.Equals("asset")) { string type = ""; string path = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("type")) { type = entry.Value.ToString(); } if (entry.Key.Equals("uri")) { path = entry.Value.ToString(); } } currentResources.addAsset(type, path); } // If it is a default-initial-position tag, store it in the scene else if (qName.Equals("default-initial-position")) { int x = int.MinValue, y = int.MinValue; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } } scene.setDefaultPosition(x, y); } // If it is an exit tag, create the new exit else if (qName.Equals("exit")) { int x = 0, y = 0, width = 0, height = 0; bool rectangular = true; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; string idTarget = ""; int destinyX = int.MinValue, destinyY = int.MinValue; int transitionType = 0, transitionTime = 0; bool notEffects = false; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("rectangular")) { rectangular = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("width")) { width = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("height")) { height = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("hasInfluenceArea")) { hasInfluence = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("influenceX")) { influenceX = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("influenceY")) { influenceY = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("influenceWidth")) { influenceWidth = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("influenceHeight")) { influenceHeight = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("idTarget")) { idTarget = entry.Value.ToString(); } if (entry.Key.Equals("destinyX")) { destinyX = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("destinyY")) { destinyY = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("transitionType")) { transitionType = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("transitionTime")) { transitionTime = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("not-effects")) { notEffects = entry.Value.ToString().Equals("yes"); } } currentExit = new Exit(rectangular, x, y, width, height); currentExit.setNextSceneId(idTarget); currentExit.setDestinyX(destinyX); currentExit.setDestinyY(destinyY); currentExit.setTransitionTime(transitionTime); currentExit.setTransitionType(transitionType); currentExit.setHasNotEffects(notEffects); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentExit.setInfluenceArea(influenceArea); } reading = READING_EXIT; } else if (qName.Equals("exit-look")) { currentExitLook = new ExitLook(); string text = null; string cursorPath = null; string soundPath = null; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("text")) { text = entry.Value.ToString(); } if (entry.Key.Equals("cursor-path")) { cursorPath = entry.Value.ToString(); } if (entry.Key.Equals("sound-path")) { soundPath = entry.Value.ToString(); } } currentExitLook.setCursorPath(cursorPath); currentExitLook.setExitText(text); if (soundPath != null) { currentExitLook.setSoundPath(soundPath); } // Debug.Log("311" + currentExitLook.getExitText()); } // If it is a next-scene tag, create the new next scene else if (qName.Equals("next-scene")) { string idTarget = ""; int x = int.MinValue, y = int.MinValue; int transitionType = 0, transitionTime = 0; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { idTarget = entry.Value.ToString(); } if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("transitionType")) { transitionType = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("transitionTime")) { transitionTime = int.Parse(entry.Value.ToString()); } } currentNextScene = new NextScene(idTarget, x, y); currentNextScene.setTransitionType((NextSceneEnumTransitionType)transitionType); currentNextScene.setTransitionTime(transitionTime); reading = READING_NEXT_SCENE; } else if (qName.Equals("point")) { int x = 0; int y = 0; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } } currentPoint = new Vector2(x, y); } // If it is a object-ref or character-ref, create the new element reference else if (qName.Equals("object-ref") || qName.Equals("character-ref") || qName.Equals("atrezzo-ref")) { Debug.Log("SceneReference Start"); string idTarget = ""; int x = 0, y = 0; float scale = 0; int layer = 0; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { idTarget = entry.Value.ToString(); } if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("scale")) { scale = float.Parse(entry.Value.ToString(), CultureInfo.InvariantCulture); } if (entry.Key.Equals("layer")) { layer = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("hasInfluenceArea")) { hasInfluence = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("influenceX")) { influenceX = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("influenceY")) { influenceY = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("influenceWidth")) { influenceWidth = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("influenceHeight")) { influenceHeight = int.Parse(entry.Value.ToString()); } } // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value // for layer if (layer == -1) { layer = 0; } currentElementReference = new ElementReference(idTarget, x, y, layer); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentElementReference.setInfluenceArea(influenceArea); } if (scale > 0.001 || scale < -0.001) { currentElementReference.setScale(scale); } reading = READING_ELEMENT_REFERENCE; } // If it is a condition tag, create the new condition, the subparser and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // If it is a effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("post-effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("not-effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("active-area")) { subParsing = SUBPARSING_ACTIVE_AREA; subParser = new ActiveAreaSubParser(chapter, scene, scene.getActiveAreas().Count); } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("barrier")) { subParsing = SUBPARSING_BARRIER; subParser = new BarrierSubParser(chapter, scene, scene.getBarriers().Count); } else if (qName.Equals("trajectory")) { subParsing = SUBPARSING_TRAJECTORY; subParser = new TrajectorySubParser(chapter, scene); } } // If it is subparsing an effect or condition, spread the call if (subParsing != SUBPARSING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); } }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.loader.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is a player tag, create the player if (qName.Equals("player")) { player = new Player(); descriptions = new List <Description>(); player.setDescriptions(descriptions); } // If it is a resources tag, create new resources else if (qName.Equals("resources")) { currentResources = new ResourcesUni(); foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("name")) { currentResources.setName(entry.Value.ToString()); } } } // If it is a condition tag, create new conditions, new subparser and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // If it is an asset tag, read it and add it to the current resources else if (qName.Equals("asset")) { string type = ""; string path = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("type")) { type = entry.Value.ToString(); } if (entry.Key.Equals("uri")) { path = entry.Value.ToString(); } } // If the asset is not an special one //if( !AssetsController.isAssetSpecial( path ) ) currentResources.addAsset(type, path); } // If it is a frontcolor or bordercolor tag, pick the color else if (qName.Equals("frontcolor") || qName.Equals("bordercolor")) { string color = ""; // Pick the color foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("color")) { color = entry.Value.ToString(); } } // Set the color in the player if (qName.Equals("frontcolor")) { player.setTextFrontColor(color); } if (qName.Equals("bordercolor")) { player.setTextBorderColor(color); } } else if (qName.Equals("textcolor")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("showsSpeechBubble")) { player.setShowsSpeechBubbles(entry.Value.ToString().Equals("yes")); } if (entry.Key.Equals("bubbleBkgColor")) { player.setBubbleBkgColor(entry.Value.ToString()); } if (entry.Key.Equals("bubbleBorderColor")) { player.setBubbleBorderColor(entry.Value.ToString()); } } } // If it is a voice tag, take the voice and the always synthesizer option else if (qName.Equals("voice")) { string voice = string.Empty; string response; bool alwaysSynthesizer = false; // Pick the voice and synthesizer option foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("name")) { voice = entry.Value.ToString(); } if (entry.Key.Equals("synthesizeAlways")) { response = entry.Value.ToString(); if (response.Equals("yes")) { alwaysSynthesizer = true; } } } player.setAlwaysSynthesizer(alwaysSynthesizer); player.setVoice(voice); } // If it is a description tag, create the new description (with its id) else if (qName.Equals("description")) { description = new Description(); subParser = new DescriptionsSubParser(description, chapter); subParsing = SUBPARSING_DESCRIPTION; } } // If a condition is being subparsed, spread the call if (subParsing != SUBPARSING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); } }
public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { if (this.reading == READING_NONE) { if (qName.Equals("animation")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("id")) { animation = new Animation(entry.Value.ToString(), factory); animation.getFrames().Clear(); animation.getTransitions().Clear(); } if (entry.Key.Equals("slides")) { if (entry.Value.ToString().Equals("yes")) { animation.setSlides(true); } else { animation.setSlides(false); } } if (entry.Key.Equals("usetransitions")) { if (entry.Value.ToString().Equals("yes")) { animation.setUseTransitions(true); } else { animation.setUseTransitions(false); } } } } if (qName.Equals("documentation")) { currentstring = string.Empty; } if (qName.Equals("resources")) { currentResources = new ResourcesUni(); foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("name")) { currentResources.setName(entry.Value.ToString()); } } } else if (qName.Equals("asset")) { string type = ""; string path = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("type")) { type = entry.Value.ToString(); } if (entry.Key.Equals("uri")) { path = entry.Value.ToString(); } } currentResources.addAsset(type, path); } if (qName.Equals("frame")) { subParser = new FrameSubParser(animation); reading = READING_FRAME; } if (qName.Equals("transition")) { subParser = new TransitionSubParser(animation); reading = READING_TRANSITION; } } if (reading != READING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); } }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.loader.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is a character tag, store the id of the character if (qName.Equals("character")) { string characterId = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("id")) { characterId = entry.Value.ToString(); } } npc = new NPC(characterId); descriptions = new List <Description>(); npc.setDescriptions(descriptions); } // If it is a resources tag, create the new resources, and switch the element being parsed else if (qName.Equals("resources")) { currentResources = new ResourcesUni(); foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("name")) { currentResources.setName(entry.Value.ToString()); } } reading = READING_RESOURCES; } // If it is an asset tag, read it and add it to the current resources else if (qName.Equals("asset")) { string type = ""; string path = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("type")) { type = entry.Value.ToString(); } if (entry.Key.Equals("uri")) { path = entry.Value.ToString(); } } // If the asset is not an special one //if( !AssetsController.isAssetSpecial( path ) ) currentResources.addAsset(type, path); } // If it is a frontcolor or bordercolor tag, pick the color else if (qName.Equals("frontcolor") || qName.Equals("bordercolor")) { string color = ""; // Pick the color foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("color")) { color = entry.Value.ToString(); } } // Set the color in the npc if (qName.Equals("frontcolor")) { npc.setTextFrontColor(color); } if (qName.Equals("bordercolor")) { npc.setTextBorderColor(color); } } else if (qName.Equals("textcolor")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("showsSpeechBubble")) { npc.setShowsSpeechBubbles(entry.Value.ToString().Equals("yes")); } if (entry.Key.Equals("bubbleBkgColor")) { npc.setBubbleBkgColor(entry.Value.ToString()); } if (entry.Key.Equals("bubbleBorderColor")) { npc.setBubbleBorderColor(entry.Value.ToString()); } } } // If it is a conversation reference tag, store the destination id, and switch the element being parsed else if (qName.Equals("conversation-ref")) { string idTarget = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { idTarget = entry.Value.ToString(); } } conversationReference = new ConversationReference(idTarget); reading = READING_CONVERSATION_REFERENCE; } // If it is a condition tag, create a new subparser else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // If it is a voice tag, take the voice and the always synthesizer option else if (qName.Equals("voice")) { string voice = ""; string response; bool alwaysSynthesizer = false; // Pick the voice and synthesizer option foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("name")) { voice = entry.Value.ToString(); } if (entry.Key.Equals("synthesizeAlways")) { response = entry.Value.ToString(); if (response.Equals("yes")) { alwaysSynthesizer = true; } } } npc.setAlwaysSynthesizer(alwaysSynthesizer); npc.setVoice(voice); } else if (qName.Equals("actions")) { subParser = new ActionsSubParser(chapter, npc); subParsing = SUBPARSING_ACTIONS; } // If it is a description tag, create the new description (with its id) else if (qName.Equals("description")) { description = new Description(); subParser = new DescriptionsSubParser(description, chapter); subParsing = SUBPARSING_DESCRIPTION; } } // If a condition or action is being subparsed, spread the call if (subParsing != SUBPARSING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); } }
/* * (non-Javadoc) * * @see conversationaleditor.xmlparser.ConversationParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is a "conversation" we pick the name, so we can build the tree later if (qName.Equals("tree-conversation")) { // Store the name string conversationName = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("id")) { conversationName = entry.Value.ToString(); } } // Create a dialogue node (which will be the root node) and add it to a new tree // The content of the tree will be built adding nodes directly to the root currentNode = new DialogueConversationNode(); conversation = new TreeConversation(conversationName, currentNode); pastOptionNodes = new List <ConversationNode>(); } // If it is a non-player character line, store the character name and audio path (if present) else if (qName.Equals("speak-char")) { // Set default name to "NPC" characterName = "NPC"; audioPath = ""; foreach (KeyValuePair <string, string> entry in attrs) { // If there is a "idTarget" attribute, store it if (entry.Key.Equals("idTarget")) { characterName = entry.Value.ToString(); } // If there is a "uri" attribute, store it as audio path if (entry.Key.Equals("uri")) { audioPath = entry.Value.ToString(); } // If there is a "synthesize" attribute, store its value if (entry.Key.Equals("synthesize")) { string response = entry.Value.ToString(); if (response.Equals("yes")) { synthesizerVoice = true; } else { synthesizerVoice = false; } } } } // If it is a player character line, store the audio path (if present) else if (qName.Equals("speak-player")) { audioPath = ""; foreach (KeyValuePair <string, string> entry in attrs) { // If there is a "uri" attribute, store it as audio path if (entry.Key.Equals("uri")) { audioPath = entry.Value.ToString(); } // If there is a "synthesize" attribute, store its value if (entry.Key.Equals("synthesize")) { string response = entry.Value.ToString(); if (response.Equals("yes")) { synthesizerVoice = true; } else { synthesizerVoice = false; } } } } // If it is a point with a set of possible responses, create a new OptionNode else if (qName.Equals("response")) { foreach (KeyValuePair <string, string> entry in attrs) { //If there is a "random" attribute, store is the options will be random if (entry.Key.Equals("random")) { if (entry.Value.ToString().Equals("yes")) { random = true; } else { random = false; } } //If there is a "keepShowing" attribute, keep the previous conversation line showing if (entry.Key.Equals("keepShowing")) { if (entry.Value.ToString().Equals("yes")) { keepShowing = true; } else { keepShowing = false; } } //If there is a "showUserOption" attribute, identify if show the user response at option node if (entry.Key.Equals("showUserOption")) { if (entry.Value.ToString().Equals("yes")) { showUserOption = true; } else { showUserOption = false; } } //If there is a "showUserOption" attribute, identify if show the user response at option node if (entry.Key.Equals("preListening")) { if (entry.Value.ToString().Equals("yes")) { preListening = true; } else { preListening = false; } } //If there is a "x" and "y" attributes with the position where the option node has to be painted, if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } } // Create a new OptionNode, and link it to the current node ConversationNode nuevoNodoOpcion = new OptionConversationNode(random, keepShowing, showUserOption, preListening, x, y); currentNode.addChild(nuevoNodoOpcion); // Change the actual node for the option node recently created currentNode = nuevoNodoOpcion; } // If we are about to read an option, change the state of the recognizer, so we can read the line of the // option else if (qName.Equals("option")) { state = STATE_WAITING_OPTION; } // If it is an effect tag, create new effect, new subparser and switch state else if (qName.Equals("effect")) { currentEffects = new Effects(); effectSubParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If there is a go back, link the current node (which will be a DialogueNode) with the last OptionNode // stored else if (qName.Equals("go-back")) { currentNode.addChild(pastOptionNodes[pastOptionNodes.Count - 1]); } } // If an effect element is being subparsed, spread the call if (subParsing == SUBPARSING_EFFECT) { effectSubParser.startElement(namespaceURI, sName, qName, attrs); } }
public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is a name tag, store the name if (qName.Equals("name")) { string soundPath = ""; // if name tag has soundPath attribute, add it to the active area data model foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("soundPath")) { soundPath = entry.Value.ToString(); } } description.setNameSoundPath(soundPath); } // If it is a brief tag, store the brief description else if (qName.Equals("brief")) { string soundPath = ""; // if brief tag has soundPath attribute, add it to the data model foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("soundPath")) { soundPath = entry.Value.ToString(); } } description.setDescriptionSoundPath(soundPath); } // If it is a detailed tag, store the detailed description else if (qName.Equals("detailed")) { string soundPath = ""; // if detailed tag has soundPath attribute, add it to the data model foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("soundPath")) { soundPath = entry.Value.ToString(); } } description.setDetailedDescriptionSoundPath(soundPath); } // If it is a condition tag, create new conditions and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } }// end if subparsing none // If it is reading an effect or a condition, spread the call if (subParsing != SUBPARSING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); } }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.loader.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { //Debug.Log("Start: " + sName + " " + qName + "\nAttr: \n " +CollectionPrinter.PrintCollection(attrs)); newEffect = null; audioPath = string.Empty; //Debug.Log(sName + " " + qName + "\nAttrs: \n" + CollectionPrinter.PrintCollection(attrs)); // If it is a cancel-action tag if (qName.Equals("cancel-action")) { newEffect = new CancelActionEffect(); } // If it is a activate tag else if (qName.Equals("activate")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("flag")) { newEffect = new ActivateEffect(entry.Value.ToString()); chapter.addFlag(entry.Value.ToString()); } } } // If it is a deactivate tag else if (qName.Equals("deactivate")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("flag")) { newEffect = new DeactivateEffect(entry.Value.ToString()); chapter.addFlag(entry.Value.ToString()); } } } // If it is a set-value tag else if (qName.Equals("set-value")) { string var = null; int value = 0; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("var")) { var = entry.Value.ToString(); } else if (entry.Key.Equals("value")) { value = int.Parse(entry.Value.ToString()); } } newEffect = new SetValueEffect(var, value); chapter.addVar(var); } // If it is a set-value tag else if (qName.Equals("increment")) { string var = null; int value = 0; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("var")) { var = entry.Value.ToString(); } else if (entry.Key.Equals("value")) { value = int.Parse(entry.Value.ToString()); } } newEffect = new IncrementVarEffect(var, value); chapter.addVar(var); } // If it is a decrement tag else if (qName.Equals("decrement")) { string var = null; int value = 0; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("var")) { var = entry.Value.ToString(); } else if (entry.Key.Equals("value")) { value = int.Parse(entry.Value.ToString()); } } newEffect = new DecrementVarEffect(var, value); chapter.addVar(var); } // If it is a macro-reference tag else if (qName.Equals("macro-ref")) { // Id string id = null; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("id")) { id = entry.Value.ToString(); } } // Store the inactive flag in the conditions or either conditions newEffect = new MacroReferenceEffect(id); } // If it is a consume-object tag else if (qName.Equals("consume-object")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { newEffect = new ConsumeObjectEffect(entry.Value.ToString()); } } } // If it is a generate-object tag else if (qName.Equals("generate-object")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { newEffect = new GenerateObjectEffect(entry.Value.ToString()); } } } // If it is a speak-char tag else if (qName.Equals("speak-char")) { audioPath = ""; // Store the idTarget, to store the effect when the tag is closed currentCharIdTarget = null; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { currentCharIdTarget = entry.Value.ToString(); } // If there is a "uri" attribute, store it as audio path if (entry.Key.Equals("uri")) { audioPath = entry.Value.ToString(); } } } // If it is a trigger-book tag else if (qName.Equals("trigger-book")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { newEffect = new TriggerBookEffect(entry.Value.ToString()); } } } // If it is a trigger-last-scene tag else if (qName.Equals("trigger-last-scene")) { newEffect = new TriggerLastSceneEffect(); } // If it is a play-sound tag else if (qName.Equals("play-sound")) { // Store the path and background string path = ""; bool background = true; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("background")) { background = entry.Value.ToString().Equals("yes"); } else if (entry.Key.Equals("uri")) { path = entry.Value.ToString(); } } // Add the new play sound effect newEffect = new PlaySoundEffect(background, path); } // If it is a trigger-conversation tag else if (qName.Equals("trigger-conversation")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { newEffect = new TriggerConversationEffect(entry.Value.ToString()); } } } // If it is a trigger-cutscene tag else if (qName.Equals("trigger-cutscene")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { newEffect = new TriggerCutsceneEffect(entry.Value.ToString()); } } } // If it is a trigger-scene tag else if (qName.Equals("trigger-scene")) { string scene = ""; int x = 0; int y = 0; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { scene = entry.Value.ToString(); } else if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } else if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } } newEffect = new TriggerSceneEffect(scene, x, y); } // If it is a play-animation tag else if (qName.Equals("play-animation")) { string path = ""; int x = 0; int y = 0; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("uri")) { path = entry.Value.ToString(); } else if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } else if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } } // Add the new play sound effect newEffect = new PlayAnimationEffect(path, x, y); } // If it is a move-player tag else if (qName.Equals("move-player")) { int x = 0; int y = 0; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } else if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } } // Add the new move player effect newEffect = new MovePlayerEffect(x, y); } // If it is a move-npc tag else if (qName.Equals("move-npc")) { string npcTarget = ""; int x = 0; int y = 0; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { npcTarget = entry.Value.ToString(); } else if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } else if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } } // Add the new move NPC effect newEffect = new MoveNPCEffect(npcTarget, x, y); } // Random effect tag else if (qName.Equals("random-effect")) { int probability = 0; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("probability")) { probability = int.Parse(entry.Value.ToString()); } } // Add the new random effect randomEffect = new RandomEffect(probability); newEffect = randomEffect; readingRandomEffect = true; positiveBlockRead = false; } // wait-time effect else if (qName.Equals("wait-time")) { int time = 0; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("time")) { time = int.Parse(entry.Value.ToString()); } } // Add the new move NPC effect newEffect = new WaitTimeEffect(time); } // show-text effect else if (qName.Equals("show-text")) { x = 0; y = 0; frontColor = 0; borderColor = 0; audioPath = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } else if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } else if (entry.Key.Equals("frontColor")) { frontColor = int.Parse(entry.Value.ToString()); } else if (entry.Key.Equals("borderColor")) { borderColor = int.Parse(entry.Value.ToString()); } // If there is a "uri" attribute, store it as audio path else if (entry.Key.Equals("uri")) { audioPath = entry.Value.ToString(); } } } else if (qName.Equals("highlight-item")) { int type = 0; bool animated = false; string id = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { id = entry.Value.ToString(); } if (entry.Key.Equals("animated")) { animated = (entry.Value.ToString().Equals("yes") ? true : false); } if (entry.Key.Equals("type")) { if (entry.Value.ToString().Equals("none")) { type = HighlightItemEffect.NO_HIGHLIGHT; } if (entry.Value.ToString().Equals("green")) { type = HighlightItemEffect.HIGHLIGHT_GREEN; } if (entry.Value.ToString().Equals("red")) { type = HighlightItemEffect.HIGHLIGHT_RED; } if (entry.Value.ToString().Equals("blue")) { type = HighlightItemEffect.HIGHLIGHT_BLUE; } if (entry.Value.ToString().Equals("border")) { type = HighlightItemEffect.HIGHLIGHT_BORDER; } } } newEffect = new HighlightItemEffect(id, type, animated); } else if (qName.Equals("move-object")) { bool animated = false; string id = ""; int x = 0; int y = 0; float scale = 1.0f; int translateSpeed = 20; int scaleSpeed = 20; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { id = entry.Value.ToString(); } if (entry.Key.Equals("animated")) { animated = (entry.Value.ToString().Equals("yes") ? true : false); } if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("scale")) { scale = float.Parse(entry.Value.ToString(), CultureInfo.InvariantCulture); } if (entry.Key.Equals("translateSpeed")) { translateSpeed = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("scaleSpeed")) { scaleSpeed = int.Parse(entry.Value.ToString()); } } newEffect = new MoveObjectEffect(id, x, y, scale, animated, translateSpeed, scaleSpeed); } else if (qName.Equals("speak-player")) { audioPath = ""; foreach (KeyValuePair <string, string> entry in attrs) { // If there is a "uri" attribute, store it as audio path if (entry.Key.Equals("uri")) { audioPath = entry.Value.ToString(); } } } // If it is a condition tag, create new conditions and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // Not reading Random effect: Add the new Effect if not null if (!readingRandomEffect && newEffect != null) { effects.add(newEffect); // Store current effect currentEffect = newEffect; } // Reading random effect if (readingRandomEffect) { // When we have just created the effect, add it if (newEffect != null && newEffect == randomEffect) { effects.add(newEffect); } // Otherwise, determine if it is positive or negative effect else if (newEffect != null && !positiveBlockRead) { randomEffect.setPositiveEffect(newEffect); positiveBlockRead = true; } // Negative effect else if (newEffect != null && positiveBlockRead) { randomEffect.setNegativeEffect(newEffect); positiveBlockRead = false; readingRandomEffect = false; newEffect = randomEffect; randomEffect = null; } // Store current effect currentEffect = newEffect; } // If it is reading an effect or a condition, spread the call if (subParsing != SUBPARSING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); endElement(namespaceURI, sName, qName); } }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.loader.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is a slidescene tag, create a new slidescene with its id if (qName.Equals("slidescene") || qName.Equals("videoscene")) { string slidesceneId = ""; bool initialScene = false; string idTarget = ""; int x = int.MinValue, y = int.MinValue; int transitionType = 0, transitionTime = 0; string next = "go-back"; bool canSkip = true; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("id")) { slidesceneId = entry.Value.ToString(); } if (entry.Key.Equals("start")) { initialScene = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("idTarget")) { idTarget = entry.Value.ToString(); } if (entry.Key.Equals("destinyX")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("destinyY")) { y = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("transitionType")) { transitionType = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("transitionTime")) { transitionTime = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("next")) { next = entry.Value.ToString(); } if (entry.Key.Equals("canSkip")) { canSkip = entry.Value.ToString().Equals("yes"); } } if (qName.Equals("slidescene")) { cutscene = new Slidescene(slidesceneId); } else { cutscene = new Videoscene(slidesceneId); } if (initialScene) { chapter.setTargetId(slidesceneId); } cutscene.setTargetId(idTarget); cutscene.setPositionX(x); cutscene.setPositionY(y); cutscene.setTransitionType((NextSceneEnumTransitionType)transitionType); cutscene.setTransitionTime(transitionTime); if (cutscene is Videoscene) { ((Videoscene)cutscene).setCanSkip(canSkip); } if (next.Equals("go-back")) { cutscene.setNext(Cutscene.GOBACK); } else if (next.Equals("new-scene")) { cutscene.setNext(Cutscene.NEWSCENE); } else if (next.Equals("end-chapter")) { cutscene.setNext(Cutscene.ENDCHAPTER); } } // If it is a resources tag, create new resources else if (qName.Equals("resources")) { currentResources = new ResourcesUni(); foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("name")) { currentResources.setName(entry.Value.ToString()); } } reading = READING_RESOURCES; } // If it is an asset tag, read it and add it to the current resources else if (qName.Equals("asset")) { string type = ""; string path = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("type")) { type = entry.Value.ToString(); } if (entry.Key.Equals("uri")) { path = entry.Value.ToString(); } } currentResources.addAsset(type, path); } // If it is an end-game tag, store it in the slidescene else if (qName.Equals("end-game")) { cutscene.setNext(Cutscene.ENDCHAPTER); } // If it is a next-scene tag, create the new next scene else if (qName.Equals("next-scene")) { string idTarget = ""; int x = int.MinValue, y = int.MinValue; int transitionType = 0, transitionTime = 0; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { idTarget = entry.Value.ToString(); } if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("transitionType")) { transitionType = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("transitionTime")) { transitionTime = int.Parse(entry.Value.ToString()); } } currentNextScene = new NextScene(idTarget, x, y); currentNextScene.setTransitionType((NextSceneEnumTransitionType)transitionType); currentNextScene.setTransitionTime(transitionTime); reading = READING_NEXT_SCENE; } // If it is a condition tag, create the new condition, the subparser and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // If it is a effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("post-effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } } // If it is reading an effect or a condition, spread the call if (subParsing != SUBPARSING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); } }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.loader.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is a timer tag, create a new timer with its time if (qName.Equals("timer")) { string time = ""; bool usesEndCondition = true; bool runsInLoop = true; bool multipleStarts = true; bool countDown = false, showWhenStopped = false, showTime = false; string displayName = "timer"; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("time")) { time = entry.Value.ToString(); } if (entry.Key.Equals("usesEndCondition")) { usesEndCondition = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("runsInLoop")) { runsInLoop = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("multipleStarts")) { multipleStarts = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("showTime")) { showTime = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("displayName")) { displayName = entry.Value.ToString(); } if (entry.Key.Equals("countDown")) { countDown = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("showWhenStopped")) { showWhenStopped = entry.Value.ToString().Equals("yes"); } } timer = new Timer(long.Parse(time)); timer.setRunsInLoop(runsInLoop); timer.setUsesEndCondition(usesEndCondition); timer.setMultipleStarts(multipleStarts); timer.setShowTime(showTime); timer.setDisplayName(displayName); timer.setCountDown(countDown); timer.setShowWhenStopped(showWhenStopped); } // If it is a condition tag, create the new condition, the subparser and switch the state else if (qName.Equals("init-condition") || qName.Equals("end-condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // If it is a effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("effect") || qName.Equals("post-effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } } // If it is reading an effect or a condition, spread the call if (subParsing != SUBPARSING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); } }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is a object tag, create the new object (with its id) if (qName.Equals("node")) { int x = 0, y = 0; float scale = 1.0f; string id = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("id")) { id = entry.Value.ToString(); } if (entry.Key.Equals("scale")) { scale = float.Parse(entry.Value.ToString(), CultureInfo.InvariantCulture); } } trajectory.addNode(id, x, y, scale); } // If it is a condition tag, create new conditions and switch the state else if (qName.Equals("side")) { string idStart = ""; string idEnd = ""; int length = -1; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idStart")) { idStart = entry.Value.ToString(); } if (entry.Key.Equals("idEnd")) { idEnd = entry.Value.ToString(); } if (entry.Key.Equals("length")) { length = int.Parse(entry.Value.ToString()); } } trajectory.addSide(idStart, idEnd, length); } else if (qName.Equals("initialnode")) { string id = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("id")) { id = entry.Value.ToString(); } } trajectory.setInitial(id); } } // If it is reading an effect or a condition, spread the call if (subParsing != SUBPARSING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); } }