Отрезание

This commit is contained in:
dddushesss 2021-12-29 21:11:12 +03:00
parent 296a5384c6
commit 6bb16f8757
5 changed files with 30 additions and 40 deletions

View File

@ -92,8 +92,8 @@ MonoBehaviour:
m_faceColor: m_faceColor:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4294967295
m_fontSize: 1 m_fontSize: 0.3
m_fontSizeBase: 1 m_fontSizeBase: 0.3
m_fontWeight: 400 m_fontWeight: 400
m_enableAutoSizing: 0 m_enableAutoSizing: 0
m_fontSizeMin: 18 m_fontSizeMin: 18

View File

@ -51,10 +51,10 @@ namespace HexFiled
} }
_renderer.material.mainTexture = _cellColor[color].Texture; _renderer.material.mainTexture = _cellColor[color].Texture;
onHexPainted?.Invoke(this);
_color = color; _color = color;
Instantiate(_cellColor[color].VFXPrefab, transform); Instantiate(_cellColor[color].VFXPrefab, transform);
onHexPainted?.Invoke(this);
} }
} }

View File

@ -100,16 +100,16 @@ namespace HexFiled
} }
} }
} }
}
// #if UNITY_EDITOR #if UNITY_EDITOR
// TMP_Text label = Object.Instantiate(_cellLabelPrefab, _gridCanvas.transform, false); TMP_Text label = Object.Instantiate(_cellLabelPrefab, _gridCanvas.transform, false);
// label.rectTransform.anchoredPosition = label.rectTransform.anchoredPosition =
// new Vector2(position.x, position.z); new Vector2(position.x, position.z);
// label.text = cell.coordinates.ToStringOnSeparateLines(); label.text = cell.coordinates.ToStringOnSeparateLines();
// #endif #endif
}
public void Init()
public void Init()
{ {
_cells = new HexCell[_height * _width]; _cells = new HexCell[_height * _width];

View File

@ -3,58 +3,44 @@ using UnityEngine;
namespace HexFiled 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 class PaintedController
{ {
public static Dictionary<UnitColor, HexCell> unitCurrentCell = new Dictionary<UnitColor, HexCell>(); public static Dictionary<UnitColor, HexCell> unitCurrentCell = new Dictionary<UnitColor, HexCell>();
private HexCell _cell;
public void SetHexColors(HexCell cell) public void SetHexColors(HexCell cell)
{ {
_cell = cell;
List<HexCell> cells = new List<HexCell>(); List<HexCell> cells = new List<HexCell>();
for(int i = 0 ; i < 6 ; i++) for(int i = 0 ; i < 6 ; i++)
{ {
cells.Add(cell.GetNeighbor((HexDirection)i )); cells.Add(cell.GetNeighbor((HexDirection)i));
} }
var hexByColorDict = DifferentHexByColor(cells); var hexByColorDict = DifferentHexByColor(cells);
foreach (var item in hexByColorDict) 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) 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) if(!path.hasPath)
{ {
path.field.ForEach(x => x.PaintHex(UnitColor.GREY)); 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) if(currentCell == end)
return ( true, closedList); return ( true, closedList);
@ -112,6 +98,10 @@ namespace HexFiled
} }
else else
{ {
if (stackIteators.Count == 0)
{
return ( false, closedList);
}
currentCell = stackIteators.Pop(); currentCell = stackIteators.Pop();
} }
} }

View File

@ -50,7 +50,7 @@ public class UnitView : MonoBehaviour
{ {
captureBar.gameObject.SetActive(true); captureBar.gameObject.SetActive(true);
_sequence = DOTween.Sequence(); _sequence = DOTween.Sequence();
_sequence.Append(captureBar.DOFillAmount(1f, 3f).OnComplete(() => _sequence.Append(captureBar.DOFillAmount(1f, 0f).OnComplete(() =>
{ {
_capureHex.Invoke(); _capureHex.Invoke();
captureBar.DOFillAmount(0f, 0f).SetEase(Ease.Linear); captureBar.DOFillAmount(0f, 0f).SetEase(Ease.Linear);