Patient PatientIsDead(Patient p) { p.inTreatment = false; BedController.Instance.WheelBedOutOfBerth(p.bed); GameController.Instance.lives [GameController.Instance.patientsDied].SetActive(false); GameController.Instance.patientsDied++; GameObject bedGo = BedController.Instance.bedToGameObjectMap [p.bed]; BedHud hud = bedGo.GetComponent <BedHud> (); hud.nameText.text = hud.nameText.text + " (RIP)"; if (p.isMale) { hud.boy.transform.DOLocalMove(new Vector3(hud.boy.transform.position.x, 10f, hud.boy.transform.position.z), 1f); } else { hud.girl.transform.DOLocalMove(new Vector3(hud.girl.transform.position.x, 10f, hud.girl.transform.position.z), 1f); } InAudio.Play(this.gameObject, SoundController.Instance.dead); if (GameController.Instance.patientsDied == 3) { GameController.Instance.GameOver(); } return(p); }
void ThirdClick() { Debug.Log(pgaBarLeft.sizeDelta.x); if (pgaBarLeft.sizeDelta.x < 50f) { if (pgaBarLeft.sizeDelta.x > 0f) { injectionQuality = (50f - pgaBarLeft.sizeDelta.x) / 50f; } else { injectionQuality = (50f - pgaBarRight.sizeDelta.x) / 50f; } InAudio.Play(this.gameObject, SoundController.Instance.bop3); // Debug.Log ("Second Click"); clicks = 3; AdministerDrugs(); clicks = 0; if (medHeld == "Defib") { InAudio.Play(this.gameObject, SoundController.Instance.doof); } } }
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { Debug.Log("Exit " + Name); canSetVolume = false; var go = animator.gameObject; InAudio.PostEvent(go, OnExitState.ToPost); int toPlayCount = OnExitState.ToPlay.Count; var toPlay = OnExitState.ToPlay; for (int i = 0; i < toPlayCount; i++) { InAudio.Play(go, toPlay[i]); } int toStopCount = OnExitState.ToStop.Count; var toStop = OnExitState.ToStop; for (int i = 0; i < toStopCount; i++) { InAudio.Stop(go, toStop[i]); } //Set Values to Max }
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { var go = animator.gameObject; int count = Parameters.ParameterList.Count; for (int i = 0; i < count; i++) { var elem = Parameters.ParameterList[i]; elem.StartVolume = InAudio._getEventWorker().GetMinVolume(go, elem.Node); //Debug.Log("Enter " + name + " " + elem.StartVolume); } canSetVolume = true; Debug.Log("Enter " + Name); InAudio.PostEvent(go, OnEnterState.ToPost); int toPlayCount = OnEnterState.ToPlay.Count; var toPlay = OnEnterState.ToPlay; for (int i = 0; i < toPlayCount; i++) { //Debug.Log("Play" + toPlay[i].Name); InAudio.Play(go, toPlay[i]); } int toStopCount = OnEnterState.ToStop.Count; var toStop = OnEnterState.ToStop; for (int i = 0; i < toStopCount; i++) { InAudio.Stop(go, toStop[i]); } }
Medication DecideWhetherBloodLoss(Patient p) { float bloodAmt = (float)UnityEngine.Random.Range(20, 50); Medication blood = new Medication("Blood", bloodAmt, UnityEngine.Random.Range(6f, 18f), 5f, UnityEngine.Random.Range(1, 3)); blood.currentLevel = UnityEngine.Random.Range(blood.dose * 0.4f, blood.dose); if (totalPatients > 2 && UnityEngine.Random.Range(0, 8) == 2) { GameObject bedGo = BedController.Instance.bedToGameObjectMap [p.bed]; BedHud hud = bedGo.GetComponent <BedHud> (); hud.successText.gameObject.SetActive(true); hud.successText.text = "Administer " + bloodAmt.ToString() + " units!"; hud.bloodText.transform.parent.transform.gameObject.SetActive(true); hud.bloodText.text = bloodAmt.ToString(); InAudio.Play(this.gameObject, SoundController.Instance.alarm); } else { blood.dose = 0f; blood.currentLevel = 0f; blood.dosesUntilCured = 0; } return(blood); }
Patient TriggerBloodLoss(Patient p) { Debug.Log("Blood loss!!"); GameObject bedGo = BedController.Instance.bedToGameObjectMap[p.bed]; BedHud hud = bedGo.GetComponent <BedHud> (); Medication m = p.currentPrescriptions ["Blood"]; m.dose = (float)UnityEngine.Random.Range(20, 50); m.currentLevel = UnityEngine.Random.Range(m.dose * 0.4f, m.dose); m.dosesUntilCured = Random.Range(1, 3); m.dosesAdministered = 0; m.effectLength = UnityEngine.Random.Range(10f, 20f); hud.successText.gameObject.SetActive(true); hud.successText.text = "Administer " + m.dose.ToString() + " units!"; InAudio.Play(this.gameObject, SoundController.Instance.alarm); hud.bloodText.transform.parent.transform.gameObject.SetActive(true); hud.bloodText.text = m.dose.ToString(); return(p); }
public void Complain() { if (complainTimer > 2f) { InAudio.Play(Camera.main.gameObject, complaints); complainTimer = 0f; } }
public void WheelBedIn(Bed b) { InAudio.Play(this.gameObject, SoundController.Instance.wheelSound); GameObject go = bedToGameObjectMap [b]; float time = 0.5f + (b.berth.column * 0.35f); go.transform.DOMove(new Vector3(b.berth.berthPosition.x - 2.5f, go.transform.position.y, 0f), time) .SetEase(Ease.Linear) .OnComplete(() => WheelToBerth(b, go)); }
void Update() { if (GameInput.AllowInput) { if (isGrounded && Input.GetButtonDown("A_" + playerPostFix)) { isGrounded = false; InAudio.Play(gameObject, jumpSound); rigidbody.AddForce(surfaceUp * Jump, ForceMode.Impulse); } } }
void FirstClick() { Bed b = BedController.Instance.gameObjectToBedMap [bedNurseNextTo]; if (b.treatmentDelay <= 0f) { InAudio.Play(this.gameObject, SoundController.Instance.bop1); isAdministeringTreatment = true; fillSpeed = UnityEngine.Random.Range(1.15f * NurseStressFactor, 1.85f * NurseStressFactor); clicks = 1; // Debug.Log ("Start Bar"); } }
public void OnPointerEnter(PointerEventData eventData) { if (enabled) { if (ActivateOnMouseOver != null) { InAudio.PostEvent(gameObject, ActivateOnMouseOver); } if (playNodeWhileMouseOver != null) { InAudio.Play(gameObject, playNodeWhileMouseOver); } } }
void SecondClick() { InAudio.Play(this.gameObject, SoundController.Instance.bop2); percentageAdministered = pgaBarLeft.sizeDelta.x / 297f; Debug.Log("First Click" + percentageAdministered + pgaBarLeft.sizeDelta.x); clicks = 2; pgaClickMark.gameObject.SetActive(true); pgaClickMark.anchoredPosition = new Vector2(250.9f - pgaBarLeft.sizeDelta.x, -12f); if (medHeld == "Defib") { InAudio.Play(this.gameObject, SoundController.Instance.clear); } }
public void GivePlayerScore(PlayerController controller, int score) { Services.Get <CameraShake>().ApplyShake(0.2f, 0.2f); if (controller == null) { Debug.LogError("Dont try and give null controllers a score"); } var item = Score.Find(s => s.Item1.Id == controller.Id); if (item == null) { item = Score.Add(controller, score); InAudio.Play(gameObject, Point); } else { if (item.Item2 < ScoreLimit) { InAudio.Play(gameObject, Point); } item.Item2 += score; } var scoreUI = FindObjectOfType <PlayerScoreUI>(); if (scoreUI) { scoreUI.GivePoints(controller, item.Item2); } if (item.Item2 > ScoreLimit && !WinnerFound) { WinnerFound = true; InAudio.StopAll(); //WinnerColor = PlayerColor(controller.Id); var hook = Services.Get <WinnerHook>().gameObject; hook.SetActive(true); for (int i = 0; i < hook.transform.childCount; i++) { hook.transform.GetChild(i).gameObject.SetActive(true); } hook.GetComponentInParent <Animator>().enabled = true; StartCoroutine(PlayWin()); } }
Patient CheckWhetherFullyRecovered(Patient p, bool stillRequiringTreatment) { if (stillRequiringTreatment == false && p.pulseRate > 0f) { Debug.Log("Patient all better!"); p.inTreatment = false; BedController.Instance.WheelBedOutOfBerth(p.bed); GameController.Instance.UpdateScore(scoreForCuringPatient); GameController.Instance.patientsCured++; GameController.Instance.curedText.text = "Cured: " + GameController.Instance.patientsCured.ToString(); InAudio.Play(this.gameObject, SoundController.Instance.bye); } return(p); }
public void OnCollisionStay(Collision collision) { name = collision.collider.gameObject.name; if (name == "Pain" || name == "Infection" || name == "Blood" || name == "Defib") { if (name != medicationName) { medicationName = name; sphere.material = sphereMaterials [materialLookup [name]]; InAudio.Play(this.gameObject, SoundController.Instance.collect); } } //if (collision.collider.gameObject.name == }
Patient CheckWhetherCausedBloodLoss(Patient p, Medication m, float injectionQuality) { if (injectionQuality < 0.5f && m.name != "Blood" && m.name != "Defib") { InAudio.Play(this.gameObject, SoundController.Instance.ouch); float chanceOfLoss = Mathf.Pow(10f - (injectionQuality * 10f), 4f); float choose = Random.Range(0f, 25000f); if (choose < chanceOfLoss) { p = TriggerBloodLoss(p); } } return(p); }
void CardiacArrest(Patient p) { Debug.Log("Cardiac arrest!!!"); GameObject bedGo = BedController.Instance.bedToGameObjectMap[p.bed]; BedHud hud = bedGo.GetComponent <BedHud> (); p.pulseRate = 0f; Medication defib = new Medication("Defib", (float)Random.Range(50, 200), 1f, 1f, 1); defib.currentLevel = defib.dose; p.prescriptions.Add(defib); hud.successText.gameObject.SetActive(true); hud.successText.text = "Shock with " + defib.dose.ToString() + " joules!"; InAudio.Play(this.gameObject, SoundController.Instance.beep); }
bool CheckWhetherMedicationFailed(Patient p, Medication m, float injectionQuality) { bool failed = false; if (injectionQuality < 0.5f && (m.name == "Blood" || m.name == "Defib")) { InAudio.Play(this.gameObject, SoundController.Instance.ouch); float chanceOfLoss = Mathf.Pow(10f - (injectionQuality * 10f), 4f); float choose = Random.Range(0f, 25000f); if (choose < chanceOfLoss) { failed = true; } } return(failed); }
public async void PlaySound(string name, int delay = 0, float volume = 1f) { if (Sounds.ContainsKey(name)) { InAudio.SetVolumeForAudioFolder(Sounds [name], volume); await Task.Delay(delay); if (volume < 1f) { InAudio.Play(Camera.main.gameObject, Sounds [name], new AudioParameters(volume, Random.Range(0.8f, 1.1f), 0, 1)); } else { InAudio.Play(Camera.main.gameObject, Sounds [name]); } } }
public void WheelBedOutOfBerth(Bed b) { InAudio.Play(this.gameObject, SoundController.Instance.wheelSound); GameObject go = bedToGameObjectMap [b]; float time = 0.5f; go.transform.DOMove(new Vector3(b.berth.berthPosition.x + 2.5f, go.transform.position.y, 0f), time) .SetEase(Ease.Linear) .OnComplete(() => WheelBedOut(b, go)); float targetRotation = -90f; if (b.berth.berthPosition.y < 0f) { targetRotation = 270f; } go.transform.DORotate(new Vector3(0f, targetRotation, 0f), time); }
public override void OnStateMachineExit(Animator animator, int stateMachinePathHash) { var go = animator.gameObject; InAudio.PostEvent(go, OnExitMachine.ToPost); int toPlayCount = OnExitMachine.ToPlay.Count; var toPlay = OnExitMachine.ToPlay; for (int i = 0; i < toPlayCount; i++) { InAudio.Play(go, toPlay[i]); } int toStopCount = OnExitMachine.ToPlay.Count; var toStop = OnExitMachine.ToStop; for (int i = 0; i < toStopCount; i++) { InAudio.Stop(go, toStop[i]); } }
public void Start() { medTypes = new Dictionary <string, string> (); medDesc = new Dictionary <string, string> (); medMax = new Dictionary <string, float> (); restrictLookup = new Dictionary <int, string> (); restrictLookup.Add(0, "Pain"); restrictLookup.Add(1, "Infection"); InAudio.Play(this.gameObject, music); medTypes.Add("Pain", "ml"); medTypes.Add("Infection", "ml"); medTypes.Add("Blood", "units"); medTypes.Add("Defib", "joules"); medDesc.Add("Pain", "Pain Meds"); medDesc.Add("Infection", "Antibiotics"); medDesc.Add("Blood", "Transfusion"); medDesc.Add("Defib", "Shock"); medMax.Add("Pain", 10f); medMax.Add("Infection", 15f); medMax.Add("Blood", 50f); medMax.Add("Defib", 200f); menu.SetActive(true); if (!PlayerPrefs.HasKey("High")) { PlayerPrefs.SetInt("High", 0); } high = PlayerPrefs.GetInt("High"); highText.text = "High: " + high; //Invoke ("GameOver", 5f); }
void TriggerCardiacArrest(Patient p) { Debug.Log("Cardiac arrest!!"); GameObject bedGo = BedController.Instance.bedToGameObjectMap[p.bed]; BedHud hud = bedGo.GetComponent <BedHud> (); Medication m = p.currentPrescriptions ["Defib"]; m.dose = (float)UnityEngine.Random.Range(50, 200); m.currentLevel = m.dose; m.dosesUntilCured = 1; m.dosesAdministered = 0; m.effectLength = 50f; p.pulseRate = 0f; hud.successText.gameObject.SetActive(true); hud.successText.text = "Shock with " + m.dose.ToString() + " joules!"; hud.defibText.text = m.dose.ToString(); hud.defibText.transform.parent.transform.gameObject.SetActive(true); InAudio.Play(this.gameObject, SoundController.Instance.beep); }
public override void OnStateMachineEnter(Animator animator, int stateMachinePathHash) { canSetVolume = false; Debug.Log("Enter Machine"); var go = animator.gameObject; InAudio.PostEvent(go, OnEnterMachine.ToPost); int toPlayCount = OnEnterMachine.ToPlay.Count; var toPlay = OnEnterMachine.ToPlay; for (int i = 0; i < toPlayCount; i++) { InAudio.Play(go, toPlay[i]); } int toStopCount = OnEnterMachine.ToPlay.Count; var toStop = OnEnterMachine.ToStop; for (int i = 0; i < toStopCount; i++) { InAudio.Stop(go, toStop[i]); } }
void CheckPgaBar() { if (isAdministeringTreatment) { if (clicks == 1) { pgaBarLeft.sizeDelta = new Vector2( pgaBarLeft.sizeDelta.x + 297f / fillSpeed * Time.deltaTime, pgaBarLeft.sizeDelta.y); if (pgaBarLeft.sizeDelta.x >= 325f) { pgaBarLeft.sizeDelta = new Vector2( 325f, pgaBarLeft.sizeDelta.y); percentageAdministered = 325f / 297f; clicks = 2; InAudio.Play(this.gameObject, SoundController.Instance.bop2); if (medHeld == "Defib") { InAudio.Play(this.gameObject, SoundController.Instance.clear); } } } if (clicks == 2) { pgaBarLeft.sizeDelta = new Vector2( pgaBarLeft.sizeDelta.x - 297f / fillSpeed * Time.deltaTime, pgaBarLeft.sizeDelta.y); if (pgaBarLeft.sizeDelta.x <= 0f) { pgaBarLeft.sizeDelta = new Vector2(0f, pgaBarLeft.sizeDelta.y); clicks = 99; } } if (clicks == 99) { pgaBarRight.sizeDelta = new Vector2( pgaBarRight.sizeDelta.x + 297 / fillSpeed * Time.deltaTime, pgaBarRight.sizeDelta.y); if (pgaBarRight.sizeDelta.x >= 28f) { pgaBarRight.sizeDelta = new Vector2( 28f, pgaBarRight.sizeDelta.y); injectionQuality = 0f; clicks = 3; InAudio.Play(this.gameObject, SoundController.Instance.bop3); AdministerDrugs(); clicks = 0; if (medHeld == "Doof") { InAudio.Play(this.gameObject, SoundController.Instance.clear); } } } } }
List <Medication> GetPrescription(Patient p) { List <Medication> prescription = new List <Medication> (); float painAmt = (float)UnityEngine.Random.Range(20, 101) / 10f; float infAmt = (float)UnityEngine.Random.Range(25, 151) / 10f; Medication pain = new Medication("Pain", painAmt, UnityEngine.Random.Range(10f, 30f), 5f, UnityEngine.Random.Range(1, 5)); Medication infection = new Medication("Infection", infAmt, UnityEngine.Random.Range(10f, 30f), 5f, UnityEngine.Random.Range(1, 5)); prescription.Add(pain); prescription.Add(infection); pain.currentLevel = UnityEngine.Random.Range(pain.dose * 0.5f, pain.dose); infection.currentLevel = UnityEngine.Random.Range(infection.dose * 0.5f, infection.dose); if (totalPatients == 1) { pain.currentLevel = pain.dose; infection.currentLevel = infection.dose; pain.dosesUntilCured = 1; infection.dosesUntilCured = 1; } ShuffleList(prescription); //float bloodAmt2 = (float)UnityEngine.Random.Range (20, 50); //Medication blood2 = new Medication ("Blood", bloodAmt2, UnityEngine.Random.Range (10f, 30f), 5f, UnityEngine.Random.Range (1, 2)); //blood2.currentLevel = UnityEngine.Random.Range (blood2.dose * 0.5f, blood2.dose); // rescription.Add (blood2); if (totalPatients < 4) { prescription [0].dose = 0f; } else { if (UnityEngine.Random.Range(0, 2) == 0) { prescription [UnityEngine.Random.Range(0, 2)].dose = 0f; } if (UnityEngine.Random.Range(0, 8) == 2) { GameObject bedGo = BedController.Instance.bedToGameObjectMap[p.bed]; BedHud hud = bedGo.GetComponent <BedHud> (); float bloodAmt = (float)UnityEngine.Random.Range(20, 50); Medication blood = new Medication("Blood", bloodAmt, UnityEngine.Random.Range(10f, 30f), 5f, UnityEngine.Random.Range(1, 2)); blood.currentLevel = UnityEngine.Random.Range(blood.dose * 0.5f, blood.dose); prescription.Add(blood); hud.successText.gameObject.SetActive(true); hud.successText.text = "Administer " + bloodAmt.ToString() + " units!"; InAudio.Play(this.gameObject, SoundController.Instance.alarm); } } return(prescription); }
//private static GameObject go; public static void Draw(InAudioNode node) { if (Application.isPlaying) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Play Node")) { if (preview != null) { preview.Stop(); } preview = InAudio.Play(InAudioInstanceFinder.Instance.gameObject, node); preview.SpatialBlend = 0.0f; preview.OnCompleted = (go, audioNode) => preview = null; } if (GUILayout.Button("Stop Playing Node") && preview != null) { InAudio.StopAll(InAudioInstanceFinder.Instance.gameObject); } if (GUILayout.Button("Stop All Instances")) { InAudio.StopAllOfNode(node); } EditorGUILayout.EndHorizontal(); } InAudioNodeData baseData = (InAudioNodeData)node._nodeData; EditorGUILayout.Separator(); DrawSelectedArea(node, baseData); Seperators(2); if (baseData.SelectedArea == 0) { EditorGUIHelper.DrawID(node._guid); #region Volume DataDrawerHelper.DrawVolume(baseData, ref baseData.MinVolume, ref baseData.MaxVolume, ref baseData.RandomVolume); #endregion Seperators(2); #region Parent pitch SetPitch(baseData); #endregion Seperators(2); #region Spatial blend SetSpatialBlend(baseData); #endregion Seperators(2); #region Delay GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); InUndoHelper.GUIUndo(baseData, "Randomize Delay", ref baseData.RandomizeDelay, () => EditorGUILayout.Toggle("Randomize Delay", baseData.RandomizeDelay)); if (baseData.RandomizeDelay) { InUndoHelper.GUIUndo(baseData, "Delay Change", ref baseData.InitialDelayMin, ref baseData.InitialDelayMax, (out float v1, out float v2) => { v1 = Mathf.Clamp(EditorGUILayout.FloatField("Min delay", baseData.InitialDelayMin), 0, baseData.InitialDelayMax); v2 = Mathf.Clamp(EditorGUILayout.FloatField("Max delay", baseData.InitialDelayMax), baseData.InitialDelayMin, float.MaxValue); }); } else { InUndoHelper.GUIUndo(baseData, "Delay", ref baseData.InitialDelayMin, () => { float delay = Mathf.Max(EditorGUILayout.FloatField("Initial delay", baseData.InitialDelayMin), 0); if (delay > baseData.InitialDelayMax) { baseData.InitialDelayMax = baseData.InitialDelayMin + 0.001f; } return(delay); }); } GUILayout.EndVertical(); GUILayout.BeginVertical(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Seperators(2); #region Audio bus DataDrawerHelper.DrawMixer(node); #endregion Seperators(2); #region Loops GUI.enabled = true; GUILayout.BeginVertical(); InUndoHelper.GUIUndo(baseData, "Use looping", ref baseData.Loop, () => EditorGUILayout.Toggle("Loop", baseData.Loop)); if (baseData.Loop) { GUI.enabled = baseData.Loop; InUndoHelper.GUIUndo(baseData, "Loop Infinite", ref baseData.LoopInfinite, () => EditorGUILayout.Toggle("Loop Infinite", baseData.LoopInfinite)); if (baseData.Loop) { GUI.enabled = !baseData.LoopInfinite; } InUndoHelper.GUIUndo(baseData, "Loop Randomize", ref baseData.RandomizeLoops, () => EditorGUILayout.Toggle("Randomize Loop Count", baseData.RandomizeLoops)); if (!baseData.RandomizeLoops) { InUndoHelper.GUIUndo(baseData, "Loop Count", ref baseData.MinIterations, () => (byte)Mathf.Clamp(EditorGUILayout.IntField("Loop Count", baseData.MinIterations), 0, 255)); } else { GUILayout.BeginHorizontal(); InUndoHelper.GUIUndo(baseData, "Loop Count", ref baseData.MinIterations, ref baseData.MaxIterations, (out byte v1, out byte v2) => { v1 = (byte)Mathf.Clamp(EditorGUILayout.IntField("Min Loop Count", baseData.MinIterations), 0, 255); v2 = (byte)Mathf.Clamp(EditorGUILayout.IntField("Max Loop Count", baseData.MaxIterations), 0, 255); //Clamp to 0-255 and so that min/max doesn't overlap v2 = (byte)Mathf.Clamp(v2, v1, 255); v1 = (byte)Mathf.Clamp(v1, 0, v2); }); GUILayout.EndHorizontal(); } } GUI.enabled = true; GUILayout.EndVertical(); #endregion Seperators(2); #region Instance limiting InUndoHelper.GUIUndo(baseData, "Limit Instances (Global)", ref baseData.LimitInstances, () => EditorGUILayout.Toggle("Limit Instances", baseData.LimitInstances)); GUI.enabled = baseData.LimitInstances; if (baseData.LimitInstances) { InUndoHelper.GUIUndo(baseData, "Max Instance Cont", ref baseData.MaxInstances, () => Math.Max(EditorGUILayout.IntField("Max Instance Count", baseData.MaxInstances), 0)); InUndoHelper.GUIUndo(baseData, "Stealing Type", ref baseData.InstanceStealingTypes, () => (InstanceStealingTypes)EditorGUILayout.EnumPopup("Stealing Type", baseData.InstanceStealingTypes)); } GUI.enabled = true; #endregion Seperators(2); #region Priority InUndoHelper.GUIUndo(baseData, "Priority", ref baseData.Priority, () => EditorGUILayout.IntSlider("Priority", baseData.Priority, 0, 255)); #endregion Seperators(2); #region Sample offset InUndoHelper.GUIUndo(baseData, "Random Second Offset", ref baseData.RandomSecondsOffset, () => EditorGUILayout.Toggle("Random Second Offset", baseData.RandomSecondsOffset)); if (baseData.RandomSecondsOffset) { InUndoHelper.GUIUndo(baseData, "First item offset", ref baseData.MinSecondsOffset, ref baseData.MaxSecondsOffset, (out float v1, out float v2) => { v1 = Mathf.Clamp(EditorGUILayout.FloatField("Min offset", baseData.MinSecondsOffset), 0, baseData.MaxSecondsOffset); v2 = Mathf.Clamp(EditorGUILayout.FloatField("Max offset", baseData.MaxSecondsOffset), baseData.MinSecondsOffset, float.MaxValue); }); } else { InUndoHelper.GUIUndo(baseData, "Delay", ref baseData.MinSecondsOffset, () => { var delay = Mathf.Max(EditorGUILayout.FloatField("First clip offset", baseData.MinSecondsOffset), 0); if (delay > baseData.MaxSecondsOffset) { baseData.MaxSecondsOffset = baseData.MinSecondsOffset + 1; } return(delay); }); } if (node._type == AudioNodeType.Audio) { var nodeData = node._nodeData as InAudioData; if (nodeData.AudioClip != null) { float length = nodeData.AudioClip.ExactLength(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Clip length"); EditorGUILayout.SelectableLabel(length.ToString(), GUILayout.Height(EditorGUIUtility.singleLineHeight)); EditorGUILayout.EndHorizontal(); if (baseData.RandomSecondsOffset && (baseData.MinSecondsOffset > length || baseData.MaxSecondsOffset > length)) { EditorGUILayout.HelpBox("Offset exceeds sound clip length", MessageType.Warning); } else if (baseData.MinSecondsOffset > length) { EditorGUILayout.HelpBox("Offset exceeds sound clip length", MessageType.Warning); } } } #endregion } else { #region Attenuation if (!node._parent.IsRootOrFolder) { InUndoHelper.GUIUndo(baseData, "Override Parent", ref baseData.OverrideAttenuation, () => GUILayout.Toggle(baseData.OverrideAttenuation, "Override Parent")); } GUI.enabled = baseData.OverrideAttenuation; if (node._parent.IsRootOrFolder) { GUI.enabled = true; } InUndoHelper.GUIUndo(node, "Rolloff Mode", ref baseData.RolloffMode, () => (AudioRolloffMode)EditorGUILayout.EnumPopup("Volume Rolloff", baseData.RolloffMode)); InUndoHelper.GUIUndo(baseData, "Set Rolloff Distance", ref baseData.MinDistance, ref baseData.MaxDistance, (out float v1, out float v2) => { if (baseData.RolloffMode != AudioRolloffMode.Custom) { v1 = EditorGUILayout.FloatField("Min Distance", baseData.MinDistance); } else { v1 = baseData.MinDistance; } v2 = EditorGUILayout.FloatField("Max Distance", baseData.MaxDistance); v1 = Mathf.Max(v1, 0.00001f); v2 = Mathf.Max(v2, v1 + 0.01f); }); if (baseData.RolloffMode == AudioRolloffMode.Custom) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Rolloff"); InUndoHelper.GUIUndo(baseData, "Set Rolloff Curve", ref baseData.FalloffCurve, () => EditorGUILayout.CurveField(baseData.FalloffCurve, GUILayout.Height(200), GUILayout.Width(200))); //baseData.FalloffCurve = EditorGUILayout.CurveField(baseData.FalloffCurve, GUILayout.Height(200), GUILayout.Width(200)); EditorGUILayout.EndHorizontal(); var keys = baseData.FalloffCurve.keys; int keyCount = keys.Length; for (int i = 0; i < keyCount; i++) { Keyframe key = keys[i]; key.time = Mathf.Clamp01(key.time); key.value = Mathf.Clamp01(key.value); try { baseData.FalloffCurve.MoveKey(i, key); } catch (Exception) { } } if (GUILayout.Button("Reset curve", GUILayout.Width(150))) { InUndoHelper.RecordObject(baseData, "Reset Curve"); baseData.FalloffCurve = new AnimationCurve(new Keyframe(0, 1), new Keyframe(0.1f, 1), new Keyframe(1, 0)); } if (Selection.activeObject == null) { EditorGUILayout.HelpBox("Please select any game object in the scene.\nIt fixes a bug in Unity Editor API", MessageType.Info, true); } EditorGUILayout.HelpBox("Unity does not support setting custom rolloff via scripts. This will perform slower than a log/linear rolloff curve", MessageType.Warning, true); GUI.enabled = false; } #endregion GUI.enabled = true; } }
void StartMusic() { InAudio.Play(Camera.main.gameObject, music); }
public void Doors() { InAudio.Play(Camera.main.gameObject, doors); }
public void Ding() { InAudio.Play(Camera.main.gameObject, ding); }