void FixedUpdate() { isImortal = lifeScript.IsImortal; //Spawn powerups if (lifeScript.GetLife() < maxLife / 2 && !firstPowerupSpawned) { firstPowerupSpawned = true; Instantiate(powerup, transform.position, transform.rotation); } if (lifeScript.GetLife() < (maxLife / 2) / 2 && firstPowerupSpawned && !secondPowerupSpawned) { secondPowerupSpawned = true; Instantiate(powerup, transform.position, transform.rotation); } //Destroy the object if life is lower than 0 if (lifeScript.GetLife() <= 0) { particlesContainer.transform.SetParent(null); Destroy(gameObject, 5); transform.position = Vector2.MoveTowards(transform.position, transform.up * 500, Time.deltaTime); GetComponent <PolygonCollider2D>().enabled = false; transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.AngleAxis(60, Vector3.forward), 1 * Time.deltaTime); if (!defeated) { SoundManager.instance.Play(SoundManager.clip.bossHit); //Play sound StartCoroutine(Fade()); SpawnPoints(); } } }
void Update() { GetLifes(); //Check current stage switch (currentStage) { case stage.Left: if (leftArm.GetLife() <= 0) { leftArm_Destroyed = true; currentStage = stage.Right; StartCoroutine(SwitchPhase()); } break; case stage.Right: if (rightArm.GetLife() <= 0) { rightArm_Destroyed = true; currentStage = stage.Head; StartCoroutine(SwitchPhase()); } break; case stage.Head: if (head.GetLife() <= 0) { DetatchObjects(thirdSequenceObj); StartCoroutine("WinSequence"); pauseSnap.TransitionTo(0.2f); } break; } }
void FixedUpdate() { //Destroy the object if life is lower than 0 if (lifeScript.GetLife() <= 0) { for (int i = 0; i < numberOfPoints; i++) { GameObject point = poolPoint.GetBullet(); point.transform.position = new Vector2(Random.Range(transform.position.x - pointSpawnRadius, transform.position.x + pointSpawnRadius), Random.Range(transform.position.y - pointSpawnRadius, transform.position.y + pointSpawnRadius)); point.SetActive(true); } particlesContainer.transform.SetParent(null); SoundManager.instance.Play(SoundManager.clip.enemyDeath); if (!Application.isEditor) { VibrationController.Vibrate(50); } if (dropUpgrade) { Instantiate(upgradeObject, transform.position, Quaternion.identity); } Destroy(gameObject); } //Rotate the object rotateObject.transform.Rotate(Vector3.forward * Time.deltaTime * rotationSpeed); }
void Start() { poolPoint = GameObject.FindGameObjectWithTag("PoolPoint").GetComponent <BulletPooler>(); //Point pooler spriteRendererComponent = transform.Find("EnemySprite").GetComponent <SpriteRenderer>(); //Enemy sprite lifeScript = GetComponent <EnemyLife>(); //Get life script maxLife = lifeScript.GetLife(); //get maximum life }