本文整理汇总了C#中Node.IsTemporary方法的典型用法代码示例。如果您正苦于以下问题:C# Node.IsTemporary方法的具体用法?C# Node.IsTemporary怎么用?C# Node.IsTemporary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node
的用法示例。
在下文中一共展示了Node.IsTemporary方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ManageAbstractNodes
public void ManageAbstractNodes(Node refNode,bool add=true)
{
if (refNode != null)
{
if (add&&!refNode.IsTemporary())
{
bool isValid = true;
int minX = 0;// ((int)mainAbstractGrid.mainGrid.transform.position.x);
int minZ = 0;// ((int)mainAbstractGrid.mainGrid.transform.position.z);
int maxX = (mainAbstractGrid.mainGrid.gridSize - 1);// +((int)mainAbstractGrid.mainGrid.transform.position.x);
int maxZ = (mainAbstractGrid.mainGrid.gridSize - 1);// +((int)mainAbstractGrid.mainGrid.transform.position.z);
/*if (refNode.xVal == minX && refNode.zVal == minZ)
isValid = false;
if (refNode.xVal == maxX && refNode.zVal == maxZ)
isValid = false;
if (refNode.xVal == minX && refNode.zVal == maxZ)
isValid = false;
if (refNode.xVal == maxX && refNode.zVal == minZ)
isValid = false;*/
if (isValid)
{
//Create a new Node
//Add to NodeList
Vector3 newLocation = refNode.gridCoordinates;
Node newNode = new Node(this.mainAbstractGrid.mainGrid, newLocation, NodeType.Abstract, nodeCounter);
nodeCounter++;
newNode.SetClusterParent(this);
nodeList.Add(newNode);
mainAbstractGrid.ManageAbstractNodeList(newNode);
}
}
else if (add && refNode.IsTemporary())
{
//If an Inserted Node
if (!nodeList.Contains(refNode))
{
nodeList.Add(refNode);
}
}
else
{
//If Remove
nodeList.Remove(refNode);
if(refNode.IsTemporary())
refNode = null;
}
}
}
示例2: StoreRefreshedPath
public void StoreRefreshedPath(Node startNode, Node endNode)
{
if (!startNode.IsTemporary() && !endNode.IsTemporary())
{
Node refStartNode = mainAbstractGrid.mainGrid.LookUpNode(startNode.xVal, startNode.zVal);
Node refEndNode = mainAbstractGrid.mainGrid.LookUpNode(endNode.xVal, endNode.zVal);
List<Node> newPath = mainAbstractGrid.mainGrid.FindPath(refStartNode, refEndNode);
int connectionKey = GetConnectionKey(startNode, endNode);
if (newPath != null&&storedPathsDictionary.ContainsKey(connectionKey))
{
storedPathsDictionary[connectionKey] = newPath;
}
}
}
示例3: RemoveNode
public void RemoveNode(Node newNode)
{
if (newNode.IsTemporary())
{
foreach (Node n in nodeDictionary.Values)
{
Node removeNode = null;
for (int j = 0; j < n.neighbors.Count; j++)
{
if (n.neighbors[j] == newNode)
removeNode = newNode;
}
if (removeNode != null)
n.neighbors.Remove(removeNode);
}
ManageNodeList(newNode, false);
}
}
示例4: ManageNodeList
public void ManageNodeList(Node refNode, bool add = true)
{
if (refNode != null)
{
if (add && !refNode.IsTemporary())
{
bool isValid = true;
//Check if node already exists
string tempKey = GetNodeKey(refNode);
Node tempNode = LookUpNode(tempKey);
if (tempNode != null)
isValid = false;
if (isValid)
{
if (refNode.nodesConnectingTo != null)
{
//ISSUE WITH refNode nodesConnectingTo
Node newNode = new Node(refNode.gridParent, refNode.gridCoordinates, NodeType.Abstract, nodeCounter);
for (int i = 0; i < refNode.nodesConnectingTo.Count; i++)
{
newNode.ManageNodesConnectingTo(refNode.nodesConnectingTo[i]);
}
nodeCounter++;
string newKey = GetNodeKey(newNode);
nodeDictionary.Add(newKey, newNode);
}
}
}
else if (add && refNode.IsTemporary())
{
//If an Inserted Node
if (!nodeDictionary.ContainsValue(refNode))
{
string newKey = GetNodeKey(refNode);
nodeDictionary.Add(newKey, refNode);
}
}
else
{
//If Remove
string newKey = GetNodeKey(refNode);
if (nodeDictionary.ContainsKey(newKey))
nodeDictionary.Remove(newKey);
if (refNode.IsTemporary())
refNode = null;
}
}
}
示例5: RemoveNode
public void RemoveNode(Node newNode)
{
//Only Remove if Node is NOT ABSTRACT
if (newNode.IsTemporary())
{
NodeCluster newCluster = newNode.clusterParent;
ManageAbstractNodeList(newNode, false);
for (int i = 0; i < newCluster.nodeList.Count; i++)
{
Node removeNode=null;
for (int j = 0; j < newCluster.nodeList[i].neighbors.Count; j++)
{
if (newCluster.nodeList[i].neighbors[j] == newNode)
removeNode = newNode;
}
if (removeNode != null)
newCluster.nodeList[i].neighbors.Remove(removeNode);
}
newCluster.ManageAbstractNodes(newNode, false);
newCluster.SetAbstractConnections();
}
}
示例6: ManageNodeList
public void ManageNodeList(Node refNode, bool add =true)
{
if (refNode != null)
{
if (add && !refNode.IsTemporary())
{
bool isValid = true;
Node tempNode = LookUpNode(refNode.xVal, refNode.zVal);
if (tempNode != null)
isValid = false;
if (isValid)
{
Node newNode = new Node(refNode.gridParent, refNode.xVal, refNode.yVal, refNode.zVal, NodeType.Abstract, nodeCounter);
newNode.nodeConnectingTo = refNode.nodeConnectingTo;
nodeCounter++;
int newKey = Grid.GetNodeKey(newNode);
nodeDictionary.Add(newKey, newNode);
}
}
else if (add && refNode.IsTemporary())
{
//If an Inserted Node
if (!nodeDictionary.ContainsValue(refNode))
{
int newKey = Grid.GetNodeKey(refNode);
nodeDictionary.Add(newKey, refNode);
}
}
else
{
//If Remove
int newKey = Grid.GetNodeKey(refNode);
if (nodeDictionary.ContainsKey(newKey))
nodeDictionary.Remove(newKey);
if (refNode.IsTemporary())
refNode = null;
}
}
}