private void RemoveEnemy(LifeCycleController lifeCycleController) { _lifeCycleControllers.Remove(lifeCycleController); if (_lifeCycleControllers.Count > 0 || Spawner.IsSpawning) { return; } FinishRound(); }
private void Split(LifeCycleController lifeCycleController) { var spawner = GameManager.Instance.Spawner; var movement = GetComponent <IMovement>(); for (var i = 0; i < splitCount; i++) { spawner.SpawnEnemy(splitPrefabs[Random.Range(0, splitPrefabs.Count)], movement.Position, Random.Range(0f, 360f), MathHelper.DegreeToVector2(Random.Range(0f, 360f))); } }
private void AddScore(LifeCycleController lifeCycleController) { lifeCycleController.OnDestroy -= AddScore; if (GameManager.Instance.IsFinished) { return; } Score += lifeCycleController.GetComponent <ScoreReward>().reward; OnScoreChange?.Invoke(Score); }
private void CheckPlayerDeath(LifeCycleController playerLifeCycleController) { if (LivesLeft > 0) { LivesLeft--; OnLivesChanged?.Invoke(LivesLeft); StartCoroutine(Respawn(playerLifeCycleController)); } else { GameManager.Instance.FinishGame(); } }
private void Wreck(LifeCycleController lifeCycleController) { var movement = lifeCycleController.GetComponent <IMovement>(); for (var i = 0; i < fragmentAmount; i++) { var velocity = MathHelper.DegreeToVector2(Random.Range(0f, 360f)) * Random.Range(minInitialSpeed, maxInitialSpeed); var position = movement.Position + velocity * wreckTimeSkip; var fragment = Instantiate(fragmentPrefabs[Random.Range(0, fragmentPrefabs.Count)], position, Quaternion.identity); fragment.GetComponent <LifeCycleController>().Spawn(); fragment.GetComponent <MovementController>() .Launch(position, Random.Range(0f, 360f), velocity); } }
private void Spawn(LifeCycleController lifeCycleController) { _rotationVelocity = 0f; _isAccelerating = false; }
private IEnumerator Respawn(LifeCycleController playerLifeCycleController) { yield return(new WaitForSeconds(respawnTime)); playerLifeCycleController.Spawn(); }
private void Spawn(LifeCycleController lifeCycleController) { _currentHealth = maxHealth; }
private void PlaySound(LifeCycleController lifeCycleController) { AudioSource.PlayClipAtPoint(destroySound, Vector3.zero); }