Esempio n. 1
0
    private void OnCreateBoard(IBoard board)
    {
        var maxPosY = float.MinValue;
        var maxPosX = float.MinValue;
        var minPosY = float.MaxValue;
        var minPosX = float.MaxValue;

        foreach (var pos in board.Positions)
        {
            var hex          = pos.Point;
            var cell         = BoardManipulationOddR.GetCellCoordinate(hex);
            var worldCellPos = tileMap.CellToWorld(cell);

            if (worldCellPos.x > maxPosX)
            {
                maxPosX = worldCellPos.x;
            }
            if (worldCellPos.y > maxPosY)
            {
                maxPosY = worldCellPos.y;
            }

            if (worldCellPos.x < minPosX)
            {
                minPosX = worldCellPos.x;
            }
            if (worldCellPos.y < minPosY)
            {
                minPosY = worldCellPos.y;
            }
        }

        Centralize(minPosX, minPosY, maxPosX, maxPosY);
    }
        void OnDrawGizmos()
        {
            if (CurrentBoard == null)
            {
                return;
            }

            foreach (var hex in controller.boardShape.GetHexPoints())
            {
                var cell          = BoardManipulationOddR.GetCellCoordinate(hex);
                var worldPosition = tileMap.CellToWorld(cell);
                Gizmos.DrawWireSphere(worldPosition, 0.93f);
            }
        }
Esempio n. 3
0
        void CreateBoardUi()
        {
            foreach (var element in _registerUiElements.Values)
            {
                ObjectPooler.Instance.Release(element.gameObject);
            }

            _registerUiElements.Clear();
            TileMap.ClearAllTiles();
            foreach (var pos in CurrentBoard.Positions)
            {
                var hex  = pos.Point;
                var cell = BoardManipulationOddR.GetCellCoordinate(hex);
                TileMap.SetTile(cell, test);
            }
        }
Esempio n. 4
0
 private void OnCreateBoard(IBoard board)
 {
     Hide();
     _highlights.Clear();
     foreach (var p in board.Positions)
     {
         var hex           = p.Point;
         var cell          = BoardManipulationOddR.GetCellCoordinate(hex);
         var worldPosition = TileMap.CellToWorld(cell);
         var highlight     = Instantiate(highlightTiles, worldPosition, Quaternion.identity, transform)
                             .GetComponent <UiHoverParticleSystem>();
         highlight.name = hex.ToString();
         if (!_highlights.ContainsKey(hex))
         {
             _highlights.Add(hex, highlight);
         }
     }
 }
        void DrawPositions()
        {
            const string uiPosition = "UiPosition_";
            var          identity   = Quaternion.identity;

            ClearPositions();
            _positions = new GameObject[CurrentBoard.Positions.Length];
            for (var i = 0; i < CurrentBoard.Positions.Length; i++)
            {
                var hex           = CurrentBoard.Positions[i].Point;
                var cell          = BoardManipulationOddR.GetCellCoordinate(hex);
                var worldPosition = tileMap.CellToWorld(cell);
                var gameObj       = Instantiate(textPosition, worldPosition, identity, transform);
                _positions[i] = gameObj;
                var tmpText   = gameObj.GetComponent <TMP_Text>();
                var sPosition = $"x:{hex.q}\ny:{hex.r}\nz:{hex.s}";
//                var sPosition = $"x:{cell.x}\ny:{cell.y}";
                tmpText.text = sPosition;
                tmpText.name = uiPosition + sPosition;
            }
        }