Пример #1
0
        void Update()
        {
            ui.Update();

            if (sc.GetSelectedAtom() == containingAtom && SuperController.singleton.editModeToggle.isOn)
            {
                ui.canvas.enabled = true;
            }

            nodes.ForEach((node) =>
            {
                node.Update();
            });

            transitions.ForEach((transition) =>
            {
                transition.Update();
            });
        }
Пример #2
0
        public override void Init()
        {
            try
            {
                sc = SuperController.singleton;

                ui = new UI(this, 0.001f);
                ui.canvas.transform.SetParent(containingAtom.mainController.transform, false);

                UIDynamicButton entrySelector = ui.CreateButton("Select Entry");
                entrySelector.transform.Translate(0, 0.1f, 0);
                entrySelector.button.onClick.AddListener(() =>
                {
                    sc.SelectModeAtom((atom) =>
                    {
                        AnimationPattern ap = atom.GetStorableByID("AnimationPattern") as AnimationPattern;
                        if (ap == null)
                        {
                            SuperController.LogError("Only Animation Patterns can be selected.");
                            return;
                        }

                        root = CreateNode(ap);
                        CreateTransition(containingAtom, root.atom);

                        active = root;

                        entrySelector.gameObject.SetActive(false);
                        PerformSave();
                    });
                });

                UIDynamicButton playButton = ui.CreateButton("Test Start", 80, 60);
                playButton.transform.Translate(0, -0.2f, 0);
                playButton.button.onClick.AddListener(() =>
                {
                    if (root == null)
                    {
                        return;
                    }

                    active = root;
                    active.Start();
                });

                UIDynamicButton nextButton = ui.CreateButton("Test Next", 80, 60);
                nextButton.transform.Translate(0, -0.3f, 0);
                nextButton.button.onClick.AddListener(() =>
                {
                    if (active == null)
                    {
                        return;
                    }

                    Transition transition = active.GetRandomTransition();
                    if (transition != null)
                    {
                        Node nextNode = GetEndNodeFromTransition(transition);
                        if (nextNode != null)
                        {
                            active.Stop();
                            nextNode.Start();
                            active = nextNode;
                        }
                    }
                });

                UIDynamicButton doneEditingButton = ui.CreateButton("Done Editing", 80, 60);
                doneEditingButton.transform.Translate(0, -0.6f, 0);
                doneEditingButton.button.onClick.AddListener(() =>
                {
                    ui.canvas.enabled = false;
                    if (sc.GetSelectedAtom() == containingAtom)
                    {
                        sc.ClearSelection();
                    }
                });

                saveString = new JSONStorableString("graph", "");
                RegisterString(saveString);

                playNextWhenReady = new JSONStorableAction("play next if ready", () =>
                {
                    if (active == null)
                    {
                        return;
                    }

                    if (started == false)
                    {
                        active.Start();
                        started = true;
                        return;
                    }

                    if (active.ap.loop == false)
                    {
                        if (active.ap.GetCurrentTimeCounter() < active.ap.GetTotalTime())
                        {
                            return;
                        }
                    }

                    Transition transition = active.GetRandomTransition();
                    if (transition != null)
                    {
                        Node nextNode = GetEndNodeFromTransition(transition);
                        if (nextNode != null)
                        {
                            active.Stop();
                            nextNode.Start();
                            active = nextNode;
                        }
                    }
                });

                RegisterAction(playNextWhenReady);
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }