public override void Show()
    {
        if (dataNode.type == SkillNodeType.Root && dataNode is SkillData)
        {
            var skillData = dataNode as SkillData;
            Title("技能【" + skillData.skillId + "】");
            skillData.skillId = (SkillId)EditorGUI.EnumPopup(NodeRect.LayoutV(20), skillData.skillId);
        }
        else
        {
            Title("[" + dataNode.type + "]");
            dataNode.type = (SkillNodeType)EditorGUI.EnumPopup(NodeRect.LayoutV(20), dataNode.type);
        }

        ViewLayout.BeginH();
        for (int i = 0; i < dataNode.boolParams.Count; i++)
        {
            dataNode.boolParams[i] = EditorGUI.Toggle(NodeRect.LayoutH(15, 15), dataNode.boolParams[i]);
        }
        ViewLayout.EndH();


        ViewLayout.BeginH();
        for (int i = 0; i < dataNode.fixedParams.Count; i++)
        {
            dataNode.fixedParams[i] = EditorGUI.FloatField(NodeRect.LayoutH(30, 15), dataNode.fixedParams[i].ToFloat()).ToFixed();
        }
        ViewLayout.EndH();
    }
Exemplo n.º 2
0
    private List <NodeRect> FindRoomsPath()
    {
        List <NodeRect> roomsPath = new List <NodeRect>();

        //Find start room
        NodeRect startRoom = FindRoomFromPoint(start);
        NodeRect endRoom   = FindRoomFromPoint(end);

        if (start != null && end != null)
        {
            //Assume only 1 direct path exists, no DFS or DFS is used
            var currentRoom = startRoom;

            while (currentRoom != endRoom)
            {
                roomsPath.Add(currentRoom);
                currentRoom = GetNextRoom(currentRoom, roomsPath);
                if (currentRoom == null)
                {
                    return(null);
                }
            }
        }
        roomsPath.Add(endRoom);
        return(roomsPath);
    }
Exemplo n.º 3
0
        /// <summary>
        /// the events or inputs
        /// </summary>
        /// <param name="e"></param>
        public override void PollEvents(Event e)
        {
            switch (e.type)
            {
            case EventType.MouseDown:
                if (e.button == 0 && NodeRect.Contains(e.mousePosition))
                {
                    IsSelected  = true;
                    IsDraggable = true;
                }
                break;

            case EventType.MouseUp:
                if (e.button == 0)
                {
                    IsDraggable = false;
                }
                break;

            case EventType.MouseDrag:
                if (e.button == 0 && IsDraggable)
                {
                    Drag(e);
                }
                break;

            case EventType.KeyDown:
                break;

            case EventType.KeyUp:
                break;
            }

            base.PollEvents(e);
        }
Exemplo n.º 4
0
    public bool ProcessEvent(Event _e)
    {
        switch (_e.type)
        {
        case EventType.MouseDown:
            if (_e.button == 0)
            {
                if (NodeRect.Contains(_e.mousePosition))
                {
                    m_isDragged = true;
                    GUI.changed = true;
                    IsSelected  = true;
                    m_nodeStyle = m_selectedNodeStyle;
                }
                else
                {
                    GUI.changed = true;
                    IsSelected  = false;
                    m_nodeStyle = m_defaultNodeStyle;
                }
            }
            else if (_e.button == 1 && IsSelected && NodeRect.Contains(_e.mousePosition))
            {
                ProcessContextMenu();
                _e.Use();
            }
            else
            {
                m_isDragged = false;
            }
            break;

        case EventType.MouseUp:
            m_isDragged = false;
            break;

        case EventType.MouseDrag:
            if (_e.button == 0 && m_isDragged)
            {
                Drag(_e.delta);
                _e.Use();
                return(true);
            }
            break;

        default:
            break;
        }
        return(false);
    }
Exemplo n.º 5
0
 private NodeRect GetNextRoom(NodeRect currentRoom, List <NodeRect> roomsPath)
 {
     for (int i = 0; i < rooms.Count; i++)
     {
         int j = rooms.IndexOf(currentRoom);
         if ((graph[i, j] != null) &&
             ((roomsPath.Count <= 1) || // 1st step
              rooms[i] != roomsPath[roomsPath.Count - 2]))   //not going backwards
         {
             return(rooms[i]);
         }
     }
     return(null);
 }
Exemplo n.º 6
0
    private void Awake()
    {
        var n1 = new NodeRect {
            Rect = new Rect(0, 0, 2, 2)
        };
        var n2 = new NodeRect {
            Rect = new Rect(1, 2, 2, 2)
        };
        var n3 = new NodeRect {
            Rect = new Rect(3, 1, 1, 2)
        };
        var n4 = new NodeRect {
            Rect = new Rect(4, 1, 2, 2)
        };

        _rects = new List <NodeRect> {
            n1, n2, n3, n4
        };

        var e1 = new NodeEdge {
            Node1 = n1, Node2 = n2, P1 = new Vector2(1, 2), P2 = new Vector2(2, 2)
        };
        var e2 = new NodeEdge {
            Node1 = n2, Node2 = n3, P1 = new Vector2(3, 2), P2 = new Vector2(3, 3)
        };
        var e3 = new NodeEdge {
            Node1 = n3, Node2 = n4, P1 = new Vector2(4, 1), P2 = new Vector2(4, 3)
        };

        var p1 = new Vector2(0, 0);
        var p2 = new Vector2(6, 2);

        _nodeEdges = new List <NodeEdge> {
            e1, e2, e3
        };
        _path = CreatePath(p1, p2, _nodeEdges, 0.1f);
    }
Exemplo n.º 7
0
    public override void Show()
    {
        if (dataNode.intType > 10 && dataNode.intType < 100)
        {
            Title("组合【" + dataNode.CompositeType + "】");
            dataNode.CompositeType = (CompositeType)EditorGUI.EnumPopup(NodeRect.LayoutV(20), dataNode.CompositeType);
        }
        else if (dataNode.intType > 100 && dataNode.intType < 1000)
        {
            Title("动作【" + dataNode.ActionType + "】");
            dataNode.ActionType = (ActionType)EditorGUI.EnumPopup(NodeRect.LayoutV(20), dataNode.ActionType);
        }
        // if(dataNode.type==SkillNodeType.Root&&dataNode is SkillData){
        //  var skillData=dataNode as SkillData;
        //  Title("技能【"+skillData.skillId+"】");
        //  skillData.skillId=(SkillId)EditorGUI.EnumPopup(NodeRect.LayoutV(20),skillData.skillId);
        // }else
        // {
        //  Title("["+dataNode.type+"]");
        //  dataNode.type=(SkillNodeType)EditorGUI.EnumPopup(NodeRect.LayoutV(20),dataNode.type);
        // }

        // ViewLayout.BeginH();
        // for (int i = 0; i < dataNode.boolParams.Count; i++)
        // {
        //  dataNode.boolParams[i]=EditorGUI.Toggle(NodeRect.LayoutH(15,15),dataNode.boolParams[i]);
        // }
        // ViewLayout.EndH();

        // ViewLayout.BeginH();
        // for (int i = 0; i < dataNode.intParams.Count; i++)
        // {
        //  dataNode.intParams[i]=EditorGUI.IntField(NodeRect.LayoutH(30,15),dataNode.intParams[i]);
        // }
        // ViewLayout.EndH();
    }
Exemplo n.º 8
0
 public static bool IsEmptyRect(this NodeRect rect)
 {
     return(rect.Width == 0 || rect.Height == 0);
 }