Example #1
0
    public void test_get_default_instances()
    {
        LayoutManagerTests.Reset(this);
        var instance = LayoutManager.Default;

        Assert(instance != null);
        LayoutManagerTests.Reset(this);
    }
    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);
    }