Exemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.CompareTag("Meteoro"))
        {
            Instantiate(prefExplosaoMeteoro, col.gameObject.transform.position, col.gameObject.transform.rotation);

            controleScore.updateScore(10);

            Destroy(col.gameObject);
            Destroy(gameObject);
        }
        else if (col.gameObject.CompareTag("GreenEnemy"))
        {
            ControleVidaScript vida = col.gameObject.GetComponent <ControleVidaScript> ();

            Destroy(gameObject);

            if (vida.lastLife())
            {
                Destroy(col.gameObject);

                controleScore.updateScore(30);
            }
            else
            {
                vida.DecreaseOne();
            }
        }
        else if (col.gameObject.CompareTag("LaserEnemy"))
        {
            Destroy(col.gameObject);
            Destroy(gameObject);
        }
    }
Exemplo n.º 2
0
    void Start()
    {
        ship = GetComponent <Blink> ();
        GameObject[] turbinas = GameObject.FindGameObjectsWithTag("Turbina");
        turbinaEsq = turbinas [0].GetComponent <Blink> ();
        turbinaDir = turbinas [1].GetComponent <Blink> ();

        GameObject obj = GameObject.FindGameObjectWithTag("LimitesTela");

        screenLimit = obj.GetComponent <BoxCollider2D> ();

        direction = 0;
        body      = GetComponent <Rigidbody2D> ();
        origin    = body.position;
        somTiro   = GetComponent <AudioSource> ();

        lancadorLaser = GameObject.FindGameObjectWithTag("Lancador");
        vida          = GetComponent <ControleVidaScript> ();
    }
Exemplo n.º 3
0
    void Start()
    {
        //GameObject[] blinkObjects = GameObject.FindGameObjectsWithTag ("GreenEnemy");
        //turbinaEsq = blinkObjects [0].GetComponent<Blink> ();
        //turbinaDir = blinkObjects [1].GetComponent<Blink> ();
        //ship = blinkObjects [2].GetComponent<Blink> ();

        GameObject obj = GameObject.FindGameObjectWithTag("LimitesTela");

        screenLimit = obj.GetComponent <BoxCollider2D> ();

        body    = GetComponent <Rigidbody2D> ();
        somTiro = GetComponent <AudioSource> ();

        lancadorLaser = GameObject.FindGameObjectWithTag("LancadorEnemy");
        vida          = GetComponent <ControleVidaScript> ();

        velocidade = Vector2.down * Random.Range(180, 220);
        InvokeRepeating("FireEnemyBullet", 1f, Random.Range(0.4f, 0.9f));
    }