Пример #1
0
    private void OnNewLevel()
    {
        level++;
        Debug.Log($"OnNewLevel: {level}");
        if (level == 1 && !unResBGM.isPlaying)
        {
            unResBGM.Play();
        }
        ;
        // will be replaced with this below
        /*if (bgmLevels[level] && !unResBGM.isPlaying) { unResBGM.Play(); };*/

        LevelPrefabInterface lvlInterface = levelGameObject.GetComponent <LevelPrefabInterface>();

        /*lvlInterface.SetPuzzle(puzzlesPresets[level]);*/
        /*lvlInterface.InitializePuzzleSteps(LevelPrefabInterface.PuzzleType.Find);*/
        lvlInterface.InitializePuzzleSteps(puzzleTypes[level]);

        // if no note, destroy note
        if (levelNotes[level] == "no")
        {
            InteractableObject[] childrenInteractions = levelGameObject.GetComponentsInChildren <InteractableObject>();
            foreach (InteractableObject i in childrenInteractions)
            {
                if (i.interactableType == InteractableObject.InteractableType.Note)
                {
                    Destroy(i.gameObject);
                }
                ;
            }
        }
    }
Пример #2
0
 // Update is called once per frame
 void Update()
 {
     #region Transition
     if (isTransition)
     {
         timer += Time.deltaTime;
         if (timer < 1)
         {
             // exit
             levelGameObject.transform.localScale = new Vector3(1, exitCurve.Evaluate(timer), 1);
         }
         else if (timer < 2)
         {
             // creating things
             // check if the levelPropertyIndex = -1, if so use the next level prefab
             if (!flipFlop)
             {
                 Destroy(levelGameObject);
                 if (level + 1 < 4)
                 {
                     levelGameObject = Instantiate(levels[0]);
                     levelGameObject.transform.localScale = new Vector3(1, 0, 1);
                     Debug.Log("New level is of tpye 0");
                 }
                 else
                 {
                     levelGameObject = Instantiate(levels[1]);
                     levelGameObject.transform.localScale = new Vector3(1, 0, 1);
                     Debug.Log("New level is of tpye 1");
                     levelPropertyIndex = 0;
                 }
                 flipFlop = true;
                 LevelPrefabInterface lpi = levelGameObject.GetComponent <LevelPrefabInterface>();
                 Color[] colours          = lpi.GetLevelLighting();
                 lpi.GetL2D().color       = colours[levelPropertyIndex];
                 levelPropertyIndex++;
                 if (levelPropertyIndex >= colours.Length)
                 {
                     levelPropertyIndex = -1;
                 }
                 ;
             }
         }
         else if (timer < 3)
         {
             // entry
             levelGameObject.transform.localScale = new Vector3(1, entryCurve.Evaluate(timer - 2), 1);
         }
         else
         {
             // finished transition
             flipFlop     = false;
             timer        = 0;
             isTransition = false;
             levelGameObject.transform.localScale = new Vector3(1, 1, 1);
             pc.SetTargetPos(new Vector3(-3.5f, 0, 0));
             OnNewLevel();
         }
     }
     #endregion
 }