fixed rounding
This commit is contained in:
parent
b298adec90
commit
43993fb918
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -233,7 +233,6 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 963194228}
|
- component: {fileID: 963194228}
|
||||||
- component: {fileID: 963194227}
|
- component: {fileID: 963194227}
|
||||||
- component: {fileID: 963194229}
|
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Main Camera
|
m_Name: Main Camera
|
||||||
m_TagString: MainCamera
|
m_TagString: MainCamera
|
||||||
@ -298,23 +297,6 @@ Transform:
|
|||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 60, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 60, y: 0, z: 0}
|
||||||
--- !u!114 &963194229
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 963194225}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 8b9a305e18de0c04dbd257a21cd47087, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
sharedProfile: {fileID: 11400000, guid: 2de9544b84ed15540888b484d269757d, type: 2}
|
|
||||||
isGlobal: 1
|
|
||||||
blendDistance: 0
|
|
||||||
weight: 1
|
|
||||||
priority: 0
|
|
||||||
--- !u!1 &1475618468
|
--- !u!1 &1475618468
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -46,26 +46,24 @@ namespace HexFiled
|
|||||||
var closeDirection = direction.MinusSixtyDeg();
|
var closeDirection = direction.MinusSixtyDeg();
|
||||||
|
|
||||||
|
|
||||||
var path = Round(
|
if (TryPaintHexList(Round(
|
||||||
UnitCurrentCell[cell.Color].previos.GetNeighbor(closeDirection),
|
UnitCurrentCell[cell.Color].previos.GetNeighbor(closeDirection),
|
||||||
UnitCurrentCell[cell.Color].previos.GetNeighbor(openDirection)
|
UnitCurrentCell[cell.Color].previos.GetNeighbor(openDirection)),
|
||||||
);
|
cell.Color))
|
||||||
|
|
||||||
if (!path.hasPath)
|
|
||||||
{
|
{
|
||||||
path.field.ForEach(x => x.PaintHex(cell.Color));
|
TryPaintHexList(Round(
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
path = Round(
|
|
||||||
UnitCurrentCell[cell.Color].previos.GetNeighbor(openDirection),
|
UnitCurrentCell[cell.Color].previos.GetNeighbor(openDirection),
|
||||||
UnitCurrentCell[cell.Color].previos.GetNeighbor(closeDirection)
|
UnitCurrentCell[cell.Color].previos.GetNeighbor(closeDirection)),
|
||||||
);
|
cell.Color);
|
||||||
if (!path.hasPath)
|
}
|
||||||
|
|
||||||
|
cell.GetListNeighbours().ForEach(x =>
|
||||||
{
|
{
|
||||||
path.field.ForEach(x => x.PaintHex(cell.Color));
|
if (x.Color == UnitColor.GREY)
|
||||||
}
|
{
|
||||||
|
TryPaintHexList(Round(x, null), cell.Color);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
@ -84,6 +82,16 @@ namespace HexFiled
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private bool TryPaintHexList((bool hasPath, List<HexCell> field) path, UnitColor color)
|
||||||
|
{
|
||||||
|
if (!path.hasPath)
|
||||||
|
{
|
||||||
|
path.field.ForEach(y => y.PaintHex(color));
|
||||||
|
}
|
||||||
|
|
||||||
|
return path.hasPath;
|
||||||
|
}
|
||||||
|
|
||||||
private Dictionary<UnitColor, List<HexCell>> DifferentHexByColor(List<HexCell> cellsList)
|
private Dictionary<UnitColor, List<HexCell>> DifferentHexByColor(List<HexCell> cellsList)
|
||||||
{
|
{
|
||||||
Dictionary<UnitColor, List<HexCell>> resultDict = new Dictionary<UnitColor, List<HexCell>>();
|
Dictionary<UnitColor, List<HexCell>> resultDict = new Dictionary<UnitColor, List<HexCell>>();
|
||||||
@ -103,7 +111,7 @@ namespace HexFiled
|
|||||||
|
|
||||||
private (bool hasPath, List<HexCell> field) Round(HexCell start, HexCell end)
|
private (bool hasPath, List<HexCell> field) Round(HexCell start, HexCell end)
|
||||||
{
|
{
|
||||||
if (start.Color == _cell.Color || end.Color == _cell.Color)
|
if (start == null || start.Color == _cell.Color)
|
||||||
{
|
{
|
||||||
return (true, null);
|
return (true, null);
|
||||||
}
|
}
|
||||||
@ -118,7 +126,7 @@ namespace HexFiled
|
|||||||
|
|
||||||
while (stackIterators.Count >= 0)
|
while (stackIterators.Count >= 0)
|
||||||
{
|
{
|
||||||
if (currentCell == end)
|
if (end != null && currentCell == end)
|
||||||
return (true, closedList);
|
return (true, closedList);
|
||||||
|
|
||||||
List<HexCell> openList = new List<HexCell>();
|
List<HexCell> openList = new List<HexCell>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user