public BatSpawner(GameObject inPrefab, Transform inTransform, Transform inTarget)
 {
     prefab         = inPrefab;
     target         = inTarget;
     spawnTransform = inTransform;
     state          = BSState.OFF;
 }
 public void SpawnBat()
 {
     if (state == BSState.READYTOSPAWN)
     {
         float   speed = Random.Range(7, 10);
         AutoBat bat   = new AutoBat(prefab, spawnTransform.position, target.position, speed);
         bats.Add(bat);
         state = BSState.ONCOOLDOWN;
         timer = Random.Range(0.5f, 3f);
     }
 }
    public void Tick()
    {
        switch (state)
        {
        case BSState.OFF:
            break;

        case BSState.READYTOSPAWN:
            SpawnBat();
            break;

        case BSState.ONCOOLDOWN:
            timer -= Time.deltaTime;
            if (timer < 0f)
            {
                state = BSState.READYTOSPAWN;
            }
            break;

        default:
            break;
        }
    }
 public void TurnOff()
 {
     state = BSState.OFF;
 }
 public void TurnOn()
 {
     state = BSState.READYTOSPAWN;
 }