コード例 #1
0
 private void DrawPageJoints(Node node, Vector2 mousePosition)
 {
     foreach (NodeJoint j in node.joints)
     {
         j.ownerID   = node.Index;
         j.ownerNode = node;
         if (j.IsConnected())
         {
             if (j.IsOutput)
             {
                 NodeJoint jnt = null;
                 if (j.connectionPoint.ownerNode != null)
                 {
                     jnt = j.connectionPoint.ownerNode.joints[j.connectionPoint.JointIndex];
                 }
                 else
                 {
                     jnt = VisualNovelEditor.FindJoint(j.connectionPoint.OwnerID, j.connectionPoint.JointIndex);
                 }
                 if (jnt != null)
                 {
                     CalculateAndDrawBezier(j.bounds.center, jnt.bounds.center, j.info, jnt.info);
                 }
             }
             GUI.Label(new Rect(new Vector2(j.bounds.position.x + j.bounds.width + 10f, j.bounds.position.y), new Vector2(50, 50)), j.connectionPoint.OwnerID + " " + (j.IsOutput ? "OUT" : "IN"), EditorGUILayoutExtensions.ChangeTextColor(_styles[StyledElement.Label], Color.white));
         }
     }
     EditorGUI.DrawRect(node.TopJoint.bounds, node.Outputting && !node.TopJoint.IsConnected() ? Color.magenta : node.TopJoint.CheckForHover(mousePosition) ? Color.yellow : Color.red);
     EditorGUI.DrawRect(node.BottomJoint.bounds, node.Outputting && !node.BottomJoint.IsConnected() ? Color.magenta : node.BottomJoint.CheckForHover(mousePosition) ? Color.yellow : Color.red);
     EditorGUI.DrawRect(node.LeftJoint.bounds, node.Outputting && !node.LeftJoint.IsConnected() ? Color.magenta : node.LeftJoint.CheckForHover(mousePosition) ? Color.yellow : Color.red);
     EditorGUI.DrawRect(node.RightJoint.bounds, node.Outputting && !node.RightJoint.IsConnected() ? Color.magenta : node.RightJoint.CheckForHover(mousePosition) ? Color.yellow : Color.red);
 }
コード例 #2
0
    public static void ResetNodeJoint(NodeJoint current)
    {
        if (current.ownerID == -1)
        {
            return;
        }
        current.IsInput  = false;
        current.IsOutput = false;
        if (current.isChoice)
        {
            current.choiceOutputSet = false;
        }

        if (current.connectionPoint != null)
        {
            //Debug.LogWarning(current.connectionPoint.ToString());
            //connectionPointconnectionPoint = null;
            NodeJoint j = null;
            if (current.connectionPoint.ownerNode != null)
            {
                j = current.connectionPoint.ownerNode.joints[current.connectionPoint.JointIndex];
            }
            else
            {
                j = FindJoint(current.connectionPoint.OwnerID, current.connectionPoint.JointIndex);
            }
            if (j != null)
            {
                if (j.isChoice)
                {
                    j.choiceOutputSet = false;
                }
                j.connectionPoint = null;
                j.IsInput         = false;
                j.IsOutput        = false;
            }

            Node n = current.connectionPoint.ownerNode ?? FindNodeByIndex(current.connectionPoint.OwnerID);
            if (n != null && n.connectionOrder != null)
            {
                if (n.connectionOrder.IndexOf(current) != -1)
                {
                    n.connectionOrder.Remove(j);
                }
            }
            current.connectionPoint = null;
        }

        Node o = current.ownerNode ?? FindNodeByIndex(current.ownerID);

        if (o != null && o.connectionOrder != null)
        {
            if (o.connectionOrder.IndexOf(current) != -1)
            {
                o.connectionOrder.Remove(current);
            }
        }
    }
コード例 #3
0
 private void DrawStateJoints(Node node, Vector2 mousePosition)
 {
     if (node.isStartNode)
     {
         node.BottomJoint.ownerID   = node.Index;
         node.BottomJoint.ownerNode = node;
         EditorGUI.DrawRect(node.BottomJoint.bounds, node.BottomJoint.CheckForHover(mousePosition) ? Color.green : Color.blue);
         if (node.BottomJoint.IsConnected())
         {
             if (node.BottomJoint.IsOutput)
             {
                 NodeJoint jnt = null;
                 if (node.BottomJoint.connectionPoint.ownerNode != null)
                 {
                     jnt = node.BottomJoint.connectionPoint.ownerNode.joints[node.BottomJoint.connectionPoint.JointIndex];
                 }
                 else
                 {
                     jnt = VisualNovelEditor.FindJoint(node.BottomJoint.connectionPoint.OwnerID, node.BottomJoint.connectionPoint.JointIndex);
                 }
                 if (jnt != null)
                 {
                     CalculateAndDrawBezier(node.BottomJoint.bounds.center, jnt.bounds.center, node.BottomJoint.info, jnt.info);
                 }
             }
         }
     }
     else //End Node
     {
         node.TopJoint.ownerID   = node.Index;
         node.TopJoint.ownerNode = node;
         EditorGUI.DrawRect(node.TopJoint.bounds, node.TopJoint.CheckForHover(mousePosition) ? Color.cyan : Color.grey);
         if (node.TopJoint.IsConnected())
         {
             if (node.TopJoint.IsOutput)
             {
                 NodeJoint jnt = null;
                 if (node.TopJoint.connectionPoint.ownerNode != null)
                 {
                     jnt = node.TopJoint.connectionPoint.ownerNode.joints[node.TopJoint.connectionPoint.JointIndex];
                 }
                 else
                 {
                     jnt = VisualNovelEditor.FindJoint(node.TopJoint.connectionPoint.OwnerID, node.TopJoint.connectionPoint.JointIndex);
                 }
                 if (jnt != null)
                 {
                     CalculateAndDrawBezier(node.TopJoint.bounds.center, jnt.bounds.center, node.TopJoint.info, jnt.info);
                 }
             }
         }
     }
 }
コード例 #4
0
    private void AssignJoints()
    {
        if (joints == null || joints.Length <= 0)
        {
            connectionOrder = new List <NodeJoint>();
            joints          = new NodeJoint[4];

            for (int i = 0; i < joints.Length; i++)
            {
                //NodeJoint joint = CreateInstance<NodeJoint>();
                NodeJoint joint = new NodeJoint()
                {
                    ownerID   = Index,
                    bounds    = Rect.zero,
                    ownerNode = this
                };
                joints[i] = joint;
            }
        }
        //if (joints[0] != null) return;
    }
コード例 #5
0
 public void Remove()
 {
     foreach (NodeJoint j in joints)
     {
         if (j.connectionPoint != null)
         {
             NodeJoint jnt = null;
             if (j.connectionPoint.ownerNode != null)
             {
                 jnt = j.connectionPoint.ownerNode.joints[j.connectionPoint.JointIndex];
             }
             else
             {
                 jnt = FindJoint(j.connectionPoint.OwnerID, j.connectionPoint.JointIndex);
             }
             if (jnt != null)
             {
                 jnt.choiceOutputSet = false;
                 jnt.connectionPoint = null;
             }
         }
     }
     connectionOrder.Clear();
 }
コード例 #6
0
    public bool ContainsJoint(NodeJoint joint)
    {
        List <NodeJoint> js = new List <NodeJoint>(joints);

        return(js.IndexOf(joint) != -1);
    }