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); }
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()); }
// Use this for initialization void Awake() { gp = GameObject.Find("Points").GetComponent <GestionPuntos>(); spawn = GameObject.Find("SpawnEnemyCore").GetComponent <SpawnEnemyScript>(); anim = gameObject.GetComponent <Animator>(); bullet3 = GameObject.Find("Bullet3").GetComponent <Bullet3>(); points3 = gameObject.GetComponent <Text>(); }
void Shoot() { GameObject bulletGO = (GameObject)Instantiate(bullet, bulletSpawn.position, bulletSpawn.rotation); Bullet3 bullets = bulletGO.GetComponent <Bullet3>(); soundPlayer.Play(); if (bullets != null) { bullets.Seek(target); } }
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); } }
// Use this for initialization void Start() { //bullet = GameObject.Find("Bullet").GetComponent<Bullet1>(); bullet = GetComponentInParent <Bullet3>(); 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!"; }
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; }
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; } }
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); } }