private void propSetup() { GameObject prop = gt.props[_propsPtr].prop; if (!prop.active) { prop.SetActive(true); } //audio setup// AudioSource __as = prop.GetComponent <AudioSource>(); __as.loop = true; __as.Play(); //attach destroy script to delete the object. int time = gt.props[_propsPtr].time; DestroyScript ds = prop.AddComponent <DestroyScript>(); ds.setInactivateFlag(); ds.setTime(time); //next prop. _propsPtr++; }
//void changeWeapon() //{ // inventory //} //helper functions. Strictly for shoot// void placeBullet(Vector3 pos) { //bullet// GameObject b = Instantiate(bullet); b.transform.position = pos; DestroyScript ds = b.AddComponent <DestroyScript>(); ds.setTime(5); //bullet// }
//plays an audio clip based on the options mentioned.// void playAudio(string name, string option) { //name and option verification.// name = name.Replace("\"", ""); int index = -1; for (int i = 0; i < Data.data.sounds.Length; i++) { if (Data.data.sounds[i].rcname == name) { index = i; break; } } if (index < 0) { UnityEngine.Debug.Log(name + " audio clip not found!!!"); return; } if (option != "once" && option != "repeat") { UnityEngine.Debug.Log("invalid option " + option + "!!!"); return; } //creating a gameobject to play audio and destroying after finished playing.// UnityEngine.GameObject audio = new UnityEngine.GameObject("audio player"); UnityEngine.AudioSource src = audio.AddComponent <UnityEngine.AudioSource>(); if (option == "once") { src.PlayOneShot(Data.data.sounds[index].clip); DestroyScript ds = audio.AddComponent <DestroyScript>(); ds.setTime(Data.data.sounds[index].clip.length + 5); } else { src.clip = Data.data.sounds[index].clip; src.Play(); src.loop = true; } }
private void Start() { _parameters = GetComponent <Parameters>(); _demolish = GetComponent <DestroyScript>(); }
void Start() { _destroyable = GetComponent <DestroyScript>(); _targetTagsComponent = GetComponent <TagListComponent>(); }