public void FindWeaponAndTryFire(GameObject newWeapon, int i) { //encontra arma e tenta atirar cada uma sozinha switch (weaponPrefab.name) { case "BossArm": GunControllerEnemyBossArm script = newWeapon.transform.GetChild(1).GetComponent <GunControllerEnemyBossArm>(); if (script != null) { //TryFire(script.fireRate); //tentar atirar //tentar atirar de acordo com o fireRate if (tempo[i] > (1 / script.fireRate)) //tentar atirar //tiros por seg permitidos { tempo[i] = 0f; if (!script.GetIsFiring() && !(isPrepFire[i])) { StartCoroutine(PrepareToFire(newWeapon, i)); } //script.Fire(); } } else { Debug.Log("Script do BossArm nao encontrado! (Fire)"); } break; case "BossGunYellow": break; default: Debug.Log("Boss Weapon not found!"); break; } }
public void FixNewWeaponRotation(GameObject newWeapon, float newAngleDegrees) { //arruma a rotacao de cada arma para o desejado switch (weaponPrefab.name) { case "BossArm": GunControllerEnemyBossArm script = newWeapon.transform.GetChild(1).GetComponent <GunControllerEnemyBossArm>(); if (script != null) { script.Gun_Turning(newAngleDegrees); //manda rodar a partir de cima no sentido horario x graus } else { Debug.Log("Script do BossArm nao encontrado!"); } break; case "BossGunYellow": GunControllerEnemyBossGunYellow script2 = newWeapon.transform.GetChild(0).GetComponent <GunControllerEnemyBossGunYellow>(); if (script2 != null) { script2.Gun_Turning(newAngleDegrees); //manda rodar a partir de cima no sentido horario x graus } else { Debug.Log("Script do BossGunYellow nao encontrado!"); } break; default: Debug.Log("Boss Weapon not found!"); break; } }
private bool canDoDamage; //verificar se pode dar dano naquele alvo // Use this for initialization void Start() { GameObject androidArm = gameObject.transform.parent.transform.GetChild(1).gameObject; //pegar braco e seu script androidArmScript = androidArm.GetComponent <GunControllerEnemyBossArm>(); //bulletDamage = androidArmScript.bulletDamage; //setar bullet damage SetTargetAndCollisionMask(); //setar o source e a collisionMask canDoDamage = true; }
public void FindWeaponAndTryFireAllTogether() { //encontra arma e tenta atirar todas juntas switch (weaponPrefab.name) { case "BossArm": bool canFireAll = true; GunControllerEnemyBossArm[] scripts = new GunControllerEnemyBossArm[quantityOfWeapons]; for (int i = 0; i < quantityOfWeapons; i++) { //pra cada arma pegar o script scripts[i] = weapons[i].transform.GetChild(1).GetComponent <GunControllerEnemyBossArm>(); if (scripts[i] == null) //se nao encontrar um dos scripts { Debug.Log("Script do BossArm nao encontrado! (Fire)"); canFireAll = false; //nao atirar } else { //se encontrar if (!(tempo[i] > (1 / scripts[i].fireRate))) //tentar atirar //tiros por seg permitidos { //se uma das armas nao estiver no tempo de atirar canFireAll = false; //nao atirar //Debug.Log("Here1"); } else { if (!(!scripts[i].GetIsFiring() && !(isPrepFire[i]))) { //se uma das armas ainda esta atirando ou coisa do genero canFireAll = false; //nao atirar //Debug.Log("Here2"); } } } } if (canFireAll) { //atirar todas as armas juntas caso possivel for (int i = 0; i < quantityOfWeapons; i++) { //pra cada arma atirar tempo[i] = 0f; StartCoroutine(PrepareToFire(weapons[i], i)); } //Debug.Log("HERE"); } break; case "BossGunYellow": break; default: Debug.Log("Boss Weapon not found!"); break; } }
public IEnumerator PrepareToFire(GameObject newWeapon, int i) //preparar pra atirar e atirar { isPrepFire[i] = true; switch (weaponPrefab.name) { case "BossArm": GunControllerEnemyBossArm script = newWeapon.transform.GetChild(1).GetComponent <GunControllerEnemyBossArm>(); if (script != null) { //Debug.Log(newWeapon.name + ": " + newWeapon.transform.GetChild(1).transform.eulerAngles); //script.Gun_Turning(((-newWeapon.transform.GetChild(1).transform.eulerAngles.z) + 90) + 5f); script.Gun_TurningLerp(45f); yield return(new WaitForSeconds(1f)); while (script.GetIsRotating()) { yield return(null); } yield return(new WaitForSeconds(script.fireRatePlus)); //esperar tempo a mais script.Fire(); //while (!(!script.GetIsThrowingAndPulling() && !script.GetIsThrowing() && !script.GetIsPulling())) //{ // yield return null; //} } else { Debug.Log("Script do BossArm nao encontrado! (Fire)"); } break; case "BossGunYellow": break; default: Debug.Log("Boss Weapon not found!"); break; } isPrepFire[i] = false; }