Esempio n. 1
0
 private void Update()
 {
     m_LineRenderer.enabled = m_CubeRefracted;
     if (m_CubeRefracted)
     {
         m_CubeRefracted = false;
         if (!m_CubeRefracted && m_LastButtonHit != null && m_CreateRefraction)
         {
             m_LastButtonHit.ForceStop();
             m_LastButtonHit = null;
         }
         m_CreateRefraction = false;
     }
 }
Esempio n. 2
0
    private void CastLaser()
    {
        if (GameController.m_GameFinished)
        {
            return;
        }
        if (!l_RayActive)
        {
            return;
        }

        Vector3    l_EndRaycastPosition = Vector3.forward * m_MaxDistance;
        RaycastHit l_RaycastHit;

        if (Physics.Raycast(new Ray(m_LineRenderer.transform.position, m_LineRenderer.transform.forward), out l_RaycastHit, m_MaxDistance, m_CollisionLayerMask.value))
        {
            l_EndRaycastPosition = Vector3.forward * l_RaycastHit.distance;
            try
            {
                if (l_RaycastHit.collider.gameObject.GetComponent <RefractionCube>() != null)
                {
                    l_RaycastHit.collider.GetComponent <RefractionCube>().CreateRefraction();
                }
                else if (l_RaycastHit.collider.gameObject.GetComponent <LaserPortal>() != null)
                {
                    l_RaycastHit.collider.GetComponent <LaserPortal>().Collide(l_RaycastHit.point, this.gameObject.transform.forward);
                }
                else if (l_RaycastHit.collider.gameObject.GetComponent <ButtonInteractable>() != null)
                {
                    m_LastButtonHit = l_RaycastHit.collider.gameObject.GetComponent <ButtonInteractable>();
                    m_LastButtonHit.Interact();
                }
                else if (l_RaycastHit.collider.gameObject.GetComponent <PlayerController>() != null)
                {
                    l_RaycastHit.collider.gameObject.GetComponent <IDamageable>().DealDamage(999, l_RaycastHit.collider);
                }
                else if (m_LastButtonHit != null)
                {
                    m_LastButtonHit.ForceStop();
                    m_LastButtonHit = null;
                }
            }
            catch { }
        }
        m_LineRenderer.SetPosition(1, l_EndRaycastPosition);
    }