public void Damage(float damage, Vector3 knockBackDir, float knockBack) { if (!isHurt) { isHurt = true; hurtVFX.BeginFlash(); currHealth -= damage; ObjectPoolManager.Spawn(deathVFX, transform.position, transform.rotation); IAudio player = ObjectPoolManager.Spawn(audioPlayerPrefab.gameObject, transform.position, transform.rotation).GetComponent <IAudio>(); player.SetUpAudioSource(AudioManager.instance.GetSound("BugsSplat")); player.PlayAtRandomPitch(); DamageNumber dmgVFX = ObjectPoolManager.Spawn(hurtNumber, transform.position, Quaternion.identity).GetComponent <DamageNumber>(); if (dmgVFX != false) { dmgVFX.Init(); dmgVFX.SetTextValuesAtScale(damage, maxHealth, knockBackDir, 2f); } if (currHealth <= 0.0f) { DisableBroodDelegate(); } Invoke("ResetHurt", hurtTime); } }
public void BossDefeated() { foreach (BaseAttackPattern baseAttack in currentAttackCycle) { baseAttack.DisableAttack(); baseAttack.AttackEnded -= NextAttackPattern; baseAttack.gameObject.SetActive(false); } hiveShield.ResetShield(); foreach (BroodNestDelegate nest in broodDelegates) { if (nest.GetAlive()) { nest.Died -= DecrementBroodDelegateCount; } nest.ResetBroodDelegate(); } ObjectPoolManager.Spawn(deathVFX, transform.position, transform.rotation); IAudio player = ObjectPoolManager.Spawn(audioPlayerPrefab.gameObject, transform.position, transform.rotation).GetComponent <IAudio>(); player.SetUpAudioSource(AudioManager.instance.GetSound("BugsSplat")); player.PlayAtRandomPitch(); GameStateManager.instance.BeginNewGameState(GameStates.LevelClear); hurtVFX.EndFlash(); anim.enabled = false; healthBarAnim.PlayAnim("BossHealthColapse"); MusicManager.instance.BeginFadeOut(); isDead = true; deathHandler.InitDeathState(); }
public void PlayOnHooverSFX() { IAudio audioPlayer = ObjectPoolManager.Spawn(audioPlayerPrefab, transform.position).GetComponent <IAudio>(); audioPlayer.SetUpAudioSource(AudioManager.instance.GetSound("ButtonHoover")); audioPlayer.PlayAtRandomPitch(); }
public void Damage(float damage, Vector3 knockBackDir, float knockBack) { if (currentStage != BossStage.Transition) { if (!isHurt && !isDead) { hurtVFX.BeginFlash(); ObjectPoolManager.Spawn(deathVFX, transform.position, transform.rotation); IAudio player = ObjectPoolManager.Spawn(audioPlayerPrefab.gameObject, transform.position, transform.rotation).GetComponent <IAudio>(); player.SetUpAudioSource(AudioManager.instance.GetSound("BugsSplat")); player.PlayAtRandomPitch(); isHurt = true; currHealth -= damage; if (currHealth < 0f) { currHealth = 0f; } DamageNumber dmgVFX = ObjectPoolManager.Spawn(hurtNumber, transform.position, Quaternion.identity).GetComponent <DamageNumber>(); if (dmgVFX != false) { dmgVFX.Init(); dmgVFX.SetTextValuesAtScale(damage, MaxHealth, knockBackDir, 10); } if (currHealth / MaxHealth <= currentStageTrigger) { currHealth = MaxHealth * currentStageTrigger; EnterTransition(); } healthBar.UpdateValue(currHealth); Invoke("ResetHurt", hurtTime); } } }
override protected void OnTriggerEnter2D(Collider2D other) { if (((1 << other.gameObject.layer) & collisionLayers) != 0) { if (!other.CompareTag("Enemy")) { IAudio audioPlayer = ObjectPoolManager.Spawn(audioPlayerPrefab, transform.position).GetComponent <IAudio>(); audioPlayer.SetUpAudioSource(AudioManager.instance.GetSound(collisionSFX)); audioPlayer.PlayAtRandomPitch(); Vector2 backDir = rb.velocity.normalized * -1; Vector2 pos = rb.position + backDir * 0.6f; ObjectPoolManager.Spawn(sparkPrefab, pos, transform.rotation); //SetupAndPlayBulletSound("BulletCollisionSFX"); SpawnFragments(); ObjectPoolManager.Recycle(gameObject); } } if (other.gameObject.CompareTag(targetTag) || other.gameObject.CompareTag("PhysicsObject")) { if (other.GetComponent <IHurtable>() != null) { other.GetComponent <IHurtable>().Damage(damage, rb.velocity.normalized, knockBack); } IAudio audioPlayer = ObjectPoolManager.Spawn(audioPlayerPrefab, transform.position).GetComponent <IAudio>(); audioPlayer.SetUpAudioSource(AudioManager.instance.GetSound(collisionSFX)); audioPlayer.PlayAtRandomPitch(); ObjectPoolManager.Spawn(sparkPrefab, transform.position, transform.rotation); ObjectPoolManager.Spawn(triggerEnemyPrefab, transform.position, Quaternion.identity); SpawnFragments(); ObjectPoolManager.Recycle(gameObject); } }
protected void Damage(float damage, Vector2 knockBackDir, float knockBack) { if (!isHurt) { if (canBeHurt) { if (navComp.enabled) { navComp.Stop(); navComp.enabled = false; } rb.AddForce(knockBackDir * knockBack, ForceMode2D.Impulse); ObjectPoolManager.Spawn(deathVFX, transform.position, transform.rotation); IAudio player = ObjectPoolManager.Spawn(audioPlayerPrefab.gameObject, transform.position, transform.rotation).GetComponent <IAudio>(); player.SetUpAudioSource(AudioManager.instance.GetSound("BugHurt")); player.PlayAtRandomPitch(); canBeHurt = false; isHurt = true; hurtVFX.BeginFlash(); currentHealth -= damage; this.knockBack = knockBack * knockBackDir; DamageNumber dmgVFX = ObjectPoolManager.Spawn(hurtNumber, transform.position, Quaternion.identity).GetComponent <DamageNumber>(); if (dmgVFX != false) { dmgVFX.Init(); dmgVFX.SetTextValues(damage, settings.maxHealth, knockBackDir); } if (currentHealth <= 0) { KillEnemy(); } } } }
public void KillDrone() { if (gameObject.activeSelf) { IAudio audioPlayer = ObjectPoolManager.Spawn(audioPlayerPrefab, transform.position).GetComponent <IAudio>(); audioPlayer.SetUpAudioSource(AudioManager.instance.GetSound("BugsSplat")); audioPlayer.PlayAtRandomPitch(); ObjectPoolManager.Spawn(explosionVFX, transform.position, transform.rotation); if (owner) { owner.Dronekilled(this); } owner.Disabled -= KillDrone; ObjectPoolManager.Recycle(gameObject); } }
public void Hatch() { IAudio audioPlayer = ObjectPoolManager.Spawn(audioPlayerPrefab, transform.position).GetComponent <IAudio>(); audioPlayer.SetUpAudioSource(AudioManager.instance.GetSound(hatchSFX)); audioPlayer.PlayAtRandomPitch(); ObjectPoolManager.Spawn(hatchVFX, transform.position, Quaternion.identity); if (GameStateManager.instance.GetCurrentGameState() != GameStates.LevelClear) { BaseEnemy enemy = ObjectPoolManager.Spawn(enemyToSpawn, transform.position, Quaternion.identity).GetComponent <BaseEnemy>(); enemy.SetTarget(target); sourceRef.BindToSpawnedEnemy(enemy); } ObjectPoolManager.Recycle(this); }
private void FireProjectile() { GameObject bullet = ObjectPoolManager.Spawn(projectilePrefab, firePoint.position, firePoint.rotation); IShootable shot = bullet.GetComponent <IShootable>(); IAudio player = ObjectPoolManager.Spawn(audioPlayerPrefab.gameObject, transform.position, transform.rotation).GetComponent <IAudio>(); player.SetUpAudioSource(AudioManager.instance.GetSound("SlimeFireProjectile")); player.PlayAtRandomPitch(); float dmg = Random.Range(settings.minDamage, settings.maxDamage); float kBack = Random.Range(settings.minKnockBack, settings.minKnockBack); shot.SetUpBullet(kBack, dmg); shot.Shoot(firePoint.up, shootForce); canAttack = false; Invoke("ResetShotTime", Random.Range(Mathf.Clamp(settings.attackRate - 1.5f, 0f, settings.attackRate), settings.attackRate + 1.5f)); }
public void SetUpBroodNest(BroodNest hiveRef) { hive = hiveRef; isAlive = true; currHealth = maxHealth; EnableBroodDelegate(); isHurt = false; IAudio player = ObjectPoolManager.Spawn(audioPlayerPrefab.gameObject, transform.position, transform.rotation).GetComponent <IAudio>(); player.SetUpAudioSource(AudioManager.instance.GetSound("BugsSplat")); player.PlayAtRandomPitch(); ObjectPoolManager.Spawn(spawnVFX, transform.position, transform.rotation); CreateTeether(); drones.SetUpAbilityData(droneData); playerTransform = GameStateManager.instance.GetPlayerTransform(); if (!playerTransform) { playerTransform = FindObjectOfType <PlayerBehaviour>().transform; } drones.playerTransform = playerTransform; pheremones.SetUpAbilityData(pheremoneData); StartCoroutine(AttackLoop()); }
private void OnTriggerEnter2D(Collider2D other) { if (((1 << other.gameObject.layer) & collisionLayers) != 0) { IAudio audioPlayer = ObjectPoolManager.Spawn(audioPlayerPrefab, transform.position).GetComponent <IAudio>(); audioPlayer.SetUpAudioSource(AudioManager.instance.GetSound("BugsSplat")); audioPlayer.PlayAtRandomPitch(); ObjectPoolManager.Spawn(explosionVFX, transform.position, transform.rotation); if (owner) { owner.Dronekilled(this); } ObjectPoolManager.Recycle(gameObject); } if (other.gameObject.CompareTag("Player")) { if (other.GetComponent <IHurtable>() != null) { other.GetComponent <IHurtable>().Damage(damage, rb.velocity.normalized, knockBack); } IAudio audioPlayer = ObjectPoolManager.Spawn(audioPlayerPrefab, transform.position).GetComponent <IAudio>(); audioPlayer.SetUpAudioSource(AudioManager.instance.GetSound("BugsSplat")); audioPlayer.PlayAtRandomPitch(); ObjectPoolManager.Spawn(explosionVFX, transform.position, transform.rotation); if (owner) { owner.Dronekilled(this); } ObjectPoolManager.Recycle(gameObject); } if (other.gameObject.CompareTag("Swarm")) { Vector2 dir = other.transform.position - transform.position; other.GetComponent <Rigidbody2D>().AddForce(dir.normalized * 2.0f, ForceMode2D.Impulse); } }
virtual protected void KillEnemy() { ObjectPoolManager.Spawn(deathVFX, transform.position, transform.rotation); IAudio player = ObjectPoolManager.Spawn(audioPlayerPrefab.gameObject, transform.position, transform.rotation).GetComponent <IAudio>(); player.SetUpAudioSource(AudioManager.instance.GetSound("BugsSplat")); player.PlayAtRandomPitch(); InitStateManager.instance.OnStateChange -= EvaluateNewState; GameStateManager.instance.OnGameStateChange -= EvaluateGameState; if (GameIntensityManager.instance != false) { GameIntensityManager.instance.DecrementNumberOfCrawlers(); } if (navComp.enabled) { navComp.Stop(); navComp.enabled = false; } aSource.Stop(); Killed?.Invoke(this); ObjectPoolManager.Recycle(gameObject); }