Exemplo n.º 1
0
        void Awake()
        {
            m_RoundText             = GameObject.FindGameObjectWithTag("UI").GetComponentInChildren <RoundText>();
            m_ShopController        = shop.GetComponent <ShopController>();
            m_CameraShake           = Camera.main.GetComponent <CameraShake>();
            m_PlayerShootController = player.GetComponent <PlayerShootController>();
            m_PlayerController      = player.GetComponent <PlayerController>();

            var storage = GameObject.FindGameObjectWithTag("RoundPersistent");

            if (storage == null)
            {
                storage = new GameObject("Round_Persistent")
                {
                    tag = "RoundPersistent"
                };
                m_RoundStorage = storage.AddComponent <RoundPersistentScore>();
            }
            else
            {
                m_RoundStorage = storage.GetComponent <RoundPersistentScore>();
            }

            m_BGMAudioPlayer = FindObjectOfType <BGMAudioPlayer>();

            if (m_BGMAudioPlayer == null)
            {
                var audioObj = new GameObject("BGM");
                audioObj.AddComponent <AudioSource>();
                m_BGMAudioPlayer = audioObj.AddComponent <BGMAudioPlayer>();
            }

            m_AudioPlayer = Camera.main.GetComponent <AudioPlayer>();
        }
Exemplo n.º 2
0
        void Awake()
        {
            m_GameManager   = GameObject.FindObjectOfType <GameManager>();
            m_PlayerLivesUI = GameObject.FindGameObjectWithTag("LivesUI").GetComponentInChildren <PlayerItemUI>();

            m_ShootController = GetComponent <PlayerShootController>();

            m_AudioPlayer = FindObjectOfType <AudioPlayer>();

            m_AudioControls = FindObjectOfType <BGMAudioPlayer>();

            if (m_AudioControls == null)
            {
                var audioObj = new GameObject("BGM");
                audioObj.AddComponent <AudioSource>();
                m_AudioControls = audioObj.AddComponent <BGMAudioPlayer>();
            }

            m_Collider = GetComponent <Collider2D>();

            m_CurrentLives = initialLives;
        }