public void DoExit() { foreach (string trigger in triggers) { TriggerMgr.ToggleTrigger(trigger, false); } ResourceMgr.CleanAllGameObjects(); }
public static void Reset() { CameraMgr.UseDefaultSkybox(); CameraMgr.Place(Vector3.zero); CameraMgr.Euler(Vector3.zero); ResourceMgr.ToggleAllGameObjects(false); TriggerMgr.ToggleAllTrigger(false); fsm.Reset(); }
public void RegisterTrigger(string _uuid) { if (triggers.Contains(_uuid)) { return; } triggers.Add(_uuid); //hide the trigger, show it when enter slate TriggerMgr.ToggleTrigger(_uuid, false); }
public static void Clean() { CameraMgr.UseDefaultSkybox(); CameraMgr.Place(Vector3.zero); CameraMgr.Euler(Vector3.zero); ResourceMgr.CleanAllGameObjects(); TriggerMgr.Clean(); fsm.Clean(); images.Clear(); }
private static void parseBeanJson(string _beanJson) { JSONNode root = JSON.Parse(_beanJson); JSONArray slateAry = root["slates"].AsArray; foreach (JSONNode slateNode in slateAry) { string slateUUID = slateNode["guid"].Value; Slate slate = SlateMgr.NewSlate(slateUUID); slate.alias = slateNode["alias"].Value; Log.Info("BeanMgr", "parse blocks"); JSONArray pipeAry = slateNode["pipes"].AsArray; foreach (JSONNode pipeNode in pipeAry) { string pipeUUID = pipeNode["guid"].Value; JSONArray actionAry = pipeNode["actions"].AsArray; foreach (JSONNode blockNode in actionAry) { string blockUUID = blockNode["guid"].Value; Block block = BlockMgr.NewBlock(blockUUID); block.action = blockNode["action"].Value; block.path = slateUUID; slate.AppendBlock(blockUUID); JSONArray paramsAry = blockNode["params"].AsArray; foreach (JSONNode node in paramsAry) { string key = node["key"].Value; string value = node["value"].Value; block.param[key] = value; } } } Log.Info("BeanMgr", "link blocks"); slate.LinkBlocks(); Log.Info("BeanMgr", "parse preloads"); JSONArray preloadAry = slateNode["preloads"].AsArray; foreach (JSONNode node in preloadAry) { string guid = node["guid"].Value; Slate.Asset asset = slate.RegisterAsset(guid); asset.slate = slateUUID; asset.group = node["group"].Value; asset.package = node["package"].Value; asset.file = node["file"].Value; asset.guid = node["guid"].Value; asset.px = node["px"].AsFloat; asset.py = node["py"].AsFloat; asset.pz = node["pz"].AsFloat; asset.rx = node["rx"].AsFloat; asset.ry = node["ry"].AsFloat; asset.rz = node["rz"].AsFloat; asset.sx = node["sx"].AsFloat; asset.sy = node["sy"].AsFloat; asset.sz = node["sz"].AsFloat; asset.gaze = node["gaze"].AsBool; asset.gazeAlias = node["gaze.alias"].Value; } Log.Info("BeanMgr", "parse triggers"); JSONArray triggerAry = slateNode["triggers"].AsArray; foreach (JSONNode node in triggerAry) { string uuid = node["uuid"].Value; string alias = node["alias"].Value; float px = node["px"].AsFloat; float py = node["py"].AsFloat; float pz = node["pz"].AsFloat; float rx = node["rx"].AsFloat; float ry = node["ry"].AsFloat; float rz = node["rz"].AsFloat; int icon = node["icon"].AsInt; int r = node["color.r"].AsInt; int g = node["color.g"].AsInt; int b = node["color.b"].AsInt; int a = node["color.a"].AsInt; SightTrigger trigger = TriggerMgr.NewSightTrigger(uuid); trigger.trigger = alias; trigger.path = slateUUID; TriggerMgr.AdjustSightTrigger(uuid, new Vector3(px, py, pz), new Vector3(rx, ry, rz)); TriggerMgr.ModifyIcon(uuid, icon); TriggerMgr.ModifyColor(uuid, r, g, b, a); TriggerMgr.AdjustSightTrigger(uuid, new Vector3(px, py, pz), new Vector3(rx, ry, rz)); slate.RegisterTrigger(uuid); } } }
public void DoEnter() { //preload assets foreach (Asset asset in assets.Values) { // asset has format like as .wav if (asset.file.Contains(".")) { byte[] data = UGCMgr.Take(asset.file); if (null == data) { this.LogError("Missing asset, group:{0} package:{1} file:{2} ", asset.group, asset.package, asset.file); continue; } if (asset.group.Equals("skybox")) { Material skybox = UGCMgr.BuildSkybox(data); CameraMgr.ApplySkybox(skybox); } } else { Object obj = ResourceMgr.FindFromPreload(asset.package, asset.file); if (null == obj) { this.LogError("Missing asset, group:{0} package:{1} file:{2} ", asset.group, asset.package, asset.file); continue; } if (asset.group.Equals("agent")) { GameObject clone = ResourceMgr.CloneGameObject(asset.package, asset.file, asset.guid); agents.Add(asset.guid); clone.transform.position = new Vector3(asset.px, asset.py, asset.pz); clone.transform.rotation = Quaternion.Euler(asset.rx, asset.ry, asset.rz); clone.transform.localScale = new Vector3(asset.sx, asset.sy, asset.sz); if (asset.gaze) { ReticleHandler handler = clone.AddComponent <ReticleHandler>(); handler.path = asset.slate; handler.trigger = asset.gazeAlias; EventTrigger et = clone.AddComponent <EventTrigger>(); EventTrigger.Entry entryEnter = new EventTrigger.Entry(); entryEnter.eventID = EventTriggerType.PointerEnter; entryEnter.callback.AddListener((data) => { handler.onPointerEnter(); }); et.triggers.Add(entryEnter); EventTrigger.Entry entryExit = new EventTrigger.Entry(); entryExit.eventID = EventTriggerType.PointerExit; entryExit.callback.AddListener((data) => { handler.onPointerExit(); }); et.triggers.Add(entryExit); EventTrigger.Entry entryClick = new EventTrigger.Entry(); entryClick.eventID = EventTriggerType.PointerClick; entryClick.callback.AddListener((data) => { handler.onPointerClick(); }); et.triggers.Add(entryClick); Collider collider = clone.GetComponent <Collider>(); if (null != collider) { collider.enabled = true; } } } else if (asset.group.Equals("skybox")) { CameraMgr.ApplySkybox(obj as Material); } } } //hide all triggers TriggerMgr.ToggleAllTrigger(false); //show trigger in current slate foreach (string trigger in triggers) { TriggerMgr.ToggleTrigger(trigger, true); } // execute startup blocks foreach (string guid in blocks) { Block block = BlockMgr.FindBlock(guid); if (block.action.Equals("Entry:Startup")) { block.Execute(); } } }
private static IEnumerator importVCB(OnImportReadyDelegate _onReady, OnImportFinishDelegate _onFinish, OnImportErrorDelegate _onError) { string path = System.IO.Path.Combine(VRXX.Platform.GetStreamingAssetsPath(), "latest.vcb"); WWW www = new WWW(path); yield return(www); if (null != www.error) { _onError(www.error); Log.Error("EditorMgr::importVCB", www.error); yield break; } _onReady(); yield return(1); try { //Read json Log.Info("EditorMgr::importVCB", "parse bean success"); JSONNode root = JSON.Parse(www.text); JSONNode nodeSets = root["sets"]; JSONNode nodeKV = root["kv"]; JSONNode nodeHash = root["hash"]; //parse slates JSONArray arySlates = nodeSets["screenplay_slates_guids"].AsArray; List <Dictionary <string, string> > assets = new List <Dictionary <string, string> >(); //create slate foreach (JSONNode slateNode in arySlates) { string slateUUID = slateNode.Value; Log.Trace("EditorMgr:importVCB", "new a image {0}", slateUUID); NewImage(slateUUID); //parse skybox string skyboxFile = nodeKV[string.Format("screenplay_slate_guid_1_preload_skybox_file:[{0}]", slateUUID)].Value; string skyboxPackage = nodeKV[string.Format("screenplay_slate_guid_1_preload_skybox_package:[{0}]", slateUUID)].Value; Dictionary <string, string> assetSkybox = new Dictionary <string, string>(); assetSkybox["package"] = skyboxPackage; assetSkybox["file"] = skyboxFile; assetSkybox["image"] = slateUUID; assetSkybox["uuid"] = ""; assetSkybox["type"] = "skybox"; assets.Add(assetSkybox); //parse agent JSONArray aryAgents = nodeSets[string.Format("screenplay_slate_guid_1_preloads_guids:[{0}]", slateUUID)].AsArray; foreach (JSONNode agentNode in aryAgents) { string agentUUID = agentNode.Value; Log.Trace("EditorMgr:importVCB", "import a agent {0}", agentUUID); string agentFile = nodeKV[string.Format("screenplay_slate_guid_1_preload_guid_2_asset_file:[{0}]:[{1}]", slateUUID, agentUUID)].Value; string agentPackage = nodeKV[string.Format("screenplay_slate_guid_1_preload_guid_2_asset_package:[{0}]:[{1}]", slateUUID, agentUUID)].Value; float posX = nodeKV[string.Format("screenplay_preload_guid_1_px:[{0}]", agentUUID)].AsFloat; float posY = nodeKV[string.Format("screenplay_preload_guid_1_py:[{0}]", agentUUID)].AsFloat; float posZ = nodeKV[string.Format("screenplay_preload_guid_1_pz:[{0}]", agentUUID)].AsFloat; float rotX = nodeKV[string.Format("screenplay_preload_guid_1_rx:[{0}]", agentUUID)].AsFloat; float rotY = nodeKV[string.Format("screenplay_preload_guid_1_ry:[{0}]", agentUUID)].AsFloat; float rotZ = nodeKV[string.Format("screenplay_preload_guid_1_rz:[{0}]", agentUUID)].AsFloat; float scaleX = nodeKV[string.Format("screenplay_preload_guid_1_sx:[{0}]", agentUUID)].AsFloat; float scaleY = nodeKV[string.Format("screenplay_preload_guid_1_sy:[{0}]", agentUUID)].AsFloat; float scaleZ = nodeKV[string.Format("screenplay_preload_guid_1_sz:[{0}]", agentUUID)].AsFloat; Dictionary <string, string> assetAgent = new Dictionary <string, string>(); assetAgent["package"] = agentPackage; assetAgent["file"] = agentFile; assetAgent["image"] = slateUUID; assetAgent["uuid"] = agentUUID; assetAgent["type"] = "agent"; assetAgent["pos.x"] = posX.ToString(); assetAgent["pos.y"] = posY.ToString(); assetAgent["pos.z"] = posZ.ToString(); assetAgent["rot.x"] = rotX.ToString(); assetAgent["rot.y"] = rotY.ToString(); assetAgent["rot.z"] = rotZ.ToString(); assetAgent["scale.x"] = scaleX.ToString(); assetAgent["scale.y"] = scaleY.ToString(); assetAgent["scale.z"] = scaleZ.ToString(); assets.Add(assetAgent); } //foreach (JSONNode agentNode in aryAgents) //parse trigger JSONArray aryTriggers = nodeSets[string.Format("screenplay_slate_guid_1_triggers_guids:[{0}]", slateUUID)].AsArray; foreach (JSONNode triggerNode in aryTriggers) { string triggerUUID = triggerNode.Value; Log.Trace("EditorMgr:importVCB", "import a trigger {0}", triggerUUID); float posX = nodeKV[string.Format("diagram_trigger_1_px:[{0}]", triggerUUID)].AsFloat; float posY = nodeKV[string.Format("diagram_trigger_1_py:[{0}]", triggerUUID)].AsFloat; float posZ = nodeKV[string.Format("diagram_trigger_1_pz:[{0}]", triggerUUID)].AsFloat; float rotX = nodeKV[string.Format("diagram_trigger_1_rx:[{0}]", triggerUUID)].AsFloat; float rotY = nodeKV[string.Format("diagram_trigger_1_ry:[{0}]", triggerUUID)].AsFloat; float rotZ = nodeKV[string.Format("diagram_trigger_1_rz:[{0}]", triggerUUID)].AsFloat; string alias = nodeKV[string.Format("diagram_trigger_1_alias:[{0}]", triggerUUID)].Value; string type = nodeKV[string.Format("diagram_trigger_1_type:[{0}]", triggerUUID)].Value; if (type.Equals("sight")) { Log.Trace("EditorMgr:importVCB", "update sight property {0}", triggerUUID); int icon = nodeKV[string.Format("diagram_gaze_1_icon:[{0}]", triggerUUID)].AsInt; int colorR = nodeKV[string.Format("diagram_gaze_1_color_r:[{0}]", triggerUUID)].AsInt; int colorG = nodeKV[string.Format("diagram_gaze_1_color_g:[{0}]", triggerUUID)].AsInt; int colorB = nodeKV[string.Format("diagram_gaze_1_color_b:[{0}]", triggerUUID)].AsInt; int colorA = nodeKV[string.Format("diagram_gaze_1_color_a:[{0}]", triggerUUID)].AsInt; TriggerMgr.NewEditorSightTrigger(triggerUUID); TriggerMgr.AdjustSightTrigger(triggerUUID, new Vector3(posX, posY, posZ), new Vector3(rotX, rotY, rotZ)); TriggerMgr.ModifyGazeAlias(triggerUUID, alias); TriggerMgr.ModifyGazeIcon(triggerUUID, icon); TriggerMgr.ModifyGazeColor(triggerUUID, colorR, colorG, colorB, colorA); Editor.Image image = fsm.FindState(slateUUID) as Editor.Image; image.triggers.Add(triggerUUID); } } }// foreach (JSONNode slateNode in arySlates) TriggerMgr.ToggleAllTrigger(false); Log.Debug("EditorMgr:importVCB", "Batch preload asset"); batchPreloadAsset(assets, () => { _onFinish(); }); } catch (System.Exception e) { Log.Exception("EditorMgr::importVX", e); } }