void Update()
    {
        if (hInGameScriptCS.isGamePaused() == true)
        {
            return;
        }

        if (hInGameScriptCS.isEnergyZero())
        {
            if (DeathScene())
            {
                return;
            }
        }

        if (hInGameScriptCS.isCustomMenuEnabled())
        {
            getClicks();           //get taps/clicks for pause menu etc.
        }
        if (mecanimEnabled)        //reset parameters for next frame
        {
            aPlayerMecAnim.SetBool("StrafeLeftAnim", false);
            aPlayerMecAnim.SetBool("StrafeRightAnim", false);
        }

        if (bControlsEnabled)
        {
            SwipeMovementControl();
        }
    }    //end of update()
    void FixedUpdate()
    {
        //pause the powerup's time if the game is paused
        if (hInGameScriptCS.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
    }
Exemple #3
0
    void FixedUpdate()
    {
        StartCoroutine(toggleFootStepsSound());

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

        if (bPlayFootsteps == true)
        {
            //adjust footsteps pitch according to movement speed
            asCharacterSounds [(int)CharacterSounds.Footsteps].pitch = hControllerScriptCS.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 Update()
    {
        if (hInGameScriptCS.isGamePaused() == true)
        {
            return;
        }

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

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

        //destroy the patch if the Player has crossed it
        if (tPlayer.position.x > (iCurrentPNum * fPatchDistance) + 100.0f)
        {
            Destroy(goPreviousPatch);
            iCurrentPNum++;
        }
    }    //end of update
Exemple #7
0
    }    //end of Start

    void FixedUpdate()
    {
        if (hInGameScriptCS.isGamePaused() == true)
        {
            return;
        }

        UpdateHUDStats();

        //show distance notification after covering 500 meters
        if (iDistanceNotifState == 0 &&
            (Mathf.Round(fCurrentDistance) % fDistanceNotification) == 0 &&
            fCurrentDistance != 0)
        {
            StartCoroutine("displayDistanceNotificaiton");
        }
    }    //end of Fixed Update
    void Update()
    {
        if (hInGameScriptCS.isGamePaused() == true)
        {
            return;
        }

        //destroy the patch if the Player has crossed it
        //if(tPlayer.position.x>(iCurrentPNum*fPatchDistance)+100.0f)
        if (isCross)
        {
            dElapseTime += Time.deltaTime;
            if (dElapseTime > 1)
            {
                isCross = false;
                Destroy(goPreviousPatch);
                iCurrentPNum++;
            }
        }
    }    //end of update
Exemple #9
0
    void FixedUpdate()
    {
        if (hInGameScriptCS.isGamePaused() == true)
        {
            return;
        }

        if (PUState == 1)                                                                                       //hide the powerup
        {
            if (hPowerupsMainControllerCS.isPowerupActive(PowerupsMainControllerCS.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 == PowerupsMainControllerCS.PowerUps.Currency ||
                    hPowerupsMainControllerCS.isPowerupActive(PowerupsMainControllerCS.PowerUps.Magnetism) == true)
                {
                    toggleMeshRenderer(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 == PowerupsMainControllerCS.PowerUps.Currency)
                {
                    toggleMeshRenderer(false);
                }
                else
                {
                    this.gameObject.SetActive(false);
                }
            }
        }

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

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

            hPowerupsMainControllerCS.collectedPowerup((int)powerupType);            //tell power-up main script what has been collected
        }

        //make the power-up spin on if its not currency
        if (powerupType != PowerupsMainControllerCS.PowerUps.Currency)
        {
            this.transform.Rotate(0, Time.deltaTime * 160, 0);
        }
    }
    void FixedUpdate()
    {
        if (hInGameScriptCS.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 (!hControllerScriptCS.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, -hControllerScriptCS.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;

                hSoundManagerCS.stopSound(SoundManagerCS.EnemySounds.Siren);
            }
        }
        else if (iEnemyState == 2)        //show the chasing character
        {
            hSoundManagerCS.playSound(SoundManagerCS.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
        {
            //to ensure correct rotation animation
            tEnemy.localEulerAngles = new Vector3(tEnemy.localEulerAngles.x, 350, tEnemy.localEulerAngles.z);

            hSoundManagerCS.playSound(SoundManagerCS.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)
        {
            hSoundManagerCS.stopSound(SoundManagerCS.EnemySounds.Siren);
        }
    }    //end of Update
Exemple #11
0
    void FixedUpdate()
    {
        if (hInGameScriptCS.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);
         */


        Matrix4x4 mat = new Matrix4x4();

        mat.SetTRS(new Vector3(0, 0, 0), Quaternion.Euler(new Vector3(0, -hControllerScriptCS.getCurrentPlayerRotation(), 0)), new Vector3(1, 1, 1));
        Vector3 pos = mat.MultiplyVector(new Vector3(-fEnemyPosition, 0, 0));

        tEnemy.position = new Vector3(Mathf.Lerp(tEnemy.position.x, (tPlayer.position.x + pos.x), Time.deltaTime * 10),
                                      tEnemy.position.y,        // Mathf.Lerp(tEnemy.position.y, (tPlayer.position.y - pos.y), Time.deltaTime*10),
                                      Mathf.Lerp(tEnemy.position.z, (tPlayer.position.z + pos.z), Time.deltaTime * 10));

        if (!hControllerScriptCS.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);
        }
        else
        {
            RaycastHit hitInfo;
            if (Physics.Linecast(tEnemy.position + new Vector3(0, 20, 0), tEnemy.position + new Vector3(0, -100, 0), out hitInfo, (1 << LayerMask.NameToLayer("Terrain_lyr"))))
            {
                tEnemy.position = new Vector3(tEnemy.position.x, Mathf.Lerp(tEnemy.position.y, hitInfo.point.y + fEnemyPositionY, Time.deltaTime * 8),
                                              tEnemy.position.z);
            }
        }

        //ignore y-axis rotation and horizontal movement in idle and death state
        if (iEnemyState < 4)
        {
            //	Vector3 pos = mat.MultiplyVector(new Vector3( 0, 0, 0));

            //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, -hControllerScriptCS.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;

                hSoundManagerCS.stopSound(SoundManagerCS.EnemySounds.Siren);
            }
        }
        else if (iEnemyState == 2)        //show the chasing character
        {
            hSoundManagerCS.playSound(SoundManagerCS.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
        {
            //to ensure correct rotation animation
            tEnemy.localEulerAngles = new Vector3(tEnemy.localEulerAngles.x, 350 - hControllerScriptCS.getCurrentPlayerRotation(), tEnemy.localEulerAngles.z);

            hSoundManagerCS.playSound(SoundManagerCS.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 - hControllerScriptCS.getCurrentPlayerRotation(), 0), Time.deltaTime * 10);      //90 degree rotation
            if (tEnemy.localEulerAngles.y <= 261)
            {
                iEnemyState = 6;
            }
        }
        else if (iEnemyState == 6)
        {
            hSoundManagerCS.stopSound(SoundManagerCS.EnemySounds.Siren);
        }
    }    //end of Update