public void OnEnemyDeath(EnemyDiedEvent enemyDiedEvent)
 {
     enemiesLeftToKill--;
     if (enemiesLeftToKill <= 0)
     {
         EventCoordinator.FireEvent(new WaveClearedEvent());
     }
 }
 public override void Shoot()
 {
     if (spawnedLaser == null)
     {
         FireLaser();
     }
     EventCoordinator.FireEvent(new DamageEvent(this, enemiesInRange[0], AttackDamage, Health.DamageType.Energy));
     PowerGrid.ConsumePower(PowerDraw);
 }
Esempio n. 3
0
 public static void TakeCommand(int requestedCommand)
 {
     currentCommand += requestedCommand;
     if (currentCommand > commandLimit)
     {
         Debug.LogError("We have exceeded our command limit.");
     }
     EventCoordinator.FireEvent(new CommandForceChangedEvent(requestedCommand, currentCommand));
 }
Esempio n. 4
0
 public static void LoseLives(int damage)
 {
     lives -= damage;
     if (lives <= 0)
     {
         EventCoordinator.FireEvent(new PlayerLostEvent());
     }
     EventCoordinator.FireEvent(new LivesLostEvent());
 }
Esempio n. 5
0
    private void Update()
    {
        Vector3 direction = target.transform.position - transform.position;

        transform.Translate(direction.normalized * speed * Time.deltaTime);
        if (Vector3.Distance(transform.position, target.transform.position) <= 0.05f)
        {
            EventCoordinator.FireEvent(new DamageEvent(shooter, target, shooter.AttackDamage, Health.DamageType.Ballistic));
            BallisticTurret.ReturnBulletToPool(this);
        }
    }
Esempio n. 6
0
 public void Detonate()
 {
     Collider[] blastedObjects = Physics.OverlapSphere(transform.position, detonationRadius);
     if (blastedObjects.Length > 0)
     {
         for (int i = 0; i < blastedObjects.Length; i++)
         {
             Enemy blastedEnemy = Enemy.GetEnemyFromCollider(blastedObjects[i]);
             if (blastedEnemy != null)
             {
                 EventCoordinator.FireEvent(new DamageEvent(launcher, blastedEnemy, launcher.AttackDamage, Health.DamageType.Explosive));
             }
         }
     }
     MissileTurret.ReturnMissileToObjectPool(this);
 }
 public override void Enter()
 {
     spawnedEnemies = 0;
     counter        = 0;
     EventCoordinator.FireEvent(new WaveStartEvent(enemiesToSpawn * numberOfSpawnPointsToUse));
     spawnPointsToUse = new Vector3[numberOfSpawnPointsToUse];
     for (int i = 0; i < numberOfSpawnPointsToUse; i++)
     {
         spawnPointsToUse[i] = SpawnPoint.spawnPoints[0];
         for (int j = 0; j < SpawnPoint.spawnPoints.Count; j++)
         {
             Vector3 distanceToBase         = Base.Position - SpawnPoint.spawnPoints[j];
             Vector3 shortestDistanceToBase = Base.Position - spawnPointsToUse[i];
             if (distanceToBase.sqrMagnitude < shortestDistanceToBase.sqrMagnitude)
             {
                 spawnPointsToUse[i] = SpawnPoint.spawnPoints[j];
             }
         }
         SpawnPoint.ExcludeSpawnPoint(spawnPointsToUse[i]);
     }
 }
Esempio n. 8
0
 private void Die()
 {
     IsDead = true;
     StartCoroutine(DeathSequence());
     EventCoordinator.FireEvent(new EnemyDiedEvent(this, deathParticles, deathSoundFX));
 }
Esempio n. 9
0
 private void OnTriggerExit(Collider other)
 {
     EventCoordinator.FireEvent(new EnemyExitedRangeEvent(other, this));
 }
Esempio n. 10
0
 public override void Enter()
 {
     counter = 0;
     EventCoordinator.FireEvent(new PreparationStageStartEvent(preparationTime));
 }
Esempio n. 11
0
 public static void RelieveCommand(int relievedCommand)
 {
     currentCommand -= relievedCommand;
     EventCoordinator.FireEvent(new CommandForceChangedEvent(-relievedCommand, currentCommand));
 }
Esempio n. 12
0
 public override void Construct()
 {
     uiController.SwitchButtonGroup(uiMainButtonsGroup);
     stateMachine.TransitionTo <BuildingIdleState>();
     EventCoordinator.FireEvent(new BaseConstructedEvent());
 }