Example #1
0
    void Start()
    {
        //Randomly Generate Model
        GameObject prefab = template.modelPrefabs.RandomItem();

        GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, modelHolder);

        if (pivotPosition.index == 0)
        {
            pivotPosition = HexMapHelper.GetTileFromWorldPoint(transform.position);
        }
        TileCoords pivotFacing = HexMapHelper.GetNeighborTiles(pivotPosition).RandomItem();

        transform.position             = HexMapHelper.GetWorldPointFromTile(pivotPosition, pivotLevel);
        modelHolder.transform.rotation = HexMapHelper.GetRotationFromFacing(pivotPosition, pivotFacing);

        footprint = new StaticFootprint(template.footprint, pivotPosition, pivotFacing, pivotLevel);
    }
Example #2
0
    // Start is called before the first frame update
    void Start()
    {
        TileCoords     startTile = HexMapHelper.GetTileFromWorldPoint(transform.position);
        TileWithFacing startVec  = new TileWithFacing()
        {
            position = startTile,
            facing   = HexMapHelper.GetNeighborTiles(startTile)[facingIndex]
        };

        List <TileWithLevel> footprintParts = new List <TileWithLevel>();

        footprintParts.Add(new TileWithLevel()
        {
            position = startVec.position, level = level
        });

        List <Vector3> lineNodes  = new List <Vector3>();
        TileWithFacing currentVec = startVec;

        for (int nodeIndex = 0; nodeIndex < maxLength; nodeIndex++)
        {
            currentVec = currentVec.Traverse(HexDirection.Forward);
            if (currentVec.position == startVec.position)
            {
                break;
            }
            lineNodes.Add(HexMapHelper.GetWorldPointFromTile(currentVec.position, level));
            footprintParts.Add(new TileWithLevel()
            {
                position = currentVec.position, level = level
            });
        }
        line.positionCount = lineNodes.Count;
        line.SetPositions(lineNodes.ToArray());

        footprint = new StaticFootprint(footprintParts);
    }