Ejemplo n.º 1
0
    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)
 {
     if (e.type == EBEventType.RoomSpawningTrigger)
     {
         RoomSpawningTriggerEvent rste = e as RoomSpawningTriggerEvent;
         if (rste.roomEntryId != roomEntry.GetId())
         {
             door.Unlock();
             roomEntry.SetSpawningEnabled(true);
             RoomsManager manager = RoomsManager.GetManager();
             manager.UnloadPrologue();
             StartCoroutine(UnsubscribeOnNextUpdate());
         }
     }
 }
    private void TranslateRoom()
    {
        attachedDoor = roomsManager.GetRandomRoomEntry();
        attachedDoor.SetSpawningEnabled(false);
        GameObject root        = roomScene.GetRoot();
        Vector3    oldPosition = root.transform.position;
        Vector3    oldRotation = root.transform.eulerAngles;

        translationFrame = Time.frameCount + 2;
        StartCoroutine(TranslateRoomOnNextUpdate(attachedDoor));
        dispatcher.SendEvent(new HallMovingTriggerEnteredEvent(
                                 translationFrame,
                                 oldPosition,
                                 oldRotation,
                                 attachedDoor.GetRootOffset(),
                                 attachedDoor.GetRootRotation()
                                 ));
    }