Exemplo n.º 1
0
 public void DrawConnection(BaseNode start, BaseNode end, EWindowCurvePlacement sPos, EWindowCurvePlacement ePos, Color col, bool disable)
 {
     Color          = col;
     startNode      = start;
     endNode        = end;
     disabled       = disable;
     startPlacement = sPos;
     endPlacement   = ePos;
 }
Exemplo n.º 2
0
        public Transition(BaseNode start, BaseNode end, EWindowCurvePlacement sPos, EWindowCurvePlacement ePos, Color col, bool disable, string val, bool enableClickPoint, string id)
        {
            if ((start.transitions.Count > 0 && start.transitions.Exists(t => t != null && t.endNode != null && end != null && t.endNode.ID == end.ID)) ||
                start.drawNode.UnconectableNodes.Contains(end.drawNode))
            {
                Debug.Log("Transition doesnt passed through constructor..."); return;
            }
            ;                                                                                                                                       // A cannot be connected ti B but B can be connected to A

            DrawConnection(start, end, sPos, ePos, col, disable);
            start.transitions.Add(this);
            end.depencies.Add(this);
            this.Value            = val;
            this.enableClickPoint = enableClickPoint;
            this.ID = id;
        }
        public static void DrawNodeCurve(Transition t, Rect start, Rect end, EWindowCurvePlacement start_, EWindowCurvePlacement end_, Color curveColor, bool disable)
        {
            Vector3 endPos   = Vector3.zero;
            Vector3 startPos = Vector3.zero;

            switch (start_)
            {
            case EWindowCurvePlacement.LeftTop:
                startPos = new Vector3(start.x + 1, start.y + 3, 0);

                break;

            case EWindowCurvePlacement.LeftBottom:
                startPos = new Vector3(start.x + 1, start.y + start.height - 3, 0);
                break;

            case EWindowCurvePlacement.CenterBottom:
                startPos = new Vector3(start.x + (start.width * 0.5f), start.y + start.height - 2, 0);

                break;

            case EWindowCurvePlacement.CenterTop:
                startPos = new Vector3(start.x + (start.width * 0.5f), start.y + 2, 0);
                break;

            case EWindowCurvePlacement.RightTop:
                startPos = new Vector3(start.x + start.width, start.y + 3, 0);
                break;

            case EWindowCurvePlacement.RightBottom:
                startPos = new Vector3(start.x + start.width, start.y + start.height - 3, 0);
                break;

            case EWindowCurvePlacement.RightCenter:
                startPos = new Vector3(start.x + start.width, start.y + (start.height * 0.5f), 0);
                break;

            case EWindowCurvePlacement.LeftCenter:
                startPos = new Vector3(start.x, start.y + (start.height * 0.5f), 0);

                break;

            case EWindowCurvePlacement.Center:
                startPos = new Vector3(start.x + (start.width * 0.5f), start.y + (start.height * 0.5f), 0);
                break;

            case EWindowCurvePlacement.Decision1:
                startPos = new Vector3(start.x + start.width, start.y + (start.height / 2 - 60), 0);
                break;

            case EWindowCurvePlacement.Decision2:
                startPos = new Vector3(start.x + start.width, start.y + (start.height / 2 - 40), 0);
                break;

            case EWindowCurvePlacement.Decision3:
                startPos = new Vector3(start.x + start.width, start.y + (start.height / 2 - 20), 0);
                break;

            case EWindowCurvePlacement.Decision4:
                startPos = new Vector3(start.x + start.width, start.y + (start.height / 2 - 0), 0);
                break;

            case EWindowCurvePlacement.Decision5:
                startPos = new Vector3(start.x + start.width, start.y + (start.height / 2 + 20), 0);
                break;
            }
            switch (end_)
            {
            case EWindowCurvePlacement.LeftTop:
                endPos = new Vector3(end.x + 1, end.y + 3, 0);

                break;

            case EWindowCurvePlacement.LeftBottom:
                endPos = new Vector3(end.x + 1, end.y + end.height - 3, 0);
                break;

            case EWindowCurvePlacement.CenterBottom:
                endPos = new Vector3(end.x + (end.width * 0.5f), end.y + end.height - 2, 0);

                break;

            case EWindowCurvePlacement.CenterTop:
                endPos = new Vector3(end.x + (end.width * 0.5f), end.y + 2, 0);
                break;

            case EWindowCurvePlacement.RightTop:
                endPos = new Vector3(end.x + end.width, end.y + 3, 0);
                break;

            case EWindowCurvePlacement.RightBottom:
                endPos = new Vector3(end.x + end.width, end.y + end.height - 3, 0);
                break;

            case EWindowCurvePlacement.RightCenter:
                endPos = new Vector3(end.x + end.width, end.y + (end.height * 0.5f), 0);
                break;

            case EWindowCurvePlacement.LeftCenter:
                endPos = new Vector3(end.x, end.y + (end.height * 0.5f), 0);

                break;

            case EWindowCurvePlacement.Center:
                endPos = new Vector3(end.x + (end.width * 0.5f), end.y + (end.height * 0.5f), 0);
                break;

            case EWindowCurvePlacement.Decision1:
                endPos = new Vector3(end.x + end.width, end.y + (end.height / 2 - 60), 0);
                break;

            case EWindowCurvePlacement.Decision2:
                endPos = new Vector3(end.x + end.width, end.y + (end.height / 2 - 40), 0);
                break;

            case EWindowCurvePlacement.Decision3:
                endPos = new Vector3(end.x + end.width, end.y + (end.height / 2 - 20), 0);
                break;

            case EWindowCurvePlacement.Decision4:
                endPos = new Vector3(end.x + end.width, end.y + (end.height / 2 - 0), 0);
                break;

            case EWindowCurvePlacement.Decision5:
                endPos = new Vector3(end.x + end.width, end.y + (end.height / 2 + 20), 0);
                break;
            }


            Vector3 startTan = startPos + Vector3.right * 50;
            Vector3 endTan   = endPos + Vector3.left * 50;

            Handles.Label(((startPos + endPos) * .5f) + Vector3.down * -5, t != null ? t.Value : "", GUIStylizer.GetStyle(curveColor, TextAnchor.MiddleCenter, 25));

            for (int i = 0; i < 3; i++)
            {
                Handles.DrawBezier(startPos, endPos, startTan, endTan, Color.black, null, 4);
            }
            Handles.DrawBezier(startPos, endPos, startTan, endTan, disable ? Color.black : curveColor, null, 3);
            if (t != null && t.enableClickPoint)
            {
                DrawTransitionClickPoint(t, startPos, endPos);
            }
        }