void Start()
    {
        GameObject listManagerGO = GameObject.Find("SceneManager");

        listManager = listManagerGO.GetComponent <LevelListManager> ();
        LevelLoad();
        BuildLevel();
    }
Beispiel #2
0
    /// <summary>
    /// Everytime an operation is run we checked if it changed the state of the game
    /// </summary>
    /// <returns><c>true</c>, if game over was checked, <c>false</c> otherwise.</returns>
    public bool CheckGameOver()
    {
        for (int i = 0; i < levelDef.numRows; i++)
        {
            for (int j = 0; j < levelDef.numColumns; j++)
            {
                Tile t = levelDef.board [i, j];

                if (t.lightable && !t.lightOn)
                {
                    Debug.Log("Try Again");
                    return(false);
                }
            }
        }

        Debug.Log("You Win");
        GameObject listManagerGO = GameObject.Find("SceneManager");

        listManager = listManagerGO.GetComponent <LevelListManager> ();
        TextAsset lvl     = Resources.Load <TextAsset> (listManager.chosenLevelUrl);
        var       level   = JSON.Parse(lvl.text);
        var       namalvl = level["name"].Value;

        if (namalvl == "1")
        {
            SceneManager.LoadScene("Quiz1");
        }
        else if (namalvl == "2")
        {
            SceneManager.LoadScene("Quiz2");
        }
        else if (namalvl == "3")
        {
            SceneManager.LoadScene("Quiz3");
        }
        else if (namalvl == "4")
        {
            SceneManager.LoadScene("Quiz4");
        }
        else if (namalvl == "5")
        {
            SceneManager.LoadScene("Quiz5");
        }
        return(true);
    }
    // private Alert alert;

    // Start is called before the first frame update
    protected override void Start()
    {
#if UNITY_TVOS
        UnityEngine.tvOS.Remote.reportAbsoluteDpadValues = true;
        UnityEngine.tvOS.Remote.allowExitToHome          = true;
#endif

        base.Start();
        this.audioSource = this.GetComponent <AudioSource>();
        // this.alert = this.iapAlert.GetComponent<Alert>();
        // alert will hide once initialized
        this.iapAlert.ToggleActive(true, false);
        this.restorePurchaseAlert?.ToggleActive(true, false);

        var sound = this.toggleSoundButton.GetComponent <CustomButton>();
        sound.Toggle(this.Context.data.IsSoundEnabled);
        sound.OnValueChangeEvent.AddListener((caller, value) =>
        {
            if (!GameContext.IsNavigationEnabled)
            {
                this.EventSystem.SetSelectedGameObject(null);
            }
            this.Context.data.IsSoundEnabled = value;
        });

        this.iapManager.WithGrant(IAPManager.IAPRemoveAds, () =>
        {
            this.UpdateMenuButton();
        });

        var version        = this.versionText.GetComponent <Text>();
        var versionBuilder = new StringBuilder("");
        // versionBuilder.AppendLine($"© Graphite Software, 2019");
        versionBuilder.Append($"v{Application.version}");
        version.text = versionBuilder.ToString();

        this.levelManager = this.levelPanel.GetComponent <LevelListManager>();
        this.levelManager.OnLevelSelectedEvent.AddListener((data, levelData) =>
        {
            Debug.Log($"Level selection: {levelData.relativePath}");
            this.Context.data.SetActiveData(this.Context, data, levelData.relativePath);
            SceneManager.LoadScene(GameplayManager.Scene);
        });
        this.menuManager = this.mainMenuPanel.GetComponent <MainMenuManager>();
        this.menuManager.OnPageSelectedEvent.AddListener((caller, page) =>
        {
            this.PlaySfx();
            switch (page)
            {
            case MainMenuManager.MenuPageType.Create:
                SceneManager.LoadScene(EditorManager.Scene);
                break;

            case MainMenuManager.MenuPageType.LevelList:
                this.NavigateLevelList();
                break;
            }
        });

        this.iapLevelsButton.onClick.AddListener(() => this.iapAlert?.PromptIap(IAPLevelPak.LevelPak1));
        this.iapManager.OnGrantEvent.AddListener((grant, fromLocal) =>
        {
            if (!fromLocal && grant.Equals(IAPLevelPak.LevelPak1))
            {
                this.iapLevelsButton.gameObject.SetActive(false);
            }
        });
        this.iapAlert.OnVisibilityEvent.AddListener((isVisible) =>
        {
            if (!isVisible && GameContext.IsNavigationEnabled && this.mainMenuPanel.activeInHierarchy)
            {
                this.SelectDefault();
            }
        });
        this.restorePurchaseAlert.OnVisibilityEvent.AddListener((isVisible) =>
        {
            if (!isVisible && GameContext.IsNavigationEnabled && this.mainMenuPanel.activeInHierarchy)
            {
                this.SelectDefault();
            }
        });

        this.restorePurchaseButton.onClick.AddListener(this.AlertRestore);
        this.iapManager.OnRestoredEvent.AddListener(this.UpdateRestore);

        this.NavigateTitle();
    }