Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Fx manager.
- /// David Oneill
- /// 11/5/2014
- /// this is the effects managementclass, holding rpc functions to broadcast to other players,
- /// syncing sounds and effects over the network! These are called by weaponBehaviour.cs +Audio classes.
- /// </summary>
- using UnityEngine;
- using System.Collections;
- public class FxManager : MonoBehaviour {
- //public AudioClip audioClipToPlay = null;
- public AudioClip AK47fireSnd;
- public AudioClip AK47reloadSnd;
- //public AudioClip AK47reloadLastSnd;//usually shell reload sound + shotgun pump or rifle chambering sound
- //public AudioClip AK47noammoSnd;
- public AudioClip AK47readySnd;
- public AudioClip ShotGunfireSnd;
- public AudioClip ShotGunreloadSnd;
- public AudioClip ShotGunreadySnd;
- public AudioClip M1911fireSnd;
- public AudioClip M1911reloadSnd;
- public AudioClip M1911readySnd;
- public AudioClip Mp5fireSnd;
- public AudioClip Mp5reloadSnd;
- public AudioClip Mp5readySnd;
- public AudioClip SniperfireSnd;
- public AudioClip SniperreloadSnd;
- public AudioClip SniperreadySnd;
- public AudioClip KatanaSnd;
- //public AudioClip SniperreloadSnd;
- public AudioClip KatanareadySnd;
- public GameObject[] dirtMarks;
- public GameObject[] metalMarks;
- public GameObject[] woodMarks;
- public GameObject[] glassMarks;
- public GameObject[] fleshMarks;
- public GameObject[] dirtMarksMelee;
- public GameObject[] metalMarksMelee;
- public GameObject[] woodMarksMelee;
- private GameObject markObj;
- public GameObject bulletTrail;
- //FootSteps
- public float dirtStepVol = 1.0f;
- public AudioClip[] dirtSteps;
- public float woodStepVol = 1.0f;
- public AudioClip[] woodSteps;
- public float metalStepVol = 1.0f;
- public AudioClip[] metalSteps;
- public float waterSoundVol = 1.0f;
- public AudioClip[] waterSounds;
- public float climbSoundVol = 1.0f;
- public AudioClip[] climbSounds;
- //landing
- public AudioClip dirtLand;
- public AudioClip metalLand;
- public AudioClip woodLand;
- public AudioClip waterLand;
- //Privates for audio
- private AudioClip footStepClip;//Footstep audio clip to be played
- private float volumeAmt = 1.0f;//volume of audio clip to be played
- [RPC]
- void BulletTrailFX(Vector3 startPos, Vector3 endPos)
- {
- GameObject bulletTrailFx = (GameObject)Instantiate(bulletTrail, startPos,Quaternion.LookRotation(startPos - endPos));
- LineRenderer lineR = bulletTrailFx.transform.Find("LineFX").GetComponent<LineRenderer>();
- lineR.SetPosition(0,startPos);
- lineR.SetPosition(1,endPos);
- // Debug.Log ("FX Call!");
- }
- [RPC]
- void ReloadAudioFX(string name,Vector3 playPoint)
- {
- switch(name){
- case "AK47":
- AudioSource.PlayClipAtPoint(AK47reloadSnd,playPoint);
- break;
- case "Katana":
- break;
- case "M1911":
- AudioSource.PlayClipAtPoint(M1911reloadSnd,playPoint);
- break;
- case "MP5":
- AudioSource.PlayClipAtPoint(Mp5reloadSnd,playPoint);
- break;
- case "Shotgun":
- AudioSource.PlayClipAtPoint(ShotGunreloadSnd,playPoint);
- break;
- case "Sniper":
- AudioSource.PlayClipAtPoint(SniperreloadSnd,playPoint);
- break;
- default:
- break;
- }
- }
- [RPC]
- void ReadyAudioFX(string name,Vector3 playPoint)
- {
- switch(name){
- case "AK47":
- AudioSource.PlayClipAtPoint(AK47readySnd,playPoint);
- break;
- case "Katana":
- AudioSource.PlayClipAtPoint(KatanareadySnd,playPoint);
- break;
- case "M1911":
- AudioSource.PlayClipAtPoint(M1911readySnd,playPoint);
- break;
- case "MP5":
- AudioSource.PlayClipAtPoint(Mp5readySnd,playPoint);
- break;
- case "Shotgun":
- AudioSource.PlayClipAtPoint(ShotGunreadySnd,playPoint);
- break;
- case "Sniper":
- AudioSource.PlayClipAtPoint(SniperreadySnd,playPoint);
- break;
- default:
- break;
- }
- }
- [RPC]
- void FireAudioFX(string name,Vector3 playPoint)
- {
- switch(name){
- case "AK47":
- AudioSource.PlayClipAtPoint(AK47fireSnd,playPoint);
- break;
- case "Katana":
- AudioSource.PlayClipAtPoint(KatanaSnd,playPoint);
- break;
- case "M1911":
- AudioSource.PlayClipAtPoint(M1911fireSnd,playPoint);
- break;
- case "MP5":
- AudioSource.PlayClipAtPoint(Mp5fireSnd,playPoint);
- break;
- case "Shotgun":
- AudioSource.PlayClipAtPoint(ShotGunfireSnd,playPoint);
- break;
- case "Sniper":
- AudioSource.PlayClipAtPoint(SniperfireSnd,playPoint);
- break;
- default:
- break;
- }
- }
- [RPC]//Come back to this
- void BulletMarkFX (bool ranged,string tag,Vector3 hitpoint, Quaternion hitNormal){
- if(ranged == true){//not a melee weapon
- //find the tag name of the hit game object and select an impact mark for the surface type
- switch(tag){
- case "Dirt":
- markObj = dirtMarks[Random.Range(0, dirtMarks.Length)];
- // Debug.Log ("This is shit");
- break;
- case "Metal":
- markObj = metalMarks[Random.Range(0, metalMarks.Length)];
- break;
- case "Wood":
- markObj = woodMarks[Random.Range(0, woodMarks.Length)];
- break;
- case "Glass":
- markObj = glassMarks[Random.Range(0, glassMarks.Length)];
- break;
- case "Flesh":
- markObj = fleshMarks[Random.Range(0, fleshMarks.Length)];
- break;
- default:
- markObj = dirtMarks[Random.Range(0, dirtMarks.Length)];
- break;
- }
- }else{
- switch(tag){//select a melee weapon impact mark
- case "Dirt":
- markObj = dirtMarksMelee[Random.Range(0, dirtMarksMelee.Length)];
- break;
- case "Metal":
- markObj = metalMarksMelee[Random.Range(0, metalMarksMelee.Length)];
- break;
- case "Wood":
- markObj = woodMarksMelee[Random.Range(0, woodMarksMelee.Length)];
- break;
- case "Glass":
- markObj = glassMarks[Random.Range(0, glassMarks.Length)];
- break;
- case "Flesh":
- markObj = fleshMarks[Random.Range(0, fleshMarks.Length)];
- break;
- default:
- markObj = dirtMarksMelee[Random.Range(0, dirtMarksMelee.Length)];
- break;
- }
- }
- //markObj = dirtMarks[Random.Range(0, dirtMarks.Length)];
- Instantiate(markObj, hitpoint, hitNormal );// Quaternion.identity);
- //AudioSource a = markObj.transform.GetComponentInChildren<AudioSource>();
- //a.pitch = Random.Range(0.96f * Time.timeScale, 1.0f * Time.timeScale);
- //markObj.transform.parent = (GameObject)hitpoint;
- //Debug.Log (tag);
- //Debug.Log (hitpoint);
- }
- //FootStep sounds!- look at changing the volume of the footsteps based on running/sneaking.
- [RPC]
- void FootStepAudio(string materialType,Vector3 playPoint)
- {
- switch(materialType){//determine which material the player is standing on and select random footstep effect for surface type
- case "Wood":
- footStepClip = woodSteps[Random.Range(0, woodSteps.Length)];
- volumeAmt = woodStepVol;
- AudioSource.PlayClipAtPoint(footStepClip,playPoint,volumeAmt);
- break;
- case "Metal":
- footStepClip = metalSteps[Random.Range(0, metalSteps.Length)];
- volumeAmt = metalStepVol;
- AudioSource.PlayClipAtPoint(footStepClip,playPoint,volumeAmt);
- break;
- case "Dirt":
- footStepClip = dirtSteps[Random.Range(0, dirtSteps.Length)];
- volumeAmt = dirtStepVol;
- AudioSource.PlayClipAtPoint(footStepClip,playPoint,volumeAmt);
- break;
- default:
- footStepClip = dirtSteps[Random.Range(0, dirtSteps.Length)];
- volumeAmt = dirtStepVol;
- AudioSource.PlayClipAtPoint(footStepClip,playPoint,volumeAmt);
- break;
- }
- }//End of FootStep
- [RPC]
- void WaterAudio(Vector3 playPoint)
- {
- footStepClip = waterSounds[Random.Range(0, waterSounds.Length)];//select random water step effect from waterSounds array
- volumeAmt = waterSoundVol;//set volume of audio clip to customized amount
- AudioSource.PlayClipAtPoint(footStepClip, playPoint, volumeAmt);
- }
- [RPC]
- void ClimbAudio(Vector3 playPoint)
- {
- footStepClip = climbSounds[Random.Range(0, climbSounds.Length)];
- volumeAmt = climbSoundVol;
- AudioSource.PlayClipAtPoint(footStepClip, playPoint, volumeAmt);
- }
- [RPC]
- void LandAudio(string tag,Vector3 playPoint)
- {
- //Debug.Log ("LandAudio");
- switch(tag){
- case "Water":
- //volumeAmt = waterSoundVol * 2;
- AudioSource.PlayClipAtPoint(waterLand,playPoint,volumeAmt);
- break;
- case "Dirt":
- //volumeAmt = dirtStepVol * 2;
- AudioSource.PlayClipAtPoint(dirtLand,playPoint,volumeAmt);
- break;
- case "Wood":
- //volumeAmt = woodStepVol * 2;
- AudioSource.PlayClipAtPoint(woodLand,playPoint,volumeAmt);
- break;
- case "Metal":
- //volumeAmt = metalStepVol * 1.5f;
- AudioSource.PlayClipAtPoint(metalLand,playPoint,volumeAmt);
- break;
- default:
- //volumeAmt = dirtStepVol * 2;
- AudioSource.PlayClipAtPoint(dirtLand,playPoint,volumeAmt);
- break;
- }
- }
- }//End#######################################################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement