当前位置: 首页>>代码示例>>C#>>正文


C# Unit.getNode方法代码示例

本文整理汇总了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());
            }
开发者ID:punster94,项目名称:AI-for-Game-Design,代码行数:14,代码来源:PathManager.cs

示例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());
 }
开发者ID:punster94,项目名称:AI-for-Game-Design,代码行数:10,代码来源:UnitAction.cs

示例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;
 }
开发者ID:punster94,项目名称:AI-for-Game-Design,代码行数:11,代码来源:PathManager.cs

示例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))
                {
//.........这里部分代码省略.........
开发者ID:punster94,项目名称:AI-for-Game-Design,代码行数:101,代码来源:TurnManager.cs


注:本文中的Unit.getNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。