public void TriggerPenalty(AdData.Function func) { int ran = 0; switch (func) { case AdData.Function.BackgroundChange: ran = Random.Range(0, m_backgrounds.Length); m_background.sprite = m_backgrounds[ran]; break; case AdData.Function.Cursor: m_cursorStart = Time.time; ran = Random.Range(0, m_cursors.Length); Cursor.SetCursor(m_cursors[ran], m_cursorHotspots[ran], CursorMode.ForceSoftware); m_changeCursor = true; break; case AdData.Function.DesktopPet: m_petStart = Time.time; DesktopPet pet = Instantiate(m_desktopPet, m_elementContainer).GetComponent <DesktopPet>(); pet.Initialize(DestroyPet); m_currentPets.Add(pet); m_pet = true; break; case AdData.Function.AlienPet: m_petStart = Time.time; DesktopPet alien = Instantiate(m_alienPet, m_elementContainer).GetComponent <DesktopPet>(); alien.Initialize(DestroyPet); m_currentPets.Add(alien); m_pet = true; break; case AdData.Function.DownloadSlowdown: m_slowdownStart = Time.time; m_slowdown = true; break; case AdData.Function.Emoticons: m_emoticonsStart = Time.time; m_lastEmoteTime = Time.time; m_emoticons = true; break; case AdData.Function.PopUpSpeed: m_speedUpStart = Time.time; m_speedUp = true; break; case AdData.Function.Virus: if (m_currentVirusWindow) { Destroy(m_currentVirusWindow); } m_currentVirusWindow = Instantiate(m_virusWindow, m_elementContainer); m_virusStart = Time.time; m_virus = true; break; } m_manager.AddPenalty(1); }
public void DestroyPet(DesktopPet pet) { m_currentPets.Remove(pet); Destroy(pet.gameObject); }