示例#1
0
    private void OnCollisionEnter(Collision collision)
    {
        if (debug)
        {
            Debug.Log("OnCollisionEnter: " + collision.gameObject.name);
        }

        // Cannot collide with "gloves on"
        VRNodeMinion enteringVrNodeMinion = collision.gameObject.GetComponent <VRNodeMinion>();

        if (enteringVrNodeMinion.glove != null && enteringVrNodeMinion.glove.gameObject.activeInHierarchy)
        {
            return;
        }

        // The collider is oversized. Use the distance from center to determine intensity of the effect.
        // This can only collide with a "Hand" Layer, which has a VRNodeMinion component. So, no check needed.
        var sit = new HandSituation();

        HandSituations.Add(sit);
        sit.hand = enteringVrNodeMinion;

        state = OpponentState.Hit;
        SetRends(rewardMat);

        // Arbitrarily assign fx one to left and fx two to right
        if (sit.hand.GetIsLeftHand())
        {
            sit.fx_hitHand = fx_hitHand_one;
        }
        else
        {
            sit.fx_hitHand = fx_hitHand_two;
        }

        sit.fx_hitHand.SetActive(true);
        sit.fx_hitHand.transform.position = sit.hand.transform.position;

        if (MyMusicTrackIndex == -1)
        {
            MyMusicTrackIndex = GameLord.instance.MusicLord.NextStemOnIndex( );
            if (debug)
            {
                Debug.Log("next track index: " + MyMusicTrackIndex);
            }
        }
    }
示例#2
0
    private void OnCollisionEnter(Collision collision)
    {
        if (state == OpponentState.Untouched)
        {
            VRNodeMinion vrNodeMinion = collision.gameObject.GetComponent <VRNodeMinion>();
            if (vrNodeMinion != null)
            {
                var sit = new HandSituation();
                HandSituations.Add(sit);
                sit.hand = vrNodeMinion;

                reboundDir = sit.hand.GetForce( ).normalized;
                reboundMod = sit.hand.GetForce( ).magnitude / Time.deltaTime * 2.0f;  // This range is about 0.0f to 4.0f.

                if (debug)
                {
                    Debug.Log("Hit by hand reboundMod: " + reboundMod);
                }

                // Can only collide with "gloves on"
                if (sit.hand.glove != null && sit.hand.glove.gameObject.activeInHierarchy)
                {
                    state = OpponentState.Hit;
                    GameLord.instance.MusicLord.PlayResponseClip(transform.localPosition);
                    SetRends(rewardMat);
                    fx_hitHand_one.SetActive(true);
                    OpponentLord.RegisterHit(this);

                    // Flatten
                    transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y, 0.1f * transform.localScale.z);

                    // Turn light
                    rewardMat.SetColor("_EmissionColor", rewardMat.color * 0.25f * reboundMod);
                }
                else
                {
                    state = OpponentState.Missed;
                    SetRends(punishMat);
                    timer = 0.5f;
                }
            }
        }
        else if (state == OpponentState.Passed)
        {
            // Can only damage the player once
            if (!damage && collision.gameObject == GameLord.instance.Player.head)
            {
                damage = true;
                timer  = 0.5f; // Give the fx time
                GameLord.instance.Player.OnDamage(transform.position);
            }
        }
        else if (state == OpponentState.Hit)
        {
            if (debug)
            {
                Debug.Log("OnCollisionEnter: Hit by other: " + collision.gameObject.name);
            }
            if (!finished)
            {
                Shrink shrink = collision.gameObject.GetComponent <Shrink>();
                if (shrink != null)
                {
                    if (debug)
                    {
                        Debug.Log("OnCollisionEnter: Hit by Shrink");
                    }
                    shrink.OnHit( );
                    fx_hitTrigger.SetActive(true);
                    timer    = 1.0f; // Give the fx time
                    finished = true;
                }
            }
        }
    }