private void EndMovement() { _currentState = bossStates.shooting; _shotCounter = 0f; _anim.SetTrigger("StopMoving"); _hitBox.gameObject.SetActive(true); }
private void EndMovement() { currentState = bossStates.shooting; shotCounter = timeBetweenShots; anim.SetTrigger("StopMoving"); }
public void TakeHit() { _currentState = bossStates.hurt; _hurtCounter = _currHurtTime; _anim.SetTrigger("Hit"); AudioManager.Instance.PlaySFX(0); BossTankMine[] mines = FindObjectsOfType <BossTankMine>(); if (mines.Length > 0f) { foreach (BossTankMine foundMine in mines) { foundMine.Explode(); } } _currentHP--; _moveSpeed++; if (_currentHP <= 0) { _isDefeated = true; } else //increase fire rate { _timeBetweenShots /= _shotSpeedUp; _timeBetweenMines /= _mineSpeedUp; } }
private void endMovement() { currentState = bossStates.shooting; shotCounter = 0f; anim.SetTrigger("StopMoving"); hitBox.SetActive(true); }
public void TakeHit() { currentState = bossStates.hurt; hurtCounter = hurtTime; anim.SetTrigger("Hit"); AudioManager.instance.PlaySFX(0); BossTankMine[] mines = FindObjectsOfType <BossTankMine>(); if (mines.Length > 0) { foreach (BossTankMine foundMine in mines) { foundMine.Explode(); } } health--; if (health <= 0) { isDefeated = true; } else { timeBetweenShots /= shotSpeedUp; timeBetweenMines /= mineSpeedUp; } }
void checkTime(int attack) { if (Time.time > lastAttackTime + attackDelay) { currentState = bossStates.idle; lastAttack = (bossStates)attack; lastAttackTime = Time.time; } }
private void EndMovement() { currentState = bossStates.shooting; // shotCounter = timeBetweenShots; shotCounter = 0f; anim.SetTrigger("StopMoving"); hitBox.SetActive(true); }
private void idle() { if (Time.time > lastAttackTime + idleDelay) { bossStates newAttack = (bossStates)Random.Range(1, 4); if (lastAttack != newAttack) { currentState = newAttack; lastAttackTime = Time.time; } } }
public void Damage(int damage) { anim.SetTrigger("Hit"); gameObject.GetComponent <Animation>().Play("RedFlash_Player"); health -= damage; currentState = bossStates.hurt; hurtCounter = hurtTime; if (health <= 0) { Destroy(gameObject); AudioManager.instance.PlaySFX(8); } }
private void bossHurt() { if (hurtCounter > 0) { hurtCounter -= Time.deltaTime; if (hurtCounter <= 0) { currentState = bossStates.moving; mineCounter = 0; if (isDefeated) { TheBoss.gameObject.SetActive(false); Instantiate(explosion, TheBoss.position, TheBoss.rotation); platformEnding.SetActive(true); AudioManager.instance.stopBossMusic(); currentState = bossStates.ended; } } } }
void Start() { currentState = bossStates.idle; lastAttack = bossStates.idle; lastAttackTime = Time.time; }
private void Update() { switch (_currentState) { case bossStates.shooting: //shoot cooldown _shotCounter -= Time.deltaTime; //can shoot again if (_shotCounter <= 0f) { _shotCounter = _timeBetweenShots; var newBullet = Instantiate(_bulletObj, _firePoint.position, _firePoint.rotation); newBullet.transform.localScale = _theBoss.localScale; } break; case bossStates.hurt: if (_hurtCounter > 0) { _hurtCounter -= Time.deltaTime; if (_hurtCounter <= 0f) { _currentState = bossStates.moving; _mineCounter = 0f; if (_isDefeated) { _theBoss.gameObject.SetActive(false); Instantiate(_explosion, _theBoss.position, _theBoss.rotation); foreach (GameObject go in _activateObjects) { go.SetActive(true); } AudioManager.Instance.StopBossMusic(); _currentState = bossStates.ended; } } } break; case bossStates.moving: if (_isMovingRight) { _theBoss.position += new Vector3(_moveSpeed * Time.deltaTime, 0f, 0f); //stop moving if (_theBoss.position.x > _rightPoint.position.x) { _theBoss.localScale = new Vector3(1f, 1f, 1f); _isMovingRight = false; EndMovement(); } } else { _theBoss.position -= new Vector3(_moveSpeed * Time.deltaTime, 0f, 0f); //stop moving if (_theBoss.position.x < _leftPoint.position.x) { _theBoss.localScale = new Vector3(-1f, 1f, 1f); _isMovingRight = true; EndMovement(); } } //Plant mines _mineCounter -= Time.deltaTime; if (_mineCounter <= 0f) { _mineCounter = _timeBetweenMines; Instantiate(_mineObj, _minePoint.position, _minePoint.rotation); } break; } #if UNITY_EDITOR if (Input.GetKeyDown(KeyCode.H)) { TakeHit(); } #endif }
private void Start() { _currentState = bossStates.shooting; PlayerHealthController.OnPlayerDied += ResetBoss; }
// Start is called before the first frame update void Start() { currentState = bossStates.shooting; player = FindObjectOfType <Player>(); }
// Update is called once per frame void Update() { switch (currentState) { case bossStates.shooting: shotCounter -= Time.deltaTime; if (shotCounter <= 0) { shotCounter = timeBetweenShots; var newBullet = Instantiate(bullet, firePoint.position, firePoint.rotation); newBullet.transform.localScale = theBoss.localScale; } break; case bossStates.hurt: if (hurtCounter > 0) { hurtCounter -= Time.deltaTime; if (hurtCounter <= 0) { currentState = bossStates.moving; } } break; case bossStates.moving: if (moveRight) { theBoss.position += new Vector3(moveSpeed * Time.deltaTime, 0f, 0f); if (theBoss.position.x > rightPoint.position.x) { theBoss.localScale = new Vector3(1f, 1f, 1f); moveRight = false; EndMovement(); } } else { theBoss.position -= new Vector3(moveSpeed * Time.deltaTime, 0f, 0f); if (theBoss.position.x < leftPoint.position.x) { theBoss.localScale = new Vector3(-1f, 1f, 1f); moveRight = true; EndMovement(); } } break; } }
// Start is called before the first frame update void Start() { currentState = bossStates.shooting; //regel hieronder zelf toegevoegd shotCounter = timeBetweenShots; }
// Update is called once per frame void Update() { switch (currentState) { case bossStates.shooting: shotCounter -= Time.deltaTime; if (shotCounter <= 0) { shotCounter = timeBetweenShots; var newBullet = Instantiate(bullet, firePoint.position, firePoint.rotation); newBullet.transform.localScale = theBoss.localScale; } break; case bossStates.hurt: if (hurtCounter > 0) { hurtCounter -= Time.deltaTime; if (hurtCounter <= 0) { currentState = bossStates.moving; mineCounter = 0; if (isDefeated) { theBoss.gameObject.SetActive(false); Instantiate(explosion, theBoss.position, theBoss.rotation); winPlatform.SetActive(true); AudioManager.instance.StopBossMusic(); currentState = bossStates.dead; } } } break; case bossStates.moving: if (moveRight) { theBoss.position += new Vector3(moveSpeed * Time.deltaTime, 0f, 0f); if (theBoss.position.x > rightPoint.position.x) { theBoss.localScale = new Vector3(1f, 1f, 1f); moveRight = false; EndMovement(); } } else { theBoss.position -= new Vector3(moveSpeed * Time.deltaTime, 0f, 0f); if (theBoss.position.x < leftPoint.position.x) { theBoss.localScale = new Vector3(-1f, 1f, 1f); moveRight = true; EndMovement(); } } mineCounter -= Time.deltaTime; if (mineCounter <= 0) { mineCounter = timeBetweenMines; Instantiate(mine, minePoint.position, minePoint.rotation); } break; default: break; } }
// Start is called before the first frame update void Start() { currentState = bossStates.shooting; }
void Update() { switch (currentState) { case bossStates.shooting: shotCounter -= Time.deltaTime; if (shotCounter <= 0) { shotCounter = timeBetweenShots; var newBullet = Instantiate(bullet, firePoint.position, firePoint.rotation); newBullet.transform.localScale = theBoss.localScale; } break; case bossStates.hurt: if (hurtCounter > 0) { hurtCounter -= Time.deltaTime; if (hurtCounter <= 0) { currentState = bossStates.moving; mineCounter = 0; if (isDefeated) { theBoss.gameObject.SetActive(false); Instantiate(explosion, theBoss.position, theBoss.rotation); winPlatform.SetActive(true); AudioManager.instance.StopBossMusic(); currentState = bossStates.ended; // Don't need a separate swith case for ended since nothing else will be happening at this point } } } break; case bossStates.moving: if (moveRight) { theBoss.position += new Vector3(moveSpeed * Time.deltaTime, 0f, 0f); if (theBoss.position.x > rightPoint.position.x) { theBoss.localScale = Vector3.one; // This is the same as: new Vector3(1f, 1f, 1f); moveRight = false; EndMovement(); } } else { theBoss.position -= new Vector3(moveSpeed * Time.deltaTime, 0f, 0f); if (theBoss.position.x < leftPoint.position.x) { theBoss.localScale = new Vector3(-1f, 1f, 1f); moveRight = true; EndMovement(); } } mineCounter -= Time.deltaTime; if (mineCounter <= 0) { mineCounter = timeBetweenMines; Instantiate(mine, minePoint.position, minePoint.rotation); } break; } #if UNITY_EDITOR // Ensures that the code below only runs within the Unity editor if (Input.GetKeyDown(KeyCode.H)) { TakeHit(); } #endif }
void Start() { currentState = bossStates.shooting; // This could also be set as = 0, since shooting is the first element in the enum, but that would make the code less readable }
// Start is called before the first frame update void Start() { currentState = bossStates.shooting; initialTimeBetweenShots = timeBetweenShots; initialTimeBetweenMines = timeBetweenMines; }
// Update is called once per frame void Update() { switch (currentState) { case bossStates.shooting: shotCounter -= Time.deltaTime; if (shotCounter <= 0) { shotCounter = timeBetweenShots; var newBullet = Instantiate(bullet, firePoint.position, firePoint.rotation); newBullet.transform.localScale = theBoss.localScale; } break; case bossStates.hurt: if (hurtCounter > 0) { hurtCounter -= Time.deltaTime; if (hurtCounter <= 0) { currentState = bossStates.moving; mineCounter = 0; if (isDefeated) { theBoss.gameObject.SetActive(false); Instantiate(explosion, theBoss.position, theBoss.rotation); winPlatform.SetActive(true); AudioManager.instance.StopBossMusic(); currentState = bossStates.ended; } } } break; case bossStates.moving: if (moveRight) { theBoss.position += new Vector3(moveSpeed * Time.deltaTime, 0f, 0f); if (theBoss.position.x > rightPoint.position.x) { theBoss.localScale = new Vector3(1f, 1f, 1f); // can be typed as ""new Vector3.one;""" as all values are 1f moveRight = false; EndMovement(); } } else { theBoss.position -= new Vector3(moveSpeed * Time.deltaTime, 0f, 0f); if (theBoss.position.x < leftPoint.position.x) { theBoss.localScale = new Vector3(-1f, 1f, 1f); moveRight = true; EndMovement(); } } mineCounter -= Time.deltaTime; if (mineCounter <= 0) { mineCounter = timeBetweenMines; Instantiate(mine, minePoint.position, minePoint.rotation); } break; } #if UNITY_EDITOR if (Input.GetKeyDown(KeyCode.H)) { TakeHit(); } #endif }
// Start is called before the first frame update void Start() { currentState = bossStates.shooting; winPlatform.SetActive(false); }