//if bullet hits ship void OnTriggerEnter2D(Collider2D collider) { PlayerBullet pBullet = collider.gameObject.GetComponent <PlayerBullet>(); // if ship hit by own bullet (bullet hell) EnemyBullet eBullet = collider.gameObject.GetComponent <EnemyBullet>(); // if ship hit by enemy bullet BossBullet bBullet = collider.gameObject.GetComponent <BossBullet>(); // if ship hit by boss bullet BossLeft bLeft = collider.gameObject.GetComponent <BossLeft>(); // if ship hits boss left gun BossRight bRight = collider.gameObject.GetComponent <BossRight>(); // if ship hits boss right gun BossCore bCore = collider.gameObject.GetComponent <BossCore>(); // if ship hits boss core Upgrade upgrade = collider.gameObject.GetComponent <Upgrade>(); // if ship hits an upgrade if (pBullet || eBullet || bBullet || bLeft || bRight || bCore) { laserCount--; AudioSource.PlayClipAtPoint(deathSound, transform.position); if (laserCount == 0) { Destroy(gameObject); GameObject shipExploding = Instantiate(explosion, transform.position, Quaternion.identity) as GameObject; Destroy(shipExploding, 1.0f); canvas.SetActive(true); } } if (upgrade) { laserCount++; } }
public Boss(Texture2D texture) : base(texture, EntityType.Boss) { Lives = 3; random = new Random(); EnemyState = new BossLeft(this); EnemyState.Enter(); SourceRectangle = new Rectangle(new Point(0, 0), new Point(32, 64)); Hit = 0; }
Animator animator; // have access to animator parameters // Use this for initialization void Start() { // have access to animators of individual boss parts animator = GetComponent <Animator>(); rightWing = GameObject.Find("RightWing").GetComponent <BossRight>(); leftWing = GameObject.Find("LeftWing").GetComponent <BossLeft>(); wholeShip = GameObject.Find("Boss").GetComponent <Boss>(); Sirens = GetComponent <AudioSource>(); }
void OnTriggerEnter2D(Collider2D collider) { PlayerController playerShip = collider.gameObject.GetComponent <PlayerController>(); // if player bullet hits player ship EnemyA enemy1 = collider.gameObject.GetComponent <EnemyA>(); // if bullet hits enemy A EnemyB enemy2 = collider.gameObject.GetComponent <EnemyB>(); // if bullet hits enemy B HellDestroyerTop destroyer = collider.gameObject.GetComponent <HellDestroyerTop>(); // The garbage bin at the top of hell mode BossRight rightWing = collider.gameObject.GetComponent <BossRight>(); // the boss's right wing BossLeft leftWing = collider.gameObject.GetComponent <BossLeft>(); // boss left wing BossCore core = collider.gameObject.GetComponent <BossCore>(); // boss core if (playerShip || enemy1 || enemy2) { Destroy(gameObject); } if (rightWing || leftWing || core) { Destroy(gameObject); GameObject bulletExploding = Instantiate(explosion, transform.position, Quaternion.identity) as GameObject; Destroy(bulletExploding, 0.2f); AudioSource.PlayClipAtPoint(explosionSound, transform.position); } if (destroyer) { hellCounter++; if (hellCounter != 4) { transform.position = new Vector3(transform.position.x, -5.2f, transform.position.z); } else { Destroy(gameObject); } } }