Beispiel #1
0
    private void UpdatePressedCellType()
    {
        ResetGrid();
        GridCell cell = GetCellOnMouse();

        if (!cell)
        {
            return;
        }

        Toggle           activeToggle     = cellTypeToggleGroup.ActiveToggles().First();
        ToggleTypeHolder toggleTypeHolder = activeToggle.GetComponent <ToggleTypeHolder>();
        PathCell         pathCell         = cell.GetComponent <PathCell>();

        pathfindController.SetCellType(pathCell, toggleTypeHolder.cellType);
        gridSavingController.SaveCell(pathCell);
    }
    public void Load()
    {
        for (int i = 0; i < gridExtension.gridSize.x; i++)
        {
            for (int j = 0; j < gridExtension.gridSize.y; j++)
            {
                string            cellPrefKey = i + " " + j;
                PathCell.CellType type        = PathCell.CellType.Empty;

                if (PlayerPrefs.HasKey(cellPrefKey))
                {
                    type = (PathCell.CellType)PlayerPrefs.GetInt(cellPrefKey);
                }

                GridCell gridCell = gridExtension.GetCell(i, j);
                if (gridCell)
                {
                    PathCell pathCell = gridCell.GetComponent <PathCell>();
                    pathfindController.SetCellType(pathCell, type);
                }
            }
        }
    }