Пример #1
0
 // Update is called once per frame
 void Update()
 {
     if (currentBench.IsSuccess)
     {
         if (CurrentState > 0)
         {
             currentBench.SetStage(CurrentLevel.states[--CurrentState]);
         }
         if (CurrentLevel.final == CurrentState)
         {
             WinButton.interactable = true;
         }
     }
     if (currentBench.IsBad)
     {
         if (CurrentState < CurrentLevel.states.Length - 1)
         {
             currentBench.SetStage(CurrentLevel.states[++CurrentState]);
         }
         if (CurrentState == CurrentLevel.states.Length - 1)
         {
             currentBench.IsBroken = true;
             EndGame();
         }
         if (CurrentLevel.final < CurrentState)
         {
             WinButton.interactable = false;
         }
     }
     DebugsText.text = "Json: " + currentJson + "\nStates: " + CurrentState + "\n" +
                       CurrentLevel.states[CurrentState].image + "\n" +
                       "Tools Size: " + CurrentLevel.tools.Length + "\n" +
                       "Scene Size: " + CurrentLevel.states.Length + "\n" +
                       CurrentLevel.states[CurrentState].crit_tool_id + "\n";
 }
Пример #2
0
    public void LoadJson(string path)
    {
        if (hasActiveLevel == true)
        {
            ResetItems();
        }
        StreamReader reader = new StreamReader(path, true);
        string       json   = reader.ReadToEnd();

        CurrentLevel = JsonUtility.FromJson <Level>(json);

        PutIngredients();
        PutTools();

        currentBench = FindObjectOfType <Bench>();
        currentBench.SetStage(CurrentLevel.states[--CurrentLevel.initial]);
        CurrentState   = CurrentLevel.initial;
        hasActiveLevel = true;
        currentJson    = path;
    }