Beispiel #1
0
    void Update()
    {
        StartCoroutine(toggleFootStepsSound());

        if (hInGameScript.isGamePaused() == true)
        {
            stopSound(CharacterSounds.Footsteps);
        }

        if (bPlayFootsteps == true)
        {
            //adjust footsteps pitch according to movement speed
            asCharacterSounds[(int)CharacterSounds.Footsteps].pitch = hControllerScript.getCurrentForwardSpeed() / 3.0f;
            if (bFootstepsPlaying == false)
            {
                if (bSoundEnabled)
                {
                    asCharacterSounds[(int)CharacterSounds.Footsteps].Play();
                }
                bFootstepsPlaying = true;
            }
        }
        else
        {
            if (bFootstepsPlaying == true)
            {
                if (bSoundEnabled)
                {
                    asCharacterSounds[(int)CharacterSounds.Footsteps].Stop();
                }
                bFootstepsPlaying = false;
            }
        }
    }
    void FixedUpdate()
    {
        //pause the powerup's time if the game is paused
        if (hInGameScript.isGamePaused() == true)
        {
            for (int j = 0; j < iPowerupCount; j++)
            {
                if (bPowerupStatus[j] == true)
                {
                    fPowerupStartTime[j] += Time.deltaTime;
                }
            }
            return;
        }

        //count down timer for the active powerup
        for (int i = 0; i < iPowerupCount; i++)
        {
            if (bPowerupStatus[i] == true)
            {
                //reduce the meter bar
                PowerupHUDVisual((Time.time - fPowerupStartTime[i]), fPowerupTotalDuration[i]);

                if (Time.time - fPowerupStartTime[i] >= fPowerupTotalDuration[i])     //deactivate the PU when time runs out
                {
                    deactivatePowerup(i);
                }
            }    //end of if PU Active == true
        }//end of for i
    }
    void FixedUpdate()
    {
        if (hInGameScript.isGamePaused() == true)
        {
            return;
        }

        StartCoroutine(UpdateHUDStats());
    }
Beispiel #4
0
    void Update()
    {
        if (hInGameScript.isGamePaused() == true)
        {
            return;
        }

        //if (hInGameScript.isEnergyZero())	//switch to death camera state on depletion of energy
        //iCameraState = 2;
    }
Beispiel #5
0
    void Update()
    {
        if (hInGameScript.isGamePaused() == true)
        {
            return;
        }

        if (bPitFallingStart)
        {
            hInGameScript.decrementEnergy((int)((hInGameScript.getCurrentEnergy() / 10.0f) + Time.deltaTime * 100));
        }
    }
    void Update()
    {
        if (hInGameScript.isGamePaused() == true)
        {
            return;
        }

        if (tPlayer.position.x > (iCurrentPNum * fPatchDistance) + 100.0f)
        {
            Destroy(goPreviousPatch);
            iCurrentPNum++;
        }
    }//end of update
    void Update()
    {
        if (hInGameScript.isGamePaused() == true)
        {
            return;
        }

        if (PUState == 1)                                                                                   //hide the powerup
        {
            if (hPowerupsMainController.isPowerupActive(PowerupsMainController.PowerUps.Magnetism) == true) //magnetism powerup is active
            {
                //adjust the currency's height
                v3CurrencyLerpPosition    = tPlayer.position;
                v3CurrencyLerpPosition.x += 2;
                v3CurrencyLerpPosition.y += 5;

                //pull the currency towards the player
                transform.position   = Vector3.Lerp(transform.position, v3CurrencyLerpPosition, (Time.time - StartTime) / 0.8f);
                transform.localScale = Vector3.Lerp(transform.localScale, new Vector3(0.1f, 0.1f, 0.1f), (Time.time - StartTime) / 0.8f);
            }
            else    //regular cases
            {
                //pull the currency towards the player
                transform.position   = Vector3.Lerp(transform.position, tPlayer.position, (Time.time - StartTime) / 0.2f);
                transform.localScale = Vector3.Lerp(transform.localScale, new Vector3(0.01f, 0.01f, 0.01f), (Time.time - StartTime) / 0.002f);
            }

            if ((Time.time - StartTime) > 0.2f)
            {
                //disable currency if magnetism is activated
                if (powerupType == PowerupsMainController.PowerUps.Currency || hPowerupsMainController.isPowerupActive(PowerupsMainController.PowerUps.Magnetism) == true)
                {
                    toggleMeshRender(false);            //make currency invisible
                }
                else
                {
                    this.gameObject.SetActive(false);            //deactivate object
                }
            }
            return;
        }

        v3DistanceVector = transform.position - tPlayer.position;

        //destroy not collect currency/ powerup
        if (v3DistanceVector.sqrMagnitude < 40000.0f)
        {
            bDestroyWhenFarFlag = true;
        }

        //destroy currency or powerup if not collected
        if (bDestroyWhenFarFlag == true)
        {
            if (v3DistanceVector.sqrMagnitude > 90000.0f)
            {
                if (powerupType == PowerupsMainController.PowerUps.Currency)
                {
                    toggleMeshRender(false);
                }
                else
                {
                    this.gameObject.SetActive(false);
                }
            }
        }

        if (powerupType == PowerupsMainController.PowerUps.Currency)//currency pull radius
        {
            fCatchRadius = hPowerupsMainController.getMagnetismRadius();
        }

        if (v3DistanceVector.sqrMagnitude < fCatchRadius) //catch the orb
        {
            PUState   = 1;                                //hide the orb
            StartTime = Time.time;

            hPowerupsMainController.collectedPowerup((int)powerupType);//tell power-up main script what has been collected
        }
    }//end of update
    void Update()
    {
//		Debug.Log("*****   " + getCurrentWalkSpeed());

        if (hInGameScript.isGamePaused() == true)
        {
            return;
        }

        if (getCurrentWalkSpeed() < 1)
        {
            hInGameScript.pauseGame();
        }

        if (hInGameScript.isEnergyZero())
        {
            //Debug.Log("*** 4 energy is at 0 - Update ControllerScript ***");
            if (DeathScene())
            {
                return;
            }
        }

        if (invincible && Time.time - invincibilityStartTime > invincibilityDuration)
        {
            CancelInvoke("invincibleFlash");
            playerRenderer.enabled = true;
            if (PersistentManagerScript.Instance.obstacles)
            {
                tFrontCollider.GetComponent <BoxCollider>().enabled       = true;
                tPlayerSidesCollider.GetComponent <BoxCollider>().enabled = true;
            }

            invincible = false;
        }

        getClicks();            //get taps/clicks for pause menu etc.

        if (bControlsEnabled)
        {
            SwipeMovementControl();
        }

        //running by pressing alternating keys
        if (Input.GetKeyDown("n"))
        {
            if (mPressedLast)
            {
                mPressedLast = false;
                nPressedLast = true;
                lastKeyPress = Time.time;
                //Debug.Log(lastKeyPress);
            }
        }

        //m
        if (Input.GetKeyDown("m"))
        {
            if (nPressedLast)
            {
                nPressedLast = false;
                mPressedLast = true;
                lastKeyPress = Time.time;
                //Debug.Log(lastKeyPress);
            }
        }
    }
    void FixedUpdate()
    {
        if (hInGameScript.isGamePaused() == true)
        {
            return;
        }

        //set the position of guard in current frame
        tEnemy.position = new Vector3(Mathf.Lerp(tEnemy.position.x, (tPlayer.position.x - fEnemyPosition), Time.deltaTime * 10), tEnemy.position.y, tEnemy.position.z);

        if (!hControllerScript.isInAir())//follow the player in y-axis if he's not jumping (cars cant jump)
        {
            tEnemy.position = new Vector3(tEnemy.position.x, Mathf.Lerp(tEnemy.position.y, tPlayer.position.y + fEnemyPositionY, Time.deltaTime * 8), tEnemy.position.z);
        }

        //ignore y-axis rotation and horizontal movement in idle and death state
        if (iEnemyState < 4)
        {
            tEnemy.position         = new Vector3(tEnemy.position.x, tEnemy.position.y, Mathf.Lerp(tEnemy.position.z, tPlayer.position.z, Time.deltaTime * 10));
            tEnemy.localEulerAngles = new Vector3(tEnemy.localEulerAngles.x, -hControllerScript.getCurrentPlayerRotation(), tEnemy.localEulerAngles.z);
        }

        if (iEnemyState == 1)//hide the chasing character
        {
            fCosLerp      += (Time.deltaTime / 10);
            fEnemyPosition = Mathf.Lerp(fEnemyPosition, fEnemyPositionX + 45, Mathf.Cos(fCosLerp) / 1000);

            if (fCosLerp >= 0.7f)
            {
                fCosLerp    = 0.0f;
                iEnemyState = 0;

                hSoundManager.stopSound(SoundManager.EnemySounds.Siren);
            }
        }
        else if (iEnemyState == 2)//show the chasing character
        {
            hSoundManager.playSound(SoundManager.EnemySounds.Siren);

            fCosLerp      += (Time.deltaTime / 4);
            fEnemyPosition = Mathf.Lerp(fEnemyPosition, fEnemyPositionX, Mathf.Cos(fCosLerp));

            if (fCosLerp >= 1.5f)
            {
                fCosLerp    = 0.0f;
                iEnemyState = 3;
            }
        }
        else if (iEnemyState == 3)//wait for 'fChaseTime' after showing character
        {
            if ((Time.time - fStumbleStartTime) % 60 >= fChaseTime)
            {
                iEnemyState = 1;
            }
        }

        //DEATH SEQUENCE
        else if (iEnemyState == 4)                                                                            //on death
        {
            tEnemy.localEulerAngles = new Vector3(tEnemy.localEulerAngles.x, 350, tEnemy.localEulerAngles.z); //to ensure correct rotation animation

            hSoundManager.playSound(SoundManager.EnemySounds.TiresSqueal);
            iEnemyState = 5;
        }
        else if (iEnemyState == 5)                                                                                                                            //pin behind the player
        {
            fEnemyPosition  = Mathf.Lerp(fEnemyPosition, fEnemyPositionX + 20, Time.fixedDeltaTime * 50);                                                     //vertical position after skid
            tEnemy.position = new Vector3(tEnemy.position.x, tEnemy.position.y, Mathf.Lerp(tEnemy.position.z, tPlayer.position.z + 20, Time.deltaTime * 10)); //horizontal position after skid

            tEnemy.localEulerAngles = Vector3.Lerp(tEnemy.localEulerAngles, new Vector3(0, 260, 0), Time.deltaTime * 10);                                     //90 degree rotation
            if (tEnemy.localEulerAngles.y <= 261)
            {
                iEnemyState = 6;
            }
        }
        else if (iEnemyState == 6)
        {
            hSoundManager.stopSound(SoundManager.EnemySounds.Siren);
        }
    }//end of Update