public void Update(float deltaTime) { void UpdateUnit(SpaceUnit unit) { Enemy enemy = unit as Enemy; if (enemy.Update(deltaTime)) { enemy.RemoveFromWorld(); } if (enemy.HaveReachedLastWayPoint) { OnEnemyReachedLastPoint?.Invoke(enemy); } } // Update units in cells. for (int y = 0; y < spacePartitioner.TotalCells.Y; y++) { for (int x = 0; x < spacePartitioner.TotalCells.X; x++) { for (int i = spacePartitioner.Cells[y][x].Count - 1; i >= 0; i--) { UpdateUnit(spacePartitioner.Cells[y][x].ElementAt(i)); } } } // Update OutOfBoundsUnits. for (int i = spacePartitioner.OutOfBoundsUnits.Count - 1; i >= 0; i--) { UpdateUnit(spacePartitioner.OutOfBoundsUnits.ElementAt(i)); } }
void Update() { if (transform.position.y <= -9) { OnBottomScreen.Invoke(); } }
public void NotifyEnemyKilled(HealthSystem enemy) { OnKillEnemy.Invoke(enemy); if (Health) { Health.NotifyEnemyKilled(enemy); } }
public virtual void Die(bool earnReward = true) { OnDeath.Invoke(this); if (earnReward) { EndlessBitDefense.GameManager.instance.EarnMoney(killingReward); } StartCoroutine(DeathFadeout()); }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.name == "Bullet_45mm_Bullet(Clone)") { if (alive) { anim.SetTrigger("Death"); } alive = false; IDied?.Invoke(); } }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("Projectile")) { TakeDamage(); } if (other.CompareTag("Goal")) { ePool.ReturnToPool(this); print("entered"); ReachedGoal?.Invoke(this); } }
void OnTriggerEnter2D(Collider2D collider) { if (collider.gameObject.CompareTag("Wall")) { OnWallCollide.Invoke(); } if (collider.gameObject.CompareTag("playerBullet")) { --numAliens; OnDeath.Invoke(points); Destroy(this.gameObject); } }
public EnemyView SpawnEnemy(EnemyData data, Vector3 origin, Quaternion rotation) { var es = Instantiate(enemySheet, origin, rotation, transform); es.SetData(data); es.mover.Mobilize(es.mover.transform.position, goal.position, es.enemyData.speed); arrangeSortingLayer.CheckandReorder(); onSpawned.Invoke(es); enemies.Add(es); es.onDestroy.AddListener(OnEnemyDestroyed); return(es); }
private void SpawnEnemy(Transform spawnpoint, WaveCluster cluster) { var enemy = Instantiate(cluster.Prefab, GameObject.Find("Enemies").transform, spawnpoint); enemy.transform.position = spawnpoint.position; enemy.WaveNumber = cluster.WaveNumber; enemy.SetSpawnPoint(spawnpoint, true); cluster.EnemyData.SetEnemy(enemy, ModifierController, _random); if (OnEnemySpawned != null) { OnEnemySpawned.Invoke(enemy); } if (EnemiesWaiting != null) { EnemiesWaiting.Value--; } }
public void Gone() { this._isAlive = false; AudioHandler.Play(CRASH_SFX, 0.6f); var crashParticle = CrashPool.GetObject(); if (crashParticle != null) { crashParticle.transform.position = transform.position; crashParticle.SetActive(true); } this.Body.velocity = Vector2.zero; StopAllCoroutines(); OnGone.Invoke(gameObject, this); }
public void Die() { Gone(); OnDie.Invoke(gameObject, this); }
public void Struck() { OnStruck.Invoke(gameObject, this); Die(); }
/// <summary> /// Функция, выключающая объект /// </summary> public void DisableObj() { gameObject.SetActive(false); ObjectDisabledEvent.Invoke(this); }
/// <summary> /// Lets the player know that he killed an enemy /// </summary> /// <param name="enemy"></param> public void NotifyEnemyKilled(HealthSystem enemy) { OnEnemyKilled.Invoke(enemy); }