示例#1
0
    // For edit
    public TrafficAIVoNode AddNode(int type, int?id = null)
    {
        var node = new TrafficAIVoNode();

        node.Type = type;

        // Init id
        if (id == null)
        {
            node.Id = this.LatestId(type) + IdBasic;
        }
        else
        {
            node.Id = (int)id;
        }

        if (this.nodeDictDict[type].ContainsKey(node.Id))
        {
            return(this.nodeDictDict[type][node.Id]);
        }

        // Add
        this.nodeListDict[type].Add(node);
        this.nodeDictDict[type].Add(node.Id, node);

        this.nodeListDict[type].Sort((e1, e2) => e1.Id - e2.Id);

        return(node);
    }
示例#2
0
    void InitNode(Vo_Traffic_Node config)
    {
        var type = config.type;
        var node = new TrafficAIVoNode(config);

        this.nodeListDict[type].Add(node);
        this.nodeDictDict[type].Add(node.Id, node);
    }
示例#3
0
    // For edit
    public void RemoveNode(TrafficAIVoNode node)
    {
        var type = node.Type;

        this.nodeListDict[type].Remove(node);
        this.nodeDictDict[type].Remove(node.Id);

        Debug.Log("TrafficModel::RemoveNode " + node.Id);
    }
示例#4
0
    // For edit
    public void RemoveEdge(TrafficAIVoNode start, TrafficAIVoNode end)
    {
        var type = start.Type;
        var id   = this.EdgeId(start.Id, end.Id);

        // Remove
        this.edgeDictDict[type].Remove(id);

        Debug.Log("TrafficModel::RemoveEdge " + id);
    }
    public TrafficAIEditNode AddNode(TrafficAIVoNode data)
    {
        var prefab = this.Node;
        var go     = UtilGameObject.CreateByGO(prefab, this.gameObject);

        var script = go.AddComponent <TrafficAIEditNode>();

        go.AddComponent <TrafficAIEditNodeLink>();

        // Init
        script.Data      = data;
        script.Data.Edit = script;
        script.ReInit();

        return(script);
    }
示例#6
0
    // For edit
    public void AddEdge(TrafficAIVoNode start, TrafficAIVoNode end)
    {
        var type = start.Type;
        var edge = new TrafficAIVoEdge();

        edge.Type  = type;
        edge.Start = start;
        edge.End   = end;
        edge.Id    = this.EdgeId(edge.StartId, edge.EndId);

        if (this.edgeDictDict[type].ContainsKey(edge.Id))
        {
            return;
        }

        // Add
        this.edgeDictDict[type].Add(edge.Id, edge);
    }