Beispiel #1
0
 void IsWon()
 {
     ui.scoreUpdate();
     if (ui.score == 5)
     {
         Destroy(gameObject);
         ui.gameOverActivated();
         ui.winActivated();
     }
 }
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "Enemy Car")
        {
            Destroy(coll);
            Destroy(gameObject);

            Scene scene = SceneManager.GetActiveScene();
            if (scene.name == "level2" || scene.name == "level3" || scene.name == "level4")
            {
                lm2.liveKiller();
            }

            ui.gameOverActivated();
            if (Settings.enginesound == true)
            {
                am.carSound.Stop();
            }

            if (Settings.crashingsound == true)
            {
                am.crashSound.Play();
            }
        }
    }
Beispiel #3
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "enemy car")//jika pemain menemukan objek dengan tag enemy car maka akan hilang
     {
         Destroy(gameObject);
         ui.gameOverActivated();
     }
 }
Beispiel #4
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Enemy Car")
     {
         Destroy(gameObject);
         ui.gameOverActivated();
     }
 }
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.gameObject.tag == "ENEMY")
     {
         ui.gameOverActivated();
         Destroy(gameObject);
     }
 }
Beispiel #6
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "Kite")
     {
         Destroy(gameObject);
         ui.gameOverActivated();
     }
 }
Beispiel #7
0
 void OnCollisionEnter2D(Collision2D col)
 {
     //Debug.Log ("destroy");
     if (col.gameObject.tag == "Enemy")
     {
         Destroy(gameObject);
         ui.gameOverActivated();
     }
 }
    //if (currentPlatformAndroid == true) {
    //COde

    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "EnemyFish")
        {
            Destroy(player2);

            ui.gameOverActivated();
        }
    }
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Enemycar")
     {
         PlayerExplosion();
         Destroy(gameObject);
         ui.gameOverActivated();
     }
 }
Beispiel #10
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Enemy")
     {
         am.explode.Play();
         Destroy(gameObject);
         ui.gameOverActivated();
     }
 }
Beispiel #11
0
 // this method is called when two game object get collided
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Enemy Car")
     {
         //Destroy (gameObject);
         gameObject.SetActive(false);
         ui.gameOverActivated();
         am.carSound.Stop();
     }
 }
Beispiel #12
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.tag == "Enemy")
     {
         Destroy(gameObject);
         //Destroy(coll.gameObject);
         Time.timeScale = 0;
         ui.gameOverActivated();
         am.carSound.Stop();
     }
 }
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "EnemyCar")
        {
            gameObject.SetActive(false);

            ui.gameOverActivated();
            cr.carSound.Stop();
            cb.blast.Play();
            pr.crashParticles.Play();
        }
    }
 IEnumerator FadeOut()
 {
     for (float f = 1f; f >= -0.05f; f -= 0.05f)
     {
         Color c = rend.material.color;
         c.a = f;
         rend.material.color = c;
         yield return(new WaitForSeconds(0.05f));
     }
     ui.gameOverActivated(true);
     am.mainBg.Stop();
 }
Beispiel #15
0
 //on collision
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Enemy Car")
     {
         //if collider with an enemy car, destroy my car.
         //Destroy(gameObject);
         gameObject.SetActive(false);
         //game over stop the score
         ui.gameOverActivated();
         // stop the car sound
         am.carSound.Stop();
     }
 }
Beispiel #16
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Enemy Car" && live <= 0)
        {
            Destroy(gameObject);
            audioManager.carSound.Pause();

            uiManager.gameOverActivated();
        }
        else
        {
            live = live - dmg;
        }
    }
Beispiel #17
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "Enemy Car")
        {
            //Destroy (gameObject);
            gameObject.SetActive(false);
            ui.gameOverActivated();
            am.carSound.Stop();

            carSpeed           = 2.5f;
            trackMove.speed    = .2f;
            EnemyCarMove.speed = 3f;
        }
    }
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "Enemy")
        {
            //Destroy (gameObject);
            if (PlayerPrefs.GetInt("ScorePoints") < Scoring.points)
            {
                PlayerPrefs.SetInt("ScorePoints", Scoring.points);
            }
            PlayerPrefs.SetInt("CharacterSelected", 0);
            gameObject.SetActive(false);
            ui.gameOverActivated();

            //am.carSound.Stop();
        }
    }
Beispiel #19
0
    // Update is called once per frame
    void Update()
    {
        //test example!!!!
        if (Input.GetKeyDown(KeyCode.Q))
        {
            oxygen.CurrentVal -= 10;
        }
        if (Input.GetKeyDown(KeyCode.W))
        {
            oxygen.CurrentVal += 10;
        }

        if (oxygen.CurrentVal == 0)
        {
            ui.gameOverActivated();
            Destroy(gameObject);
        }
    }
    void OnStateCycle()
    {
        Vector3 localScale = transform.localScale;

        transform.localEulerAngles = Vector3.zero;
        //Debug.Log(currentState);

        if (health <= 0 && !deathInit)
        {
            anim.SetTrigger("Die");
            deathInit = true;


            {
                ui.gameOverActivated();
                Destroy(gameObject);
            }
        }

        switch (currentState)
        {
        case PlayerController.PlayerStates.idle:
            if (IsGrounded())
            {
                anim.SetBool("Falling", false);
                anim.SetBool("isOnWall", false);
            }
            r2d.velocity = new Vector2(0, r2d.velocity.y);
            break;

        case PlayerController.PlayerStates.left:
            if (!IsGrounded())
            {
                anim.SetBool("Walking", false);
                anim.SetBool("Falling", true);
                if (IsNextToWall())
                {
                    if (!jumpingFromWall)
                    {
                        anim.SetBool("Landing", false);
                        anim.SetBool("Falling", false);
                        anim.SetBool("Jumping", false);
                        anim.SetBool("isOnWall", true);
                        r2d.velocity = new Vector2(r2d.velocity.x, 0);
                        break;
                    }
                    jumpingFromWall = false;
                }
            }
            else
            {
                anim.SetBool("Falling", false);
                anim.SetBool("isOnWall", false);
            }

            r2d.velocity = new Vector2(-moveSpeed, r2d.velocity.y);
            if (localScale.x > 0.0f)
            {
                localScale.x        *= -1.0f;
                transform.localScale = localScale;
            }
            break;

        case PlayerController.PlayerStates.right:

            //  Debug.Log("Chão is " + IsGrounded());
            if (!IsGrounded())
            {
                anim.SetBool("Walking", false);
                anim.SetBool("Falling", true);
                if (IsNextToWall())
                {
                    if (!jumpingFromWall)
                    {
                        anim.SetBool("Landing", false);
                        anim.SetBool("Falling", false);
                        anim.SetBool("Jumping", false);
                        anim.SetBool("isOnWall", true);
                        r2d.velocity = new Vector2(r2d.velocity.x, 0);
                        break;
                    }
                    jumpingFromWall = false;
                }
            }
            else
            {
                anim.SetBool("Falling", false);
                anim.SetBool("isOnWall", false);
            }

            r2d.velocity = new Vector2(moveSpeed, r2d.velocity.y);
            if (localScale.x < 0.0f)
            {
                localScale.x        *= -1.0f;
                transform.localScale = localScale;
            }
            break;

        case PlayerController.PlayerStates.jump:
            if (IsGrounded())
            {
                OnStateChange(PlayerController.PlayerStates.falling);
            }
            break;

        case PlayerController.PlayerStates.landing:
            break;

        case PlayerController.PlayerStates.falling:
            if (IsGrounded())
            {
                OnStateChange(PlayerController.PlayerStates.landing);
            }
            //if (IsNextToWall()) anim.SetBool("Falling", false);
            break;

        case PlayerController.PlayerStates.kill:
            OnStateChange(PlayerController.PlayerStates.resurrect);
            break;

        case PlayerController.PlayerStates.resurrect:
            OnStateChange(PlayerController.PlayerStates.idle);
            break;
        }
    }