// Use this for initialization void Start() { players = GameObject.FindGameObjectsWithTag("Player"); GameObject f = GameObject.FindGameObjectWithTag("Failure"); if (f != null) { print("Got text"); fail = f.GetComponent <Text>(); } bg = GameObject.Find("BackgroundMusic").GetComponent <BackgroundMusicManager>(); GameObject obj = GameObject.FindWithTag("Fade"); if (obj != null) { fade = obj.GetComponent <Image> (); } setFade = false; startFade = true; gameOver = false; fade.color = Color.black; setAlpha = 0.0f; startAlpha = 1.0f; GameObject obj2 = GameObject.Find("NetworkManager"); if (obj2) { NetworkManager man = obj2.GetComponent <NetworkManager> (); man.levelLoader = this; host = man.Host; } }
protected void EndGame() { BackgroundMusicManager.Pitch(1f); if (grabbable) { grabbable.Reset(); } if (ballSpawner) { ballSpawner.Reset(); } backboard.SetActive(true); gameOverUI.SetActive(true); if (PlayerPrefs.GetFloat(gameKey + "_HIGHSCORE") < ScoreKeeper.instance.score) { PlayerPrefs.SetFloat(gameKey + "_HIGHSCORE", ScoreKeeper.instance.score); highScoreText.text = "HIGHSCORE:\n" + ScoreKeeper.instance.score.ToString(ScoreKeeper.instance.score % 1 < 0.0001 ? "N0" : "N2"); } for (int j = 0; j < targets.Length; j++) { if (targets[j].isSpawned) { targets[j].Despawn(); } } ScoreKeeper.isGameRunning = false; }
// Start is called before the first frame update void Start() { GameObject managers = GameObject.FindGameObjectWithTag("Managers"); uiManager = managers.GetComponentInChildren <UIManager>(); bgmManager = managers.GetComponentInChildren <BackgroundMusicManager>(); anim = GetComponent <Animator>(); }
void Awake() { _slider = gameObject.GetComponent <Slider>(); gameManager = FindObjectOfType <GameManager>(); backgroundMusicManager = FindObjectOfType <BackgroundMusicManager>(); _slider.maxValue = backgroundMusicManager.FinalScore; }
// Start is called before the first frame update void Start() { if (GameObject.Find("BMM") != null) { BackgroundMusicManager BMM = GameObject.Find("BMM").GetComponent <BackgroundMusicManager>(); BMM.Play(_musicName); } }
// Start is called before the first frame update void Start() { cameraT.position = cameraStartT.position; GameObject managers = GameObject.FindGameObjectWithTag("Managers"); bgmManager = managers.GetComponentInChildren <BackgroundMusicManager>(); bgmManager.PlaySound(1); }
public void SetSingleton() { if (Instance != null) { print("Instancia já inicializada. Essa será destruida."); DestroyImmediate(this); } Instance = this; }
// Start is called before the first frame update void Awake() { instance = this; asource = gameObject.AddComponent <AudioSource>(); asource.clip = start; asource.Play(); shouldLoop = true; }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(this.gameObject); } }
// Start is called before the first frame update void Start() { pAnimator = GetComponentInChildren <Animator>(); GameObject constantManagers = GameObject.FindGameObjectWithTag("ConstantManagers"); livesManager = constantManagers.GetComponentInChildren <LivesManager>(); GameObject managers = GameObject.FindGameObjectWithTag("Managers"); bgmManager = managers.GetComponentInChildren <BackgroundMusicManager>(); }
private void Awake() { if (BMMInstance != null) { Destroy(gameObject); } else { BMMInstance = this; } }
// Start is called before the first frame update void Start() { // Check for duplicate instances if (_Instance != null && _Instance != this) { Destroy(this.gameObject); return; } // Use this object as persistent instance _Instance = this; DontDestroyOnLoad(this.gameObject); }
private void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(this); } else if (instance != null && instance != this) { Destroy(gameObject); return; } }
// Start is called before the first frame update void Start() { // Initialize members _firstAidSpawner = GetComponent <FirstAidSpawner>(); _dialogueDisplayer = GetComponent <DialogueDisplayer>(); _audioSource = GetComponent <AudioSource>(); _bgm = GameObject.Find("Background Music").GetComponent <BackgroundMusicManager>(); _timeElapsed = 0f; _isPlayerHoldingFirstAid = false; // (Re)start game RestartGame(); }
void Awake() { if (Instance == null) { Instance = this; } //If an instance already exists, destroy whatever this object is to enforce the singleton. else if (Instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
// Start is called before the first frame update void Start() { playerMovement = GetComponent <PlayerMovement>(); anim = GetComponentInChildren <Animator>(); playerCol = GetComponent <CapsuleCollider2D>(); GameObject constantManagers = GameObject.FindGameObjectWithTag("ConstantManagers"); livesManager = constantManagers.GetComponentInChildren <LivesManager>(); GameObject managers = GameObject.FindGameObjectWithTag("Managers"); uiManager = managers.GetComponentInChildren <UIManager>(); sfxManager = managers.GetComponentInChildren <SFXManager>(); bgmManager = managers.GetComponentInChildren <BackgroundMusicManager>(); }
private void Awake() { if (_instance == null) { _instance = this; DontDestroyOnLoad(gameObject); _src = GetComponent <AudioSource>(); for (int i = 0; i < _musicName.Length; ++i) { _musicList.Add(_musicName[i], _musicClip[i]); } } else { Destroy(this); } }
private void Awake() { if (myself == null) { myself = this; DontDestroyOnLoad(gameObject); return; } if (myself == this) { return; } else { Destroy(gameObject); } }
public static BackgroundMusicManager instance = null; //Allows other scripts to call functions from SoundManager. void Awake() { //Check if there is already an instance of SoundManager if (instance == null) { //if not, set it to this. instance = this; } //If instance already exists: else if (instance != this) { //Destroy this, this enforces our singleton pattern so there can only be one instance of SoundManager. Destroy(gameObject); } //Set SoundManager to DontDestroyOnLoad so that it won't be destroyed when reloading our scene. DontDestroyOnLoad(gameObject); }
// Update is called once per frame void Update() { if (!Scenes.Contains(Application.loadedLevelName)) { Destroy(this.gameObject); } if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
IEnumerator SpawnTargets() { shouldSpawn = true; startTime = Time.time; bool hasPitched = false; while (shouldSpawn) { while (spawnTimeIndex < spawnTimes.Length && spawnTimes[spawnTimeIndex] < Time.time - startTime) { spawnTimeIndex++; int i = Random.Range(0, targets.Length); for (int j = 0; j < targets.Length; j++) { if (!targets[(j + i) % targets.Length].isSpawned) { targets[i].Spawn(this); Debug.Log("spawning"); break; } } } timeText.text = "Time:\n" + Mathf.Clamp(gameTime - (Time.time - startTime), 0f, gameTime).ToString("n2"); float runTime = Time.time - startTime; if (gameTime - runTime < 10.3f && !hasPitched) { Debug.Log("tryna pitch"); BackgroundMusicManager.Pitch(Mathf.Pow(1.05946f, 3)); hasPitched = true; } if (Time.time - startTime < gameTime) { yield return(null); } else { shouldSpawn = false; } } EndGame(); }
void Awake() { if (Instance != null) { Destroy(gameObject); } else { Instance = this; DontDestroyOnLoad(gameObject); } foreach (Sound s in sounds) { s.source = gameObject.AddComponent <AudioSource>(); s.source.clip = s.clip; s.source.loop = s.loop; s.source.outputAudioMixerGroup = mixerGroup; } }
// Use this for initialization void Start() { music = GameObject.Find ("MusicHolder").GetComponent<BackgroundMusicManager> (); music.TurnOnForwardClip (); }
private void Awake() { backgroundMusicManager = Camera.main.GetComponentInChildren <BackgroundMusicManager>(); }
private void LoadAudioClip(string _soundPath, BackgroundMusicManager.AduioLoadAsyncCallback cb) { if (string.IsNullOrEmpty(_soundPath)) { return; } base.StartCoroutine(this.LoadResourceAsync(string.Format("Audio/{0}", _soundPath), cb)); }
private IEnumerator LoadResourceAsync(string clipName, BackgroundMusicManager.AduioLoadAsyncCallback cb) { return null; //BackgroundMusicManager.<LoadResourceAsync>c__Iterator12 <LoadResourceAsync>c__Iterator = new BackgroundMusicManager.<LoadResourceAsync>c__Iterator12(); //<LoadResourceAsync>c__Iterator.clipName = clipName; //<LoadResourceAsync>c__Iterator.cb = cb; //<LoadResourceAsync>c__Iterator.<$>clipName = clipName; //<LoadResourceAsync>c__Iterator.<$>cb = cb; //return <LoadResourceAsync>c__Iterator; }
// Use this for initialization void Start() { players = GameObject.FindGameObjectsWithTag ("Player"); GameObject f = GameObject.FindGameObjectWithTag ("Failure"); if(f != null) { print ("Got text"); fail = f.GetComponent<Text>(); } bg = GameObject.Find ("BackgroundMusic").GetComponent<BackgroundMusicManager>(); GameObject obj = GameObject.FindWithTag ("Fade"); if (obj != null) fade = obj.GetComponent<Image> (); setFade = false; startFade = true; gameOver = false; fade.color = Color.black; setAlpha = 0.0f; startAlpha = 1.0f; GameObject obj2 = GameObject.Find ("NetworkManager"); if (obj2) { NetworkManager man = obj2.GetComponent<NetworkManager> (); man.levelLoader = this; host = man.Host; } }
/// <summary> /// The main game constructor. /// </summary> public Game1() { Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); graphics.IsFullScreen = true; graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings); // Frame rate is 60 fps IsFixedTimeStep = false; //TargetElapsedTime = TimeSpan.FromTicks(166667); #if WINDOWS graphics.IsFullScreen = false; #endif // you can choose whether you want a landscape or portait // game by using one of the two helper functions. InitializePortraitGraphics(); //InitializeLandscapeGraphics(); //Get CI ci = (CultureInfo)CultureInfo.CurrentCulture.Clone(); ci.NumberFormat.NumberDecimalSeparator = "."; ci.NumberFormat.NumberGroupSeparator = ","; //Load the waves wavedefines = Content.Load<BoardWaveDefines>("Maps\\Waves"); maxwave = wavedefines.GetMaxWave(); // Create the accounting table currentGameAccounting = new WaveAccountingTable(maxwave); // Create the screen manager component. screenManager = new ScreenManager(this); Components.Add(screenManager); //attempt to deserialize overall gameplay state. bool loaded; loaded = DeserializeState(); if (loaded == true) { boardSeed = state.boardSeed; currentwave = state.currentWave; finalscore = state.currentTotalScore; currentGameAccounting.Load(state.accountingentries); } // attempt to deserialize the screen manager from disk. if that // fails, we add our default screens. //if (!screenManager.DeserializeState()) //{ // Activate the first screens. background = new BackgroundScreen("sprites\\Titles\\MainMenu"); background.StartCursor(2.0f); screenManager.AddScreen(background, null); screenManager.AddScreen(new SplashScreen(), null); //screenManager.AddScreen(new GameOverScreen(), PlayerIndex.One); //screenManager.AddScreen(new GameplayScreen(), null); //} //music backgroundMusicManager = new BackgroundMusicManager(this); MainMenuSong = Content.Load<Song>("Sounds\\Music\\jm_menu_loop"); GameSong = Content.Load<Song>("Sounds\\Music\\jm_main_loop"); }