public void StartMusic(PotTypes songType) { PlantSongVariation variation = songs.GetVariation(songType); currentClips = variation.variations; theSource.clip = variation.startingClip; variationTempo.SetTempo(variation.startingClip.length); variationTempo.beat.AddListener(ClipSwap); // make it be triggered by the tempo globalTempo.beat.AddListener(DoBeat); }
// Update is called once per frame void Update() { if (transform.parent != null && isPlanted == false) //if it has a parent and it isnt planted { if (transform.parent.transform.gameObject.CompareTag("pot")) //if parent is a pot, play music { isPlanted = true; potType = transform.parent.transform.gameObject.GetComponent <Pot>().potType; sounds.StartMusic(potType); } } else if (isPlanted == true && (transform.parent == null || transform.parent.gameObject.CompareTag("player"))) //if it was planted, but its parent isnt a pot(player or nothing) stop music { isPlanted = false; potType = PotTypes.Empty; sounds.StopMusic(); } }
public PlantSongVariation GetVariation(PotTypes type) { if (type == PotTypes.Empty) { throw new System.Exception("Cannot play an empty pot type!"); } switch (type) { case PotTypes.Busy: return(busyClips); case PotTypes.Medium: return(mediumClips); case PotTypes.Calm: return(calmClips); case PotTypes.Empty: break; } return(calmClips); }