Пример #1
0
    private void DoPathFinding()
    {
        if (brain == null)
        {
            Dictionary <Transform, List <Link> > linkMap = graph.nodes.ToDictionary(node => node, graph.GetLinksToNode);
            brain = new JulesStarBrain(linkMap);
        }

        bestPath = brain.GetBestPath(start.accessPoints, new HashSet <Transform>(end.accessPoints));
        if (bestPath != null)
        {
            pathDisplay.Display(bestPath);
            startIndicator.transform.position = bestPath.start.position + (1f * -Vector3.forward);
            endIndicator.transform.position   = bestPath.lastNode.position + (1f * -Vector3.forward);
        }
    }
Пример #2
0
    void MoveCheck()
    {
        for (int i = 0; i < moveRangeTiles.Length; i++)
        {
            moveRangeTiles[i].Highlight(moveColor);
        }
        if (CastleManager.hoveredObject is Tile)
        {
            if (CheckRange((Tile)CastleManager.hoveredObject))
            {
                moveTile = (Tile)CastleManager.hoveredObject;
                //GetAttackTiles(moveTile);
            }
        }
        //for (int i = 0; i < attackRangeTiles.Count; i++)
        //{
        //	attackRangeTiles[i].HighlightSecondary(attackColor);
        //}
        if (moveTile != tile)
        {
            if (pathfinding == null)
            {
                pathfinding = Pathfinding.GetPath(tile, moveTile);
            }
            else
            {
                pathfinding.Create(tile, moveTile);
            }

            pathDisplay.Display(pathfinding);
            pathDisplay.line.startColor = pathDisplay.line.endColor = GameManager.instance.players[player].unitColor;
            if (CastleManager.selectedObject && CastleManager.selectedObject is Tile)
            {
                if (CastleManager.selectedObject == tile)
                {
                    Unselect();
                }
                else if (CheckRange((Tile)CastleManager.selectedObject))
                {
                    movementUsed += pathfinding.path[pathfinding.path.Count - 1].index;
                    Move(moveTile);
                }
            }
        }
    }