/// <summary> /// wait to see if more shots are fired; user accuracy may not be 100%, it's possible /// for the first shot or two to miss. /// If the only shots fired are misses, then the intent was not to shoot a person, and /// therefore classified as illegally discharging your weapon (an automatic fail) /// </summary> /// <returns></returns> IEnumerator wait(float t) { float timer = t; while (timer > 0) { timer -= Time.deltaTime; yield return(0); } if (shot[(int)SHOT.NOTHING] == shot.Sum()) { if (T3Ending == null) { //user only shot at nothing; illegal discharge of weapon scenarioResult = SCENARIO_RESULT.DISCHARGE; StartCoroutine(scenarioEndingKill()); } } }
/// <summary> /// coroutine for T2 Outside situation; /// scripted sequence where security guard and suspect exchange words. /// </summary> /// <returns></returns> IEnumerator coOutsideSituation() { int interruptCount = 0; Audio1 = suspect.GetComponent <AudioSource>(); Audio2 = guard.GetComponent <AudioSource>(); JimAnim.SetBool("Outside", true); //animate guard to drop stuff (play dropping stuff audio) Audio2.clip = ExtraSFX[RangeConstants.dropStuff_index]; Audio2.Play(); float coTimer = 0f; JimAnim.SetInteger("Scripted Index", 0); JimAnim.SetTrigger("PlayScripted"); //============================= //FIRST DEFUSE SITUATION //============================= for (int i = 0; i < RangeConstants.outside_firstDefuse; i++) { if (i % 2 == 0) //JIM { if (i == RangeConstants.outside_firstDefuse - 1) { scFSM.triggerKill(); Audio1.clip = OutsideScriptClips[i]; Audio1.Play(); JimAnim.SetInteger("Scripted Index", i); JimAnim.SetTrigger("PlayScripted"); while (Audio1.isPlaying) { yield return(0); } suspectGun.SetActive(true); while (coTimer < 1f) { coTimer += Time.deltaTime; yield return(0); } Audio1.clip = ExtraSFX[RangeConstants.gunShot_index]; Audio1.Play(); GuardAnim.SetTrigger("death"); while (Audio1.isPlaying) { yield return(0); } //Audio1.PlayOneShot(ExtraSFX[RangeConstants.gunShot_index]); scFSM.Grumble = false; scenarioResult = SCENARIO_RESULT.SUSPECT_KILL; if (T3Ending == null) { T3Ending = StartCoroutine(scenarioEndingKill()); } break; } Audio1.clip = OutsideScriptClips[i]; Audio1.Play(); if (i > 0) { JimAnim.SetInteger("Scripted Index", i); JimAnim.SetTrigger("PlayScripted"); } while (Audio1.isPlaying) { if (interrupt) { interruptCount++; goto interrupted; } else { yield return(0); } } } else //GUARD { Audio2.clip = OutsideScriptClips[i]; Audio2.Play(); GuardAnim.SetInteger("Scripted Index", i); GuardAnim.SetTrigger("PlayScripted"); while (Audio2.isPlaying) { if (interrupt) { interruptCount++; goto interrupted; } else { yield return(0); } } } } interrupted: if (interrupt) { JimAC.turnToCamera(); JimAnim.SetTrigger("interrupt"); } //let lines finish while (Audio1.isPlaying) { yield return(0); } while (Audio2.isPlaying) { yield return(0); } //reset the interrupt variable interrupt = false; coTimer = 0f; //============================= //SECOND DEFUSE SITUATION //============================= if (interruptCount > 0) { while (coTimer < 2f) { coTimer += Time.deltaTime; yield return(0); } scFSM.setDefuseScore(2); for (int j = RangeConstants.outside_firstDefuse; j < RangeConstants.outside_secondDefuse; ++j) { if (j % 2 == 0)//JIM { if (j == RangeConstants.outside_secondDefuse - 1) { coTimer = 0; scFSM.triggerKill(); Audio1.clip = OutsideScriptClips[j]; Audio1.Play(); JimAnim.SetInteger("Scripted Index", j); JimAnim.SetTrigger("PlayScripted"); while (Audio1.isPlaying) { yield return(0); } while (coTimer < 1f) { coTimer += Time.deltaTime; yield return(0); } suspectGun.SetActive(true); while (coTimer < 1.75f) { coTimer += Time.deltaTime; yield return(0); } Audio1.clip = ExtraSFX[RangeConstants.gunShot_index]; Audio1.Play(); GuardAnim.SetTrigger("death"); while (Audio1.isPlaying) { yield return(0); } scFSM.Grumble = false; scenarioResult = SCENARIO_RESULT.SUSPECT_KILL; if (T3Ending == null) { T3Ending = StartCoroutine(scenarioEndingKill()); } break; } Audio1.clip = OutsideScriptClips[j]; Audio1.Play(); JimAnim.SetInteger("Scripted Index", j); JimAnim.SetTrigger("PlayScripted"); while (Audio1.isPlaying) { if (interrupt) { goto interrupted2; } else { yield return(0); } } } else//GUARD { Audio2.clip = OutsideScriptClips[j]; Audio2.Play(); GuardAnim.SetInteger("Scripted Index", j); GuardAnim.SetTrigger("PlayScripted"); while (Audio2.isPlaying) { if (interrupt) { goto interrupted2; } else { yield return(0); } } } } interrupted2: if (interrupt) { JimAC.turnToCamera(); JimAnim.SetTrigger("interrupt"); } //let lines finish while (Audio1.isPlaying) { yield return(0); } while (Audio2.isPlaying) { yield return(0); } interrupt = false; } }
/// <summary> /// coroutine for T2 Office situation; /// scripted sequence where boss and suspect exchange words. /// </summary> /// <returns></returns> IEnumerator coOfficeSituation() { int interruptCount = 0; Audio1 = suspect.GetComponent <AudioSource>(); Audio2 = boss.GetComponent <AudioSource>(); JimAnim.SetBool("Office", true); float coTimer = 0f; //============================= //FIRST DEFUSE SITUATION //============================= for (int i = 0; i < RangeConstants.office_firstDefuse; i++) { //JIM has one line that is back to back (special case) if (i == RangeConstants.office_firstDefuse - 1) { scFSM.triggerKill(); Audio1.clip = OfficeScriptClips[i]; Audio1.Play(); JimAnim.SetInteger("Scripted Index", i); JimAnim.SetTrigger("PlayScripted"); while (Audio1.isPlaying) { yield return(0); } while (coTimer < 2.5f) { coTimer += Time.deltaTime; if (coTimer >= 1.5f) { if (!suspectGun.activeSelf) { suspectGun.SetActive(true); } } yield return(0); } Audio1.clip = ExtraSFX[RangeConstants.gunShot_index]; Audio1.Play(); BossAnim.SetTrigger("death"); while (Audio1.isPlaying) { yield return(0); } scFSM.Grumble = false; scenarioResult = SCENARIO_RESULT.SUSPECT_KILL; if (T3Ending == null) { T3Ending = StartCoroutine(scenarioEndingKill()); } break; } if (i % 2 == 0)//JIM { Audio1.clip = OfficeScriptClips[i]; Audio1.Play(); JimAnim.SetInteger("Scripted Index", i); JimAnim.SetTrigger("PlayScripted"); while (Audio1.isPlaying) { if (interrupt) { interruptCount++; goto interrupted; } else { yield return(0); } } } else //BOSS { Audio2.clip = OfficeScriptClips[i]; Audio2.Play(); BossAnim.SetInteger("Scripted Index", i); BossAnim.SetTrigger("PlayScripted"); while (Audio2.isPlaying) { if (interrupt) { interruptCount++; goto interrupted; } else { yield return(0); } } } } interrupted: if (interrupt) { JimAC.turnToCamera(); JimAnim.SetTrigger("interrupt"); } //let lines finish while (Audio1.isPlaying) { yield return(0); } while (Audio2.isPlaying) { yield return(0); } interrupt = false; coTimer = 0f; //============================= //SECOND DEFUSE SITUATION //============================= if (interruptCount > 0) { while (coTimer < 2f) { coTimer += Time.deltaTime; yield return(0); } scFSM.setDefuseScore(2); for (int j = RangeConstants.office_firstDefuse; j < RangeConstants.office_secondDefuse; ++j) { if (j % 2 == 0)//BOSS { Audio2.clip = OfficeScriptClips[j]; Audio2.Play(); BossAnim.SetInteger("Scripted Index", j); BossAnim.SetTrigger("PlayScripted"); while (Audio2.isPlaying) { if (interrupt) { interruptCount++; goto interrupted2; } yield return(0); } } else//JIM { if (j == RangeConstants.office_secondDefuse - 1) { scFSM.triggerKill(); Audio1.clip = OfficeScriptClips[j]; Audio1.Play(); JimAnim.SetInteger("Scripted Index", j); JimAnim.SetTrigger("PlayScripted"); while (Audio1.isPlaying) { yield return(0); } suspectGun.SetActive(true); while (coTimer < 3.5f) { coTimer += Time.deltaTime; yield return(0); } Audio1.clip = ExtraSFX[RangeConstants.gunShot_index]; Audio1.Play(); BossAnim.SetTrigger("death"); while (Audio1.isPlaying) { yield return(0); } scFSM.Grumble = false; scenarioResult = SCENARIO_RESULT.SUSPECT_KILL; if (T3Ending == null) { T3Ending = StartCoroutine(scenarioEndingKill()); } break; } if (j == RangeConstants.office_firstDefuse + 1) { JimAC.turnToBoss(); } Audio1.clip = OfficeScriptClips[j]; Audio1.Play(); JimAnim.SetInteger("Scripted Index", j); JimAnim.SetTrigger("PlayScripted"); while (Audio1.isPlaying) { if (interrupt) { interruptCount++; goto interrupted2; } else { yield return(0); } } } } interrupted2: if (interrupt) { JimAC.turnToCamera(); JimAnim.SetTrigger("interrupt"); } //let lines finish while (Audio1.isPlaying) { yield return(0); } while (Audio2.isPlaying) { yield return(0); } interrupt = false; } }
/// <summary> /// logic to determine what happens when the user has fired the gun. /// </summary> /// <param name="targetTag">tag belonging to the object the user shot</param> public void shotsFired(string targetTag) { switch (targetTag) { case "Jim": if (!scFSM.Tier2) { shot[(int)SHOT.JIM]++; if (WaitShot != null) { StopCoroutine(WaitShot); } //wtf? don't shoot him if (T3Ending == null) { scenarioResult = SCENARIO_RESULT.USER_KILL; T3Ending = StartCoroutine(scenarioEndingKill()); } } else { shot[(int)SHOT.JIM]++; if (WaitShot != null) { StopCoroutine(WaitShot); } if (T3Ending == null) { scenarioResult = SCENARIO_RESULT.USER_KILL; T3Ending = StartCoroutine(scenarioEndingKill()); } } break; case "Boss": shot[(int)SHOT.BOSS]++; if (WaitShot != null) { StopCoroutine(WaitShot); } if (T3Ending == null) { scenarioResult = SCENARIO_RESULT.USER_KILL; T3Ending = StartCoroutine(scenarioEndingKill()); } //wtf? don't shoot him break; case "SecuirtyGuard": shot[(int)SHOT.GUARD]++; if (WaitShot != null) { StopCoroutine(WaitShot); } if (T3Ending == null) { scenarioResult = SCENARIO_RESULT.USER_KILL; T3Ending = StartCoroutine(scenarioEndingKill()); } //wtf? don't shoot him break; default: //DO NOT DISCHARGE YOUR WEAPON! shot[(int)SHOT.NOTHING]++; if (WaitShot == null) { WaitShot = StartCoroutine(wait(2f)); } break; } }