Exemple #1
0
        public void loadGlobalVariablesState(string globalVariablesXml)
        {
            XmlSerializer            deserializer       = new XmlSerializer(typeof(DialoguerGlobalVariables));
            XmlReader                xmlReader          = XmlReader.Create(new StringReader(globalVariablesXml));
            DialoguerGlobalVariables newGlobalVariables = (DialoguerGlobalVariables)deserializer.Deserialize(xmlReader);

            //Booleans
            for (int i = 0; i < newGlobalVariables.booleans.Count; i += 1)
            {
                if (i >= globalVariables.booleans.Count)
                {
                    Debug.LogWarning("Loaded Global Boolean Count exceeds existing Global Boolean Count");
                    break;
                }
                globalVariables.booleans[i] = newGlobalVariables.booleans[i];
            }

            //Floats
            for (int i = 0; i < newGlobalVariables.floats.Count; i += 1)
            {
                if (i >= globalVariables.floats.Count)
                {
                    Debug.LogWarning("Loaded Global Float Count exceeds existing Global Float Count");
                    break;
                }
                globalVariables.floats[i] = newGlobalVariables.floats[i];
            }

            //Strings
            for (int i = 0; i < newGlobalVariables.strings.Count; i += 1)
            {
                if (i >= globalVariables.strings.Count)
                {
                    Debug.LogWarning("Loaded Global String Count exceeds existing Global String Count");
                    break;
                }
                globalVariables.strings[i] = newGlobalVariables.strings[i];
            }
        }
		public DialoguerData getDialoguerData(){
			
			#region Global Variables
			List<bool> globalBooleans = new List<bool>();
			List<float> globalFloats = new List<float>();
			List<string> globalStrings = new List<string>();
			
			for(int i = 0; i<globals.booleans.variables.Count; i+=1){
				bool parsedBoolean;
				bool success = bool.TryParse(globals.booleans.variables[i].variable, out parsedBoolean);
				if(!success) Debug.LogWarning("Global Boolean "+i+" did not parse correctly, defaulting to false");
				globalBooleans.Add(parsedBoolean);
			}
			
			for(int i = 0; i<globals.floats.variables.Count; i+=1){
				float parsedFloat;
				bool success = float.TryParse(globals.floats.variables[i].variable, out parsedFloat);
				if(!success) Debug.LogWarning("Global Float "+i+" did not parse correctly, defaulting to 0");
				globalFloats.Add(parsedFloat);
			}
			
			for(int i = 0; i<globals.strings.variables.Count; i+=1){
				globalStrings.Add(globals.strings.variables[i].variable);
			}

			DialoguerGlobalVariables newGlobalVariables = new DialoguerGlobalVariables(globalBooleans, globalFloats, globalStrings);
			#endregion
			
			#region Dialogues
			List<DialoguerDialogue> newDialogues = new List<DialoguerDialogue>();
			
			// Loop through Dialogues
			for(int d = 0; d<this.dialogues.Count; d+=1){
				DialogueEditorDialogueObject dialogue = dialogues[d];
				
				#region Dialogue Phases
				List<AbstractDialoguePhase> newPhases = new List<AbstractDialoguePhase>();
				// Loop through phases
				for(int p = 0; p<dialogue.phases.Count; p+=1){
					DialogueEditorPhaseObject phase = dialogue.phases[p];
					
					switch(phase.type){
						
						case DialogueEditorPhaseTypes.TextPhase:
							newPhases.Add(new TextPhase(phase.text, phase.theme, phase.newWindow, phase.name, phase.portrait, phase.metadata, phase.audio, phase.audioDelay, phase.rect, phase.outs));
						break;
						
						case DialogueEditorPhaseTypes.BranchedTextPhase:
							newPhases.Add(new BranchedTextPhase(phase.text, phase.choices, phase.theme, phase.newWindow, phase.name, phase.portrait, phase.metadata, phase.audio, phase.audioDelay, phase.rect, phase.outs));
						break;
						
						case DialogueEditorPhaseTypes.WaitPhase:
							newPhases.Add(new WaitPhase(phase.waitType, phase.waitDuration, phase.outs));
						break;
						
						case DialogueEditorPhaseTypes.SetVariablePhase:
							newPhases.Add(new SetVariablePhase(phase.variableScope, phase.variableType, phase.variableId, phase.variableSetEquation, phase.variableSetValue, phase.outs));
						break;
						
						case DialogueEditorPhaseTypes.ConditionalPhase:
							newPhases.Add(new ConditionalPhase(phase.variableScope, phase.variableType, phase.variableId, phase.variableGetEquation, phase.variableGetValue, phase.outs));
						break;
						
						case DialogueEditorPhaseTypes.SendMessagePhase:
							newPhases.Add(new SendMessagePhase(phase.messageName, phase.metadata, phase.outs));
						break;
						
						case DialogueEditorPhaseTypes.EndPhase:
							newPhases.Add(new EndPhase());
						break;
						
						default:
						 newPhases.Add(new EmptyPhase());
						break;
						
					}
				}
				#endregion
				
				#region Dialogue Variables
				//Booleans
				List<bool> localBooleans = new List<bool>();
				for(int i = 0; i<dialogue.booleans.variables.Count; i+=1){
					bool newBoolean;
					bool success = bool.TryParse(dialogue.booleans.variables[i].variable, out newBoolean);
					if(!success) Debug.Log("Dialogue "+d+": Boolean "+i+" not formatted correctly. Defaulting to false");
					localBooleans.Add(newBoolean);
				}
				
				//Floats
				List<float> localFloats = new List<float>();
				for(int i = 0; i<dialogue.floats.variables.Count; i+=1){
					float newFloat;
					bool success = float.TryParse(dialogue.floats.variables[i].variable, out newFloat);
					if(!success) Debug.Log("Dialogue "+d+": Float "+i+" not formatted correctly. Defaulting to 0");
					localFloats.Add(newFloat);
				}
				
				//Strings
				List<string> localStrings = new List<string>();
				for(int i = 0; i<dialogue.strings.variables.Count; i+=1){
					localStrings.Add(dialogue.strings.variables[i].variable);
				}
				
				DialoguerVariables localVariables = new DialoguerVariables(localBooleans, localFloats, localStrings);
				#endregion
				
				DialoguerDialogue newDialogue = new DialoguerDialogue(dialogue.name, dialogue.startPage, localVariables, newPhases);
				//Debug.Log(newDialogue.ToString());
				newDialogues.Add(newDialogue);
			}
			#endregion
			
			#region Themes
			List<DialoguerTheme> newThemes = new List<DialoguerTheme>();
			for(int i = 0; i<themes.themes.Count; i+=1){
				newThemes.Add(new DialoguerTheme(themes.themes[i].name, themes.themes[i].linkage));
			}
			#endregion
			
			DialoguerData newData = new DialoguerData(newGlobalVariables, newDialogues, newThemes);
			return newData;
		}
Exemple #3
0
 public DialoguerData(DialoguerGlobalVariables globalVariables, List <DialoguerDialogue> dialogues, List <DialoguerTheme> themes)
 {
     this.globalVariables = globalVariables;
     this.dialogues       = dialogues;
     this.themes          = themes;
 }
Exemple #4
0
		public DialoguerData(DialoguerGlobalVariables globalVariables, List<DialoguerDialogue> dialogues, List<DialoguerTheme> themes){
			this.globalVariables = globalVariables;
			this.dialogues = dialogues;
			this.themes = themes;
		}