public object DOMParse(XmlElement element, params object[] parameters) { var mapScene = new MapScene(element.Attributes["id"].Value); var chapter = parameters[0] as Chapter; mapScene.CameraType = ExParsers.ParseEnum <CameraType>(ExString.Default(element.GetAttribute("cameraType"), CameraType.Aerial2D.ToString())); mapScene.RenderStyle = ExParsers.ParseEnum <RenderStyle>(ExString.Default(element.GetAttribute("renderStyle"), RenderStyle.Tile.ToString())); mapScene.TileMetaIdentifier = ExString.Default(element.GetAttribute("tileMetaIdentifier"), "OSMTile"); mapScene.UsesGameplayArea = ExString.EqualsDefault(element.GetAttribute("usesGameplayArea"), "yes", false); mapScene.GameplayArea = ExParsers.ParseDefault(element.GetAttribute("gameplayArea"), new RectD(Vector2d.zero, Vector2d.zero)); mapScene.LatLon = ExParsers.ParseDefault(element.GetAttribute("center"), Vector2d.zero); mapScene.Zoom = ExParsers.ParseDefault(element.GetAttribute("zoom"), 19); bool initialScene = ExString.EqualsDefault(element.GetAttribute("start"), "yes", false); if (initialScene) { chapter.setTargetId(mapScene.getId()); } int layer = 0; foreach (var e in element.SelectNodes("map-element")) { var mapElementNode = e as XmlElement; MapElement mapElement = null; XmlElement extElemNode; var targetId = mapElementNode.GetAttribute("targetId"); if ((extElemNode = (XmlElement)mapElementNode.SelectSingleNode("ext-elem-ref")) != null) { var extElem = new ExtElemReference(targetId); mapElement = extElem; extElem.TransformManagerDescriptor = GetDescriptor(ExString.Default(extElemNode.GetAttribute("transformManager"), typeof(GeopositionedDescriptor).FullName)); foreach (var param in extElem.TransformManagerDescriptor.ParameterDescription) { var paramNode = extElemNode.SelectSingleNode("param[@name=\"" + param.Key + "\"]"); if (paramNode != null) { extElem.TransformManagerParameters.Add(param.Key, parseParam(param.Value.Type, paramNode.InnerText)); } } } else { mapElement = new GeoReference(targetId); } mapElement.Conditions = DOMParserUtility.DOMParse <Conditions>(mapElementNode.SelectSingleNode("condition") as XmlElement, parameters); mapElement.Layer = ExParsers.ParseDefault(mapElementNode.GetAttribute("layer"), layer); mapElement.Scale = ExParsers.ParseDefault(mapElementNode.GetAttribute("scale"), 1f); mapElement.Orientation = (Orientation)ExParsers.ParseDefault(mapElementNode.GetAttribute("orientation"), 2); layer = Mathf.Max(mapElement.Layer, layer) + 1; mapScene.Elements.Add(mapElement); } return(mapScene); }
public void TargetChanged(IChapterTarget target) { if (!string.IsNullOrEmpty(target.getXApiClass()) && target.getXApiClass() == "accesible") { TrackerAsset.Instance.Accessible.Accessed(target.getId(), ExParsers.ParseEnum <AccessibleTracker.Accessible>(target.getXApiType())); TrackerAsset.Instance.Flush(); } UpdateCompletables(completableController => completableController.UpdateMilestones(target)); }
private void trackSceneChange(IChapterTarget target) { if (!string.IsNullOrEmpty(target.getXApiClass()) && target.getXApiClass() == "accesible") { TrackerAsset.Instance.Accessible.Accessed(target.getId(), ExParsers.ParseEnum <AccessibleTracker.Accessible>(target.getXApiType())); TrackerAsset.Instance.Flush(); } CompletablesController.Instance.TargetChanged(target); }
private void TraceExit(bool exited, IChapterTarget targetOnExit) { var ed = area.Element as Exit; // ALTERNATIVE if ("alternative".Equals(targetOnExit.getXApiClass(), IgnoreCase)) { var parsedType = (AlternativeTracker.Alternative)Enum.Parse(typeof(AlternativeTracker.Alternative), targetOnExit.getXApiType(), true); if (ConditionChecker.check(ed.getConditions())) { if (targetOnExit.getXApiType() == "menu") { TrackerAsset.Instance.Alternative.Selected(targetOnExit.getId(), ed.getNextSceneId(), parsedType); } else { TrackerAsset.Instance.setSuccess(true); TrackerAsset.Instance.Alternative.Selected(targetOnExit.getId(), ed.getNextSceneId(), parsedType); } } else { if (targetOnExit.getXApiType() != "menu") { TrackerAsset.Instance.setSuccess(false); TrackerAsset.Instance.Alternative.Selected(targetOnExit.getId(), "Incorrect", parsedType); } } TrackerAsset.Instance.Flush(); } // ACCESIBLE // If no exited, accesible doesnt matter if (!exited) { return; } // If no destination accesible doesnt matter var destination = Game.Instance.GameState.GetChapterTarget(ed.getNextSceneId()); if (destination == null) { return; } if ("accesible".Equals(destination.getXApiClass(), IgnoreCase)) { var type = ExParsers.ParseDefault(destination.getXApiType(), AccessibleTracker.Accessible.Accessible); TrackerAsset.Instance.Accessible.Accessed(destination.getId(), type); } }
private Rect GetSceneRect(SceneDataControl scene) { if (!this.positions.ContainsKey(scene.getId())) { string id = GetScenePropertyId(Controller.Instance.SelectedChapterDataControl, scene); string X = ProjectConfigData.getProperty(id + ".X"); string Y = ProjectConfigData.getProperty(id + ".Y"); positions.Add(scene.getId(), new Vector2(ExParsers.ParseDefault(X, 0), ExParsers.ParseDefault(Y, 0))); } var background = scene.getPreviewBackground(); if (!sizes.ContainsKey(background)) { Texture2D scenePreview = null; Vector2 previewSize = new Vector2(800, 600); if (!images.ContainsKey(background)) { scenePreview = Controller.ResourceManager.getImage(background) ?? Controller.ResourceManager.getImage(SpecialAssetPaths.ASSET_EMPTY_IMAGE); images[background] = scenePreview; } else { scenePreview = images[background]; } if (scenePreview) { previewSize = new Vector2(scenePreview.width, scenePreview.height); } sizes.Add(background, previewSize); Color color; try { var pixel = scenePreview.GetPixel(scenePreview.width / 2, scenePreview.height / 2); var colorAsVector = ToHSV(new Color(1f - pixel.r, 1f - pixel.g, 1f - pixel.b)); colorAsVector.y *= 2f; colorAsVector.z *= 1.5f; color = FromHSV(colorAsVector); } catch { // Error getting the pixel color = UnityEngine.Random.ColorHSV(0f, 1f, 0.8f, 1f, 0.5f, 1f, 1f, 1f); } sceneColors[background] = color; } return(new Rect(positions[scene.getId()], sizes[background] * SceneScaling)); }
public void OnAfterDeserialize() { if (parameters == null) { return; } TransformManagerParameters = new Dictionary <string, object>(); for (int i = 0; i < parameters.Count; i++) { TransformManagerParameters.Add(parameters[i], ExParsers.Parse(values[i], Type.GetType(types[i]))); } }
private static int ExtractFileVersion(string text) { if (string.IsNullOrEmpty(text)) { return(-1); } var xmlDocument = new XmlDocument(); xmlDocument.XmlResolver = null; xmlDocument.LoadXml(text); XmlElement root = xmlDocument.DocumentElement; return(ExParsers.ParseDefault(root.GetAttribute("version"), 0)); }
private static int GetFileVersion(string path, ResourceManager resourceManager) { var xmlText = resourceManager.getText(path); if (string.IsNullOrEmpty(xmlText)) { return(-1); } var xmlDocument = new XmlDocument(); xmlDocument.LoadXml(xmlText); XmlElement root = xmlDocument.DocumentElement; return(ExParsers.ParseDefault(root.GetAttribute("version"), 0)); }
public object DOMParse(XmlElement element, params object[] parameters) { var triggerSceneEffect = new TriggerZonedSceneEffect( element.GetAttribute("idTarget"), element.GetAttribute("zoneId"), int.Parse(element.GetAttribute("x")), int.Parse(element.GetAttribute("y"))) { DestinyScale = ExParsers.ParseDefault(element.GetAttribute("scale"), CultureInfo.InvariantCulture, float.MinValue) }; triggerSceneEffect.setTransitionTime(ExParsers.ParseDefault(element.GetAttribute("transitionTime"), 0)); triggerSceneEffect.setTransitionType((TransitionType)ExParsers.ParseDefault(element.GetAttribute("transitionType"), 0)); return(triggerSceneEffect); }
public object DOMParse(XmlElement element, params object[] parameters) { var trackerConfig = new TrackerConfig(); trackerConfig.setRawCopy(element.GetAttribute("rawCopy") == "yes"); trackerConfig.setHost(element.GetAttribute("host")); trackerConfig.setTrackingCode(element.GetAttribute("trackingCode")); trackerConfig.setDebug(element.GetAttribute("debug") == "yes"); trackerConfig.setFlushInterval(ExParsers.ParseDefault(element.GetAttribute("flushInterval"), 3)); if (element.HasAttribute("storageType")) { trackerConfig.setStorageType(ExParsers.ParseEnum <TrackerConfig.StorageType>(element.GetAttribute("storageType"))); } if (element.HasAttribute("traceFormat")) { trackerConfig.setTraceFormat(ExParsers.ParseEnum <TrackerConfig.TraceFormat>(element.GetAttribute("traceFormat"))); } return(trackerConfig); }
private LoginScene ParseLoginScene(XmlElement element, params object[] parameters) { var background = (XmlElement)element.SelectSingleNode("background"); var login = (XmlElement)element.SelectSingleNode("login"); var token = (XmlElement)element.SelectSingleNode("token"); return(new LoginScene() { // Background BackgroundBorder = ExParsers.ParseDefault(background.GetAttribute("border"), UnityEngine.Color.black), BackgroundColor = ExParsers.ParseDefault(background.GetAttribute("color"), new UnityEngine.Color(1, 1, 1, 0.6f)), BackgroundPath = background.GetAttribute("path"), // Login LoginTitle = login.GetAttribute("title"), LoginColor = ExParsers.ParseDefault(login.GetAttribute("color"), new UnityEngine.Color(1, 1, 1, 0.6f)), // Continue TokenText = token.GetAttribute("token"), TokenPlaceholder = token.GetAttribute("placeholder"), }); }
public Vector2 this[string id] { get { if (!positions.ContainsKey(id)) { var idX = id + X; var idY = id + Y; if (!ProjectConfigData.existsKey(idX)) { ProjectConfigData.setProperty(idX, "0"); } if (!ProjectConfigData.existsKey(idY)) { ProjectConfigData.setProperty(idY, "0"); } var x = ProjectConfigData.getProperty(idX); var y = ProjectConfigData.getProperty(idY); positions.Add(id, new Vector2(ExParsers.ParseDefault(x, 0), ExParsers.ParseDefault(y, 0))); } return(positions[id]); } set { if (value == this[id]) // this[id] forces positions[id] initialization { return; } positions[id] = value; ProjectConfigData.setProperty(id + X, value.x.ToString(CultureInfo.InvariantCulture)); ProjectConfigData.setProperty(id + Y, value.y.ToString(CultureInfo.InvariantCulture)); } }
private SurveyScene ParseSurveyScene(XmlElement element, params object[] parameters) { var background = (XmlElement)element.SelectSingleNode("background"); var open = (XmlElement)element.SelectSingleNode("open"); var cont = (XmlElement)element.SelectSingleNode("continue"); return(new SurveyScene() { // Background BackgroundBorder = ExParsers.ParseDefault(background.GetAttribute("border"), UnityEngine.Color.black), BackgroundColor = ExParsers.ParseDefault(background.GetAttribute("color"), new UnityEngine.Color(1, 1, 1, 0.6f)), BackgroundPath = background.GetAttribute("path"), // Open OpenBorder = ExParsers.ParseDefault(open.GetAttribute("border"), UnityEngine.Color.black), OpenColor = ExParsers.ParseDefault(open.GetAttribute("color"), new UnityEngine.Color(1, 1, 1, 0.6f)), OpenText = open.GetAttribute("text"), // Continue ContinueBorder = ExParsers.ParseDefault(cont.GetAttribute("border"), UnityEngine.Color.black), ContinueColor = ExParsers.ParseDefault(cont.GetAttribute("color"), new UnityEngine.Color(1, 1, 1, 0.6f)), ContinueText = cont.GetAttribute("text"), }); }
private ConfigData(string fileName) { Debug.Log("Loading config data at: " + fileName); this.configFile = fileName; Properties configuration = new Properties(fileName); try { configuration.Reload(fileName); languageFile = configuration.GetProperty("LanguageFile"); aboutFile = configuration.GetProperty("AboutFile"); loadingImage = configuration.GetProperty("LoadingImage"); // Editor editorWindowX = ExParsers.ParseDefault(configuration.GetProperty("EditorWindowX"), int.MaxValue); editorWindowY = ExParsers.ParseDefault(configuration.GetProperty("EditorWindowY"), int.MaxValue); editorWindowW = ExParsers.ParseDefault(configuration.GetProperty("EditorWindowWidth"), int.MaxValue); editorWindowH = ExParsers.ParseDefault(configuration.GetProperty("EditorWindowHeight"), int.MaxValue); engineWindowX = ExParsers.ParseDefault(configuration.GetProperty("EngineWindowX"), int.MaxValue); engineWindowY = ExParsers.ParseDefault(configuration.GetProperty("EngineWindowY"), int.MaxValue); engineWindowW = ExParsers.ParseDefault(configuration.GetProperty("EngineWindowWidth"), int.MaxValue); engineWindowH = ExParsers.ParseDefault(configuration.GetProperty("EngineWindowHeight"), int.MaxValue); debugWindowX = ExParsers.ParseDefault(configuration.GetProperty("DebugWindowX"), int.MaxValue); debugWindowY = ExParsers.ParseDefault(configuration.GetProperty("DebugWindowY"), int.MaxValue); debugWindowW = ExParsers.ParseDefault(configuration.GetProperty("DebugWindowWidth"), int.MaxValue); debugWindowH = ExParsers.ParseDefault(configuration.GetProperty("DebugWindowHeight"), int.MaxValue); showItemReferences_F = bool.Parse(configuration.GetProperty("ShowItemReferences")); showNPCReferences_F = bool.Parse(configuration.GetProperty("ShowNPCReferences")); showStartDialog_F = bool.Parse(configuration.GetProperty("ShowStartDialog")); debugOptions = new DebugSettings(); if (configuration.GetProperty("PaintBoundingAreas") != null) { debugOptions.setPaintBoundingAreas(bool.Parse(configuration.GetProperty("PaintBoundingAreas"))); } if (configuration.GetProperty("PaintGrid") != null) { debugOptions.setPaintGrid(bool.Parse(configuration.GetProperty("PaintGrid"))); } if (configuration.GetProperty("PaintHotSpots") != null) { debugOptions.setPaintHotSpots(bool.Parse(configuration.GetProperty("PaintHotSpots"))); } exportsPath = configuration.GetProperty("ExportsDirectory"); if (exportsPath != null) { ReleaseFolders.setExportsPath(exportsPath); } reportsPath = configuration.GetProperty("ReportsDirectory"); if (reportsPath != null) { ReleaseFolders.setReportsPath(reportsPath); } projectsPath = configuration.GetProperty("ProjectsDirectory"); if (projectsPath != null) { ReleaseFolders.setProjectsPath(projectsPath); } effectSelectorTab = ExParsers.ParseDefault(configuration.GetProperty("EffectSelectorTab"), 0); extraProperties = new Properties(); if (!string.IsNullOrEmpty(configuration.GetProperty("ExtraProperties"))) { extraProperties.ReloadFromString(configuration.GetProperty("ExtraProperties")); } } catch (FileNotFoundException) { checkConsistency(); } catch (IOException) { checkConsistency(); } catch (Exception) { checkConsistency(); } }