상속: MonoBehaviour
예제 #1
0
 // Description:	Setter for SimViewRoad
 // PRE:			The properties of origin, destination and roadRenderer are uninitialized
 // POST:		Initialize origin, destination and roadRenderer with the parameters passed in
 public void SetProperties(BuildViewNode theOrigin, BuildViewNode theDestination, int theNumOfLane)
 {
     origin      = theOrigin;
     destination = theDestination;
     _length     = Vector3.Distance(origin.transform.position, destination.transform.position);
     _numOfLane  = theNumOfLane;
 }
 // Description: Removes a node from the list of selected nodes
 // PRE:         The node given exists in selectedNodes and has a SpriteRenderer
 // POST:        The node will no longer exist in selectedNodes and the UI
 //              will accurately reflect this change
 public void RemoveNode(BuildViewNode exisitingNode)
 {
     selectedNodes.Remove(exisitingNode.node);
     exisitingNode.node.GetComponent <SpriteRenderer>().sprite = (Sprite)Resources.Load("BuildNode", typeof(Sprite));
     UpdateNodeInspector();
     UpdateLinkInspector();
 }
예제 #3
0
 // Description:	Setter for SimViewRoad
 // PRE:			The properties of origin, destination and roadRenderer are uninitialized
 // POST:		Initialize origin, destination and roadRenderer with the parameters passed in
 public void SetProperties(BuildViewNode theOrigin, BuildViewNode theDestination, int theNumOfLane)
 {
     origin = theOrigin;
     destination = theDestination;
     _length = Vector3.Distance(origin.transform.position, destination.transform.position);
     _numOfLane = theNumOfLane;
 }
 // Description: Adds a node to the list of selected nodes and reflects these updates in the UI
 // PRE:         The node given exists in the scene and has a SpriteRenderer
 // POST:        The node is in the list of selected nodes
 public void AddNode(BuildViewNode newNode)
 {
     if (!selectedNodes.Contains(newNode.node))
     {
         selectedNodes.Add(newNode.node);
         newNode.node.GetComponent <SpriteRenderer>().sprite = (Sprite)Resources.Load("BuildViewNode", typeof(Sprite));
         UpdateNodeInspector();
         UpdateLinkInspector();
     }
 }
 // Description: Adds a node to the list of selected nodes and reflects these updates in the UI
 // PRE:         The node given exists in the scene and has a SpriteRenderer
 // POST:        The node is in the list of selected nodes
 public void AddNode(BuildViewNode newNode)
 {
     if (!selectedNodes.Contains(newNode.node))
     {
         selectedNodes.Add(newNode.node);
         newNode.node.GetComponent<SpriteRenderer>().sprite = (Sprite) Resources.Load("BuildViewNode", typeof(Sprite));
         UpdateNodeInspector();
         UpdateLinkInspector();
     }
 }
    // Description: Deletes a node and ensures all connected links are also deleted.
    // PRE:         existingNode is a node that exists in the scene
    // POST:        The node and it's connected links are removed/deleted
    public void DeleteNodeInstances(BuildViewNode existingNode)
    {
        List<ConnectedNodes> nodesToBeDeleted = new List<ConnectedNodes>();
        Node node = existingNode.node;
        selectedNodes.Remove(existingNode.node);

        foreach(ConnectedNodes cn in connectedNodes.Keys)
        {
            if (cn.origin == node || cn.destination == node)
            {
                nodesToBeDeleted.Add(cn);
            }
        }

        for(int i = nodesToBeDeleted.Count - 1; i >= 0; i--)
        {
            Destroy((GameObject) connectedNodes[nodesToBeDeleted[i]]);
            UpdateNumberOfNodeConnections(nodesToBeDeleted[i], false);
            connectedNodes.Remove(nodesToBeDeleted[i]);
        }
    }
    // Description: Deletes a node and ensures all connected links are also deleted.
    // PRE:         existingNode is a node that exists in the scene
    // POST:        The node and it's connected links are removed/deleted
    public void DeleteNodeInstances(BuildViewNode existingNode)
    {
        List <ConnectedNodes> nodesToBeDeleted = new List <ConnectedNodes>();
        Node node = existingNode.node;

        selectedNodes.Remove(existingNode.node);

        foreach (ConnectedNodes cn in connectedNodes.Keys)
        {
            if (cn.origin == node || cn.destination == node)
            {
                nodesToBeDeleted.Add(cn);
            }
        }

        for (int i = nodesToBeDeleted.Count - 1; i >= 0; i--)
        {
            Destroy((GameObject)connectedNodes[nodesToBeDeleted[i]]);
            UpdateNumberOfNodeConnections(nodesToBeDeleted[i], false);
            connectedNodes.Remove(nodesToBeDeleted[i]);
        }
    }
 // Description: Removes a node from the list of selected nodes
 // PRE:         The node given exists in selectedNodes and has a SpriteRenderer
 // POST:        The node will no longer exist in selectedNodes and the UI
 //              will accurately reflect this change
 public void RemoveNode(BuildViewNode exisitingNode)
 {
     selectedNodes.Remove(exisitingNode.node);
     exisitingNode.node.GetComponent<SpriteRenderer>().sprite = (Sprite)Resources.Load("BuildNode", typeof(Sprite));
     UpdateNodeInspector();
     UpdateLinkInspector();
 }