Esempio n. 1
0
    public void OnBlackout( )
    {
        // Change the scene.
        if (debug)
        {
            Debug.Log("in scene switch");
        }

        // Switch scene.
        IterateState( );

        // Set player avatar configuration start position and floor center
        Transform playerStartPosition = GetCurrentSceneRoot().transform.Find("PlayerStartPosition");

        if (playerStartPosition != null)
        {
            Player.transform.localPosition = playerStartPosition.position;
            FloorCenter = playerStartPosition.position;
        }
        else
        {
            Player.transform.localPosition = Vector3.zero;
            FloorCenter = Vector3.zero;
        }

        // Change the music.
        MusicLord.OnSceneSwitch( );

        // Clear global objects and parent colliding objects to the active scene.
        OpponentLord.OnSceneSwitch( );

        blackoutTimer = blackoutLength;
    }
Esempio n. 2
0
 protected void ToDisable()
 {
     if (debug)
     {
         Debug.Log("to disable");
     }
     finished = false;
     OpponentLord.StoreOpponent(this);
 }
Esempio n. 3
0
    private void InitOpponentLord( )
    {
        GameObject temp = Instantiate(opponentLordPrefab);

        if (temp.GetComponentInChildren <OpponentLord> ( ) != null)
        {
            opponentLord = temp.GetComponentInChildren <OpponentLord> ( );
            opponentLord.Init(opponentCount, opponentPrefab);
            opponentLord.DisableOpponents( );
        }
        else
        {
            Debug.LogError("OpponentLord component not found.");
        }
    }
Esempio n. 4
0
    private void InCollision( )
    {
        distToCore = 0.0f;

        // Iterate through the list of hands
        for (int i = 0; i < HandSituations.Count; i++)
        {
            Vector3 handRelative = HandSituations[i].hand.transform.InverseTransformPoint(transform.position);

            // In future, omit Sqrt to optimize.
            HandSituations[i].myDistToCore = Mathf.Sqrt(Mathf.Pow(handRelative.x, 2) + Mathf.Pow(handRelative.y, 2));

            // Make distToCore be from 0 to 1
            HandSituations[i].myDistToCore /= radius;
            if (debug)
            {
                Debug.Log(i + " mydistToCore " + HandSituations[i].myDistToCore);
            }

            // Pulse intentity increases with proximity
            int pulseIntensity = Mathf.RoundToInt(999.0f / HandSituations[i].myDistToCore); // High is 3999
            HandSituations[i].hand.HapticPulse(pulseIntensity);
            // if (debug) Debug.Log(i + " pulseIntensity " + pulseIntensity);

            // Register a point for every x seconds in collision
            scoreTimer += Time.deltaTime;
            if (scoreTimer > 2.0f)
            {
                OpponentLord.RegisterHit(this);
                scoreTimer = 0.0f;
            }

            // Place the hand fx on the fingertips.
            HandSituations[i].fx_hitHand.transform.position = HandSituations[i].hand.transform.position + 0.15f * HandSituations[i].hand.transform.forward;

            // Set the total distToCore based on how many hands there are.
            distToCore += HandSituations[i].myDistToCore / HandSituations.Count;
        }
    }
Esempio n. 5
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;
                }
            }
        }
    }