row col 倒转之前
This commit is contained in:
@@ -747,237 +747,6 @@ public partial class MapManager : MonoBehaviour
|
||||
|
||||
return cell.cellType;
|
||||
}
|
||||
|
||||
private void ShowCellType(GameObject go, CellType type)
|
||||
{
|
||||
if ((type & CellType.Safe) == CellType.Safe)
|
||||
{
|
||||
var materials = new Material[2];
|
||||
materials[1] = _cellDefaultMat;
|
||||
go.GetComponent<MeshRenderer>().materials = materials;
|
||||
}
|
||||
|
||||
if ((type & CellType.Move) == CellType.Move)
|
||||
{
|
||||
go.GetComponent<MeshRenderer>().material = _cellMoveMat;
|
||||
}
|
||||
|
||||
if ((type & CellType.Obstacle) == CellType.Obstacle)
|
||||
{
|
||||
go.GetComponent<MeshRenderer>().material = _cellObsMat;
|
||||
}
|
||||
|
||||
if ((type & CellType.Hide) == CellType.Hide)
|
||||
{
|
||||
go.GetComponent<MeshRenderer>().material = _cellHideMat;
|
||||
}
|
||||
|
||||
//if ((type & CellType.None) == CellType.None)
|
||||
if (type == CellType.None)
|
||||
{
|
||||
go.GetComponent<MeshRenderer>().material = _cellDefaultMat;
|
||||
}
|
||||
}
|
||||
|
||||
public void CalculationCells(int cellWidth, int cellHeight, int mapWidth, int mapHeight)
|
||||
{
|
||||
//RemoveAllCells();
|
||||
|
||||
_cellWidth = cellWidth;
|
||||
_cellHeight = cellHeight;
|
||||
this.mapWidth = mapWidth;
|
||||
this.mapHeight = mapHeight;
|
||||
|
||||
_cellRows = mapHeight / _cellHeight; //<2F><> == <20><>
|
||||
_cellCols = mapWidth / _cellWidth; //<2F><> == <20><>
|
||||
|
||||
cellsNode = new CellNode[_cellRows*_cellCols];
|
||||
int index = 0;
|
||||
|
||||
for(int y=0; y < _cellRows; y++)
|
||||
{
|
||||
for(int x=0; x < _cellCols; x++)
|
||||
{
|
||||
index = y * _cellCols + x;
|
||||
|
||||
cellsNode[index] = new CellNode(x, y, index, CellType.Obstacle);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>layer<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
public void AddLayerCell(GameObject go, CellType layer)
|
||||
{
|
||||
List<GameObject> cells = null;
|
||||
|
||||
if (((CellType)layer & CellType.Move) == CellType.Move)
|
||||
{
|
||||
cells = _layCellsMap[CellType.Move];
|
||||
cells.Add(go);
|
||||
}
|
||||
|
||||
if (((CellType)layer & CellType.Obstacle) == CellType.Obstacle)
|
||||
{
|
||||
cells = _layCellsMap[CellType.Obstacle];
|
||||
cells.Add(go);
|
||||
}
|
||||
|
||||
if (((CellType)layer & CellType.Hide) == CellType.Hide)
|
||||
{
|
||||
cells = _layCellsMap[CellType.Hide];
|
||||
cells.Add(go);
|
||||
}
|
||||
|
||||
if (((CellType)layer & CellType.Safe) == CellType.Safe)
|
||||
{
|
||||
cells = _layCellsMap[CellType.Safe];
|
||||
cells.Add(go);
|
||||
}
|
||||
|
||||
if (((CellType)layer & CellType.Stall) == CellType.Stall)
|
||||
{
|
||||
cells = _layCellsMap[CellType.Stall];
|
||||
cells.Add(go);
|
||||
}
|
||||
|
||||
if (((CellType)layer & CellType.Audio) == CellType.Audio)
|
||||
{
|
||||
cells = _layCellsMap[CellType.Audio];
|
||||
cells.Add(go);
|
||||
}
|
||||
|
||||
if (((CellType)layer & CellType.Trigger) == CellType.Trigger)
|
||||
{
|
||||
cells = _layCellsMap[CellType.Trigger];
|
||||
cells.Add(go);
|
||||
}
|
||||
|
||||
if (((CellType)layer & CellType.Monster) == CellType.Monster)
|
||||
{
|
||||
cells = _layCellsMap[CellType.Monster];
|
||||
cells.Add(go);
|
||||
}
|
||||
}
|
||||
|
||||
public void HideCellsExcludeLayers(int layers)
|
||||
{
|
||||
if (layers == 0)
|
||||
return;
|
||||
|
||||
if(layers < (int)CellType.Stall)
|
||||
{
|
||||
bool safeNoHide = ((CellType)layers & CellType.Safe) == CellType.Safe;
|
||||
|
||||
foreach (var layerCells in _layCellsMap)
|
||||
{
|
||||
safeNoHide = (layerCells.Key & CellType.Safe) == CellType.Safe;
|
||||
if (((int)layerCells.Key & layers) != (int)layerCells.Key)
|
||||
{
|
||||
HideCellsWithLayer(layerCells.Key, layers, safeNoHide);
|
||||
}
|
||||
}
|
||||
|
||||
HideSpecialPoint(EditCellType.SellArea);
|
||||
HideSpecialPoint(EditCellType.AudioTrigger);
|
||||
HideSpecialPoint(EditCellType.TriggerCell);
|
||||
HideSpecialPoint(EditCellType.ReliveCell);
|
||||
HideSpecialPoint(EditCellType.FuBenArea);
|
||||
HideSpecialPoint(EditCellType.MonsterArea);
|
||||
HideSpecialPoint(EditCellType.JuBaoArea);
|
||||
}
|
||||
else
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD>
|
||||
HideCells();
|
||||
|
||||
if(((CellType)layers & CellType.Stall) == CellType.Stall)
|
||||
{
|
||||
ShowSpecialPoint(EditCellType.SellArea);
|
||||
}
|
||||
|
||||
if (((CellType)layers & CellType.Audio) == CellType.Audio)
|
||||
{
|
||||
ShowSpecialPoint(EditCellType.AudioTrigger);
|
||||
}
|
||||
|
||||
if (((CellType)layers & CellType.Trigger) == CellType.Trigger)
|
||||
{
|
||||
ShowSpecialPoint(EditCellType.TriggerCell);
|
||||
}
|
||||
|
||||
if (((CellType)layers & CellType.Monster) == CellType.Monster)
|
||||
{
|
||||
ShowSpecialPoint(EditCellType.MonsterArea);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void HideCellsWithLayer(CellType hideLayer, int showLayers, bool safeNoHide)
|
||||
{
|
||||
var cells = _layCellsMap[hideLayer];
|
||||
foreach(var cell in cells)
|
||||
{
|
||||
CellType ct = GetCellType(cell.name);
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD>ȫ<EFBFBD><C8AB>
|
||||
if(safeNoHide)
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (((int)ct & (int)showLayers) == showLayers)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD>ڰ<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD><C7A3><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ȫ<EFBFBD><C8AB>
|
||||
if (((int)ct & (int)showLayers) == showLayers)
|
||||
continue;
|
||||
}
|
||||
//
|
||||
// continue;
|
||||
|
||||
cell.SetActive(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void RemoveLayerCellInLayCellsMap(GameObject go)
|
||||
{
|
||||
List<GameObject> removeGos = new List<GameObject>();
|
||||
foreach(var cells in _layCellsMap.Values)
|
||||
{
|
||||
GameObject f = cells.Find(cell => cell.name == go.name);
|
||||
if (f == null)
|
||||
continue;
|
||||
|
||||
removeGos.Add(f);
|
||||
}
|
||||
|
||||
for(int i=0; i<removeGos.Count; i++)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void CleanSafe()
|
||||
{
|
||||
var cells = _layCellsMap[CellType.Safe];
|
||||
if (cells == null)
|
||||
return;
|
||||
|
||||
foreach(var cell in cells)
|
||||
{
|
||||
if (cell.GetComponent<MeshRenderer>().materials.Length == 2)
|
||||
cell.GetComponent<MeshRenderer>().materials = new Material[1];
|
||||
|
||||
CellType ct = GetCellType(cell.name);
|
||||
CellType new_ct = (ct ^= CellType.Safe);
|
||||
SetCellType(cell.name, new_ct);
|
||||
ShowCellType(cell, new_ct);
|
||||
}
|
||||
|
||||
cells.Clear();
|
||||
}
|
||||
public bool isDragging = false;
|
||||
public Vector3 downPos;
|
||||
public SceneArea currentComponent;
|
||||
@@ -1025,4 +794,17 @@ public partial class MapManager : MonoBehaviour
|
||||
currentComponent = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetCell()
|
||||
{
|
||||
if (MapManager.Instance.map == null) return;
|
||||
int cellTotal = MapManager.Instance.map.selector.horizontalNumber * MapManager.Instance.map.selector.verticalNumber;
|
||||
cellsNode = new CellNode[cellTotal];
|
||||
for (int row = 0; row < MapManager.Instance.map.selector.horizontalNumber; row++)
|
||||
for (int col = 0; col < MapManager.Instance.map.selector.verticalNumber; col++)
|
||||
{
|
||||
int index = row * MapManager.Instance.map.selector.verticalNumber + col;
|
||||
cellsNode[index] = new CellNode(row,col,index, MapManager.Instance.map.selector.getCellType(index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user