/// Apply a layout to a specific target public void Add(TStream stream, ILayout layout, LayoutFactoryDelegate factory, IAnimationTarget target) { var anims = new List <IAnimation>(); foreach (var lp in layout.Layout(target)) { var animation = factory(lp); _manager.Streams.Add(stream, animation); anims.Add(animation); } _pending.Add(new LayoutPending(anims.ToArray(), layout)); }
public void Start() { var layout = new LinearPlanarSpread(plane); LayoutFactoryDelegate factory = (LayoutObject target) => { var animation = new MoveSingle(target.position, target.rotation); animation.AnimationCurve = new SineWave(period); animation.AnimationTarget = new TargetSingle(target.gameObject); return(animation); }; AnimationManager.Default.Configure(Streams.STREAM_0, AnimationStreamType.DEFER, 16); LayoutManager.Default.Add(Streams.STREAM_0, layout, factory, new TargetByComponent <DemoMarker>()); }
public void test_layout() { LayoutManagerTests.Reset(this); AnimationManager.Default.Configure(Streams.STREAM_0, AnimationStreamType.DEFER, 30); var layout = new UniformPlanarFold(this.SpawnBlank(), 10f, 10f, 10f); LayoutFactoryDelegate factory = (LayoutObject target) => { var animation = new MoveSingle(target.position, target.rotation); animation.AnimationCurve = new Linear(1f); animation.AnimationTarget = new TargetSingle(target.gameObject); return(animation); }; var targets = new GameObject[] { this.SpawnBlank(), this.SpawnBlank(), this.SpawnBlank(), this.SpawnBlank(), this.SpawnBlank(), this.SpawnBlank(), }; LayoutManager.Default.Add(Streams.STREAM_0, layout, factory, new TargetGroup(targets)); Assert(AnimationManager.Default.Streams.Active(Streams.STREAM_0)); int count = 0; AnimationManager.Default.Events.AddEventHandler <LayoutCompleteEvent>((ep) => { count += 1; }); AnimationHandler.Default.Update(0.5f); Assert(AnimationManager.Default.Streams.Active(Streams.STREAM_0)); Assert(AnimationManager.Default.Streams.Active(Streams.STREAM_0)); Assert(count == 0); AnimationHandler.Default.Update(0.5f); AnimationHandler.Default.Update(0.5f); Assert(!AnimationManager.Default.Streams.Active(Streams.STREAM_0)); Assert(count == 1); LayoutManagerTests.Reset(this); }
public void Start() { factory = (LayoutObject target) => { var animation = new MoveSingle(target.position, target.rotation); animation.AnimationCurve = new Linear(duration); animation.AnimationTarget = new TargetSingle(target.gameObject); return animation; }; AnimationManager.Default.Events.AddEventHandler<LayoutCompleteEvent>((ep) => { offset += 1; if (offset >= 4) { offset = 0; } idle = true; }); AnimationManager.Default.Configure(Streams.STREAM_0, AnimationStreamType.DEFER, 16); }
public void Start() { factory = (LayoutObject target) => { var animation = new MoveSingle(target.position, target.rotation); animation.AnimationCurve = new Linear(duration); animation.AnimationTarget = new TargetSingle(target.gameObject); return(animation); }; AnimationManager.Default.Events.AddEventHandler <LayoutCompleteEvent>((ep) => { offset += 1; if (offset >= 4) { offset = 0; } idle = true; }); AnimationManager.Default.Configure(Streams.STREAM_0, AnimationStreamType.DEFER, 16); }