public void Decorate(GameObject go, ParkitectObject PO) { if (go.GetComponent<Waypoints>()) { go.GetComponent<Waypoints>().waypoints = PO.waypoints; } else { go.AddComponent<Waypoints>().waypoints = PO.waypoints; } CustomFlatRide RA = go.AddComponent<CustomFlatRide>(); RA.xSize = (int) PO.XSize; RA.zSize = (int)PO.ZSize; RA.excitementRating = float.Parse(PO.XMLNode["Excitement"].InnerText); RA.intensityRating = float.Parse(PO.XMLNode["Intensity"].InnerText); RA.nauseaRating = float.Parse(PO.XMLNode["Nausea"].InnerText); RestraintRotationController controller = go.AddComponent<RestraintRotationController>(); controller.closedAngles = Loader.getVector3(PO.XMLNode["RestraintAngle"].InnerText); RA.motors = FlatRideLoader.LoadMotors(PO.XMLNode, go, RA); RA.phases = FlatRideLoader.LoadPhases(PO.XMLNode,go,RA); foreach (Phase P in RA.phases) { foreach (RideAnimationEvent RAE in P.Events) { RAE.Check(RA); } } BasicFlatRideSettings(RA); }
public void Decorate(GameObject go, ParkitectObject PO) { string ShaderName; if (go.GetComponent <BuildableObject>() != null && PO.recolorable) { CustomColors cc = go.AddComponent <CustomColors>(); List <Color> colors = new List <Color>(); if (PO.color1 != new Color(0.95f, 0, 0)) { colors.Add(PO.color1); } if (PO.color2 != new Color(0.32f, 1, 0)) { colors.Add(PO.color2); } if (PO.color3 != new Color(0.95f, 0, 0)) { colors.Add(PO.color3); } if (PO.color4 != new Color(1, 0, 1)) { colors.Add(PO.color4); } cc.setColors(colors.ToArray()); ShaderName = "CustomColors" + PO.XMLNode["shader"].InnerText; } else { ShaderName = PO.XMLNode["shader"].InnerText; } foreach (Material material in AssetManager.Instance.objectMaterials) { if (material.name == ShaderName) { SetMaterial(go, material); // edge case for fences Fence fence = go.GetComponent <Fence>(); if (fence != null) { if (fence.flatGO != null) { SetMaterial(fence.flatGO, material); } if (fence.postGO != null) { SetMaterial(fence.postGO, material); } } break; } } }
public void Decorate(GameObject go, ParkitectObject PO) { if (go.GetComponent <Waypoints>()) { go.GetComponent <Waypoints>().waypoints = PO.waypoints; } else { go.AddComponent <Waypoints>().waypoints = PO.waypoints; } CustomFlatRide RA = go.AddComponent <CustomFlatRide>(); RA.xSize = (int)PO.XSize; RA.zSize = (int)PO.ZSize; RA.excitementRating = float.Parse(PO.XMLNode["Excitement"].InnerText); RA.intensityRating = float.Parse(PO.XMLNode["Intensity"].InnerText); RA.nauseaRating = float.Parse(PO.XMLNode["Nausea"].InnerText); RestraintRotationController controller = go.AddComponent <RestraintRotationController>(); controller.closedAngles = Loader.getVector3(PO.XMLNode["RestraintAngle"].InnerText); RA.motors = FlatRideLoader.LoadMotors(PO.XMLNode, go, RA); RA.phases = FlatRideLoader.LoadPhases(PO.XMLNode, go, RA); foreach (Phase P in RA.phases) { foreach (RideAnimationEvent RAE in P.Events) { RAE.Check(RA); } } BasicFlatRideSettings(RA); }
public void LoadFromXML() { XmlDocument doc = new XmlDocument(); string[] files = System.IO.Directory.GetFiles(Path, "*.xml"); doc.Load(files[0]); XmlElement xelRoot = doc.DocumentElement; XmlNodeList ModNodes = xelRoot.SelectNodes("/Mod"); foreach (XmlNode Mod in ModNodes) { modName = Mod["ModName"].InnerText; modDiscription = Mod["ModDiscription"].InnerText; } XmlNodeList ObjectNodes = xelRoot.SelectNodes("/Mod/Objects/Object"); foreach (XmlNode ParkOBJ in ObjectNodes) { ParkitectObject PO = new ParkitectObject(); PO.ObjName = ParkOBJ["OBJName"].InnerText; PO.type = (ParkitectObject.ObjType)Enum.Parse(typeof(ParkitectObject.ObjType), ParkOBJ["Type"].InnerText, true); PO.XSize = float.Parse(ParkOBJ["X"].InnerText); PO.ZSize = float.Parse(ParkOBJ["Z"].InnerText); PO.inGameName = ParkOBJ["inGameName"].InnerText; PO.price = Int32.Parse(ParkOBJ["price"].InnerText); PO.grid = Convert.ToBoolean(ParkOBJ["grid"].InnerText); PO.snapCenter = Convert.ToBoolean(ParkOBJ["snapCenter"].InnerText); PO.heightDelta = Int32.Parse(ParkOBJ["heightDelta"].InnerText); PO.recolorable = Convert.ToBoolean(ParkOBJ["recolorable"].InnerText); if (PO.recolorable) { PO.color1 = HexToColor(ParkOBJ["Color1"].InnerText); PO.color2 = HexToColor(ParkOBJ["Color2"].InnerText); PO.color3 = HexToColor(ParkOBJ["Color3"].InnerText); PO.color4 = HexToColor(ParkOBJ["Color4"].InnerText); } XmlNodeList WaypointsNodes = ParkOBJ.SelectNodes("Waypoints/Waypoint"); foreach (XmlNode xndNode in WaypointsNodes) { Waypoint w = new Waypoint(); w.isOuter = Convert.ToBoolean(xndNode["isOuter"].InnerText); w.isRabbitHoleGoal = Convert.ToBoolean(xndNode["isRabbitHoleGoal"].InnerText); if (xndNode["connectedTo"].InnerText != "") { w.connectedTo = xndNode["connectedTo"].InnerText.Split(',').ToList().ConvertAll(s => Int32.Parse(s)); } w.localPosition = getVector3(xndNode["localPosition"].InnerText); PO.waypoints.Add(w); } PO.XMLNode = ParkOBJ; ParkitectObjects.Add(PO); } UnityEngine.Debug.Log("Loaded from XML in : " + files[0]); }
public void Decorate(GameObject go, ParkitectObject PO) { string ShaderName; if (go.GetComponent<BuildableObject>() != null && PO.recolorable) { CustomColors cc = go.AddComponent<CustomColors>(); List<Color> colors = new List<Color>(); if (PO.color1 != new Color(0.95f, 0, 0)) colors.Add(PO.color1); if (PO.color2 != new Color(0.32f, 1, 0)) colors.Add(PO.color2); if (PO.color3 != new Color(0.95f, 0, 0)) colors.Add(PO.color3); if (PO.color4 != new Color(1, 0, 1)) colors.Add(PO.color4); cc.setColors(colors.ToArray()); ShaderName = "CustomColors" + PO.XMLNode["shader"].InnerText; } else { ShaderName = PO.XMLNode["shader"].InnerText; } foreach (Material material in AssetManager.Instance.objectMaterials) { if (material.name == ShaderName) { SetMaterial(go, material); // edge case for fences Fence fence = go.GetComponent<Fence>(); if (fence != null) { if (fence.flatGO != null) { SetMaterial(fence.flatGO, material); } if (fence.postGO != null) { SetMaterial(fence.postGO, material); } } break; } } }