Esempio n. 1
0
    private void HighlightPath(IEnumerable <IPathNode <HexNode> > path)
    {
        if (path == null)
        {
            return;
        }

        Dictionary <ITile, bool> tiles = new Dictionary <ITile, bool>();

        IEnumerator <IPathNode <HexNode> > enumerator = path.GetEnumerator();

        //enumerator.MoveNext(); // Skips first //
        //tiles.Add(enumerator.Current.GetNode().Tile, true);

        while (enumerator.MoveNext())
        {
            IPathNode <HexNode> node    = enumerator.Current;
            HexNode             hexNode = node.GetNode();
            ITile tile = hexNode.Tile;

            if (tiles.ContainsKey(tile))
            {
                continue;
            }
            tiles.Add(tile, true);

            Vector3    position = new Vector3(tile.PosX, tile.PosY + 0.05f, tile.PosZ);
            Quaternion rotation = Quaternion.Euler(90, hexNode.Direction.DirectionRotation() - 90, 0);

            GameObject highlight = Instantiate(pathArrowPrefab, position, rotation, transform);
            highlightedPath.Add(highlight);
            lastPathArrowRotation = rotation;
        }
    }
Esempio n. 2
0
    private IEnumerator Step(IPathNode <HexNode> pathNode)
    {
        HexNode node = pathNode.GetNode();

        if (node.Direction != orientation)
        {
            yield return(Rotate(node));
        }
        else
        {
            yield return(Walk(node));
        }
    }