Example #1
0
        public void Spawn(EnemyPath path, bool boss, float duration)
        {
            var p     = path == EnemyPath.Left ? _leftPositions : _rightPositions;
            var enemy = boss ? _bossPool.Spawn() : _minionPool.Spawn();

            enemy.transform.rotation = Quaternion.identity;
            enemy.transform.position = p[0];
            enemy.Type = boss ? EnemyType.Boss : EnemyType.Minion;
            enemy.Path = path;
            var tweener = new TweenerCore <Vector3, Path, PathOptions> [1];

            tweener[0] = enemy.transform.DOPath(p, duration, PathType.CatmullRom).OnUpdate(() =>
            {
                tweener[0].timeScale = GameTime.Scale;
                if (enemy.IsDead || !enemy.gameObject.activeSelf)
                {
                    tweener[0].Kill();
                }
            }).OnComplete(() =>
            {
                if (boss)
                {
                    _bossPool.Despawn(enemy);
                }
                else
                {
                    _minionPool.Despawn(enemy);
                }
            });
        }
Example #2
0
 public void Initialize(BossPool bossPool, MinionPool minionPool)
 {
     _bossPool       = bossPool;
     _minionPool     = minionPool;
     _leftPositions  = _leftPositionsRaw.Select(x => x.position).ToArray();
     _rightPositions = _rightPositionsRaw.Select(x => x.position).ToArray();
     MessageManager.ReceiveEvent <PlayerDamagedEvent>().Subscribe(ev =>
     {
         if (ev.Source.Type == EnemyType.Boss)
         {
             _bossPool.Despawn(ev.Source);
         }
         else
         {
             _minionPool.Despawn(ev.Source);
         }
     });
 }