예제 #1
0
    private void OnEnable()
    {
        if (_mode == Mode.Edit)
        {
            label.text            = "Edit Scenario";
            nameInput.text        = _data.name;
            nameInput.readOnly    = true;
            mapNameInput.text     = _data.mapFileName;
            descriptionInput.text = _data.description;

            numberOfShiftsInput.text    = _data.goal.numberOfShifts.ToString();
            targetShaleAmountInput.text = _data.goal.numberOfShifts.ToString();
        }
        else if (_mode == Mode.Create)
        {
            _data = null;

            nameInput.text        = "Scenario " + Mathf.RoundToInt(UnityEngine.Random.value * 100000).ToString();
            nameInput.readOnly    = false;
            mapNameInput.text     = "";
            descriptionInput.text = "";

            numberOfShiftsInput.text    = "0";
            targetShaleAmountInput.text = "0";

            numberOfShiftsToggle.isOn    = true;
            targetShaleAmountToggle.isOn = true;
        }
    }
    public static LevelScenarioData Load(string name)
    {
        if (File.Exists(GetFilePath(name)))
        {
            try
            {
                BinaryFormatter   bf        = new BinaryFormatter();
                FileStream        file      = File.Open(GetFilePath(name), FileMode.Open);
                LevelScenarioData loadedMap = (LevelScenarioData)bf.Deserialize(file);

                file.Close();

                return(loadedMap);
            }
            catch (SystemException e)
            {
                Debug.LogError(e);
                return(null);
            }
        }
        else
        {
            Debug.LogError("File doens't exit");
            return(null);
        }
    }
예제 #3
0
    public void OnSaveButtonClick()
    {
        string name        = nameInput.text;
        string mapName     = mapNameInput.text;
        string description = descriptionInput.text;

        int numberOfShifts    = Int32.Parse(numberOfShiftsInput.text);
        int targetShaleAmount = Int32.Parse(targetShaleAmountInput.text);

        if (_mode == Mode.Create)
        {
            LevelScenarioData.Goal goal     = new LevelScenarioData.Goal(numberOfShifts, targetShaleAmount);
            LevelScenarioData      scenario = new LevelScenarioData(mapName, name, description, 0, goal);
            scenario.Save();
        }
        else if (_mode == Mode.Edit)
        {
            _data.goal        = new LevelScenarioData.Goal(numberOfShifts, targetShaleAmount);
            _data.description = description;
            _data.mapFileName = mapName;
            _data.index       = 0;

            _data.Save();
        }
    }
예제 #4
0
 public GameplayData(string name, MapData mapData, LevelScenarioData scenarioData, LevelProgressData progressData)
 {
     this.name         = name;
     this.mapData      = mapData;
     this.scenarioData = scenarioData;
     this.progressData = progressData;
 }
    public void OnSelect(BaseEventData eventData)
    {
        scenarioEditorMenu.SelectScenario(this);

        data = LevelScenarioData.Load(scenarioName);
        scenarioEditorMenu.SetScenarioOverview(data);

        Debug.Log("Loaded: " + data.description);
    }
예제 #6
0
    private void FetchGrid()
    {
        scenarios = LevelScenarioData.GetScenariosInDirectory();

        Debug.Log("scenarios count in directory -> " + scenarios.Length);

        for (int i = 0; i < scenarios.Length; i++)
        {
            Button           button           = Instantiate(buttonPrefab, grid);
            ScenarioSelector scenarioSelector = button.gameObject.AddComponent <ScenarioSelector>();
            scenarioSelector.scenarioName = scenarios[i];
            scenarioSelector.newGameMenu  = this;
        }
    }
    public void EndShift()
    {
        LevelScenarioData scenarioData = ScenarioProgressController.Singleton.scenarioData;
        LevelProgressData progressData = ScenarioProgressController.Singleton.progressData;

        progressData.shiftsPassed++;

        MapData mapData = new MapData(scenarioData.name, BlockGridController.Singleton.grid);

        GameplayData gameplayData = new GameplayData(
            "Saved Game - " + scenarioData.name + " - Shift #" + (progressData.shiftsPassed + 1) + " - " + DateTime.Now.ToString("MM-dd-yyyy--HH-mm-ss"),
            mapData,
            scenarioData,
            progressData
            );

        SceneSwitcher.Singleton.ToResultsScene(new NextShiftLoaderData(gameplayData));
    }
예제 #8
0
 public void SetEditMode(LevelScenarioData data)
 {
     _mode = Mode.Edit;
     _data = data;
 }
 public GamePlayLoaderData(SavedMapLoaderData savedMapLoaderData, LevelScenarioData scenarioData)
 {
     this.savedMapLoaderData = savedMapLoaderData;
     this.scenarioData       = scenarioData;
 }
예제 #10
0
 public void SetScenarioOverview(LevelScenarioData data)
 {
     contentText.text = data.ToString();
 }