Beispiel #1
0
    /// <summary>Loads the chosen grid.</summary>
    public void LoadGrid()
    {
        if (loadFileName == null)
        {
            Debug.LogWarning("WARNING: Load file has not been set!");
            return;
        }

        GridInfo info = JsonSaveLoad.LoadFile <GridInfo>(FolderPath.Grids, loadFileName);

        RemoveGrid();
        gridParams.type = info.type;
        switch (info.type)
        {
        case GridType.Radial:
        {
            if (info.parameters != null && info.parameters.Length == 1 && info.parameters[0] > 0)
            {
                gridParams.radius = info.parameters[0];
                CreateRadialGrid(info.GetTiles(), info.GetSpawns(), info.GetLevelObjects());
            }
            break;
        }

        case GridType.Square:
        {
            if (info.parameters != null && info.parameters.Length == 2 && info.parameters[0] > 0 && info.parameters[1] > 0)
            {
                gridParams.height = info.parameters[0];
                gridParams.width  = info.parameters[1];
                CreateSquareGrid(info.GetTiles(), info.GetSpawns(), info.GetLevelObjects());
            }
            break;
        }
        }

        onLevelLoad.Invoke();

        CameraManager.Instance.UpdateBounds(gridParams.type, info.parameters);
        currentGridFile = loadFileName;
        savefileName    = loadFileName;
    }