Пример #1
0
                public static MoveSingle Create(Property p, Vector3 o, Axis3 a, Vector3Callback c)
                {
                    GameObject g = null;

                    switch (a)
                    {
                    case Axis3.X:
                        g = GameObject.Instantiate(x.Object);
                        break;

                    case Axis3.Y:
                        g = GameObject.Instantiate(y.Object);
                        break;

                    case Axis3.Z:
                        g = GameObject.Instantiate(z.Object);
                        break;

                    default:
                        return(null);
                    }
                    MoveSingle m = g.AddComponent <MoveSingle>();

                    m.property   = p;
                    m.DragEvent += c;
                    return(m);
                }
Пример #2
0
    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);
    }
Пример #4
0
                public static Move Create(Property p, Vector3 o, Vector3Callback c)
                {
                    Move m = null;

                    if (p.mdp.Count > 0)
                    {
                        m = p.mdp.Dequeue();
                        m.gameObject.SetActive(true);
                        m.transform.position = o;
                    }
                    else
                    {
                        m = new GameObject("Position Handle").AddComponent <Move>();
                        m.transform.position = o;
                        m.transform.SetParent(Parent);
                        Vector3Callback _c = (v) => { m.transform.position = v; if (m.callback != null)
                                                      {
                                                          m.callback(v);
                                                      }
                        };

                        for (int i = 0; i < 3; i++)
                        {
                            MoveSingle s = MoveSingle.Create(p, o, (Axis3)i, null);
                            s.transform.SetParent(m.transform, false);
                            s.DragEvent += (v) => { _c(v); s.transform.position = v; };
                        }
                        for (int i = 0; i < 3; i++)
                        {
                            MoveDouble d = MoveDouble.Create(p, o, (Axis3)i, null);
                            d.transform.SetParent(m.transform, false);
                            d.DragEvent += (v) => { _c(v); d.transform.position = v; };
                        }
                    }
                    m.callback = c;
                    m.property = p;
                    p.mep.Add(m);
                    return(m);
                }
Пример #5
0
    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);
    }