Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(m_flashKeycode) && lightUI.value >= 100)
        {
            m_flashed.Invoke();

            lightUI.value = 0;

            //flashlight

            //send raycast in direction to find wall

            RaycastHit2D wallHits = Physics2D.Raycast(transform.position, eMC.GetCurrentForward(), m_flashDistance, wall);

            Vector3 hitPoint = new Vector3();

            if (wallHits)
            {
                hitPoint = wallHits.point;
            }
            else
            {
                hitPoint = transform.position + eMC.GetCurrentForward() * m_flashDistance;
            }

            //send raycast in direction to find ghost

            RaycastHit2D[] ghostHits = Physics2D.RaycastAll(transform.position, eMC.GetCurrentForward(), (Vector3.Distance((Vector2)hitPoint, (Vector2)transform.position)), ghost);

            //render flashlight

            lr.positionCount = 2;
            lr.SetPosition(0, transform.position + Vector3.forward * -1);
            lr.SetPosition(1, hitPoint + Vector3.forward * -1);

            StartCoroutine(DerenderLine(flashTime));

            ScoreManager sM = ScoreManager.Instance;

            //stun
            foreach (RaycastHit2D ghostHit in ghostHits)
            {
                ghostHit.collider.transform.parent.GetComponent <AI_Controller>().ChangeState(AI_Controller.AIStates.STUN);

                sM.ChangeScore((m_spookyTimeManager.IsSpookyTimeActive()) ?  spooktTimeStunAward:stunAward);
            }
        }
    }
Esempio n. 2
0
 private void Update()
 {
     if (!m_enableInput)
     {
         return;
     }
     m_movementController.MoveCharacter(GetInput(), m_lerpTime);
     Debug.DrawLine(transform.position, transform.position + m_movementController.GetCurrentForward(), Color.red);
 }