Example #1
0
    /// <summary>
    /// Creates a pathfinding instance and generates a path for you.
    /// </summary>
    /// <param name="start">Start tile</param>
    /// <param name="end">End tile</param>
    /// <returns></returns>
    public static Pathfinding GetPath(Tile start, Tile end)
    {
        Pathfinding newPath = new Pathfinding();

        newPath.Create(start, end);
        return(newPath);
    }
Example #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);
                }
            }
        }
    }