상속: MonoBehaviour
예제 #1
0
 void Start()
 {
     DontDestroyOnLoad(this.gameObject);
     if (!MainMenuMusic.PlaySong())
     {
         Destroy(this.gameObject);
     }
     music = GetComponent <AudioSource>();
 }
 public void Awake()
 {
     GameObject.Find("SoundSwitch").GetComponent <Image>().enabled = AudioListener.volume == 0 ? false : true;
     keyPressed           = AudioListener.volume == 0 ? true : false;
     music                = GameObject.FindObjectOfType <MainMenuMusic>();
     music.source         = AudioSource.FindObjectOfType <AudioSource>();
     music.source.enabled = true;
     music.Play();
 }
예제 #3
0
 public override void Exit()
 {
     base.Exit();
     Program.Instance.Interface.ClearInterface();
     if (MainMenuMusic != null)
     {
         MainMenuMusic.Stop();
     }
     MainMenuMusic = null;
 }
예제 #4
0
    public override void OnStart(Action callback)
    {
        mainMenuBackgroundPanel = UiManager.EnablePanel <BackgroundPanel>();
        mainMenuBackgroundPanel.SetImage(Resources.Load <Sprite>(mainMenuBackgroundPath));
        mainMenuSelectShipPanel = UiManager.EnablePanel <MainMenuPanel>();

        mainMenuMusic = new MainMenuMusic();
        AudioManager.Instance.PlayMusic(mainMenuMusic);

        callback?.Invoke();
    }
예제 #5
0
 // Start is called before the first frame update
 void Start()
 {
     gameObj    = GameObject.Find("MainMenuMusic");
     spawnData  = gameObj.GetComponent <MainMenuMusic>();
     moveSpeed  = spawnData.moveSpeed != 0 ? spawnData.moveSpeed : 3;
     spawnDelay = spawnData.spawnDelay != 0 ? spawnData.spawnDelay: 6;
     Debug.Log("MOVE SPEED FROM OBJECT:\t" + moveSpeed);
     Debug.Log("SPAWN DELAY FROM OBJECT:\t" + spawnDelay);
     startSpawn(); // We will start the spawn when the game starts
     InvokeRepeating("RemoveLasers", 10.0f, 5.0f);
 }
    public void ResetGame()
    {
        points       = 0;
        currentLevel = 1;
        fruitCounter = 0;
        easterBlocks = 0;
        lives        = MAX_LIVES;
        MainMenuMusic music = GameObject.FindObjectOfType <MainMenuMusic>();

        music.Stop();
    }
예제 #7
0
 void Start()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
 }
예제 #8
0
    public void Awake()
    {
        if (Application.loadedLevelName == "SimpleMainMenu" || Application.loadedLevelName == "Tutorial") {
            DontDestroyOnLoad (this.gameObject);

            // if there's no GameManager object, create one
            if (instance == null)
                instance = this as MainMenuMusic;
            // if there's an existing GameManager, destroy it
            else
                Destroy (gameObject);
        }
    }
예제 #9
0
 // Use this for initialization
 void Start()
 {
     if (mainMenuMusic == null)
     {
         mainMenuMusic = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
     DontDestroyOnLoad(gameObject);
     music = this.GetComponent <AudioSource>();
 }
예제 #10
0
    void OnEnable()
    {
        if (inst != null && inst != this)
        {
            Destroy(this);
        }

        // musicSource.Play();
        AudioListener.volume = PlayerPrefs.GetFloat("MasterVolume");

        DontDestroyOnLoad(gameObject);
        inst = this;
    }
예제 #11
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
     source = GameObject.Find("MenuMusic").GetComponent <AudioSource>();
     DontDestroyOnLoad(source);
 }
예제 #12
0
    //Keep Audio Playing throughout Menu States
    void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(gameObject);
            return;
        }
        else
        {
            instance = this;
        }

        DontDestroyOnLoad(gameObject);
        //GameOptionData.InitializeGame();
    }
예제 #13
0
    // Start is called before the first frame update
    void Start()
    {
        mainMenuMusic = GameObject.FindGameObjectWithTag("main_menu_music_tag").GetComponent <MainMenuMusic>();
        mainMenuMusic.PlayMainMenuMusic();

        // TODO remove these
        //PlayerPrefs.SetInt("PlayWithMotion", -1);
        //PlayerPrefs.SetString("Inventory", "");
        //PlayerPrefs.SetInt("ShowMotionMessage", 1);
        //PlayerPrefs.SetString("ChosenProjectile", "");


        // Start with motion controls by default until changed by user in settings
        if (PlayerPrefs.GetInt("PlayWithMotion", -1) == -1)
        {
            Settings.EnableMotionControls();
        }
    }
예제 #14
0
 // Start is called before the first frame update
 void Start()
 {
     if (Settings.IsPlayWithMotion())
     {
         checkImage.gameObject.SetActive(true);
         xImage.gameObject.SetActive(false);
     }
     else
     {
         checkImage.gameObject.SetActive(false);
         xImage.gameObject.SetActive(true);
     }
     musicVolumeText.text   = Settings.GetMusicVolume().ToString();
     effectsVolumeText.text = Settings.GetEffectsVolume().ToString();
     mainMenuMusic          = GameObject.FindGameObjectWithTag("main_menu_music_tag")?.GetComponent <MainMenuMusic>();
     mainMenuMusicMaxVolume = (mainMenuMusic != null) ? mainMenuMusic.GetMainMenuSongMaxVolume() : 0;
     sm = GameObject.FindGameObjectWithTag("sound_manager_tag")?.GetComponent <SoundManager>();
 }
    void Start()
    {
        MainMenuMusic music = GameObject.FindObjectOfType <MainMenuMusic>();

        labels = GameObject.FindGameObjectsWithTag("ScoreLabel");
        int        i      = 0;
        List <int> scores = new List <int>();

        for (int j = 1; j <= 5; j++)
        {
            scores.Add(PlayerPrefs.GetInt("highscorePos" + j));
        }
        var sortedList      = labels.OrderBy(go => go.name).ToList();
        var descendingOrder = scores.OrderByDescending(p => p);

        foreach (GameObject label in sortedList)
        {
            label.GetComponent <Text>().text = scores[i].ToString();
            i++;
        }
    }
    void Start()
    {
        MainMenuMusic music = GameObject.FindObjectOfType <MainMenuMusic>();

        if (music.source != null)
        {
            music.Stop();
            music.source.enabled = false;
        }
        music.source         = GameObject.Find("PacmanTheme").GetComponent <AudioSource>();
        music.source.enabled = true;
        music.source.Play();
        levelLoading = false;
        gameManager  = FindObjectOfType <GameManager>();
        gameManager.SetPacmanAsGame();
        playerPosition = transform.position;
        dest           = transform.position;
        addUnlockedFruits(gameManager.getFruitCounter());
        pointsText      = GameObject.Find("LivesText").GetComponent <Text>();
        pointsText.text = "Lives: " + gameManager.lives;
        pointsText      = GameObject.Find("PointsText").GetComponent <Text>();
        pointsText.text = "Points: " + gameManager.points;
    }
예제 #17
0
 void Awake()
 {
     gameObj        = GameObject.Find("MainMenuMusic");
     currentSpawner = gameObj.GetComponent <MainMenuMusic>();
 }
 public void PlayMainMenuMusicAudio()
 {
     MainMenuMusic.Play();
 }
 public void StopMainMenuMusicAudio()
 {
     MainMenuMusic.Stop();
 }