private IEnumerator AnimateCatch() { float startTime = Time.time; Quaternion from = controller.transform.rotation; Quaternion to = Quaternion.LookRotation(Vector3.up, controller.transform.right); float initialY = controller.transform.position.y; bool soundPlayed = false; float t = 0.0f; while (t < 1.0f) { t = (Time.time - startTime) / catchAnimationTime; Quaternion rotation = Quaternion.Slerp(from, to, t); controller.transform.rotation = rotation; if ((t > 0.7f) && !soundPlayed) { controller.PlayFallingSound(); soundPlayed = true; } yield return(null); } cameraFading.FadeToBlack(fadeToBlackTime); yield return(new WaitUntil(() => cameraFading.GetState() == FadingManager.State.Faded)); RoomScene room = roomsManager.GetRandomWakeUpRoom(); RoomEntry entry = roomsManager.GetRandomRoomEntry(); room.ClearCollectibles(); entry.AttachRoom(room); entry.SetSpawningEnabled(false); Transform wakeUpPosition = room.GetWakeUpPosition(); controller.transform.position = wakeUpPosition.position; controller.transform.rotation = wakeUpPosition.rotation; Vector3 eulerAngles = controller.transform.eulerAngles; eulerAngles.x = 0.0f; eulerAngles.z = 0.0f; controller.transform.eulerAngles = eulerAngles; Vector3 pos = controller.transform.position; pos.y = initialY; controller.transform.position = pos; yield return(new WaitForSeconds(wakeUpTime)); cameraFading.FadeToNormal(fadeToNormalTime); controller.enabled = true; dispatcher.SendEvent(new EBEvent() { type = EBEventType.ApplyMadnessAfterMonsterCaught }); }
public void OnReceived(EBEvent e) { switch (e.type) { case EBEventType.RoomSpawningTrigger: RoomSpawningTriggerEvent rstee = (e as RoomSpawningTriggerEvent); if (rstee.action == TriggerAction.Enter) { if ((rstee.roomEntryId == id) && spawningEnabled) { roomsManager.DisableAllRoomScenes(); RoomScene room = roomsManager.GetRandomRoomScene(); AttachRoom(room); SetSpawningEnabled(false); room.ClearCollectibles(); Transform itemPlace = room.GetCollectiblePlaceholder(); if (itemPlace != null) { CollectibleItem item = itemsManager.GetItem(); if (item != null) { item.transform.parent = itemPlace; item.transform.position = itemPlace.position; item.transform.rotation = itemPlace.rotation; item.SetRoomScene(room); item.gameObject.SetActive(true); } } } if (rstee.roomEntryId != id) { SetSpawningEnabled(true); } } break; case EBEventType.DoorClosingTrigger: DoorClosingTriggerEvent dcte = (e as DoorClosingTriggerEvent); if ((dcte.roomEntryId == id) && (dcte.action == TriggerAction.Exit)) { CloseDoor(); } break; case EBEventType.HallMovingTriggerEntered: CloseDoor(); break; } }