public void Play(TreeCanvas canvas) { if (_controller == null) { _prevPosition = hero.transform.position; FireFxRoot r = new FireFxRoot(); TreeWrap.Init(); TreeEditorFactory.Start(); new TreeToRuntimeComp(canvas, TreeFactory.CreateInstance, r).Transfer(); _controller = new EtFireFxContoller(hero, r) { targetPos = hero.transform.position }; FireFxInfo[] infos = new FireFxInfo[targets.Length]; for (int i = 0; i < targets.Length; i++) { FireFxInfo info = new FireFxInfo(new FireEnemy(targets[i])); if (i == 0) { _controller.mainTargetInfo = info; _controller.targetPos = info.position; _controller.endHostPos = info.position; } infos[i] = info; } _controller.targetInfos = infos; _controller.completeEvent.AddListener(OnComplete); GameTicker.tickerManager.Add(_controller); _controller.Start(); } else { Debug.Log("the current firefx control is running"); } }
public static FireFxRoot GetFireSetting(string path) { if (File.Exists(path)) { TreeEditorFactory.Start(); XDocument doc = XDocument.Load(path); XElement root = doc.Root; string canvasType = StringDataTools.XAttribute(root, "type"); TreeCanvas canvas = TreeEditorFactory.GetCanvas(canvasType); canvas.Read(root); FireFxRoot r = new FireFxRoot(); new TreeToRuntimeComp(canvas, TreeFactory.CreateInstance, r).Transfer(); return(r); } GlobalLogger.LogError(string.Format("{0} is not a valid path", path)); return(null); }
internal void OnEnable() { if (!followCamera) { Debug.LogError("no camera found"); return; } FileTools.Start(); //LuaManager.Init(); //new Lua_Starter(() => { Debug.Log("lua init complete"); }).Start(); GameObject o = GameObject.Find("HudCanvas"); if (o) { HudManager.panel = o.GetComponent <RectTransform>(); } _hostEntity = new TestHost(gameObject, speed); _hostEntity.Initialize(); MachineWrap.Init(); TreeWrap.Init(); string stream = FileTools.wwwStreamingAssetsPath; if (string.IsNullOrEmpty(stream)) { return; } CpxRetriever r = new CpxRetriever { actionRetriever = CpxMachineFactory.GetAction, stateRetriever = CpxMachineFactory.GetState, conditionRetriever = CpxMachineFactory.GetCondition }; MachineFactory.Start(); MachineChart m = MachineFileManager.Load(AssetDatabase.GetAssetPath(machineFile)); CpxController ctrl = new ChartToMachine().Transfer(m, r); _hostEntity.runtimeController.Inititalize(ctrl); TreeEditorFactory.Start(); _fireSettings = new FireFxRoot[_fxAssets.Length]; for (int i = 0, len = _fireSettings.Length; i < len; i++) { _fireSettings[i] = GetFireSetting(_fxAssets[i]); } }