private IEnumerator PlayMusic(string musicID, float wait) { yield return(new WaitForSeconds(wait)); // we need a small wait for the SoundLoader to initialise first time audioSource.PlayOneShot(SoundLoader.LoadSound(musicID)); Debug.LogWarning("TODO: Fix Format Issue. Defaulting to temporary solution..."); switch (musicID) { case "D_INTROA": audioSource.clip = D_INTROA; audioSource.Play(); break; case "D_INTER": audioSource.clip = D_INTER; audioSource.Play(); break; case "D_E1M1": audioSource.clip = D_E1M1; audioSource.Play(); break; } }
public override void Init() { if (C.FireSound.Get() != null) { Audio = gameObject.AddComponent <AudioSource>(); Audio.playOnAwake = false; Audio.spatialBlend = 1.0f; Audio.rolloffMode = AudioRolloffMode.Linear; Audio.minDistance = 2.0f; Audio.maxDistance = 30.0f; Audio.loop = false; // TODO: replace with class sound, once we can load sound LVLs Audio.clip = SoundLoader.LoadSound("wpn_rep_blaster_fire"); } if (C.OrdnanceName.Get() == null) { Debug.LogWarning($"Missing Ordnance class in cannon '{name}'!"); } if (transform.childCount > 0) { HpFire = transform.GetChild(0).Find("hp_fire"); } if (HpFire == null) { Debug.LogWarning($"Cannot find 'hp_fire' in '{name}', class '{C.Name}'!"); } // Total amount of 4 magazines Ammunition = C.RoundsPerClip * 3; MagazineAmmo = C.RoundsPerClip; }
public void PlayShootAnimation() { if (animIdx < weaponTypes [weaponIdx].attackSprites.Length) { SetWeaponSprite(weaponTypes [weaponIdx].attackSprites [animIdx]); // Muzzle if (animIdx < weaponTypes [weaponIdx].muzzleSprites.Length && !string.IsNullOrEmpty(weaponTypes [weaponIdx].muzzleSprites [animIdx])) { Texture t = TextureLoader.Instance.GetSpriteTexture(weaponTypes [weaponIdx].muzzleSprites [animIdx]); weaponTypes [weaponIdx].muzzleImage.texture = t; weaponTypes [weaponIdx].muzzleImage.gameObject.SetActive(true); } else if (weaponTypes[weaponIdx].muzzleImage != null) { weaponTypes [weaponIdx].muzzleImage.gameObject.SetActive(false); } // Audio if (animIdx < weaponTypes [weaponIdx].audioFrames.Length) { if (!string.IsNullOrEmpty(weaponTypes [weaponIdx].audioFrames [animIdx])) { AudioClip clip = SoundLoader.LoadSound(weaponTypes [weaponIdx].audioFrames [animIdx]); audioSource.PlayOneShot(clip); } } if (animIdx == weaponTypes [weaponIdx].attackIdx) { if (weaponTypes [weaponIdx].ammoType != AmmoType.UNLM) { SetAmmo(weaponTypes[weaponIdx].name, GetAmmo(weaponTypes[weaponIdx].name) - 1); guiManager.SetAmmo(GetAmmo(weaponTypes[weaponIdx].name)); } switch (weaponTypes[weaponIdx].attackType) { case AttackType.MeleeOneShot: TryHitRaycast(1.5f, weaponTypes[weaponIdx].damage); break; case AttackType.RaycastOneShot: TryHitRaycast(Mathf.Infinity, weaponTypes[weaponIdx].damage); break; } } animIdx++; Invoke("PlayShootAnimation", AnimationUpdateTick); } else { animIdx = 0; SetWeaponSprite(weaponTypes [weaponIdx].idleSprite); } }
void Start() { Sprite = GetComponent <Image>(); Debug.Assert(ImageCheck != null); Debug.Assert(Icon1 != null); Debug.Assert(Icon2 != null); Debug.Assert(Txt != null); HoverSound = SoundLoader.LoadSound("ui_menumove"); }
void Start() { RawImage image = GetComponent <RawImage>(); Debug.Assert(image != null); MapMat = image.materialForRendering; Debug.Assert(MapMat != null); CPSelectSound = SoundLoader.LoadSound("ui_menumove"); // TODO: Load texture from "MapTexture" property specified in PhxCommandpost class Texture2D cpTexture = TextureLoader.Instance.ImportUITexture("hud_flag_icon"); MapMat.SetTexture("_CPTex", cpTexture); if (SCENE.MapTexture != null) { Debug.Assert(SCENE.MapTexture.width == SCENE.MapTexture.height); MapMat.SetTexture("_MapTex", SCENE.MapTexture); } RectTransform rt = transform as RectTransform; MapMat.SetVector("_SpriteSize", new Vector4(rt.sizeDelta.x, rt.sizeDelta.y)); if (Mode == PhxUIMapMode.StaticClickable) { for (int i = 0; i < CPButtons.Length; ++i) { CPButtons[i] = Instantiate(CPButtonPrefab, transform); CPButtons[i].gameObject.SetActive(false); RectTransform t = CPButtons[i].transform as RectTransform; t.sizeDelta = new Vector2(cpTexture.width, cpTexture.height); int idx = i; Button btn = CPButtons[i].GetComponent <Button>(); btn.onClick.AddListener(() => { PhxCommandpost cp = CommandPosts[idx]; if (cp.Team == MATCH.Player.Team) { SelectCP(idx); } }); } } }
public override void Init() { Transform hpHolo = transform.Find(string.Format("{0}/hp_hologram", C.Name)); if (hpHolo != null) { GameObject holoPrefab = Resources.Load <GameObject>("cp_holo"); GameObject holo = Instantiate(holoPrefab, hpHolo); HoloRay = holo.GetComponent <LineRenderer>(); Light = holo.GetComponentInChildren <HDAdditionalLightData>(); HoloWidthStart = HoloRay.startWidth; HoloWidthEnd = HoloRay.endWidth; HoloAlpha = HoloRay.material.GetColor("_UnlitColor").a; LightIntensity = Light.intensity; } AudioAmbient = gameObject.AddComponent <AudioSource>(); AudioAmbient.spatialBlend = 1.0f; AudioAmbient.clip = SoundLoader.LoadSound("com_blg_commandpost2"); AudioAmbient.pitch = 1.0f; AudioAmbient.volume = 0.5f; AudioAmbient.rolloffMode = AudioRolloffMode.Linear; AudioAmbient.minDistance = 2.0f; AudioAmbient.maxDistance = 30.0f; AudioAmbient.Play(); AudioCapture = gameObject.AddComponent <AudioSource>(); AudioCapture.spatialBlend = 1.0f; AudioCapture.loop = true; AudioCapture.pitch = 1.0f; AudioCapture.volume = 0.8f; AudioCapture.rolloffMode = AudioRolloffMode.Linear; AudioCapture.minDistance = 2.0f; AudioCapture.maxDistance = 30.0f; AudioAction = gameObject.AddComponent <AudioSource>(); AudioAction.spatialBlend = 1.0f; AudioAction.loop = false; AudioAction.pitch = 1.1f; AudioAction.volume = 0.5f; AudioAction.rolloffMode = AudioRolloffMode.Linear; AudioAction.minDistance = 2.0f; AudioAction.maxDistance = 30.0f; }
void Start() { Debug.Assert(Left != null); Debug.Assert(Center != null); Debug.Assert(Right != null); if (!string.IsNullOrEmpty(LocalizePath)) { Text.text = ENV.GetLocalized(LocalizePath); } Left.texture = TextureLoader.Instance.ImportUITexture("bf2_buttons_botleft"); Center.texture = TextureLoader.Instance.ImportUITexture("bf2_buttons_items_center"); Right.texture = TextureLoader.Instance.ImportUITexture("bf2_buttons_botright"); HoverSound = SoundLoader.LoadSound("ui_menumove"); ClickSound = SoundLoader.LoadSound("ui_planetzoom"); }
public void TryUse() { Ray ray = new Ray(transform.position, weaponManager.transform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, 2, -1)) { PokeableLinedef lc = hit.collider.gameObject.GetComponent <PokeableLinedef> (); if (lc != null) { lc.Poke(gameObject); } else { oofAudio.PlayOneShot(SoundLoader.LoadSound("DSOOF")); } } }
// Start is called before the first frame update void Start() { Debug.Assert(TopBarLeft != null); Debug.Assert(TopBarCenter != null); Debug.Assert(TopBarRight != null); Debug.Assert(HeaderText != null); Debug.Assert(DetailBox != null); Debug.Assert(DetailText != null); TopBarLeft.texture = TextureLoader.Instance.ImportUITexture("bf2_buttons_topleft"); TopBarCenter.texture = TextureLoader.Instance.ImportUITexture("bf2_buttons_title_center"); TopBarRight.texture = TextureLoader.Instance.ImportUITexture("bf2_buttons_topright"); // kinda hacky, since Unity doesn't allow to change a sprites texture on the fly, but well... Texture2D boxTexSrc = TextureLoader.Instance.ImportUITexture("border_3_pieces"); Texture2D boxTexDst = DetailBox.sprite.texture; boxTexDst.SetPixels32(boxTexSrc.GetPixels32()); boxTexDst.Apply(); Sound = SoundLoader.LoadSound("ui_menumove"); }
private void Awake() { audioSource = GetComponent <AudioSource> (); foreach (SoundInput si in sounds) { if (soundDict.ContainsKey(si.name)) { Debug.LogError("Tried to Add Duplicate Sound ID: " + si.name); continue; } else if (si.soundIds.Length > 0) { AudioClip[] clips = new AudioClip[si.soundIds.Length]; for (int i = 0; i < si.soundIds.Length; i++) { clips[i] = SoundLoader.LoadSound(si.soundIds[i]); } soundDict.Add(si.name, clips); continue; } Debug.LogError("No IDs supplied for Sound: " + si.name); } }
// Use this for initialization void Start() { pickupClip = SoundLoader.LoadSound(pickupSound); }
public void Go() { audioSource.PlayOneShot(SoundLoader.LoadSound(audioToPlay)); }