Exemple #1
0
        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));
            }
        }
Exemple #2
0
 void Update()
 {
     if (transform.position.y <= -9)
     {
         OnBottomScreen.Invoke();
     }
 }
Exemple #3
0
 public void NotifyEnemyKilled(HealthSystem enemy)
 {
     OnKillEnemy.Invoke(enemy);
     if (Health)
     {
         Health.NotifyEnemyKilled(enemy);
     }
 }
Exemple #4
0
    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);
     }
 }
Exemple #7
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.gameObject.CompareTag("Wall"))
        {
            OnWallCollide.Invoke();
        }

        if (collider.gameObject.CompareTag("playerBullet"))
        {
            --numAliens;
            OnDeath.Invoke(points);
            Destroy(this.gameObject);
        }
    }
Exemple #8
0
    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);
    }
Exemple #9
0
        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--;
            }
        }
Exemple #10
0
    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);
    }
Exemple #11
0
 public void Die()
 {
     Gone();
     OnDie.Invoke(gameObject, this);
 }
Exemple #12
0
 public void Struck()
 {
     OnStruck.Invoke(gameObject, this);
     Die();
 }
Exemple #13
0
 /// <summary>
 /// Функция, выключающая объект
 /// </summary>
 public void DisableObj()
 {
     gameObject.SetActive(false);
     ObjectDisabledEvent.Invoke(this);
 }
Exemple #14
0
 /// <summary>
 /// Lets the player know that he killed an enemy
 /// </summary>
 /// <param name="enemy"></param>
 public void NotifyEnemyKilled(HealthSystem enemy)
 {
     OnEnemyKilled.Invoke(enemy);
 }