示例#1
0
 void Awake()
 {
     if (gc == null)
     {
         gc = this;
     }
     else
     {
         // if this one's a duplicate, destroy
         Destroy(this.gameObject);
         return;
     }
     DontDestroyOnLoad(this);
     titleText         = editorTitleText;
     dialogueUI        = GetComponentInChildren <DialogueUI>();
     signUI            = GetComponentInChildren <SignUI>();
     pc                = GetComponentInChildren <PlayerController>();
     rm                = GetComponent <RespawnManager>();
     playerFollower    = gc.GetComponentInChildren <PlayerFollower>();
     save              = gc.GetComponent <SaveWrapper>().save;
     blackoutUI        = GetComponentInChildren <BlackFadeUI>();
     pauseUI           = GetComponentInChildren <PauseUI>();
     abilityUIAnimator = GameObject.Find("AbilityGetUI").GetComponent <Animator>();
     inventory         = gc.GetComponentInChildren <InventoryController>();
     parallaxOption    = gc.GetComponentInChildren <ParallaxOption>();
     bossHealthUI      = GameObject.Find("BossHealthUI").GetComponent <BarUI>();
     bossHealthUI.gameObject.SetActive(false);
     playerMenu     = GameObject.Find("PlayerMenu");
     binarySaver    = gc.GetComponent <BinarySaver>();
     saveWrapper    = gc.GetComponent <SaveWrapper>();
     audioListener  = gc.GetComponentInChildren <AudioListener>();
     bossFightIntro = gc.GetComponentInChildren <BossFightIntro>(includeInactive: true);
 }
示例#2
0
 virtual protected void Start()
 {
     bossHealthUI   = GlobalController.bossHealthUI;
     startBossFight = Resources.Load("ScriptableObjects/Events/StartBossFight") as GameEvent;
     stopBossFight  = Resources.Load("ScriptableObjects/Events/StopBossFight") as GameEvent;
     victoryEffect  = Resources.Load("Effects/Final Blow Prefab") as GameObject;
     if (startFightOnEnable)
     {
         StartFight();
     }
 }
示例#3
0
 private void SetComponents()
 {
     ui_Components = new UI_Component[]
     {
         new MessageLogUI(),
         new InfoUI(),
         new BarUI("HealthBar")
         // new DynamicUIMenu("InventoryUI"),
         //new DynamicUIMenu("MiniMenuUI")
     };
     barUI  = (BarUI)ui_Components[2];
     infoUI = (InfoUI)ui_Components[1];
 }
示例#4
0
        #pragma warning restore 0649

    void Awake()
    {
        gc                = this;
        titleText         = editorTitleText;
        dialogueUI        = GetComponentInChildren <DialogueUI>();
        signUI            = GetComponentInChildren <SignUI>();
        pc                = GetComponentInChildren <PlayerController>();
        rm                = GetComponent <RespawnManager>();
        playerFollower    = gc.GetComponentInChildren <PlayerFollower>();
        blackoutUI        = GetComponentInChildren <BlackFadeUI>();
        pauseUI           = GetComponentInChildren <PauseUI>();
        abilityUIAnimator = GameObject.Find("AbilityGetUI").GetComponent <Animator>();
        inventory         = gc.GetComponentInChildren <InventoryController>();
        parallaxOption    = gc.GetComponentInChildren <ParallaxOption>();
        bossHealthUI      = GameObject.Find("BossHealthUI").GetComponent <BarUI>();
        bossHealthUI.gameObject.SetActive(false);
        playerMenu     = GameObject.Find("PlayerMenu");
        audioListener  = gc.GetComponentInChildren <AudioListener>();
        bossFightIntro = gc.GetComponentInChildren <BossFightIntro>(includeInactive: true);

#if UNITY_EDITOR
        EditorApplication.playModeStateChanged += OnPlayModeChange;
#endif
    }
示例#5
0
    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        currentScene = scene;
        if (currentScene.buildIndex != 1)
        {
            Debug.Log("This is Menu scene");
            //GET ALL GAMEOBJECT
            //THIS ONE IS FOR HIGHSCORE (SAME NAME as the one on Game scene)
            highScore      = GameObject.Find("HighScoreText").GetComponent <TextMeshProUGUI>();
            highScore.text = "HighScore: \n" + PlayerPrefs.GetInt("HighScore", 0).ToString();

            //THIS ONE IS FOR CHOICES TEXT
            finalScore      = GameObject.Find("ChoicesText").GetComponent <TextMeshProUGUI>();
            finalScore.text = "Are you sure you want to\nreset? It will set your score\nback to 0.";

            //THIS ONE IS FOR TRANSITION
            deathUI = GameObject.FindObjectOfType <TransitionToGame>().gameObject;
            deathUI.SetActive(false);

            //THIS ONE IS FOR RESET MENU (To get Reset function)
            crosshair = GameObject.Find("ResetChoice");

            //THIS ONE IS FOR SETTINGS
            gameUI = GameObject.Find("SettingsMenu");

            //------------------
            //GET ALL BUTTON
            //THIS ONE IS FOR PLAY
            deadRetryButton = GameObject.Find("PlayButton").GetComponent <Button>();
            deadRetryButton.onClick.AddListener(() => Play());

            //THIS ONE IS FOR QUIT
            deadMainButton = GameObject.Find("QuitButton").GetComponent <Button>();
            deadMainButton.onClick.AddListener(() => Quit());

            //THIS ONE IS FOR RESET
            pauseRetryButton = GameObject.Find("YesButton").GetComponent <Button>();
            pauseRetryButton.onClick.AddListener(() => ResetScore());
            crosshair.SetActive(false); // That way we could insert Reset onClick function first, then disable it. Don't know why it won't set to false if I place below MASTER VOLUME

            //---------------------
            //GET ALL SLIDER
            //THIS ONE IS FOR MASTER VOLUME
            masterSlider = GameObject.Find("MasterSlider").GetComponent <Slider>();
            masterSlider.onValueChanged.AddListener(SetMusicLvl);

            //THIS ONE IS FOR EFFECT VOLUME
            effectSlider = GameObject.Find("EffectSlider").GetComponent <Slider>();
            effectSlider.onValueChanged.AddListener(SetEffectLvl);
            //-----------------

            gameUI.SetActive(false);
            masterSlider.value = PlayerPrefs.GetFloat("MasterSlider", 0); // It seems that I have to copy the value to here again as it will not take the slider value
            effectSlider.value = PlayerPrefs.GetFloat("EffectSlider", 0);
        }
        else
        {
            Debug.Log("This is Game scene");

            //SET THE COUNTER ALL TO 0    (Not going to broke something, but it was suppose to reset before creating singleton, so yeah
            EnemyCounter      = 0;
            numberEnemyKilled = 0;

            //GET ALL GAMEOBJECT TYPE
            barUI   = GameObject.FindObjectOfType <BarUI>();
            deathUI = GameObject.Find("Death Canvas");

            finalScore = GameObject.Find("Score text").GetComponent <TextMeshProUGUI>();
            highScore  = GameObject.Find("HighScoreText").GetComponent <TextMeshProUGUI>();

            gameUI      = GameObject.Find("Game Canvas");
            crosshair   = GameObject.Find("Crosshair");
            PlayerStart = GameObject.Find("PlayerStart").transform;
            //------------------------
            //GET ALL BUTTON
            pauseRetryButton = GameObject.Find("PauseRetryButton").GetComponent <Button>();
            pauseRetryButton.onClick.AddListener(() => Retry());
            pauseMainButton = GameObject.Find("PauseMainMenuButton").GetComponent <Button>();
            pauseMainButton.onClick.AddListener(() => MainMenu());
            deadRetryButton = GameObject.Find("DeadRetryButton").GetComponent <Button>();
            deadRetryButton.onClick.AddListener(() => Retry());
            deadMainButton = GameObject.Find("DeadMainMenuButton").GetComponent <Button>();
            deadMainButton.onClick.AddListener(() => MainMenu());

            //------------------------
            //GET ALL SLIDER (SAME NAME as the one on Main scene)
            masterSlider = GameObject.Find("MasterSlider").GetComponent <Slider>();
            masterSlider.onValueChanged.AddListener(SetMusicLvl);
            effectSlider = GameObject.Find("EffectSlider").GetComponent <Slider>();
            effectSlider.onValueChanged.AddListener(SetEffectLvl);
            //-----------------

            //-----------------
            deathUI.SetActive(false); // set false on here, that way all gameobject and button related to this can get before set false
            // I don't set pauseUI off here since I did that on PauseUI script
        }
        SpawnPlayer(); // either way, it will check again for every scene changes
        highScore.text = PlayerPrefs.GetInt("HighScore", 0).ToString();

        //Get the slider value and set the audio again, works when changing scene except main scene
        masterSlider.value = PlayerPrefs.GetFloat("MasterSlider", 0);
        effectSlider.value = PlayerPrefs.GetFloat("EffectSlider", 0);

        masterMixer.SetFloat("MusicVol", PlayerPrefs.GetFloat("MasterSlider", 0));
        masterMixer.SetFloat("SFXVol", PlayerPrefs.GetFloat("EffectSlider", 0));
    }