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);
        }
    }
예제 #2
0
 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>());
 }
    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);
    }