public void Jukebox_Should_Throw_PlaySong_If_Song_Cost_Negative() { //arrange var jukebox = new Jukebox(); //act Action act = () => jukebox.PlaySong(new Song(1, String.Empty, -1, null)); //assert act.ShouldThrow <ArgumentOutOfRangeException>(); }
public void Jukebox_Should_Throw_PlaySong_If_Null() { //arrange var jukebox = new Jukebox(); //act Action act = () => jukebox.PlaySong(null); //assert act.ShouldThrow <ArgumentNullException>(); }
/* UNITY FUNCTIONS */ // Called when the object is initialized. void Awake() { if (gInstance == null) { gInstance = this; } else { // change song if different if (gInstance.CurrentSong != CurrentSong) { gInstance.PlaySong(CurrentSong); } Destroy(gameObject); } PlaySong(CurrentSong); DontDestroyOnLoad(gameObject); }
public void Jukebox_Should_Not_Play_Song_IF_Enought_Balance() { //arrange var artist = new Artist(1, String.Empty); var songs = new List <Song>() { new Song(1, string.Empty, 1, null), new Song(2, string.Empty, 2, artist), new Song(3, string.Empty, 3, null), new Song(4, string.Empty, 4, artist) }; var jukebox = new Jukebox(); jukebox.InsertCD(new CD(songs)); jukebox.IncreaseBalance(new Coin(1)); //act jukebox.PlaySong(songs[2]); //assert jukebox.Balance.ShouldBeEquivalentTo(1); }
// Update is called once per frame void Update() { if (fadeDir) { fade += (Time.deltaTime / fadeTime) * 0.75f; if (fade > 1f) { fade = 1f; } if (artwork.color.a < fade) { artwork.color = new Color(1f, 1f, 1f, fade); } if (textBox.color.a < fade) { textBox.color = new Color(1f, 1f, 1f, fade); } artwork.sprite = art[index]; textBox.text = text[index]; if (textEmphasized[index]) { textBox.font = fontEmphasized; textBox.fontSize = 44; } else { textBox.font = fontNormal; textBox.fontSize = 28; } if (!startedPlayingSong && (music[index] != null || musicLoop[index])) { jukebox.PlaySong(music[index]); startedPlayingSong = true; } jukebox.SetLoop(musicLoop[index]); } else { fade -= Time.deltaTime / fadeTime; startedPlayingSong = false; if (fade <= 0f) { fade = 0f; fadeDir = true; } if (artwork.sprite != art[index]) { artwork.color = new Color(1f, 1f, 1f, fade); } if (!textBox.text.Equals(text[index])) { textBox.color = new Color(1f, 1f, 1f, fade); } } if (Input.GetAxis("Fire1") == 0) { canPressNext = true; } if (Input.GetAxis("Fire1") > 0 && canPressNext && fadeDir) { canPressNext = false; if (index < art.Length - 1 && autoTime <= 0f) { fadeDir = false; index++; } else if (index >= art.Length - 1) { EndCutscene(); } } if (Input.GetAxis("Pause") > 0 && canPressNext) { canPressNext = false; EndCutscene(); } autoTimer += Time.deltaTime; if (autoTime > 0f && autoTimer > autoTime && index < art.Length - 1) { autoTimer = 0f; fadeDir = false; index++; } }