// GetExtraProperties, GetFullProeperties, GetDeepProperties public static SimpleJSON.JSONClass GetUeoBaseProps(SimpleJSON.JSONClass obj, UserEditableObject ueo, SceneSerializationType serializationType) { // oops -- we are setting "all" the properties including rotation and position. This SHOULD be warpped in USerEditableObject but we didn't do it that way // and a refactor would risk breaking existing levels, // so for now we leave ueo.setprops / ueo.getprops as a "higher level" properties, where as THIS BaseProps is the "full" properties of the object if (obj == null) { Debug.LogError("null obj"); return(obj); } else if (ueo == null) { Debug.LogError("ueo null for " + obj["name"] + ", str;" + obj.ToString()); return(obj); } obj["name"] = ueo.GetName; obj["position"] = JsonUtil.GetTruncatedPosition(ueo.transform); obj["rotation"] = JsonUtil.GetRotation(ueo.transform); obj["active"].AsBool = ueo.gameObject.activeSelf; if (serializationType == SceneSerializationType.Instance) { obj[JsonUtil.scaleKey].AsInt = JsonUtil.GetScaleAsInt(ueo.transform); } obj["properties"] = ueo.GetProperties(); return(obj); }
bool ObjectIsSerializeable(UserEditableObject ueo, SceneSerializationType serializationType) { switch (serializationType) { case SceneSerializationType.Class: if (ueo.isSerializeableForClass) { return(true); } break; case SceneSerializationType.Instance: if (ueo.IsSerializeableForSceneInstance()) { return(true); } break; default: return(false); break; } return(false); }
// public List<LevelBuilderEventObject> GetUeoGroupFromObject(UserEditableObject ueo){ // // We need to re-assign the newly undone (redone?) creation (destruction?) of // //an object because whenever obejcts are RE created they lose their original ueo reference in the events list (pastEvents or futureEvents) // List<LevelBuilderEventObject> lbeos = new List<LevelBuilderEventObject>(); // lbeos.Add(new LevelBuilderEventObject(ueo,ueo.GetUuid(),JsonUtil.GetUeoBaseProps(new SimpleJSON.JSONClass(),ueo,SceneSerializationType.Class))); // return lbeo; // // } // public void RegisterModifyEvent(GameObject p) { if (pastEvents.Count > 0) { // Debug.Log("past ev > 0"); UserEditableObject ueo = p.GetComponent <UserEditableObject>(); if (ueo && ueo == pastEvents[pastEvents.Count - 1].lbeos[0].ueo) { if (pastEvents[pastEvents.Count - 1].lbeos[0].N.ToString() == JsonUtil.GetUeoBaseProps(new SimpleJSON.JSONClass(), ueo, SceneSerializationType.Class).ToString() && pastEvents[pastEvents.Count - 1].type == LevelBuilderEventType.Modified ) { if (debug) { Debug.Log("<color=fff>Register</color> Could not modify..dupe;" + pastEvents.Count); } return; } else { // Debug.Log("s1;"+pastEvents[pastEvents.Count-1].lbeos[0].N.ToString()); // Debug.Log("s2;"+JsonUtil.GetUeoBaseProps(new SimpleJSON.JSONClass(), ueo,SceneSerializationType.Class).ToString()); } } } else { } RegisterLevelBuilderEvent(p.GetComponentsInChildren <UserEditableObject>(), LevelBuilderEventType.Modified); // Debug.Log("<color=fff>Register</color> Could not modify..pastcount;"+pastEvents.Count); }
override public void OnMenuOpened() { if (LevelBuilder.inst.currentPiece) { UserEditableObject ueo = LevelBuilder.inst.currentPiece.GetComponent <UserEditableObject>(); tagsInput.text = string.Join(",", ueo.myTags.ToArray()); } }
public void Undo() { if (pastEvents.Count > 0) { LevelBuilderEvent ue = pastEvents[pastEvents.Count - 1]; if (debug) { Debug.Log("<color=#9f9>Undo: " + ue.type + "</color> ueos:"); } switch (ue.type) { case LevelBuilderEventType.Create: foreach (LevelBuilderEventObject lbeo in ue.lbeos) { if (lbeo.ueo) { Destroy(lbeo.ueo.gameObject); } } break; case LevelBuilderEventType.Delete: List <LevelBuilderEventObject> replacementGroup = new List <LevelBuilderEventObject>(); foreach (LevelBuilderEventObject lbeo in ue.lbeos) { if (debug) { Debug.Log("<color=5f5>Creating (undo)</color>: " + lbeo.uuid); } UserEditableObject ueo = LevelBuilderObjectManager.inst.PlaceObject(lbeo.N, SceneSerializationType.Class, lbeo.uuid); replacementGroup.Add(new LevelBuilderEventObject(ueo, lbeo.uuid, JsonUtil.GetUeoBaseProps(new SimpleJSON.JSONClass(), ueo, SceneSerializationType.Class))); ReconnectBrokenUuidsForUndeletedObjects(ueo, lbeo.uuid); } ue.lbeos = replacementGroup; break; case LevelBuilderEventType.Modified: foreach (LevelBuilderEventObject lbeo in ue.lbeos) { // Debug.Log("undo mod;"+kvp.Key.myName); lbeo.ueo.SetProperties(lbeo.N); lbeo.ueo.SetTransformProperties(lbeo.N); // JsonUtil.SetUeoTransformProps(kvp.key, kvp.Value); } break; default: break; } futureEvents.Add(ue); pastEvents.Remove(ue); } }
public void ResetTaggedObjects() { foreach (UserEditableObject ueo in GetMatchingTaggedObjects()) { SimpleJSON.JSONClass obj = JsonUtil.GetUeoBaseProps(new SimpleJSON.JSONClass(), ueo, SceneSerializationType.Instance); UserEditableObject u2 = LevelBuilderObjectManager.inst.PlaceObject(obj, SceneSerializationType.Instance); // object is now fresh and new. u2.OnLevelBuilderObjectCreated(); u2.OnGameStarted(); Destroy(ueo.gameObject); } }
public bool TypeIsRegisterable(UserEditableObject ueo) { if (ueo.GetType() == typeof(UEO_DraggingParent)) { return(false); } if (ueo.GetType() == typeof(PlayerStart)) { return(false); } return(true); }
public void Redo() { if (futureEvents.Count > 0) { LevelBuilderEvent ue = futureEvents[futureEvents.Count - 1]; if (debug) { Debug.Log("<color=#9f9>Redo: " + ue.type + "</color> ueos:"); } switch (ue.type) { case LevelBuilderEventType.Create: List <LevelBuilderEventObject> replacementGroup = new List <LevelBuilderEventObject>(); foreach (LevelBuilderEventObject lbeo in ue.lbeos) { if (debug) { Debug.Log("<color=5f5>Creating (</color><color=44f>do</color>): " + lbeo.uuid); } UserEditableObject ueo = LevelBuilderObjectManager.inst.PlaceObject(lbeo.N, SceneSerializationType.Class, lbeo.uuid); replacementGroup.Add(new LevelBuilderEventObject(ueo, ueo.GetUuid(), JsonUtil.GetUeoBaseProps(new SimpleJSON.JSONClass(), ueo, SceneSerializationType.Class))); ReconnectBrokenUuidsForUndeletedObjects(ueo, ueo.GetUuid()); } ue.lbeos = replacementGroup; break; case LevelBuilderEventType.Delete: foreach (LevelBuilderEventObject lbeo in ue.lbeos) { if (lbeo.ueo) { Destroy(lbeo.ueo.gameObject); } } break; case LevelBuilderEventType.Modified: foreach (LevelBuilderEventObject lbeo in ue.lbeos) { lbeo.ueo.SetProperties(lbeo.N); lbeo.ueo.SetTransformProperties(lbeo.N); } break; default: break; // Debug.Log("redoing properties of:"+ue.obj.name+", set prop to:"+ue.prop.ToString()); // ue.obj.GetComponent<UserEditableObject>().SetProperties(ue.prop); } futureEvents.Remove(ue); pastEvents.Add(ue); } }
void Start() { rend = GetComponent <Renderer>(); moveSpeed = Vector3.Distance(A.position, B.position); // clearColor = rend.material.color; ueo = transform.root.GetComponent <UserEditableObject>(); if (!ueo) { Destroy(gameObject); } // StopLooping(); }
public override void OnMarkerMenuClosed() { base.OnMarkerMenuClosed(); foreach (Transform t in transform) { UserEditableObject ueo = t.GetComponent <UserEditableObject>(); if (ueo) { ueo.OnMarkerMenuClosed(); } } // WebGLComm.inst.Debug("<color=#f0f>DP:</color>menu closed"); UnparentAll(); }
public void SetTags() { if (LevelBuilder.inst.currentPiece) { UserEditableObject ueo = LevelBuilder.inst.currentPiece.GetComponent <UserEditableObject>(); ueo.ClearTags(); if (tagsInput.text != "") { List <string> ts = new List <string>(); ts.AddRange(tagsInput.text.Replace(" ", string.Empty).Split(',')); ueo.AddTags(ts); // Debug.Log("ueo name;"+ueo.myName+",tags:"+ueo.tags[0]); } } }
// Freshly populate the placed objects // public List<LevelBuilderSelectableObject> GetPlacedObjects(SceneSerializationType type){ // LevelBuilderSelectableObject // return ueos; // } public UserEditableObject PlaceObject(SimpleJSON.JSONClass N, SceneSerializationType type, int uuid = -1) { // Debug.Log("placing:"+N["name"]); GameObject objToPlace = GetPrefabInstanceFromName(N["name"].Value); bool objActiveState = true; if (N.GetKeys().Contains("active")) { // Debug.Log("obj active;"+N["active"].ToString()); objActiveState = N["active"].AsBool; // if the object has this information, it might have been inactive when it was serialized. } if (objToPlace == null) { Debug.Log("<color=red>obj null</color>:" + N["name"]); return(null); } objToPlace.transform.position = JsonUtil.GetRealPositionFromTruncatedPosition(N); // objToPlace.name += Random.Range(0,100000); objToPlace.transform.rotation = JsonUtil.GetRealRotationFromJsonRotation(N); SimpleJSON.JSONClass props = (SimpleJSON.JSONClass)N["properties"]; UserEditableObject ueo = objToPlace.GetComponent <UserEditableObject>(); if (uuid != -1) { props[UserEditableObject.uuidKey].AsInt = uuid; } else if (N.GetKeys().Contains(UserEditableObject.uuidKey)) { props[UserEditableObject.uuidKey].AsInt = N[UserEditableObject.uuidKey].AsInt; } ueo.OnLevelBuilderObjectCreated(); ueo.SetProperties(props); if (LevelBuilder.inst.levelBuilderIsShowing) { ueo.OnLevelBuilderObjectPlaced(); } if (!objActiveState) { objToPlace.SetActive(objActiveState); } // Debug.Log("Built;"+ueo.name+"at :"+ueo.transform.position); return(ueo); }
void MachineSolved(bool levelWasJustLoaded = false) { foreach (GameObject o in machinesToStart) { UserEditableObject ueo = o.GetComponent <UserEditableObject>(); ueo.StartMachine(levelWasJustLoaded); } finished = true; Destroy(resetLever); AudioManager.inst.PlayElectricArc(transform.position, 1, 1); StartCoroutine(LightningFX(liquidLevel, 10, 5)); StartCoroutine(LightningFX(indicatorArrow, 15, 3)); StartCoroutine(LightningFX(machinesToStart[0].transform, 10, 7)); SinTransparency st = liquidLevel.gameObject.AddComponent <SinTransparency>(); st.amplitude = 1.1f; st.frequency = 7; // indicatorArrow.gameObject.SetActive(false); }
public int SaveDragParentToClipboard(GameObject draggingParent) { // User clicked "save clipboard" icon on the marker menu // Save to the next available slot if available. int slot = GetFirstAvailableClipboardSlot(); if (slot == -1) { // Debug.Log("<color=#f00>No clip </color> was avail"); return(slot); } // Saves to the next available slip if there is one // if none, a dialogue pops saying "No more clipboard snips available! Delete one by clicking the red X" // move clipboard icon from obj marker menu to clipboard icon in top right. GameObject fx = (GameObject)Instantiate(LevelBuilder.inst.markerMenuClipBoardGroup.transform.GetChild(0).gameObject, LevelBuilder.inst.markerMenuClipBoardGroup.transform.GetChild(0).position, LevelBuilder.inst.markerMenuClipBoardGroup.transform.GetChild(0).rotation); fx.transform.SetParent(LevelBuilder.inst.markerMenuClipBoardGroup.transform); LevelBuilder.inst.AddFXObject(fx, UIValueCommClipboard.inst.clipboardUiElements[slot].position); // UIValueCommClipboard.inst.ClipboardSaved(slot); List <UserEditableObject> ueos = new List <UserEditableObject>(); foreach (Transform t in draggingParent.transform) { UserEditableObject ueo = t.GetComponent <UserEditableObject>(); if (ueo) { // should ALWAYS have ueo.. but this is fragile! What if drag parent somehow dragging a piece that ISNT Ueo? ueos.Add(ueo); } } SaveClipboardSnip(slot, JsonLevelSaver.inst.SerializeUserEditableObjects(ueos)); AudioManager.inst.PlayWingFlap(Player.inst.transform.position); SaveClipboardToServer(); return(slot); }
public void PasteDraggingParentFromClipboard(int i) { // Ireally, really don't like how I'm accessing a bunch of LevelBuilder objects here like draggingparent and current piece and draggingpicesesbucket. Oh well. // AudioManager.inst.LevelBuilderPreview(); AudioManager.inst.PlayInventoryClose(); // User saved smething on clipboard and now wants to instantiate it. if (clipboardSnips[i] == null) { // Debug.Log("<color=#f00>No snip </color>at i:"+i); return; } SimpleJSON.JSONArray clipboardArray = clipboardSnips[i]; List <GameObject> draggingPiecesToCreate = new List <GameObject>(); List <UserEditableObject> ueos = new List <UserEditableObject>(); foreach (SimpleJSON.JSONClass n in clipboardArray) { // Create the objects from string memory. UserEditableObject ueo = LevelBuilderObjectManager.inst.PlaceObject(n, SceneSerializationType.Class); ueos.Add(ueo); // for group manager // Note that this creates the peice wherever it was in world space when the copy was made, so we'll reposition the items to current mouse pos after creation. draggingPiecesToCreate.Add(ueo.gameObject); } LevelBuilder.inst.draggingParent = LevelBuilder.inst.MakeDraggingParentWithPieces(draggingPiecesToCreate); // group these objects together for selection nd select them RaycastHit hit = new RaycastHit(); if (Physics.Raycast(LevelBuilder.inst.camSky.transform.position, LevelBuilder.inst.camSky.transform.forward, out hit)) { // Debug.Log("hitp:"+hit.point); LevelBuilder.inst.draggingParent.transform.position = hit.point; // reposition drag parent LevelBuilder.inst.currentPiece = LevelBuilder.inst.draggingParent; LevelBuilder.inst.BeginMovingObject(); LevelBuilderGroupManager.inst.MakeGroup(ueos); // PlaceContextMenu(draggingParent); } else { // Debug.Log("nohit"); // Finisheddr Destroy(LevelBuilder.inst.draggingParent); } }
public List <UserEditableObject> GroupContainingObject(UserEditableObject ueo) { if (debug) { Debug.Log("checking if obj " + ueo.GetUuid() + " is in a group."); } CleanGroups(); foreach (List <UserEditableObject> gr in groups) { if (gr.Contains(ueo)) { if (debug) { Debug.Log("It was!"); } return(gr); } } return(new List <UserEditableObject>()); }
public void ReconnectBrokenUuidsForUndeletedObjects(UserEditableObject ueo, int uuid) { // Debug.Log("Trying to reconnect uuid :"+uuid); List <LevelBuilderEvent> allEvents = new List <LevelBuilderEvent>(); allEvents.AddRange(pastEvents); allEvents.AddRange(futureEvents); foreach (LevelBuilderEvent ev in allEvents) { foreach (LevelBuilderEventObject lbeo in ev.lbeos) { if (lbeo.uuid == uuid) { lbeo.ueo = ueo; // Debug.Log("reconnecting:"+lbeo.ueo.name+" to id;"+uuid); } else { // Debug.Log(lbeo.ueo.GetUuid()+"!="+uuid); } } } }
GhostTarget GetTarget() { // Debug.Log("getting target:"); GhostTarget newTarget = new GhostTarget(); if (moveObj) { return(new GhostTarget(moveObj.GetComponent <UserEditableObject>(), moveObj.transform.position)); } if (copyObj) { return(new GhostTarget(copyObj.GetComponent <UserEditableObject>(), copyObj.transform.position)); } if (Utils.IntervalElapsed(0.5f) || GetUserInputThisFrame()) { float closest = Mathf.Infinity; // RaycastHit hit = new RaycastHit(); float maxDist = copyObj || moveObj ? 160f : 80f; float radius = copyObj || moveObj ? 10f : 2f; activeObj.Text = ""; activeTarget = null; foreach (RaycastHit hit in Physics.SphereCastAll(new Ray(transform.position, transform.forward), radius, maxDist)) { UserEditableObject ueo = hit.collider.transform.root.GetComponent <UserEditableObject>(); if (ueo && hit.distance < closest) { closest = hit.distance; newTarget.ueo = ueo; newTarget.p = hit.point; activeObj.Text = newTarget.ueo.myName; } } } return(newTarget); }
void CreateTowerPiece(int i) { Fraction fr = baseFraction; if (info.type == NumberTowerType.Simple) { // fr is always base fraction. } if (info.type == NumberTowerType.Addition) { fr = Fraction.Add(baseFraction, Fraction.Multiply(new Fraction(i, 1), baseFraction)); } else if (info.type == NumberTowerType.Multiplication) { fr = new Fraction(Mathf.Pow(baseFraction.numerator, i), baseFraction.denominator); } GameObject towerPiece = null; if (i == towerHeightMin - 1) { // Debug.Log("fr:"+fr); if (info.type == NumberTowerType.Simple) { towerPiece = NumberManager.inst.CreateNumber(fr, transform.position, NumberShape.Face); } else if (info.type == NumberTowerType.Addition) { towerPiece = NumberManager.inst.CreateNumber(fr, transform.position, NumberShape.SimpleHat); } else if (info.type == NumberTowerType.Multiplication) { towerPiece = NumberManager.inst.CreateNumber(fr, transform.position, NumberShape.Hat); } } else { towerPiece = NumberManager.inst.CreateNumber(fr, transform.position, NumberShape.Sphere); } towerPiece.GetComponent <NumberInfo>().numberChangedDelegate += ChildChanged; towerPiece.GetComponent <NumberInfo>().numberDestroyedDelegate += RemoveChildChanged; towerPiece.transform.parent = transform; UserEditableObject ueo = towerPiece.GetComponent <UserEditableObject>(); ueo.isSerializeableForSceneInstance = false; NumberInfo ni = towerPiece.GetComponent <NumberInfo>(); Destroy(ni.GetComponent <PickUppableObject>()); ni.GetComponent <Rigidbody>().isKinematic = true; ni.GetComponent <Rigidbody>().useGravity = false; ni.transform.localScale = Vector3.one * pieceSize; MonsterAIRevertNumber mairn = towerPiece.AddComponent <MonsterAIRevertNumber>(); mairn.SetNumber(ni.fraction); if (towerPieces.ContainsKey(i)) { // if (towerPieces[i] && towerPieces[i].gameObject){ // Destroy(towerPieces[i].gameObject); // } } towerPieces.Add(i, ni); float pitch = 0.5f + 0.5f * ((i + 1f) / (towerHeightMin)); // Debug.Log("pitch "+pitch+" for i:"+i); if (!LevelBuilder.inst.levelBuilderIsShowing) { AudioManager.inst.PlayBubblePop(transform.position, pitch); } // ni.childMeshRenderer.enabled = false; // ni.outlineMesh.enabled = false; // these are invisible by default, we want to enable them SetPositionForTowerPiece(i); EffectsManager.inst.RevertSparks(ni.transform.position, 2); }
public GhostTarget(UserEditableObject ueo2 = null, Vector3 p2 = default(Vector3)) { ueo = ueo2; p = p2; }
void LateUpdate() { if (!LevelBuilder.inst.levelBuilderIsShowing) { return; } float fadeSpeed = 3f; Color newc = Color.Lerp(lr.material.color, Color.clear, Time.unscaledDeltaTime * fadeSpeed); lr.material.SetColor("_Color", newc); lineTimer -= Time.unscaledDeltaTime; destroyTimer -= Time.unscaledDeltaTime; if (lineTimer < 0) { lr.SetVertexCount(0); } else { } // if (Input.GetMouseButtonDown(0)){ // JsonLevelSaver.inst.LevelBuilderUndo(); // } activeTarget = GetTarget(); if (activeTarget == null) { return; } UserEditableObject ueo = activeTarget.ueo; if (!ueo) { moveObj = null; copyObj = null; return; } if (Input.GetKey(KeyCode.Backspace) && destroyTimer < 0) { if (LevelBuilder.inst.levelBuilderIsShowing) { if (activeTarget.ueo) { destroyTimer = 0.5f; LevelBuilder.inst.DeleteObject(activeTarget.ueo.gameObject); DrawTargetLine(Color.red, activeTarget.p); } } } float wd = Input.mouseScrollDelta.y; // could be 0.1, 0.5, or 4, 5 agt high speeds if (wd != 0) { wd = wd > 0 ? Mathf.Max(wd, 0.5f) : Mathf.Min(-0.5f, wd); ueo.transform.position += Vector3.up * Mathf.RoundToInt((wd * 0.5f) * 4) * 0.5f; DrawTargetLine(Color.blue, activeTarget.p); } float moveFactor = 0.5f; if (Input.GetKey(KeyCode.RightBracket)) { ueo.transform.position += Vector3.up * moveFactor; DrawTargetLine(Color.green, activeTarget.p); } else if (Input.GetKey(KeyCode.LeftBracket)) { ueo.transform.position += Vector3.down * moveFactor; DrawTargetLine(Color.green, activeTarget.p); } else if (Input.GetKey(KeyCode.F)) { ueo.transform.position += Utils.FlattenVector(transform.forward).normalized *moveFactor; DrawTargetLine(Color.green, activeTarget.p); } else if (Input.GetKey(KeyCode.B)) { ueo.transform.position += Utils.FlattenVector(-transform.forward).normalized *moveFactor; DrawTargetLine(Color.green, activeTarget.p); } else if (Input.GetKey(KeyCode.R)) { ueo.transform.position += Utils.FlattenVector(transform.right).normalized *moveFactor; DrawTargetLine(Color.green, activeTarget.p); } else if (Input.GetKey(KeyCode.L)) { ueo.transform.position += Utils.FlattenVector(-transform.right).normalized *moveFactor; DrawTargetLine(Color.green, activeTarget.p); } else if (Input.GetKeyDown(KeyCode.Equals)) { UEO_ScaleManipulator scale = ueo.GetComponentInChildren <UEO_ScaleManipulator>(); if (scale) { scale.transform.localScale += scale.scaleFactor * Vector3.one; DrawTargetLine(Color.magenta, activeTarget.p); } } else if (Input.GetKeyDown(KeyCode.Minus)) { UEO_ScaleManipulator scale = ueo.GetComponentInChildren <UEO_ScaleManipulator>(); if (scale) { scale.transform.localScale -= scale.scaleFactor * Vector3.one; DrawTargetLine(Color.magenta, activeTarget.p); } } if (Input.GetKeyDown(KeyCode.C)) { carryingCopyObjecty = true; copyObj = LevelBuilder.inst.DuplicateObject(ueo.transform.position, ueo.gameObject); copyObjDist = Vector3.Distance(copyObj.transform.position, transform.position); } if (copyObj) { copyObj.transform.position = transform.position + transform.forward * copyObjDist; DrawTargetLine(Color.yellow, copyObj.transform.position); } if (Input.GetKeyUp(KeyCode.C)) { copyObj = null; carryingCopyObjecty = false; } int shift = Input.GetKey(KeyCode.LeftShift) ? 9 : 1; // if hold shift, rotate 45 degrees instead of 5 if (Input.GetMouseButtonDown(1)) { ueo.transform.Rotate(Vector3.up, 5 * shift); DrawTargetLine(Color.green, ueo.transform.position); } if (Input.GetMouseButtonDown(2)) { ueo.transform.Rotate(Vector3.up, -5 * shift); DrawTargetLine(Color.green, ueo.transform.position); } if (Input.GetMouseButtonDown(0)) { // hold right mouse to begin moving // Debug.Log("mousdown got:"+moveObj); moveObj = ueo.gameObject; moveObjOffset = transform.InverseTransformVector(moveObj.transform.position - transform.position); // moveObjDist = Vector3.Distance(moveObj.transform.position,transform.position); } if (moveObj) { moveObj.transform.position = transform.position + transform.TransformVector(moveObjOffset); // moveObj.transform.position = transform.position + transform.forward * moveObjDist + moveObjOffset; DrawTargetLine(Color.blue, transform.position + transform.forward * 10f); } if (Input.GetMouseButtonUp(0)) { moveObj = null; } }
SimpleJSON.JSONClass LoadLevelClass(SimpleJSON.JSONClass N, bool centerOnPlayer = true) { // ttransition2 // WebGLComm.inst.Debug("UTY.levelloader. load leve Class."); // TODO: Figure out what the screenshot camera is and preload it // Screenshotter.DefaultCAmera.position,rotation = x LevelBuilder.inst.currentPiece = null; // lose previous reference in case of leftover bs from last edit session. LevelBuilder.inst.UserFinishedPlacingObject(); if (N["Tags"] == null || N["Tags"] == "") { LevelBuilder.inst.levelTagsInput.text = "None"; } else { LevelBuilder.inst.levelTagsInput.text = N["Tags"]; } if (N["Description"] == null || N["Description"] == "") { LevelBuilder.inst.levelDescriptionInput.text = "No description"; } else { LevelBuilder.inst.levelDescriptionInput.text = Utils.FakeToRealQuotes(N["Description"]); } int i = 0; int totalObjectsToPlace = N["Objects"].AsArray.Childs.Count(); string objectsString = ""; Debug.Log("objs len:" + totalObjectsToPlace); Debug.Log("objs contetsn:" + N["Objects"].ToString()); foreach (SimpleJSON.JSONClass levelObj in N["Objects"].AsArray.Childs) { // Debug.Log("n array:"+i+", name:"+levelObj.ToString()); i++; // if (i > 5) continue; // if (levelObj["name"].Value == "Stella" || levelObj["name"].Value == "Generic Character") continue; // oops, these are severely corrupted somehow and placing a ton of them // Debug.Log("placing:"+levelObj["name"]); // Debug.Log("placing;"+levelObj["name"].Value); Debug.Log("N name;" + levelObj["name"]); UserEditableObject ueo = LevelBuilderObjectManager.inst.PlaceObject(levelObj, SceneSerializationType.Class); objectsString += levelObj["name"].Value + ","; UpdateProgress(i, totalObjectsToPlace); if (ueo) { LevelBuilderEventManager.inst.ReconnectBrokenUuidsForUndeletedObjects(ueo, ueo.GetUuid()); } else { WebGLComm.inst.Debug("<color=#f00>Missing:</color>" + levelObj["name"]); } } // Debug.Log("<color=#00f>JSON</color>: "+N.ToString()); if (N["ScreenshotCameraInfo"] != null && N["ScreenshotCameraInfo"] != "") { Screenshotter.inst.SetScreenshotCameraInfo((SimpleJSON.JSONClass)N["ScreenshotCameraInfo"]); } // WebGLComm.inst.Debug("Placed "+i+" objects for LEVEL CLASS for level:"+N["Name"]); // LevelBuilder.inst.loadingLevelObjectScreen.SetActive(false); OnLevelClassLoaded(); return(N); }
public LevelBuilderEventObject(UserEditableObject _ueo, int _uuid, SimpleJSON.JSONClass _N) { ueo = _ueo; uuid = _uuid; N = _N; }