Ejemplo n.º 1
0
    private void GenerateGrid()
    {
        var positions = BoardPositionHelper.GenerateBoard(_size);

        foreach (var position in positions)
        {
            var hex = PrefabUtility.InstantiatePrefab(_hexPrefab) as GameObject;
            var pos = position.ToAxial().ToPixel();
            hex.transform.position = new Vector3(pos.x, 0, pos.y);
            hex.name = $"Hex (X:{position.x} Y:{position.y} Z:{position.z})";
        }
    }
Ejemplo n.º 2
0
        public void PlaceRandomEnemies()
        {
            var spots = new List <CubicHexCoord>()
            {
                new CubicHexCoord()
            };
            var board = BoardPositionHelper.GenerateBoard(_boardSize);

            while (spots.Count <= _enemyAmount)
            {
                var go = Instantiate(_enemyPrefab);

                CubicHexCoord spot = GetRandomSpot(board);
                while (spots.Contains(spot))
                {
                    spot = GetRandomSpot(board);
                }

                go.transform.position = BoardPositionHelper.BoardToWorldPosition(spot);
                spots.Add(spot);
            }
        }