public void StartUp() { cType=controlType; main=GetComponent<SCR_main>(); if(highlightSound){ SND_highlight=SCR_main.CreateSound(transform,highlightSound,false,false); } if(selectSound){ SND_select=SCR_main.CreateSound(transform,selectSound,false,false); } }
public static SCR_sound CreateSound(Transform parentTrans, AudioClip fxClip, bool randomPitch, bool distanceOn) { GameObject soundInst = Instantiate(soundObj, parentTrans.transform.position, parentTrans.transform.rotation) as GameObject; SCR_sound sound = soundInst.GetComponent <SCR_sound>(); sound.StartUp(fxClip, randomPitch, distanceOn); Transform soundTrans = soundInst.transform; soundTrans.parent = parentTrans; return(sound); }
public void StartUp(int _spawnSlot) { spawnSlot = _spawnSlot; transform.position += (Vector3.up * yOffset); //Mesh Setup int meshCount = 0; int lightCount = 0; for (int i = 0; i < 2; i++) { foreach (Renderer m in gameObject.GetComponentsInChildren <Renderer>()) { if (i == 1) { mesh[meshCount] = m; } meshCount++; } foreach (Light l in gameObject.GetComponentsInChildren <Light>()) { if (i == 1) { lights[lightCount] = l; } lightCount++; } if (i == 0) { mesh = new Renderer[meshCount]; if (lightCount > 0) { lights = new Light[lightCount]; } } meshCount = 0; lightCount = 0; } if (collectSound) { SND_collect = SCR_main.CreateSound(transform, collectSound, false, true); } StartFlash(); }
public static SCR_sound[] SetupSoundArray(Transform parentTrans, AudioClip[] fxClips, bool randomPitch, bool distanceOn) { SCR_sound[] SND = null; if (fxClips != null) { SND = new SCR_sound[fxClips.Length]; for (int i = 0; i < fxClips.Length; i++) { SND[i] = SCR_main.CreateSound(parentTrans, fxClips[i], randomPitch, distanceOn); } } return(SND); }
public void StartUp() { cType = controlType; main = GetComponent <SCR_main>(); if (highlightSound) { SND_highlight = SCR_main.CreateSound(transform, highlightSound, false, false); } if (selectSound) { SND_select = SCR_main.CreateSound(transform, selectSound, false, false); } }
void Awake() { int i=0; //Mesh Setup int meshCount=0; for(i=0; i<2; i++){ foreach (Renderer m in gameObject.GetComponentsInChildren<Renderer>()){ if(i==1){ mesh[meshCount]=m; } meshCount++; } if(i==0){ mesh=new Renderer[meshCount]; } meshCount=0; } //Player or Enemy if(GetComponent<SCR_characterControl>()){ gameObject.tag="Player"; isPlayer=true; cc=GetComponent<SCR_characterControl>(); SetRotAngle(transform.position+(Vector3.forward*-10f)); SetRotTarget(); } else { gameObject.tag="Enemy"; isPlayer=false; invulnerable=true; ai=GetComponent<SCR_enemyAI>(); StartFlash(1,4); float patrolMult=0.5f; runSpeedArray=new float[2]{ runSpeed, runSpeed*patrolMult }; runAnimSpeedPatrol=(animSpeed[1]*patrolMult); } //Melee or Ranged if(GetComponent<SCR_characterMelee>()){ characterMelee=GetComponent<SCR_characterMelee>(); characterMelee.StartUp(isPlayer); melee=true; } else { characterRanged=GetComponent<SCR_characterRanged>(); melee=false; } //Animation Setup int animCount=0; for(i=0; i<2; i++){ foreach (AnimationState clip in GetComponent<Animation>()) { if(i==1){ animArray[animCount]=clip.name; } animCount++; } if(i==0){ animArray=new string[animCount]; animCount=0; } } //Set the cross fade speed for each animation animBlendSpeed=new float[9]{ 0.15f, 0.15f, 0.1f, 0.15f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; //Set the speed for each animation for(i=0; i<animArray.Length; i++){ if(GetComponent<Animation>()[animArray[i]]){ GetComponent<Animation>()[animArray[i]].speed=animSpeed[i]; } } if(rollSound){ SND_roll=SCR_main.CreateSound(transform,rollSound,false,true); } if(GetComponent<BoxCollider>()){ hitBoxSize=(GetComponent<BoxCollider>().size.x*transform.localScale.x*0.5f); } transform.rotation=rotTarget; if(isPlayer){ cc.StartUp(); } else { ai.StartUp(); } }
public static SCR_sound[] SetupSoundArray(Transform parentTrans,AudioClip[] fxClips,bool randomPitch,bool distanceOn) { SCR_sound[] SND=null; if(fxClips!=null){ SND=new SCR_sound[fxClips.Length]; for(int i=0; i<fxClips.Length; i++){ SND[i]=SCR_main.CreateSound(parentTrans,fxClips[i],randomPitch,distanceOn); } } return SND; }
public static void PlayRandomSound(SCR_sound[] sound) { if(sound!=null){ int randomSound=Random.Range(0,sound.Length); sound[randomSound].PlaySound(); } }
public void StartUp(int _spawnSlot) { spawnSlot=_spawnSlot; transform.position+=(Vector3.up*yOffset); //Mesh Setup int meshCount=0; int lightCount=0; for(int i=0; i<2; i++){ foreach (Renderer m in gameObject.GetComponentsInChildren<Renderer>()){ if(i==1){ mesh[meshCount]=m; } meshCount++; } foreach (Light l in gameObject.GetComponentsInChildren<Light>()){ if(i==1){ lights[lightCount]=l; } lightCount++; } if(i==0){ mesh=new Renderer[meshCount]; if(lightCount>0){ lights=new Light[lightCount]; } } meshCount=0; lightCount=0; } if(collectSound){ SND_collect=SCR_main.CreateSound(transform,collectSound,false,true); } StartFlash(); }
void Awake() { int i = 0; //Mesh Setup int meshCount = 0; for (i = 0; i < 2; i++) { foreach (Renderer m in gameObject.GetComponentsInChildren <Renderer>()) { if (i == 1) { mesh[meshCount] = m; } meshCount++; } if (i == 0) { mesh = new Renderer[meshCount]; } meshCount = 0; } //Player or Enemy if (GetComponent <SCR_characterControl>()) { gameObject.tag = "Player"; isPlayer = true; cc = GetComponent <SCR_characterControl>(); SetRotAngle(transform.position + (Vector3.forward * -10f)); SetRotTarget(); } else { gameObject.tag = "Enemy"; isPlayer = false; invulnerable = true; ai = GetComponent <SCR_enemyAI>(); StartFlash(1, 4); float patrolMult = 0.5f; runSpeedArray = new float[2] { runSpeed, runSpeed *patrolMult }; runAnimSpeedPatrol = (animSpeed[1] * patrolMult); } //Melee or Ranged if (GetComponent <SCR_characterMelee>()) { characterMelee = GetComponent <SCR_characterMelee>(); characterMelee.StartUp(isPlayer); melee = true; } else { characterRanged = GetComponent <SCR_characterRanged>(); melee = false; } //Animation Setup int animCount = 0; for (i = 0; i < 2; i++) { foreach (AnimationState clip in GetComponent <Animation>()) { if (i == 1) { animArray[animCount] = clip.name; } animCount++; } if (i == 0) { animArray = new string[animCount]; animCount = 0; } } //Set the cross fade speed for each animation animBlendSpeed = new float[9] { 0.15f, 0.15f, 0.1f, 0.15f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; //Set the speed for each animation for (i = 0; i < animArray.Length; i++) { if (GetComponent <Animation>()[animArray[i]]) { GetComponent <Animation>()[animArray[i]].speed = animSpeed[i]; } } if (rollSound) { SND_roll = SCR_main.CreateSound(transform, rollSound, false, true); } if (GetComponent <BoxCollider>()) { hitBoxSize = (GetComponent <BoxCollider>().size.x *transform.localScale.x *0.5f); } transform.rotation = rotTarget; if (isPlayer) { cc.StartUp(); } else { ai.StartUp(); } }