public void OnSkillDestroy(NetworkMessage netMsg) { MObjects.SkillDestroy mObject = netMsg.ReadMessage <MObjects.SkillDestroy>(); Skill s = Skill.list.Find(x => x.id == mObject.id); if (s != null) { ParticleSystem[] ps = s.GetComponentsInChildren <ParticleSystem>(); foreach (ParticleSystem p in ps) { var m = p.main; m.loop = false; p.Stop(true, ParticleSystemStopBehavior.StopEmitting); } SoundPlayer_Frequent sfq = s.GetComponent <SoundPlayer_Frequent>(); if (sfq != null) { sfq.down = true; } Destroy(s.gameObject, s.GetComponent <HookScript>() ? 0: 3f); Destroy(s); } }
public static void PlaySound(string[] sound, GameObject t, bool languageSound = false, float mod = 1f, float blend = 1f, bool isLoop = false) { if (sound == null || sound.Length == 0) { return; } AudioSource source = t.GetComponent <AudioSource>(); if (source == null) { source = t.AddComponent <AudioSource>(); } source.spatialBlend = blend; ushort dSound = (ushort)Random.Range(0, sound.Length); string tSound = "Sounds/" + ((languageSound) ? Language.loaded + "/" : "") + sound[dSound]; AudioClip ac = Resources.Load <AudioClip>(tSound); if (!isLoop) { source.PlayOneShot(ac, mod * Settings.soundVolume); } else { SoundPlayer_Frequent spf = source.GetComponent <SoundPlayer_Frequent>(); if (spf == null) { spf = t.AddComponent <SoundPlayer_Frequent>(); } source.clip = ac; spf.mod = mod; } }