private void Awake() { if (main == null) { main = this; } }
/// <summary> /// Moves to a desired position setting targetPosition to a new value to interpolate /// </summary> /// <param name="positionIndex">Bijection with notes index (see LivePlayer.cs)</param> public static void MoveNoteToPosition(VisualNote noteToMove, int positionIndex) { List <Vector3> possiblePositions = PositionProvider.possiblePositions; if (possiblePositions == null || positionIndex >= possiblePositions.Count || possiblePositions[positionIndex] == null) { Debug.LogWarning("Sending to nonexisting position"); return; } noteToMove.targetPosition = possiblePositions[positionIndex]; }
public override void Update(GameTime gameTime) { for (int i = 0; i < notes.Count; i++) { VisualNote note = notes[i]; note.Update(ExhibeatSettings.TimeElapsed /*gameTime.ElapsedGameTime.Milliseconds*/); if (note.time_left < 0) { notes.Remove(note); ExhibeatSettings.GetAudioManager().stop(clapSongIdx); ExhibeatSettings.GetAudioManager().play(clapSongIdx); Press(); i--; } #if ANIMATED_TILE else { note.sprite_sheet.Update(gameTime); } #endif } if (pressAnimation) { if (glowTargetOpacity > 0f) // apparition { if (glowOpacity >= 0.7f) { glowTargetOpacity = 0f; } else { glowOpacity += 0.05f; } } else // disparition { if (glowOpacity > 0f) { glowOpacity -= 0.01f; } else { glowOpacity = 0f; pressAnimation = false; } } } }
public void buttonPressed(Buttons button, float diff) { pressed = true; float beat = Mathf.Round(conductor.songPositionInBeats); //Debug.Log(button.ToString() + " pressed at " + diff.ToString("F2") + " different from beat " + beat); bool noteHit = (int)beat >= 1 && visualNotes[(int)beat] != null; if (noteHit) { VisualNote vNote = visualNotes[(int)beat].GetComponent <VisualNote>(); if (button == vNote.note.direction && !vNote.hit) { vNote.getHit(); if (Mathf.Abs(diff) < PerfectNote) { Score += 100; spawnFeedback("PERFECT!", PerfectColor); } else if (Mathf.Abs(diff) < GreatNote) { Score += 75; spawnFeedback("GREAT!", GreatColor); } else if (Mathf.Abs(diff) < OkNote) { Score += 45; spawnFeedback("OK", OkColor); } else { Score += 15; spawnFeedback("OOF", OofColor); } LiveScoreText.text = Score.ToString(); } else { //Wrong direction! } } if (saveNotes && !noteHit) { Note newNote = new Note(Mathf.Round(conductor.songPositionInBeats), button); notes.Add(newNote); } }
public void startGame() { foreach (GameObject item in visualNotes) { if (item) { Destroy(item); } } Score = 0; gameStarted = true; TutorialCanvas.SetActive(false); ScoreboardCanvas.SetActive(false); visualNotes = new GameObject[500]; conductor.startConductor(); foreach (Note note in notes) { GameObject vNote = Instantiate(visualNote, parentVisualNote); VisualNote vscript = vNote.GetComponent <VisualNote>(); vscript.note = note; vscript.conductor = conductor; visualNotes[(int)note.beat] = vNote; } }