Ejemplo n.º 1
0
    void Start()
    {
        _preloaded = this.SubBosses.Count / 3;
        ObjectPools.Preload(this.GibsPreloadKey, _preloaded);
        _preloadTimer = this.TimeBetweenPreloads;

        this.AttackTargets = PlayerTargetController.Targets;
        int hp = 1;

        foreach (GameObject subBoss in this.SubBosses)
        {
            subBoss.GetComponent <BossWeakSubBehavior>().OnAttackFinished = subBossAttackFinished;
            Damagable damagable = subBoss.GetComponent <Damagable>();
            damagable.DirectSetHealth(hp);
            damagable.OnDeathCallbacks.Add(this.SubBossKilled);
            hp = hp >= 4 ? 1 : hp + 1;
        }

        for (int i = 0; i < this.EnemySpawners.Length; ++i)
        {
            this.EnemySpawners[i].SpawnCallback = enemySpawned;
            this.EnemySpawners[i].Targets       = this.AttackTargets;
        }

        this.GetComponent <BossHealth>().DeathCallbacks.Add(onDeath);
        _stateMachine.AddState(ROTATION_STATE, updateRotation, enterRotation, exitRotation);
        _stateMachine.AddState(ATTACKING_STATE, updateAttacking, enterAttacking, exitAttacking);
        GlobalEvents.Notifier.Listen(BeginGameplayEvent.NAME, this, gameplayBegin);
    }
Ejemplo n.º 2
0
 private string updateRotation()
 {
     _enemySpawnCooldown += Time.deltaTime;
     _subSpawnCooldown   += Time.deltaTime;
     if (_enemySpawnCooldown >= this.TimeBetweenEnemySpawns)
     {
         _enemySpawnCooldown = 0.0f;
         this.EnemySpawners[Random.Range(0, this.EnemySpawners.Length - 1)].BeginSpawn();
     }
     if (_subSpawnCooldown >= this.TimeBetweenSubSpawns)
     {
         _subSpawnCooldown = 0.0f;
         if (_ogPositionsToSpawn.Count > 0)
         {
             int     index  = Random.Range(0, _ogPositionsToSpawn.Count);
             Vector2 choice = _ogPositionsToSpawn[index];
             _ogPositionsToSpawn.RemoveAt(index);
             GameObject subBoss = Instantiate(this.SubBossPrefab, new Vector3(choice.x, choice.y, this.transform.position.z), Quaternion.identity) as GameObject;
             subBoss.transform.parent        = this.transform;
             subBoss.transform.localRotation = Quaternion.identity;
             this.SubBosses.Add(subBoss);
             subBoss.GetComponent <BossWeakSubBehavior>().OnAttackFinished = subBossAttackFinished;
             Damagable damagable = subBoss.GetComponent <Damagable>();
             damagable.DirectSetHealth(Random.Range(1, 5));
             damagable.OnDeathCallbacks.Add(this.SubBossKilled);
         }
     }
     return(!_switchState ? ROTATION_STATE : ATTACKING_STATE);
 }