public override void ClearData() { foreach (var editData in SummaryObjectList) { editData.Count = 0; } FenceAreaMap.Clear(); FenceObjectList.Clear(); EditingObjectList.Clear(); DamagingObjectList.Clear(); SummaryObjectList.Clear(); SelectedBuildData = null; }
public void AddToFenceList(Vector2Int grid) { FenceObjectList.Add(grid); List <int> connectedList = new List <int>(); foreach (var neighbor in MapHelper.NeighborGrids) { var neighborGrid = neighbor + grid; foreach (var map in FenceAreaMap) { if (map.Value.HasGrid(neighborGrid.x, neighborGrid.y)) { if (!connectedList.Contains(map.Key)) { connectedList.Add(map.Key); } break; } } } if (connectedList.Count <= 0) { var fenceArea = new FenceAreaData(); fenceArea.Fences.Add(grid); FenceAreaMap.Add(++FenceAreaUid, fenceArea); } else if (connectedList.Count == 1) { FenceAreaMap[connectedList[0]].Fences.Add(grid); } else { var fenceArea = new FenceAreaData(); fenceArea.Fences.Add(grid); foreach (var connectedId in connectedList) { foreach (var fence in FenceAreaMap[connectedId].Fences) { fenceArea.Fences.Add(fence); } FenceAreaMap.Remove(connectedId); } FenceAreaMap.Add(++FenceAreaUid, fenceArea); } }