Пример #1
0
    public void OnTriggerEnter(Collider other)
    {
        TargetCube targetCube = other.GetComponent <TargetCube>();

        if (targetCube != null)
        {
            targetCube.DestroyObject();
        }
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        height = ColliderHeight * transform.lossyScale.y;
        width  = ColliderWidth * transform.lossyScale.x;

        tc = GetComponent <TargetCube>();

        inertia         = mass / 12.0f * (height * height + width * width);
        gravityVector   = new Vector2(0, -gravityConstant);
        LinearVelocity  = new Vector2(0, 0);
        AngularVelocity = 0.0f;
    }
Пример #3
0
    public void OnTriggerEnter(Collider other)
    {
        TargetCube targetCube = other.GetComponentInParent <TargetCube>();

        if (targetCube != null)
        {
            bool hasEnoughVelocity = (saberEdgeVelocity.magnitude >= GameManager.Instance.slashIntensityThreshold) ? true : false;
            bool hasCorrectAngle   = (Vector3.Dot(-targetCube.transform.up, saberEdgeVelocity.normalized) >= GameManager.Instance.slashAngleThreshold) ? true : false;

            if (hasEnoughVelocity && hasCorrectAngle && saberColor == targetCube.cubeColor)
            {
                targetCube.CorrectHit();
                VRControllerManager.instance.PlayHaptic(transform.parent.gameObject, 10, .1f, .01f);
            }
            else
            {
                targetCube.DestroyObject();
            }
        }
    }
Пример #4
0
    public void SetActive(bool state)
    {
        if (m_Renderer == null)
        {
            m_Renderer = GetComponent <Renderer>();
        }
        m_Renderer.material.color = state ? m_ActiveColor : m_InActiveColor;

        var size = new Vector3(1, 1, 0.1F);

        transform.localScale = state ? Vector3.one * 0.4F : Vector3.one * 0.25F;

        if (state == true)
        {
            m_SelectedTarget = this;
        }

        if (state == false && m_SelectedTarget == this)
        {
            m_SelectedTarget = null;
        }
    }