public void Initialize(RecordConductor conductor, NoteRecorder recorder, Transform startPoint, Transform endPoint, float beat) { this.conductor = conductor; this.recorder = recorder; this.startPos = startPoint; this.endPos = endPoint; this.beat = beat; // Set to initial position. transform.position = startPoint.position; moving = true; }
private void OnGUI() { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Audio Source"); audioSource = (AudioSource)EditorGUILayout.ObjectField(audioSource, typeof(AudioSource), true); EditorGUILayout.EndHorizontal(); if (audioSource != null) { if (EditorApplication.isPlaying) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Note Recorder"); noteRecorder = (NoteRecorder)EditorGUILayout.ObjectField(noteRecorder, typeof(NoteRecorder), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Music File"); musicClip = (AudioClip)EditorGUILayout.ObjectField(musicClip, typeof(AudioClip), false); EditorGUILayout.EndHorizontal(); if (audioSource.clip != musicClip) { audioSource.clip = musicClip; } if (GUILayout.Button("Load Music")) { musicPath = EditorUtility.OpenFilePanel("Load Music File", "", "mp3"); if (musicPath.Length != 0) { musicClip = LoadMusic(musicPath); } } if (musicClip != null && noteRecorder != null) { DrawMNFileSettings(); if (IsMNDataValid()) { if (GUILayout.Button("Start Recording")) { songData = new SongParser.Metadata(); songData.title = songTitle; songData.subtitle = subtitle; songData.artist = artist; songData.bannerPath = bannerPath; songData.backgroundPath = backgroundPath; songData.musicPath = Path.GetFileName(musicPath); songData.offset = offset; songData.sampleStart = sampleStart; songData.sampleLength = sampleLength; songData.bpm = bpm; string _targetPath = musicPath.Replace(Path.GetFileName(musicPath), ""); audioSource.Play(); noteRecorder.InitRecording(songData, _targetPath); } } else { EditorGUILayout.HelpBox("Song title, artist, and BPM must be valid to start recording.", MessageType.Warning); } } else { if (musicClip == null) { EditorGUILayout.HelpBox("Load a music file to start recording.", MessageType.Info); } if (noteRecorder == null) { EditorGUILayout.HelpBox("A Note Recorder from the scene is required.", MessageType.Info); } } } else { EditorGUILayout.HelpBox("Enter Playmode to start recording.", MessageType.Info); } } else { EditorGUILayout.HelpBox("An Audio Source from the scene is required.", MessageType.Info); } }
// Use this for initialization void Start() { song = GetComponent <Song1>(); aManager = GetComponent <AudioManager>(); //Get a reference to the audio manager currentBeat = 0; //The current beat of focus nextBeat = 0; //The next beat for spawning //initialize other variables comboCount = 0; beatHit = false; score = 0; //World coordinates of the range for hitting a beat topLeftRange = mainCamera.ViewportToWorldPoint(new Vector3(0.0f, 0.3f)); botRightRange = mainCamera.ViewportToWorldPoint(new Vector3(1.0f, 0.1f)); keySpawns = new Dictionary <int, Vector3>(); //Create a new dictionary for each possible key and it's spawn location song.createSongMap(); // physically puts in the notes into the Lists beatmap = song.LoadandSetNotes(); // return the created lists beatmapTimes = song.LoadandSetTimes(); // return the created lists //For loop to set up key spawn locations for (int i = 0; i < 9; i++) { //1 - 9 keys //ViewPointToWorld of the spawning location //Vector3 spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.091f * (i + 1), 1.1f)); Vector3 spawnPoint; if (i == 0) { spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.065f, 1.1f)); keySpawns.Add(i + 1, spawnPoint); } else if (i == 1) { spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.16f, 1.1f)); keySpawns.Add(i + 1, spawnPoint); } else if (i == 2) { spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.2555f, 1.1f)); keySpawns.Add(i + 1, spawnPoint); } else if (i == 3) { spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.355f, 1.1f)); keySpawns.Add(i + 1, spawnPoint); } else if (i == 4) { spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.45f, 1.1f)); keySpawns.Add(i + 1, spawnPoint); } else if (i == 5) { spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.55f, 1.1f)); keySpawns.Add(i + 1, spawnPoint); } else if (i == 6) { spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.645f, 1.1f)); keySpawns.Add(i + 1, spawnPoint); } else if (i == 7) { spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.742f, 1.1f)); keySpawns.Add(i + 1, spawnPoint); } else if (i == 8) { spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.841f, 1.1f)); keySpawns.Add(i + 1, spawnPoint); } //Add the 0 key if (i == 8) { //increment i for 0 i++; //Change the spawn location to adjust for the new i value spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.935f, 1.1f)); keySpawns.Add(0, spawnPoint); } } aManager.loadAudioFiles("Sounds/Songs"); aManager.setSongToPlay(0); aManager.playSong(); noteFallSpeed = 4.0f; timeOffset = noteFallSpeed * 5.7f; percentPerHit = 100.0f / beatmap.Count; //Set the initial state to InGame currState = gameState.InGame; recorder = GetComponent <NoteRecorder>(); }