public override bool Activate()
    {
        if (_siljaBeh == null)
        {
            GameObject siljaGO = GameObject.FindGameObjectWithTag("Player");
            _siljaBeh = siljaGO.GetComponent <SiljaBehaviour>();
        }

        if (!ObjectivesManager.Instance.IsInteractionEligable(this))
        {
            return(false);
        }

        base.Activate();


        if (IsInteracting)
        {
            OnInvestigateEnabled();

            ObjectivesManager.Instance.OnInteractionComplete(this, true);

            CameraTransitioner transitioner = _siljaBeh.thisCamera.GetComponent <CameraTransitioner>();
            StartCoroutine(ActivateEventAfterTransition(transitioner));
        }
        else
        {
            OnInvestigateDisabled();
            UIManager.Instance.hideCursor();
            UIManager.Instance.lookAtUI(false);
        }

        return(IsInteracting);
    }
    private IEnumerator ActivateEventAfterTransition(CameraTransitioner t)
    {
        while (t.Mode == CameraTransitioner.CameraMode.Transitioning)
        {
            yield return(null);
        }

        m_onInteractionActivated.Invoke();
    }
Ejemplo n.º 3
0
    private IEnumerator UnfreezeSiljaAfterTransition(CameraTransitioner t)
    {
        while (t.Mode == CameraTransitioner.CameraMode.Transitioning)
        {
            yield return(null);
        }

        _siljaBeh.IsMoveEnabled = true;
    }
    private void OnInvestigateDisabled()
    {
        _siljaBeh.interactor.m_backgroundDrag.onMouseDragBegin -= OnComponentDragBegin;
        _siljaBeh.interactor.m_backgroundDrag.onMouseDrag      -= OnComponentDragged;
        _siljaBeh.interactor.m_backgroundDrag.onMouseDragEnd   -= OnComponentDragEnd;

        CameraTransitioner transitioner = _siljaBeh.camTransitioner;
        CameraFollow       camControl   = _siljaBeh.cameraFollow;


        UnityAction finishAction = () =>
        {
            // setting up the character motion state

            _siljaBeh.IsMoveEnabled = true;

            if (_collider != null)
            {
                _collider.enabled = true;
            }
        };

        // change materials
        for (int i = 0; i < m_materialsToChange.Length; i++)
        {
            m_materialsToChange[i].renderer.sharedMaterial = m_materialsToChange[i].materialDefault;
        }

        if (LightStatesMachine.Instance.IsLightOn())
        {
            transitioner.AddTPPCompleteAction(finishAction);
        }
        else
        {
            transitioner.AddFPPCompleteAction(finishAction);
        }

        // reversing the previous object's transform
        transform.localPosition = _originalPos;
        transform.localRotation = _originalRot;

        if (LightStatesMachine.Instance.IsLightOn())
        {
            _siljaBeh.ShiftToThirdPerson();
        }
        else
        {
            _siljaBeh.ShiftFirstToFirstPerson();
        }

        Cursor.SetCursor(null, Vector2.zero, cursorMode);
    }
Ejemplo n.º 5
0
    private new void Awake()
    {
        base.Awake();

        m_movementController.InitializeCharacterController(45f, 0.3f, 0.01f, 0.25f, 1.76f);
        m_movementController.InitializeCharacterMotor(false, 1f, 1f, 1f, false, false, false);


        interactor = gameObject.GetComponent <Interactor>();

        camTransitioner = thisCamera.GetComponent <CameraTransitioner>();
        cameraFollow    = thisCamera.GetComponent <CameraFollow>();
        flshCtrl        = gameObject.GetComponent <FlashlightController>();

        firstPersonRig.gameObject.SetActive(false);

        var neckBone = siljaAnimation.GetBoneTransform(HumanBodyBones.Neck);

        cameraFollow.cameraFocusTarget = neckBone;

        m_eyesTransform = siljaAnimation.GetBoneTransform(HumanBodyBones.Head);
    }
    private void OnInvestigateEnabled()
    {
        _siljaBeh.interactor.m_backgroundDrag.onMouseDragBegin += OnComponentDragBegin;
        _siljaBeh.interactor.m_backgroundDrag.onMouseDrag      += OnComponentDragged;
        _siljaBeh.interactor.m_backgroundDrag.onMouseDragEnd   += OnComponentDragEnd;

        CameraTransitioner transitioner = _siljaBeh.camTransitioner;
        CameraFollow       camControl   = _siljaBeh.cameraFollow;

        _siljaBeh.IsMoveEnabled = false;

        transitioner.AddFPPCompleteAction(() =>
        {
            camControl.CamControlType = CameraFollow.CameraControlType.CCT_Overwritten;

            UIManager.Instance.showCursor();
            UIManager.Instance.lookAtUI(true);

            Transform fpCamTransform = transitioner.FPPCameraTransform;
            transform.position       = fpCamTransform.TransformPoint(Vector3.forward * _faceDistance);


            transform.LookAt(fpCamTransform);

            if (_collider != null)
            {
                _collider.enabled = false;
            }

            // change materials
            for (int i = 0; i < m_materialsToChange.Length; i++)
            {
                m_materialsToChange[i].renderer.sharedMaterial = m_materialsToChange[i].materialInteracting;
            }
        });

        _siljaBeh.ShiftToFirstPerson();
    }
    private IEnumerator UnfreezeSiljaAfterTransition(CameraTransitioner t)
    {
        while (t.Mode == CameraTransitioner.CameraMode.Transitioning)
            yield return 0;

        _siljaBeh.IsMoveEnabled = true;
    }
Ejemplo n.º 8
0
    // called by Interactor.cs
    public override bool Activate()
    {
        StopAllCoroutines();
        overrideTransform.position = overrideTransformPos;
        overrideTransform.rotation = overrideTransformRotation;

        if (_siljaBeh == null)
        {
            GameObject siljaGO = GameObject.FindGameObjectWithTag("Player");
            _siljaBeh = siljaGO.GetComponent <SiljaBehaviour>();
        }

        CameraTransitioner transitioner = _siljaBeh.thisCamera.GetComponent <CameraTransitioner>();

        if (!ObjectivesManager.Instance.IsInteractionEligable(this))
        {
            return(false);
        }

        base.Activate();


        if (IsInteracting)
        {
            _siljaBeh.cameraFollow.CamControlType = CameraFollow.CameraControlType.CCT_LookingAtObject;
        }
        else
        {
            if (LightStatesMachine.Instance.IsLightOn())
            {
                _siljaBeh.cameraFollow.CamControlType = CameraFollow.CameraControlType.CCT_Default;
            }
            else
            {
                _siljaBeh.cameraFollow.CamControlType = CameraFollow.CameraControlType.CCT_FPSLook;
            }
        }

        _siljaBeh.cameraFollow.focusPoint = transform.position;


        if (IsInteracting)
        {
            UIManager.Instance.lookAtUI(true);
        }
        else
        {
            UIManager.Instance.lookAtUI(false);
        }

        if (IsInteracting)
        {
            if (overrideTransform != null)
            {
                overrideTransform.LookAt(transform);

                if (LightStatesMachine.Instance.IsLightOn())
                {
                    transitioner.TransitionTPPtoOther(overrideTransform);
                }
                else
                {
                    transitioner.TransitionFPPtoOther(overrideTransform);
                }
            }
            else
            {
                if (LightStatesMachine.Instance.IsLightOn())
                {
                    transitioner.TransitionTPPtoFPP(transform);
                }
                else
                {
                    transitioner.TransitionFPPtoFPP();
                }
            }
        }
        else
        {
            if (overrideTransform != null)
            {
                overrideTransform.LookAt(transform);

                if (LightStatesMachine.Instance.IsLightOn())
                {
                    transitioner.TransitionOtherToTPP(overrideTransform);
                }
                else
                {
                    transitioner.TransitionOtherToFPP(overrideTransform);
                }
            }
            else
            {
                if (LightStatesMachine.Instance.IsLightOn())
                {
                    transitioner.TransitionFPPtoTPP();
                }
                else
                {
                    transitioner.TransitionFPPtoFPP();
                }
            }
        }

        if (IsInteracting)
        {
            _siljaBeh.IsMoveEnabled = false;
            StartCoroutine(ActivateEventAfterTransition(transitioner));
        }
        else
        {
            StartCoroutine(UnfreezeSiljaAfterTransition(transitioner));
        }

        ObjectivesManager.Instance.OnInteractionComplete(this, true);
        return(IsInteracting);
    }
Ejemplo n.º 9
0
	private new void Awake()
	{
        base.Awake();

        m_movementController.InitializeCharacterController(45f, 0.3f, 0.01f, 0.25f, 1.76f);
        m_movementController.InitializeCharacterMotor(false, 1f, 1f, 1f, false, false, false);


        interactor = gameObject.GetComponent<Interactor>();

        camTransitioner = thisCamera.GetComponent<CameraTransitioner>();
		cameraFollow = thisCamera.GetComponent<CameraFollow>();
        flshCtrl = gameObject.GetComponent<FlashlightController>();

		firstPersonRig.gameObject.SetActive(false);

        var neckBone = siljaAnimation.GetBoneTransform(HumanBodyBones.Neck);
        cameraFollow.cameraFocusTarget = neckBone;
	}