Exemplo n.º 1
0
    // Use this for initialization
    void Awake()
    {
        gp    = GameObject.Find("Points").GetComponent <GestionPuntos>();
        spawn = GameObject.Find("SpawnEnemyCore").GetComponent <SpawnEnemyScript>();

        anim = gameObject.GetComponent <Animator>();

        bullet4 = GameObject.Find("Bullet4").GetComponent <Bullet4>();
        points4 = gameObject.GetComponent <Text>();
    }
Exemplo n.º 2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Bullet1")
        {
            bull1 = collision.gameObject.GetComponent <Bullet1>();

            if (bull1.rainbow)
            {
                vida--;

                //tempo = 0;
            }
        }

        if (collision.gameObject.tag == "Bullet2")
        {
            bull2 = collision.gameObject.GetComponent <Bullet2>();

            if (bull2.rainbow)
            {
                vida--;
                //tempo = 0;
            }
        }

        if (collision.gameObject.tag == "Bullet3")
        {
            bull3 = collision.gameObject.GetComponent <Bullet3>();

            if (bull3.rainbow)
            {
                vida--;
                //tempo = 0;
            }
        }

        if (collision.gameObject.tag == "Bullet4")
        {
            bull4 = collision.gameObject.GetComponent <Bullet4>();

            if (bull4.rainbow)
            {
                vida--;
                //tempo = 0;
            }
        }

        if (fugida && collision.gameObject.tag == "EndofZone")
        {
            Destroy(gameObject, 5);
        }
    }
Exemplo n.º 3
0
    void Start()
    {
        gp = GameObject.Find("Points").GetComponent <GestionPuntos>();

        bullet1        = GameObject.Find("Bullet1").GetComponent <Bullet1>();
        bullet2        = GameObject.Find("Bullet2").GetComponent <Bullet2>();
        bullet3        = GameObject.Find("Bullet3").GetComponent <Bullet3>();
        bullet4        = GameObject.Find("Bullet4").GetComponent <Bullet4>();
        SpawnEnemyCore = GameObject.Find("SpawnEnemyCore").GetComponent <SpawnEnemyScript>();

        playerObjectiu = Random.Range(1, 4);    // esta chapat a 1 per fer probes, haura de ser un 4
        FindAllPlayers();
        vida  = 1;
        tempo = 5;

        rendContent.enabled = false;
        rendNormal.enabled  = true;
    }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        //bullet = GameObject.Find("Bullet").GetComponent<Bullet1>();
        bullet  = GetComponentInParent <Bullet4>();
        text    = gameObject.GetComponent <Text>();
        do_once = true;
        color   = Random.Range(0, 4);
        name    = Random.Range(0, 6);

        names = new string[6];

        names[0] = "SEXY";
        names[1] = "KAWAII";
        names[2] = "LOVE";
        names[3] = "PRETTY";
        names[4] = "NICE";
        names[5] = "U\nROCK!";
    }
Exemplo n.º 5
0
    void Shoot()
    {
        GameObject Bullet;
        GameObject Bullet2;
        GameObject Bullet3;
        GameObject Bullet4;
        GameObject Bullet5;

        BulletPhase = Random.Range(1, 6);

        switch (BulletPhase)
        {
        case 1:
            // Create projectile
            Bullet = Instantiate(Projectile, FirePoint.transform.position, transform.rotation);     // Middle

            // Slow bullets
            Bullet.GetComponent <S_Bullet>().SetBulletSpeed(BulletSpeed, 5f);
            break;

        case 2:
            // Create projectile
            Bullet  = Instantiate(Projectile, FirePoint.transform.position, transform.rotation);    // Left
            Bullet2 = Instantiate(Projectile, FirePoint.transform.position, transform.rotation);    // Right

            // Spawn bullets apart by set degrees
            Bullet.GetComponent <S_Bullet>().ChangeBulletDirection(new Vector3(1f, 0.5f, 0f));
            Bullet2.GetComponent <S_Bullet>().ChangeBulletDirection(new Vector3(1f, -0.5f, 0f));

            // Slow bullets
            Bullet.GetComponent <S_Bullet>().SetBulletSpeed(BulletSpeed, 5f);
            Bullet2.GetComponent <S_Bullet>().SetBulletSpeed(BulletSpeed, 5f);
            break;

        case 3:
            // Create projectile
            Bullet  = Instantiate(Projectile, FirePoint.transform.position, transform.rotation);    // Left
            Bullet2 = Instantiate(Projectile, FirePoint.transform.position, transform.rotation);    // Middle
            Bullet3 = Instantiate(Projectile, FirePoint.transform.position, transform.rotation);    // Right

            // Spawn bullets apart by set degrees
            Bullet.GetComponent <S_Bullet>().ChangeBulletDirection(new Vector3(1f, 0.5f, 0f));
            Bullet3.GetComponent <S_Bullet>().ChangeBulletDirection(new Vector3(1f, -0.5f, 0f));

            // Slow bullets
            Bullet.GetComponent <S_Bullet>().SetBulletSpeed(BulletSpeed, 5f);
            Bullet2.GetComponent <S_Bullet>().SetBulletSpeed(BulletSpeed, 5f);
            Bullet3.GetComponent <S_Bullet>().SetBulletSpeed(BulletSpeed, 5f);
            break;

        case 4:
            // Create projectile
            Bullet  = Instantiate(Projectile, FirePoint.transform.position, transform.rotation);    // Upper Left
            Bullet2 = Instantiate(Projectile, FirePoint.transform.position, transform.rotation);    // Left
            Bullet3 = Instantiate(Projectile, FirePoint.transform.position, transform.rotation);    // Right
            Bullet4 = Instantiate(Projectile, FirePoint.transform.position, transform.rotation);    // Upper Right

            // Spawn bullets apart by set degrees
            Bullet.GetComponent <S_Bullet>().ChangeBulletDirection(new Vector3(1f, 0.6f, 0f));    // Upper Left
            Bullet2.GetComponent <S_Bullet>().ChangeBulletDirection(new Vector3(1f, 0.3f, 0f));   // Left
            Bullet3.GetComponent <S_Bullet>().ChangeBulletDirection(new Vector3(1f, -0.3f, 0f));  // Right
            Bullet4.GetComponent <S_Bullet>().ChangeBulletDirection(new Vector3(1f, -0.6f, 0f));  // Upper Right

            // Slow bullets
            Bullet.GetComponent <S_Bullet>().SetBulletSpeed(BulletSpeed, 5f);
            Bullet2.GetComponent <S_Bullet>().SetBulletSpeed(BulletSpeed, 5f);
            Bullet3.GetComponent <S_Bullet>().SetBulletSpeed(BulletSpeed, 5f);
            Bullet4.GetComponent <S_Bullet>().SetBulletSpeed(BulletSpeed, 5f);
            break;

        case 5:
            // Create projectile
            Bullet  = Instantiate(Projectile, FirePoint.transform.position, transform.rotation);    // Upper Left
            Bullet2 = Instantiate(Projectile, FirePoint.transform.position, transform.rotation);    // Left
            Bullet3 = Instantiate(Projectile, FirePoint.transform.position, transform.rotation);    // Middle
            Bullet4 = Instantiate(Projectile, FirePoint.transform.position, transform.rotation);    // Right
            Bullet5 = Instantiate(Projectile, FirePoint.transform.position, transform.rotation);    // Upper Right

            // Spawn bullets apart by set degrees
            Bullet.GetComponent <S_Bullet>().ChangeBulletDirection(new Vector3(1f, 0.9f, 0f));    // Upper Left
            Bullet2.GetComponent <S_Bullet>().ChangeBulletDirection(new Vector3(1f, 0.5f, 0f));   // Left
            Bullet4.GetComponent <S_Bullet>().ChangeBulletDirection(new Vector3(1f, -0.5f, 0f));  // Right
            Bullet5.GetComponent <S_Bullet>().ChangeBulletDirection(new Vector3(1f, -0.9f, 0f));  // Upper Right

            // Slow bullets
            Bullet.GetComponent <S_Bullet>().SetBulletSpeed(BulletSpeed, 5f);
            Bullet2.GetComponent <S_Bullet>().SetBulletSpeed(BulletSpeed, 5f);
            Bullet3.GetComponent <S_Bullet>().SetBulletSpeed(BulletSpeed, 5f);
            Bullet4.GetComponent <S_Bullet>().SetBulletSpeed(BulletSpeed, 5f);
            Bullet5.GetComponent <S_Bullet>().SetBulletSpeed(BulletSpeed, 5f);
            break;

        default:
            Debug.Log("Bullet Phase not found");
            break;
        }
    }
Exemplo n.º 6
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "p1" && !ent)
        {
            player1       = collision.gameObject.GetComponent <P1>();
            player1.isSad = true;
            ent           = true;
            vida--;
            tempo = 0;
        }
        if (collision.gameObject.tag == "p2" && !ent)
        {
            player2       = collision.gameObject.GetComponent <P2>();
            player2.isSad = true;
            ent           = true;
            vida--;
            tempo = 0;
        }
        if (collision.gameObject.tag == "p3" && !ent)
        {
            player3       = collision.gameObject.GetComponent <P3>();
            player3.isSad = true;
            ent           = true;
            vida--;
            tempo = 0;
        }
        if (collision.gameObject.tag == "p4" && !ent)
        {
            player4       = collision.gameObject.GetComponent <P4>();
            player4.isSad = true;
            ent           = true;
            vida--;
            tempo = 0;
        }

        if (collision.gameObject.tag == "Bullet1" /* && EstaEnDefensa() == false*/)
        {
            bull1 = collision.gameObject.GetComponent <Bullet1>();

            if (bull1.rainbow)
            {
                ent           = true;
                gp.P1_points += 10;
                vida--;
                tempo = 0;
            }
        }

        if (collision.gameObject.tag == "Bullet2" /* && EstaEnDefensa() == false*/)
        {
            bull2 = collision.gameObject.GetComponent <Bullet2>();

            if (bull2.rainbow)
            {
                ent           = true;
                gp.P2_points += 10;
                vida--;
                tempo = 0;
            }
        }

        if (collision.gameObject.tag == "Bullet3" /* && EstaEnDefensa() == false*/)
        {
            bull3 = collision.gameObject.GetComponent <Bullet3>();

            if (bull3.rainbow)
            {
                ent           = true;
                gp.P3_points += 10;
                vida--;
                tempo = 0;
            }
        }

        if (collision.gameObject.tag == "Bullet4" /*&& EstaEnDefensa() == false*/)
        {
            bull4 = collision.gameObject.GetComponent <Bullet4>();

            if (bull4.rainbow)
            {
                ent           = true;
                gp.P4_points += 10;
                vida--;
                tempo = 0;
            }
        }

        if (ent && collision.gameObject.tag == "EndofZone")
        {
            Destroy(this, 5);
        }
    }