public void ChangeToNone(bool canRevert) { if ((CELL_TYPE)CellData.cellType == CELL_TYPE.WALL) { SpriteMap2AStarMap.ResetAStarMapCell(Owner.Map, CellData, ref Owner.PathfindingMap); } // Debug.Log("set null:" + CellData.row + "," + CellData.col + "," + Render.sprite.name); Render.sprite = null; m_preType = CellData.cellType; CellData.cellType = (int)CELL_TYPE.NONE; if (canRevert) { StartCoroutine(Revert(10)); } }
public void AutoAStarMap() { if (cells == null) { return; } string filePath; filePath = EditorUtility.SaveFilePanel("Save map file", Application.dataPath, "", "txt"); if (string.IsNullOrEmpty(filePath)) { return; } AStarMap map = SpriteMap2AStarMap.SpriteMapToAStarMap(ToMapData()); AStarMapStream.Write(map, filePath); Debug.Log("AutoAStarMap success."); }
IEnumerator Revert(float second) { yield return(new WaitForSeconds(second)); if (!string.IsNullOrEmpty(CellData.resName)) { Render.sprite = Resources.Load("Sprites/" + CellData.resName, typeof(Sprite)) as Sprite; } CellData.cellType = m_preType; // if ((CELL_TYPE)CellData.cellType == CELL_TYPE.WALL) { SpriteMap2AStarMap.ResetAStarMapCell(Owner.Map, CellData, ref Owner.PathfindingMap); } // object[] p = new object[2]; p[0] = (object)CellData.row; p[1] = (object)CellData.col; GameStateManager.Instance().FSM.CurrentState.Message("MapCellRevert", p); }