public override void OnTriggerStay(Collider2D other) { if (waiting) { return; } if (onDoor && !onDoor.NeedsKey) { if (onDoor.GetState() == Door.State.ConfirmedLock) { var audio = fsm.gameObject.GetComponent <AudioSource>(); IEnumerator waitSound(Door door) { yield return(new WaitForSeconds(tryingToOpenDoorSound.length)); waiting = false; if (!door.NeedsKey && Random.value <= brokeDoorPercentage()) { door.ForceOpen(brokeDoorPercentage() == 1); } else { // nao deixa o jason preso fora da grid da porta fsm.transform.position = AstarPath.active.GetNearest(fsm.transform.position).position; } if (door.IsUnbrokable) { enemyFsm.MoveAndSetState <WalkAroundState>(); var state = enemyFsm.GetState() as WalkAroundState; state?.WalkFarFormPlayer(); } else { OnEnter(); } } waiting = true; audio.PlayOneShot(tryingToOpenDoorSound); onDoor.Shake(); fsm.PathFinder.StopFollowing(); fsm.StartCoroutine(waitSound(onDoor)); onDoor = null; } } }
void Update() { var newSpeed = difficulties[inventary.NumberOfKeys].jasonSpeed; mover.SetMoveSeed(newSpeed); var newBrokeDoorPercentage = difficulties[inventary.NumberOfKeys].jasonBrokeDoorPercentage; fsm.SetBrokeDoorPercentage(newBrokeDoorPercentage); fsm.SetTimeToGiveUp(difficulties[inventary.NumberOfKeys].jasonTimeToGiveUp); jsonWalkAudio.pitch = animator.speed = difficulties[inventary.NumberOfKeys].jasonWalkSoundSpeed; if (inventary.NumberOfKeys == difficulties.Length - 1 && !shadowsMidtonesHighlights.active) { shadowsMidtonesHighlights.active = true; fsm.MoveAndSetState <FollowingTarget>( fsm.Awareness.HasTargetOnSight() || fsm.CurrentState == nameof(FollowingTarget) ? fsm.transform.position : GameObject.Find("LastApearEvent").transform.position); musicNormal.Pause(); hardMusic.Play(); } }