diff --git a/Assets/Prefab/Hex Cell Label.prefab b/Assets/Prefab/Hex Cell Label.prefab index 06a732c0..4593a8b8 100644 --- a/Assets/Prefab/Hex Cell Label.prefab +++ b/Assets/Prefab/Hex Cell Label.prefab @@ -92,8 +92,8 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 1 - m_fontSizeBase: 1 + m_fontSize: 0.3 + m_fontSizeBase: 0.3 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 18 diff --git a/Assets/Scripts/HexFiled/HexCell.cs b/Assets/Scripts/HexFiled/HexCell.cs index 6b31a579..3ac02e11 100644 --- a/Assets/Scripts/HexFiled/HexCell.cs +++ b/Assets/Scripts/HexFiled/HexCell.cs @@ -51,10 +51,10 @@ namespace HexFiled } _renderer.material.mainTexture = _cellColor[color].Texture; - onHexPainted?.Invoke(this); + _color = color; Instantiate(_cellColor[color].VFXPrefab, transform); - + onHexPainted?.Invoke(this); } } diff --git a/Assets/Scripts/HexFiled/HexGrid.cs b/Assets/Scripts/HexFiled/HexGrid.cs index e4a3ecdb..45bc6d71 100644 --- a/Assets/Scripts/HexFiled/HexGrid.cs +++ b/Assets/Scripts/HexFiled/HexGrid.cs @@ -100,16 +100,16 @@ namespace HexFiled } } } - } -// #if UNITY_EDITOR -// TMP_Text label = Object.Instantiate(_cellLabelPrefab, _gridCanvas.transform, false); -// label.rectTransform.anchoredPosition = -// new Vector2(position.x, position.z); -// label.text = cell.coordinates.ToStringOnSeparateLines(); -// #endif + +#if UNITY_EDITOR + TMP_Text label = Object.Instantiate(_cellLabelPrefab, _gridCanvas.transform, false); + label.rectTransform.anchoredPosition = + new Vector2(position.x, position.z); + label.text = cell.coordinates.ToStringOnSeparateLines(); +#endif + } - - public void Init() + public void Init() { _cells = new HexCell[_height * _width]; diff --git a/Assets/Scripts/HexFiled/PaintedController.cs b/Assets/Scripts/HexFiled/PaintedController.cs index 0e5a617d..d4e64ad8 100644 --- a/Assets/Scripts/HexFiled/PaintedController.cs +++ b/Assets/Scripts/HexFiled/PaintedController.cs @@ -3,58 +3,44 @@ using UnityEngine; namespace HexFiled { - struct HexIterator - { - private HexCell _cell; - private HexCell _previous; - private bool _isVisited; - - - public HexIterator(HexCell cell, bool isVisited, HexCell previous) - { - _cell = cell; - _isVisited = isVisited; - _previous = previous; - - } - - public HexCell Cell => _cell; - public HexCell Previous => _previous; - public bool Isvisited => _isVisited; - - } + public class PaintedController { public static Dictionary unitCurrentCell = new Dictionary(); + private HexCell _cell; public void SetHexColors(HexCell cell) { + _cell = cell; List cells = new List(); for(int i = 0 ; i < 6 ; i++) { - cells.Add(cell.GetNeighbor((HexDirection)i )); + cells.Add(cell.GetNeighbor((HexDirection)i)); } var hexByColorDict = DifferentHexByColor(cells); foreach (var item in hexByColorDict) { - if(item.Value.Count > 0 && item.Key != UnitColor.GREY && item.Key != cell.Color) + if(item.Value.Count > 0 && item.Key != UnitColor.GREY && item.Key != cell.Color ) { foreach(var cellNeighbour in item.Value) { - if(unitCurrentCell.ContainsKey(cell.Color)) + if(unitCurrentCell.ContainsKey(item.Key)) { - var path = HasPath(cellNeighbour, unitCurrentCell[cell.Color]); + var path = HasPath(cellNeighbour, unitCurrentCell[item.Key]); if(!path.hasPath) { path.field.ForEach(x => x.PaintHex(UnitColor.GREY)); } - //Debug.Log("123"); } } } + else if (item.Key == UnitColor.GREY) + { + + } } } @@ -89,7 +75,7 @@ namespace HexFiled - while(stackIteators.Count > 0 ) + while(stackIteators.Count >= 0 ) { if(currentCell == end) return ( true, closedList); @@ -112,6 +98,10 @@ namespace HexFiled } else { + if (stackIteators.Count == 0) + { + return ( false, closedList); + } currentCell = stackIteators.Pop(); } } diff --git a/Assets/Scripts/Units/Views/UnitView.cs b/Assets/Scripts/Units/Views/UnitView.cs index 7c55ddc4..092c2738 100644 --- a/Assets/Scripts/Units/Views/UnitView.cs +++ b/Assets/Scripts/Units/Views/UnitView.cs @@ -50,7 +50,7 @@ public class UnitView : MonoBehaviour { captureBar.gameObject.SetActive(true); _sequence = DOTween.Sequence(); - _sequence.Append(captureBar.DOFillAmount(1f, 3f).OnComplete(() => + _sequence.Append(captureBar.DOFillAmount(1f, 0f).OnComplete(() => { _capureHex.Invoke(); captureBar.DOFillAmount(0f, 0f).SetEase(Ease.Linear);