private void Start()
    {
        a = GetComponent <Bullet1>();
        b = GetComponent <Bullet2>();
        c = GetComponent <Bullet3>();

        switch (type)
        {
        case TipoDeBala.Normal:
            transform.GetComponent <Renderer>().material.color = new Color(0, 0, 1, 1);
            instBullet = a;
            break;

        case TipoDeBala.Paralizadora:
            instBullet = b;
            transform.GetComponent <Renderer>().material.color = new Color(0, 1, 1, 1);
            break;

        case TipoDeBala.Desactivadora:
            instBullet = c;
            transform.GetComponent <Renderer>().material.color = new Color(1, 0, 1, 1);
            break;

        default:
            break;
        }
        StartCoroutine(Dead2());
    }
Exemplo n.º 2
0
    void StraightShot()
    {
        GameObject Bullet;

        Bullet = (Instantiate(bulletprefab, transform.position, transform.rotation)) as GameObject;

        GameObject Bullet2;

        Bullet2 = (Instantiate(bulletprefab, transform.position, transform.rotation)) as GameObject;

        Bullet2.GetComponent <Rigidbody2D>().transform.Translate(new Vector3(1, 0, 0));

        GameObject Bullet3;

        Bullet3 = (Instantiate(bulletprefab, transform.position, transform.rotation)) as GameObject;

        Bullet3.GetComponent <Rigidbody2D>().transform.Translate(new Vector3(-1, 0, 0));



        //Bullet.GetComponent<Rigidbody2D>().AddForce(new Vector2(0, bullet_speed*Time.deltaTime));

        //Bullet.transform.Translate(Vector2(0, bullet_speed));

        //Rigidbody Bullet = (Rigidbody)Instantiate(bulletprefab, transform.position + transform.forward, transform.rotation);
        //Bullet.GetComponent<Rigidbody2D>().AddForce(transform.forward * bullet_speed, ForceMode2D.Impulse);

        Destroy(Bullet, 1);

        Destroy(Bullet2, 1);

        Destroy(Bullet3, 1);
    }
Exemplo n.º 3
0
 public override void Initialize()
 {
     base.Initialize();
     for (int i = 0; i < CountOfBullets; i++)
     {
         BulletBase bullet = new Bullet2(Danmaku, GetPosition(FiArray[i]), Danmaku.MainObject, OwnerObject, OnCollision);
         Bullets.Add(bullet);
     }
 }
Exemplo n.º 4
0
    //이함수를 animation event로 1번만 불러야 하는데....
    //12 frame -> 2번
    //60 frame -> 다수가 불리는데
    //어떻게 해야 1번만 부를나요?
    //Anmation의 동작이 loop가 아니여야한다...
    protected override void AnimationComplete(int _idx)
    {
        //Debug.Log (" > " + _idx);
        //Transform _go = Instantiate (prefabBullet, spawnPoint.position, spawnPoint.rotation);
        GameObject _go = PoolManager.ins.Instantiate("Bullet2", spawnPoint.position, spawnPoint.rotation);

        Bullet2 _scp = _go.GetComponent <Bullet2> ();

        _scp.SetTarget(tempEnemy, damage);
    }
Exemplo n.º 5
0
    // Use this for initialization
    void Awake()
    {
        gp = GameObject.Find("Points").GetComponent <GestionPuntos>();


        anim = gameObject.GetComponent <Animator>();

        spawn = GameObject.Find("SpawnEnemyCore").GetComponent <SpawnEnemyScript>();

        bullet2 = GameObject.Find("Bullet2").GetComponent <Bullet2>();
        points2 = gameObject.GetComponent <Text>();
    }
Exemplo n.º 6
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.º 7
0
    void Start()
    {
        isRendered = false;

        //弾の攻撃力とか取るためのやつ
        BulletObje = GameObject.Find("Bullet").gameObject.GetComponent <Bullet2>();

        //ミサイルの攻撃力とか取るためのやつ
        MissileObje = GameObject.Find("Missile").gameObject.GetComponent <Missile2>();

        // キャンバス下に設定するために取得
        canvas = GameObject.Find("Canvas").gameObject;

        rigidbody_a = GetComponent <Rigidbody>();
    }
Exemplo n.º 8
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.º 9
0
    // Use this for initialization
    void Start()
    {
        //bullet = GameObject.Find("Bullet").GetComponent<Bullet1>();
        bullet  = GetComponentInParent <Bullet2>();
        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.º 10
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.º 11
0
    void Update()
    {
        v   = Input.GetAxisRaw("Vertical");
        h   = Input.GetAxisRaw("Horizontal");
        dir = Constant.V3_FORWARD;

        //auto forward...
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            bMoveForward = !bMoveForward;
        }
        else if (Input.GetKeyDown(KeyCode.Comma))
        {
            bRun  = !bRun;
            speed = bRun ? speedRun : speedMove;
        }
        else if (v != 0)
        {
            eulerAngles           = transform.eulerAngles;
            eulerAngles.y         = Camera.main.transform.eulerAngles.y;
            transform.eulerAngles = eulerAngles;
        }
        else if (h != 0)
        {
            //side move -> left, right
            v   = 1;
            dir = Constant.V3_RIGHT * (h < 0 ? -1 : +1);
            if (Input.GetMouseButton(1))
            {
                //side + 우클릭...
                eulerAngles           = transform.eulerAngles;
                eulerAngles.y         = Camera.main.transform.eulerAngles.y;
                transform.eulerAngles = eulerAngles;
            }
        }
        else if (v < 0)
        {
            bMoveForward = false;
        }


        //-----------------------
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            Bullet2 _bullet = Instantiate(bullet, spawnPoint[0].position, spawnPoint[0].rotation) as Bullet2;
            //_bullet.transform.SetParent ();
            _bullet.Init();
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            Bullet2 _bullet;
            for (int i = 0, iMax = spawnPoint.Length; i < iMax; i++)
            {
                _bullet = Instantiate(bullet, spawnPoint [i].position, spawnPoint [i].rotation) as Bullet2;
                //_bullet.transform.SetParent ();
                _bullet.Init();
            }
        }

        if (bMoveForward)
        {
            v = 1;
        }

        transform.Translate(v * dir * speed * Time.deltaTime);
    }
Exemplo n.º 12
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);
        }
    }