Exemplo n.º 1
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (!pause.gamepaused)
     {
         if (collision.gameObject.tag == "shield")
         {
             if (PlayerPrefs.GetInt("sound") == 1)
             {
                 bombexplode.Play();
             }
             Score.scorecount += 30 * Score.scoremultiplier;
             Destroy(obj);
             GameObject         dest   = Instantiate(GameObject.Find("bombexploded"), obj.transform.position, obj.transform.rotation);
             destroytroopscript script = dest.AddComponent <destroytroopscript>() as destroytroopscript;
             script.obj = dest;
             Score.bombexploded++;
         }
         else
         if (collision.gameObject.tag == "gun")
         {
             bang.SetActive(true);
             Score.flagStop = true;
             SceneManager.LoadScene(3, LoadSceneMode.Additive);
             Destroy(obj);
         }
     }
 }
Exemplo n.º 2
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (!pause.gamepaused)
     {
         if (collision.gameObject.tag == "troop")
         {
             if (obj.transform.position.x < -1.25f && obj.transform.position.y < -2.4f)
             {
                 Score.troopLeftCount += 1;
                 Destroy(objParachute);
                 Destroy(this);
             }
             else if (obj.transform.position.x > -1.25f && obj.transform.position.y < -2.4f)
             {
                 Score.troopRightCount += 1;
                 Destroy(objParachute);
                 Destroy(this);
             }
         }
         if (collision.gameObject.tag == "line")
         {
             if (obj.transform.position.x < -1.25f)
             {
                 Score.troopLeftCount += 1;
             }
             else
             {
                 Score.troopRightCount += 1;
             }
             Destroy(this);
         }
         if (collision.gameObject.tag == "bullet")
         {
             if (PlayerPrefs.GetInt("sound") == 1)
             {
                 troopexplode.Play();
             }
             Score.scorecount += 5 * Score.scoremultiplier;
             Destroy(obj);
             Destroy(objParachute);
             Destroy(collision.gameObject);
             GameObject         desttroop = GameObject.Find("desttroop1");
             GameObject         dest      = Instantiate(desttroop, obj.transform.position, obj.transform.rotation);
             destroytroopscript script    = dest.AddComponent <destroytroopscript>() as destroytroopscript;
             script.obj = dest;
             Score.troopkilled++;
         }
     }
 }
Exemplo n.º 3
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (!pause.gamepaused)
     {
         if (collision.gameObject.tag == "bullet")
         {
             if (PlayerPrefs.GetInt("sound") == 1)
             {
                 troopexplode.Play();
             }
             Score.scorecount += 5 * Score.scoremultiplier;
             Destroy(parachute);
             Destroy(troop);
             Destroy(collision.gameObject);
             GameObject         desttroop = GameObject.Find("desttroop1");
             GameObject         dest      = Instantiate(desttroop, troop.transform.position, troop.transform.rotation);
             destroytroopscript script    = dest.AddComponent <destroytroopscript>() as destroytroopscript;
             script.obj = dest;
             Score.troopkilled++;
         }
     }
 }
Exemplo n.º 4
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (!pause.gamepaused)
        {
            if (collision.gameObject.tag == "leftheli")
            {
                if (PlayerPrefs.GetInt("sound") == 1)
                {
                    jetexplode.Play();
                }
                Score.scorecount += 10 * Score.scoremultiplier;
                Destroy(obj);
                Destroy(collision.gameObject);
                GameObject         desthj = GameObject.Find("destroyhelijet");
                GameObject         dest   = Instantiate(desthj, collision.gameObject.transform.position, collision.gameObject.transform.rotation);
                destroytroopscript script = dest.AddComponent <destroytroopscript>() as destroytroopscript;
                script.obj = dest;
                Score.hjdestroyed++;
            }
            if (collision.gameObject.tag == "rightheli")
            {
                if (PlayerPrefs.GetInt("sound") == 1)
                {
                    jetexplode.Play();
                }
                Score.scorecount += 10 * Score.scoremultiplier;
                Destroy(obj);
                Destroy(collision.gameObject);
                GameObject         desthj = GameObject.Find("destroyhelijet");
                GameObject         dest   = Instantiate(desthj, collision.gameObject.transform.position, collision.gameObject.transform.rotation);
                destroytroopscript script = dest.AddComponent <destroytroopscript>() as destroytroopscript;
                script.obj = dest;
                Score.hjdestroyed++;
            }
            if (collision.gameObject.tag == "bomb")
            {
                if (PlayerPrefs.GetInt("sound") == 1)
                {
                    bombexplode.Play();
                }
                Score.scorecount += 30 * Score.scoremultiplier;
                Destroy(obj);
                Destroy(collision.gameObject);
                GameObject         desthj = GameObject.Find("bombexploded");
                GameObject         dest   = Instantiate(desthj, collision.gameObject.transform.position, collision.gameObject.transform.rotation);
                destroytroopscript script = dest.AddComponent <destroytroopscript>() as destroytroopscript;
                script.obj = dest;
                Score.bombexploded++;
            }
            if (collision.gameObject.tag == "rocket")
            {
                if (PlayerPrefs.GetInt("sound") == 1)
                {
                    bombexplode.Play();
                }
                Score.scorecount += 50 * Score.scoremultiplier;
                Destroy(obj);
                Destroy(collision.gameObject);
                GameObject         desthj = GameObject.Find("bombexploded");
                GameObject         dest   = Instantiate(desthj, collision.gameObject.transform.position, collision.gameObject.transform.rotation);
                destroytroopscript script = dest.AddComponent <destroytroopscript>() as destroytroopscript;
                script.obj = dest;
            }
            if (collision.gameObject.tag == "spaceship")
            {
                if (PlayerPrefs.GetInt("sound") == 1)
                {
                    jetexplode.Play();
                }
                Destroy(obj);
                Destroy(collision.gameObject);
                if (bang)
                {
                    bang.SetActive(true);
                }
                Score.flagStop = true;
                SceneManager.LoadScene(3, LoadSceneMode.Additive);
            }

            if (Score.flagStop)
            {
                Destroy(this);
            }
        }
    }