public void LinkBlocks() { //Link blocks List <string> startupBlocks = new List <string>(0); for (int i = 0; i < blocks.Count; ++i) { string guid = blocks[i]; Block block = BlockMgr.FindBlock(guid); if (block.action.Equals("Entry:Startup", System.StringComparison.InvariantCultureIgnoreCase)) { startupBlocks.Add(guid); } if (block.action.Contains("Exit")) { continue; } if (i + 1 < blocks.Count) { string next = blocks[i + 1]; Block nextblock = BlockMgr.FindBlock(next); if (!nextblock.action.Contains("Entry")) { block.nexts.Add(next); } } } }
public void Execute() { this.LogDebug("Ready execute block {0}", action); param["path"] = path; VRXX.Action.ActionHub.Invoke(action, param, () => { this.LogDebug("Execute block {0} finish", action); foreach (string next in nexts) { Block block = BlockMgr.FindBlock(next); block.Execute(); } }); }
public static void Stop() { BlockMgr.Clean(); SlateMgr.Stop(); }
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(); } } }