void OnTriggerEnter(Collider other) { if (!paused) { if (InvadersGameData.directionChanged == false && other.tag == "Wall") { InvadersGameData.invadersDirection *= -1.0f; InvadersGameData.directionChanged = true; InvadersGameData.descendInvaders(); } else if (other.tag == "Laser") { InvadersGameData.notifyDecease(this.invaderID); ExplodeAndDestroy(); InvadersGameData.Score = InvadersGameData.Score + 1; InvadersGameData.remainingInvaders = InvadersGameData.remainingInvaders - 1; } else if (other.tag == "Player") { playerActions pa = other.GetComponent <playerActions>(); pa.ExplodeAndDestroy(); ExplodeAndDestroy(); } } }
// Update is called once per frame void Update() { float fireConstraint = Random.value; if (!paused) { if (fireConstraint < 0.0025f && InvadersGameData.canFire(this.invaderID)) { Vector3 rPosition = transform.position; rPosition.x -= 1.5f; // logica de disparo if (fireConstraint < 0.00025f) { Instantiate(nukePrefab, rPosition, Quaternion.identity); } else { Instantiate(rocketPrefab, rPosition, Quaternion.Euler(0, 0, 270)); } } } }