Exemple #1
0
 private void OnTriggerEnter(Collider other)
 {
     Destroy(gameObject);
     if (!gameObject.CompareTag("Bad"))
     {
         gameManager.GameOver();
     }
 }
Exemple #2
0
    void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.tag != "walltop")
        {
            // Zero out the bird's velocity
            rb2d.velocity = Vector2.zero;
            // If the bird collides with something set it to dead...
            isDead = true;
            //...tell the Animator about it...
            anim.SetTrigger("Die");
            //...and tell the game control about it.
            // GameControl.instance.BirdDied ();

            gameManage.GameOver();

            AudioControl.PlayOneShot(AudioDead);
            StartCoroutine(StopAudio());
        }
    }
Exemple #3
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     Gamemanager.GameOver();
 }
Exemple #4
0
    // Update is called once per frame
    void Update()
    {
        if (tS < 0)
        {
            if (GameObject.Find("z" + i))
            {
                zo = GameObject.Find("z" + i);
            }
            else
            {
                i++;
            }
        }
        else
        {
            tS = tS - Time.deltaTime;
            zo = GameObject.Find("yyyy");
        }
        if (GameObject.Find("zb"))
        {
            zob = GameObject.Find("zb");
        }
        else
        {
            zob = GameObject.Find("yyyy");
        }
        x  = zo.GetComponent <Enemies> ();
        xx = zob.GetComponent <EnemyBosses> ();
        float   tempy = box.size.y;
        float   horiz = Input.GetAxis("Horizontal");
        float   vert  = Input.GetAxis("Vertical");
        Vector2 gerak = new Vector2(horiz, vert);

        if (!gameOver)
        {
            rig.velocity = (gerak * speed);
            if (rig.velocity.x < 0)                                             //move
            {
                rend.flipX = true;
            }
            else if (rig.velocity.x > 0)
            {
                rend.flipX = false;
            }

            if (Input.GetKeyDown("space"))                              //attackinput
            {
                rend.sprite = manw;
                box.size    = new Vector2(1.07f, tempy);                                //change collider
            }
            if (t > 0)                                                                  //attack
            {
                t = t - 1 * Time.deltaTime;
            }
            else
            {
                rend.sprite = origin;
                box.size    = new Vector2(0.63f, tempy);                                        //change collider original
                t           = 0.4f;
            }
        }
        //lvl up
        if (exp >= maxExp)
        {
            level += 1;
            maxHp  = Mathf.Round(maxHp * 1.03f);
            hp     = maxHp;
            maxExp = Mathf.Round(maxExp * 1.5f);
            speed  = speed * 1.001f;
            atk    = atk * 1.2f;
            manager.PopUpT();
        }
        if (manager.CPop())
        {
            if (ti > 0)
            {
                ti = ti - Time.deltaTime;
            }
            else
            {
                manager.PopUpF();
                ti = 1f;
            }
        }
        if (check)                                                                                              //decrease hp
        {
            if (!gameOver)
            {
                if (ti > 0)
                {
                    ti = ti - Time.deltaTime;
                }
                else
                {
                    float temp = x.atk;
                    hp = hp - (temp * zos.Count);
                    ti = 1f;
                    manager.PopUpF();
                    //				Debug.Log (x.atk);
                }
            }
            check = false;
        }
        if (checkz)                                                                                             //decrease hp
        {
            if (!gameOver)
            {
                if (tj > 0)
                {
                    tj = tj - Time.deltaTime;
                }
                else
                {
                    float temp1 = xx.atk;
                    hp = hp - (temp1 * zbos.Count);
                    tj = 1f;
                    manager.PopUpF();
                    //Debug.Log (xx.atk);
                }
            }
            checkz = false;
        }
        //Constraint position
        if (transform.position.y >= 2.23f)
        {
            if (rig.velocity.y > 0)
            {
                rig.velocity = new Vector2(0, 0);
            }
        }
        else if (transform.position.y <= -4.11f)
        {
            if (rig.velocity.y < 0)
            {
                rig.velocity = new Vector2(0, 0);
            }
        }
        if (transform.position.x >= 8.53f)
        {
            if (rig.velocity.x > 0)
            {
                rig.velocity = new Vector2(0, 0);
            }
        }
        else if (transform.position.x <= -8.51f)
        {
            if (rig.velocity.x < 0)
            {
                rig.velocity = new Vector2(0, 0);
            }
        }

        if (hp <= 0)                                                            //Game over
        {
            manager.GameOver();
            gameOver = true;
            hp       = 0;
            if (ti > 0)
            {
                ti = ti - Time.deltaTime;
            }
            else
            {
                SceneManager.LoadScene("mainmenu");
            }
        }
        if (PlayerPrefs.GetInt("zkill") < kill)
        {
            PlayerPrefs.SetInt("zkill", kill);
        }
    }