// Start is called before the first frame update
    protected virtual void Start()
    {
        currentTile       = HexMapHelper.GetTileFromWorldPoint(transform.position);
        currentTileFacing = HexMapHelper.GetNeighborTiles(currentTile)[0];

        PositionAndOrientPiece();
        eventPublisher.Publish(new Events.CompletedSetup());
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        Vector3    cursorWorldPos = GetPlaneIntersection();
        TileCoords selectedTile   = HexMapHelper.GetTileFromWorldPoint(cursorWorldPos);

        //Debug.Log("SelectedTile = " + selectedTile);
        transform.position = HexMapHelper.GetWorldPointFromTile(selectedTile, HexMapUI.currentUIMapLevel);
    }
Exemple #3
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);
    }
Exemple #4
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);
    }