// Use this for initialization void Start() { BeatHandler_ = this.BeatHandlerObject.GetComponent<BeatHandler>(); BeatHandler_.OnBeat += Handle_OnBeat; BeatMapper_ = this.BeatMapperObject.GetComponent<BeatMapper>(); }
public void LoadTracks(MusicTrack[] tracks, int currentLevel, float progress) { this.currentLevel = currentLevel; this.tracks = tracks; this.mapper = gameObject.AddComponent <BeatMapper>(); mapper.ChangeBeatMap(tracks[currentLevel - 1].BeatMap); InitialiseTracks(progress); }
/// <summary> /// Sets initial variables and components /// </summary> void Start() { // set beat mapper component beatMapper = soundManager.GetComponent <BeatMapper>(); // keeping track of all objects in the game enemySpawner = GetComponent <EnemySpawner>(); player = GameObject.FindGameObjectWithTag("Player"); playerWaypoint = GameObject.FindGameObjectWithTag("PlayerWaypoint"); playerScript = player.GetComponent <Player>(); // set audio source component audioSource = soundManager.GetComponent <AudioSource>(); audioSource.clip = mainTheme; audioSource.Play(); // Make sure our projections are white to start outerLeftProjector.material.color = M_NO_ENEMY.color; outerRightProjector.material.color = M_NO_ENEMY.color; innerProjector.material.color = M_NO_ENEMY.color; // Spawn in our initial enemy destruction prefabs SpawnInitialEnemyDestructs(); // detect what platform we are playing on #if UNITY_STANDALONE DESKTOPGAME = true; #endif #if UNITY_IOS MOBILEGAME = true; #endif #if UNITY_ANDROID MOBILEGAME = true; #endif // effect for the menu of the game /* * GameObject[] lights = GameObject.FindGameObjectsWithTag("AvailableLight"); * if (lights.Length > 0) * { * for (int i = 0; i < lights.Length; i++) * { * lights[i].GetComponent<LightFlicker>().myLight = lights[i].GetComponent<Light>(); * lights[i].GetComponent<LightFlicker>().flash = true; * lights[i].GetComponent<LightFlicker>().totalSeconds = 5; * lights[i].GetComponent<LightFlicker>().intensityStep = lights[i].GetComponent<LightFlicker>().maxIntensity / 60; * lights[i].GetComponent<LightFlicker>().intensityStep = lights[i].GetComponent<LightFlicker>().intensityStep / (lights[i].GetComponent<LightFlicker>().totalSeconds / 2); * lights[i].GetComponent<LightFlicker>().myLight.enabled = true; * int randomColorNum = Random.Range(0, lights[i].GetComponent<LightFlicker>().colors.Count); * lights[i].GetComponent<LightFlicker>().myLight.color = lights[i].GetComponent<LightFlicker>().colors[randomColorNum]; * lights[i].GetComponent<LightFlicker>().repeat = true; * float randomDelay = Random.Range(0, 2.5f); * lights[i].GetComponent<LightFlicker>().beginningDelay = randomDelay; * } * } */ }
private BeatMapper beatMapper; //our beatMapper script, which contains the player's beatMap #endregion /// <summary> /// Sets initial variables and components /// Reads in our mapped out beats /// </summary> public void Start() { // current amount of time passed since the game started currentGameTime = 0f; startedMusic = false; // reset the map positionInMap = -1; // Get to our beatMap soundManager = GameObject.FindWithTag("SoundManager"); beatMapper = soundManager.GetComponent <BeatMapper>(); beatMap = beatMapper.listOfBeats; // set GameManager script gm = GameObject.FindWithTag("Manager").GetComponent <GameManager>(); player = GameObject.FindWithTag("Player"); CalculateDistance(); //********* // SET OUR LISTS HERE listOfMaps = new List <BeatMap>(); // if our left list is empty, then we have 1 button input if (beatMapper.listOfBeatsLeft.Count == 0) { // Fill it with a generic beat listOfMaps.Add(new global::BeatMap(beatMapper.listGenericMegalovania, true)); delayTimer = Mathf.Abs(-spawnOffset + listOfMaps[0].untilNextSpawn); GameObject.FindGameObjectWithTag("SoundManager").GetComponent <MusicPicker>().SetMegalovania(); } // otherwise, we have multi-button input else { // add both our left and right maps listOfMaps.Add(new BeatMap(beatMapper.listOfBeatsLeft, true)); listOfMaps.Add(new BeatMap(beatMapper.listOfBeatsRight, false)); // set our music delay timer to be the lesser of the two beatMap lists first spawns, // and start our music after that amount of time if (listOfMaps[0].untilNextSpawn > listOfMaps[1].untilNextSpawn) { delayTimer = Mathf.Abs(-spawnOffset + listOfMaps[1].untilNextSpawn); } else { delayTimer = Mathf.Abs(-spawnOffset + listOfMaps[0].untilNextSpawn); } } StartCoroutine("StartMusic"); }
private BeatMapper beatMapper; //our beatMapper script, which contains the player's beatMap #endregion /// <summary> /// Sets initial variables and components /// </summary> public void Start() { // current amount of time passed since the game started currentGameTime = 0f; startedMusic = false; // reset the map positionInMap = -1; // Get to our beatMap soundManager = GameObject.FindWithTag("SoundManager"); beatMapper = soundManager.GetComponent <BeatMapper>(); beatMap = beatMapper.listOfBeats; // set GameManager script gm = GameObject.FindWithTag("Manager").GetComponent <GameManager>(); player = GameObject.FindWithTag("Player"); // Calculate our beats per minute bps = this.gameObject.GetComponent <MusicManager>().rootObj.beatsPerMinute / 60f; // calculate the distance between the player and where the enemies spawn CalculateDistance(); // If our beatMap doesn't have anything contained in it, we want to spawn based on beats per minute if (beatMap.Count <= 0) { timeUntilNextBeat = (1f / bps); spawning = true; } // Otherwise, we do want to spawn based on our beatMap input else { positionInMap = 0; timeUntilNextBeat = beatMap[positionInMap] - beatMapper.timeBetweenStartOfSongAndFirstBeat; timeSinceLastSpawn = 0f; spawning = true; } }
private AudioSource audioSource; // audio source component #endregion /// <summary> /// Sets initial variables and components /// </summary> void Start() { // set beat mapper component beatMapper = soundManager.GetComponent <BeatMapper>(); // keeping track of all objects in the game enemySpawner = GetComponent <EnemySpawner>(); player = GameObject.FindGameObjectWithTag("Player"); playerScript = player.GetComponent <Player>(); // set audio source component audioSource = soundManager.GetComponent <AudioSource>(); audioSource.clip = mainTheme; audioSource.Play(); // detect what platform we are playing on #if UNITY_STANDALONE DESKTOPGAME = true; #endif #if UNITY_IOS MOBILEGAME = true; #endif #if UNITY_ANDROID MOBILEGAME = true; #endif }
public void RegisterOnBeatCallback(BeatMapper mapper) { this.mapper = mapper; this.mapper.OnBeat += Shoot; }
private AudioSource audioSource; // The audioSource that plays the songs. A part of the soundManager #endregion void Start() { // Initialize our class variables audioSource = soundManager.GetComponent <AudioSource>(); beatMapper = soundManager.GetComponent <BeatMapper>(); }