protected override void OnUpdate()
        {
            if (SpawnControl == null)
            {
                SpawnControl = SpawnController.Instance;
            }

            SpawnDropsItem();

            if (!SpawnControl.CanSpawn)
            {
                return;
            }
            else
            {
                switch (SpawnControl.ControlMode)
                {
                case SpawnControlMode.Game:
                    SpawnGame();
                    break;

                case SpawnControlMode.WaveGen:
                    SpawnWave();
                    break;
                }
            }
        }
        protected override void OnUpdate()
        {
            Entities.ForEach((Entity entity, ref WaveComponent wave) =>
            {
                if (!CurWave(wave))
                {
                    return;
                }
                if (Control == null)
                {
                    Control = SpawnController.Instance;
                }
                if (Control.MaxCountInScene != wave.MaxEnemyAtOnce)
                {
                    Control.MaxCountInScene = wave.MaxEnemyAtOnce;
                }

                if (!wave.AllEnemiesDispatched)
                {
                    DynamicBuffer <WaveBufferComponent> WaveBuffer = EntityManager.GetBuffer <WaveBufferComponent>(entity);
                    foreach (WaveBufferComponent waveEnemy in WaveBuffer)
                    {
                        int count = waveEnemy.EnemySpecForWave.SpawnCount;
                        while (count != 0)
                        {
                            NativeArray <int> dispatched = new NativeArray <int>(1, Allocator.TempJob);


                            var testing = new DispatchSpawnsToSpawnPointsEnemy()
                            {
                                SpawnCount       = count,
                                SpawnID          = waveEnemy.EnemySpecForWave.spawnID,
                                count            = dispatched,
                                chunkEnemyBuffer = GetArchetypeChunkBufferType <EnemySpawnData>(),
                                C1 = GetArchetypeChunkComponentType <EnemySpawnTag>()
                            };

                            JobHandle handle = testing.Schedule(m_Group);
                            handle.Complete();

                            count -= testing.count[0];
                            wave.EnemiesDispatched += dispatched[0];
                            dispatched.Dispose();
                        }
                    }
                    wave.AllEnemiesDispatched = true;
                }
                WaveComponent currentwave = wave;
                Entities.ForEach((ref Destroytag tag, ref EnemyTag Enemy) => {
                    currentwave.EnemiesDefeated++;
                });
                wave = currentwave;
                if (WaveDefeat(wave))
                {
                    PostUpdateCommands.DestroyEntity(entity);
                    wavecnt++;
                }
            });
        }
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
 protected override void OnCreate()
 {
     base.OnCreate();
     SpawnControl = SpawnController.Instance;
 }