Example #1
0
 private void SideEnemyBehaviour()
 {
     if (!_isSideEnemy)
     {
         _sideEnemyTimer += Time.deltaTime;
         if (_sideEnemyTimer >= _sideEnemyTime)
         {
             CreateSideEnemy();
             _isSideEnemy    = true;
             _sideEnemyTimer = 0;
         }
     }
     else
     {
         if (_sideEnemy != null)
         {
             _sideEnemy.MoveEnemy(Time.deltaTime);
             if (_sideEnemy.IsOutOfBounds())
             {
                 ObjectPoolerManager.instance.HideObject(_sideEnemy.gameObject);
                 _isSideEnemy = false;
                 _sideEnemy   = null;
             }
         }
     }
 }
Example #2
0
    public void CreateSideEnemy()
    {
        int        side         = Random.Range(0, 2);
        GameObject sideEnemyObj = ObjectPoolerManager.instance.GetPoolableObjectById("SideEnemy");

        _sideEnemy = sideEnemyObj.GetComponent <SideEnemyMovement>();
        if (_sideEnemy != null)
        {
            if (side == 0)
            {
                _sideEnemy.StartEnemyData(Side.LEFT, leftPosition.position);
            }
            else
            {
                _sideEnemy.StartEnemyData(Side.RIGHT, rightPosition.position);
            }
        }
    }
Example #3
0
 private void OnSideEnemyKilled()
 {
     _isSideEnemy = false;
     _sideEnemy   = null;
 }