示例#1
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("Car"))
     {
         SFXEvents.SFXCarFallEvent();
     }
 }
 private void HandleHornInput()
 {
     if (Input.GetKeyDown(KeyCode.H))
     {
         SFXEvents.SFXHornEvent(this.gameObject);
     }
 }
示例#3
0
    public IEnumerator Boost()
    {
        Rigidbody rb = this.GetComponent <Rigidbody>();

        rb.AddForce(rb.transform.forward * boostForce);
        SFXEvents.SFXBoostEvent(this.gameObject);   //Play boost sfx
        yield return(new WaitForSeconds(1.3f));
    }
    public void OnKickOffClick()
    {
        // save car index in PlayerPrefs
        PlayerPrefs.SetInt("CarIndex", this.carIndex);

        // load main scene:
        SceneManager.LoadScene("SampleScene");

        // play game start sfx
        SFXEvents.SFXGameStartEvent();
    }
 private void OnCollisionEnter(Collision collision)
 {
     // simulate the bouciness effect:
     if (!collision.gameObject.CompareTag("Ground") && !collision.gameObject.name.Equals("Out Zone"))
     {
         float   impactForce = collision.impulse.magnitude;
         Vector3 normal      = collision.contacts[0].normal;
         Debug.DrawRay(this.transform.position, normal, Color.red, 100);
         //rb.AddForce(normal * impactForce * this.bouncinessForce, ForceMode.VelocityChange);
         rb.AddForce(normal * this.bouncinessForce, ForceMode.VelocityChange);
         SFXEvents.SFXBounceEvent(collision.gameObject); //play bounce sfx
     }
 }
示例#6
0
    public IEnumerator Shield()
    {
        Rigidbody rb = this.GetComponent <Rigidbody>();

        rb.mass = 100000;
        if (this.name.Equals("CarPlayer"))
        {
            this.GetComponent <CarControl>().speed = 374997;
        }
        SFXEvents.SFXShieldEvent(this.gameObject);         //Play shield sfx
        this.GetComponent <MeshRenderer>().enabled = true; //Display Shield

        //Shield for X seconds
        yield return(new WaitForSeconds(this.shieldDuration));

        rb.mass = 400;
        if (this.name.Equals("CarPlayer"))
        {
            this.GetComponent <CarControl>().speed = 1500;
        }
        this.GetComponent <MeshRenderer>().enabled = false; //Hide Shield
    }
示例#7
0
    private void HandleGameLoseEvent()
    {
        // hide game UI menu:
        this.gameUiMenu.gameObject.SetActive(false);

        // update best score:
        BestScoreManager.SaveBestScore(score);

        // display game over menu:
        this.gameOverMenu.gameObject.SetActive(true);

        // update title:
        this.gameOverTitle.text = "Game Over - You Lost!";

        // update score and best score texts:
        this.scoreTxt.text     = score.ToString();
        this.bestScoreTxt.text = BestScoreManager.GetBestScore().ToString();

        // color objects accordingly:
        this.ColorGameOverMenuItems(this.loseColor);

        // play game lose sfx
        SFXEvents.SFXGameLoseEvent();
    }