Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (checkAvgEnv == true)
        {
            if (currAvgEnv > (prevAvgEnv * 1.002f))
            {
                //Torch changes to dreader color
                if (currFlameColor == 0)
                {
                    changeTorches(dreadTorch);
                    randomNum();
                    if (flameSoundPlaying == false && currRand == 1)
                    {
                        flameBGM.Play();
                        flameSoundPlaying = true;
                    }
                    currFlameColor = 1;
                }
                //Walls change as heart rate increases due to being scared.
                //crossFadeScript.crossFadeTo (mainWallChange, wallOffset, wallTiling);
                crossFadeScript.crossFadeTo(mainWallChange, wallOffset, wallTiling, smallWallOffset, smallWallTiling, tinyWallOffset, tinyWallTiling, threshWallOffset, threshWallTiling);

                //Add more enemies (delusions of enemies) in the pillar room based on high HRV
                pillarRoom.enableDelusions();

                //change enemy range radius
                //endEnemyRadius.GetComponent<SphereCollider>().radius = 32f;
                foreach (GameObject enemyRange in enemyDetectors)
                {
                    enemyRange.GetComponent <SphereCollider>().radius = 32f;
                }

                toggleEnvFlags();
            }
            else if (currAvgEnv <= (prevAvgEnv * 1.002f))                 //Should still be *0.something equivalent of high heart rate value
            //torch changes back to normal
            {
                if (currFlameColor == 1)
                {
                    changeTorches(baseTorch);
                    currFlameColor = 0;
                }
                //reset enemy range radius
                //endEnemyRadius.GetComponent<SphereCollider>().radius = 25f;
                foreach (GameObject enemyRange in enemyDetectors)
                {
                    enemyRange.GetComponent <SphereCollider>().radius = 25f;
                }

                toggleEnvFlags();
            }
            else                 //When the value is near the previous average (initially anyways)
            {
                toggleEnvFlags();
            }
        }

        /**envTime += Time.deltaTime;
         *      if (envTime >= 1f) {
         * pillarRoom.enableDelusions();
         * //Debug.Log(floor.terrainData.splatPrototypes[0].texture);
         * //floor.terrainData.splatPrototypes[0].texture = (Texture2D) firstWallChange;
         *
         * //crossFadeScript.crossFadeTo (mainWallChange, wallOffset, wallTiling, smallWallOffset, smallWallTiling, tinyWallOffset, tinyWallTiling, threshWallOffset, threshWallTiling);
         *              envTime = 0f;
         *      }**/

        //Set of code to check player location, and change wall texture and materials accordingly. Also start changing the roof
        //The tricky part: The tiling and offset for the other stuff when they come (if they have different tillings and offsets that is)
        if (crossFadeScript.hasWallsChanged() == true && respawnLocation.passedCheckPoint1 == true && usedSecondChange == false)
        {
            mainWallChange = secondWallChange;
            crossFadeScript.setNewMaterial(thirdMaterial, thirdSmallWallMaterial, thirdTinyWallMaterial, thirdThreshMaterial);
            crossFadeScript.resetWallChanging();
            crossFadeScript.startChangeRoof();
            usedSecondChange = true;
        }
        else if (crossFadeScript.hasWallsChanged() == true && respawnLocation.passedCheckPoint3 == true && usedThirdChange == false)
        {
            mainWallChange = thirdWallChange;
            crossFadeScript.setNewMaterial(fourthMaterial, fourthSmallWallMaterial, fourthTinyWallMaterial, fourthThreshMaterial);
            crossFadeScript.resetWallChanging();
            crossFadeScript.startChangeRoof();
            usedThirdChange = true;
        }
    }