예제 #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 Start( )
    {
        instance = this;

        if (isVR)
        {
            player_VR.SetActive(true);
            player_PC.SetActive(false);
            HeadVR      = player_VR.GetComponent <VRNodeLord> ( ).head;
            LeftHandVR  = player_VR.GetComponent <VRNodeLord> ( ).leftHand;
            RightHandVR = player_VR.GetComponent <VRNodeLord> ( ).rightHand;
        }
        else
        {
            player_VR.SetActive(false);
            player_PC.SetActive(true);
            HeadPC      = player_PC.GetComponent <PlayerCurriculumPC> ( ).Head;
            LeftHandPC  = player_PC.GetComponent <PlayerCurriculumPC> ( ).LeftHand;
            RightHandPC = player_PC.GetComponent <PlayerCurriculumPC> ( ).RightHand;
        }
    }
예제 #3
0
    private void OnCollisionExit(Collision collision)
    {
        if (debug)
        {
            Debug.Log("OnCollisionExit");
        }
        VRNodeMinion exitingVrNodeMinion = collision.gameObject.GetComponent <VRNodeMinion>();

        if (exitingVrNodeMinion != null)
        {
            // Iterate through the list of hands
            for (int i = HandSituations.Count - 1; i >= 0; i--)
            {
                if (exitingVrNodeMinion == HandSituations[i].hand)
                {
                    HandSituations.RemoveAt(i);
                }
            }

            // Adjust the state based on number of current collisions
            if (HandSituations.Count == 0)
            {
                state = OpponentState.Untouched;
                SetRends(rhythmMat);
                rewardMat.SetColor("_EmissionColor", rewardMat.color * 0.5f);
                if (debug)
                {
                    Debug.Log("OnCollisionExit: Untouched");
                }
            }
            else
            {
                state = OpponentState.Hit;
            }
        }
    }
예제 #4
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;
                }
            }
        }
    }