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"); } }
private static FireFxRoot GetFireSetting(Object t) { TreeWrap.Init(); string path = AssetDatabase.GetAssetPath(t); 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); }
protected override void OnEnter() { _status = CompStatus.COMPLETE; object obj = machine.GetRuntimeData <object>(CpxState.TEMP_DATA); if (obj == null) { GlobalLogger.LogError("no setting data retrieved"); return; } _fighter = entity as IFightableEntity; if (_fighter == null) { return; } _fx = GetFireFx(obj); if (_fx == null) { return; } LuaTable tb = obj as LuaTable; Vector3 pos; if (tb != null && tb.TryGet("position", out pos)) { model.MoveTo(pos); } float orient; if (tb != null && tb.TryGet("orient", out orient)) { Debug.Log(string.Format("model.orient ={0}, data.orient ={1}", model.orientation, orient)); model.orientation = orient; } _status = CompStatus.RUNING; _fireRunner = new FxFireRunner(_fighter, _fx) { targetInfos = new FireFxInfo[0], targetPos = GetTargetPosition(tb) }; _fireRunner.completeEvent.AddListener(OnComplete); try { _fireRunner.Start(); } catch (Exception e) { GlobalLogger.LogError(e); _status = CompStatus.COMPLETE; } }
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); }