Ejemplo n.º 1
0
        public static ScriptableObject[] ObjectAtPosition (Vector2 position) {
            for (int i = DialogueEditorGUI.Cache.Nodes.Count - 1; i >= 0; i--) {
                BaseNode node = DialogueEditorGUI.Cache.Nodes.Get (i);

                if (node.Position.Contains (position))
                    return new ScriptableObject[] { node };

                for (int j = node.Nodules.Count - 1; j >= 0; j--)
                    if (node.Nodules.Get (j).Position.Contains (position))
                        return new ScriptableObject[] { node.Nodules.Get (j), node };

                if (node is MainNode) {
                    MainNode main = node as MainNode;

                    for (int j = main.Options.Count - 1; j >= 0; j--) {
                        OptionNode option = main.Options.Get (j);

                        if (option.Position.Contains (position))
                            return new ScriptableObject[] { option, main };

                        for (int k = option.Nodules.Count - 1; k >= 0; k--)
                            if (option.Nodules.Get (k).Position.Contains (position))
                                return new ScriptableObject[] { option.Nodules.Get (k), option, main };
                    }
                }
            }
            return new ScriptableObject[] { null };
        }
Ejemplo n.º 2
0
        public static OptionNode Create(string nodeTitle, string nodeTextArea, MainNode main)
        {
            OptionNode option = Instantiate(NodeTypes.GetDefaultNode("OptionNode")) as OptionNode;

            option.Construct(nodeTitle, nodeTextArea, main);
            return(option);
        }
Ejemplo n.º 3
0
        public static OptionNode Create(string _name, MainNode _mainNode)
        {
            OptionNode option = Instantiate(NodeTypes.GetDefaultNode("OptionNode")) as OptionNode;

            option.Construct(_name, option.textArea, _mainNode);
            return(option);
        }
Ejemplo n.º 4
0
 protected void Construct(string nodeTitle, string nodeTextArea, MainNode main)
 {
     name     = nodeTitle;
     textArea = nodeTextArea;
     mainNode = main;
     actor    = DialogueEditorGUI.Cache.Actors.Get(0);
     nodules  = NoduleDatabase.CreateNew(this);
     DialogueEditorGUI.Cache.SaveNewObject(this, mainNode);
 }
Ejemplo n.º 5
0
        public static OptionDatabase CreateNew(MainNode mainNode)
        {
            var DB = CreateInstance <OptionDatabase> ();

            DB.name     = mainNode.name + " - " + DB.GetType().Name;
            DB.mainNode = mainNode;

            if (!DB)
            {
                throw new UnityException();
            }
            DB.Construct();
            return(DB);
        }
Ejemplo n.º 6
0
 protected override void Construct(string nodeTitle, Vector2 nodePos, string nodeTextArea, Actor nodeActor)
 {
     mainNode = null;
     base.Construct(nodeTitle, nodePos, nodeTextArea, nodeActor);
 }
Ejemplo n.º 7
0
 public override void ReplaceAllReferences(Func <ScriptableObject, ScriptableObject> ReplacedSO)
 {
     base.ReplaceAllReferences(ReplacedSO);
     mainNode = (MainNode)ReplacedSO(mainNode);
 }
Ejemplo n.º 8
0
        static void AddCallBack(object callBackObj)
        {
            EditorStates states = callBackObj as EditorStates;

            if (states == null)
            {
                throw new UnityException();
            }
            EditorState state = states.curState;

            if (states.info.Contains("Node"))
            {
                switch (states.curSpace)
                {
                case EventSpace.Node:
                    if (states.info == "OptionNode")
                    {
                        if (state.selectedObject is MainNode)
                        {
                            MainNode main = state.selectedObject as MainNode;
                            main.Options.Add(OptionNode.Create(main.Options.NextItemName("Option"), main));
                        }
                        else
                        {
                            goto default;
                        }
                    }
                    else if (states.info == "MainNode")
                    {
                        goto default;
                    }
                    else
                    {
                        Debug.LogError("Cannot recognise name of 'Node'. Add More Error here");
                        return;
                    }
                    break;

                default:
                    EditorCache cache = DialogueEditorGUI.Cache;
                    cache.Nodes.Add(DialogueNode.Create(states.info,
                                                        cache.Nodes.NextItemName(states.info),
                                                        CanvasGUI.CanvasToScreenPosition(state, states.mousePos),
                                                        cache.Actors.DefaultActor));
                    break;
                }
            }
            else if (states.info.Contains("Nodule"))
            {
                BaseNode node = (states.curSpace == EventSpace.Node) ? state.selectedObject as BaseNode :
                                (states.curSpace == EventSpace.Nodule) ? (state.selectedObject as BaseNodule).MainNode :
                                null;

                if (node)
                {
                    node.Nodules.Add(BaseNodule.Create(states.info, node.Nodules.NextItemName(states.info), node));
                }
            }
            else
            {
                throw new UnityException();
            }
        }