本文整理汇总了C#中Unit.getNode方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.getNode方法的具体用法?C# Unit.getNode怎么用?C# Unit.getNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit.getNode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PathMemoizer
public PathMemoizer(PathFinder p, Unit unitRef)
{
uRef = unitRef;
pathFinderRef = p;
nodesCanWalkTo = new List<Node>();
nodesCanWalkToSet = new HashSet<Node>();
nodesInRange = new List<Node>(); ;
nodesInRangeSet = new HashSet<Node>();
reverseNodesInRangeSetCost = new Dictionary<Node, int>();
currentTargets = new List<Node.NodePointer>();
initialize(unitRef.getNode(), unitRef.getCurrentWater());
}
示例2: DoNothing
/// <summary>
/// Creates an action that causes a unit to
/// stay in place and not attack anything.
/// </summary>
/// <param name="u">The unit to create the action for.</param>
/// <returns>The UnitAction.</returns>
public static UnitAction DoNothing(Unit u)
{
return new UnitAction(u, null, u.getNode());
}
示例3: getClosestNode
/// <summary>
/// Does Dijkstra to find the first thing that satisfies a pred, returns null if nothing found.
/// </summary>
public Node getClosestNode(Unit u, Predicate<Node> satisfies)
{
List<Node> nodeList = pathFinderRef.nodesThatSatisfyPred(u.getNode(), satisfies, float.PositiveInfinity, true, false);
if (nodeList.Count > 0)
return nodeList[0];
else
return null;
}
示例4: Update
public void Update()
{
if (delayTime <= 0 && !moving)
{
if (aiTurn && toActAI.Count == 0)
{
selectionState = State.EnemyTurn;
foreach (Unit unit in aiUnits)
toActAI.Enqueue(unit);
if (toActAI.Count == 0)
{
moving = true;
UIManager.getUIManager().clearDisplay();
pathFinder.clearRangeDisplay();
return;
}
}
if (aiTurn)
{
currentAIUnit = toActAI.Dequeue();
UIManager.getUIManager().setDisplayedUnit(currentAIUnit);
pathFinder.displayRangeOfUnit(currentAIUnit, currentAIUnit.getNode().getPos());
currentAction = ai.RunAI(currentAIUnit, playerUnits);
UIManager.getUIManager().setDisplayedUnit(currentAIUnit);
lockMovement();
currentAction.Move(finishedMoveCallbackAI);
}
if (!aiTurn && toActAI.Count == 0)
{
selectionState = State.EnemyTurn;
foreach (Unit unit in playerUnits)
toActAI.Enqueue(unit);
if (toActAI.Count == 0)
{
moving = true;
UIManager.getUIManager().clearDisplay();
pathFinder.clearRangeDisplay();
return;
}
}
if (!aiTurn)
{
currentAIUnit = toActAI.Dequeue();
UIManager.getUIManager().setDisplayedUnit(currentAIUnit);
pathFinder.displayRangeOfUnit(currentAIUnit, currentAIUnit.getNode().getPos());
currentAction = ai.RunAI(currentAIUnit, aiUnits);
UIManager.getUIManager().setDisplayedUnit(currentAIUnit);
lockMovement();
currentAction.Move(finishedMoveCallbackAI);
}
else
{
selectionState = State.OurTurnNoSelection;
if (Input.GetMouseButtonDown((int)MouseButton.left))
{
Vector2 position = getMousePos();
if (positionInGraph(position))
{
Node clickedNode = pathFinder.closestMostValidNode(position);
if (unitSelected)
{
currentlySelectedUnit.deselect();
unitSelected = false;
selectionState = State.OurTurnNoSelection;
}
if (clickedNode.Occupied)
{
currentlySelectedUnit = clickedNode.Occupier;
currentlySelectedUnit.select();
unitSelected = true;
pathFinder.displayRangeOfUnit(currentlySelectedUnit, position);
if (currentlySelectedUnit.isEnemy())
selectionState = State.UnitActed;
else
selectionState = State.UnitFresh;
}
else
{
pathFinder.clearRangeDisplay();
selectionState = State.OurTurnNoSelection;
}
}
}
if (Input.GetMouseButtonDown((int)MouseButton.right))
{
//.........这里部分代码省略.........