Пример #1
0
        protected override void OnUpdate()
        {
            var spawnTimer = _spawnCapsuleData.SpawnTimer -= Time.DeltaTime;

            if (spawnTimer <= 0)
            {
                var newEntity = EntityManager.Instantiate(_spawnCapsuleData.EntityPrefab);

                var newTranslation = new Translation()
                {
                    Value = _spawnCapsuleData.RandomSpawnPos
                };

                EntityManager.SetComponentData(newEntity, newTranslation);
                _spawnCapsuleData.SpawnTimer = _spawnCapsuleData.SpawnInterval;
            }

            if (Input.GetKeyDown(_spawnCapsuleData.FunKey))
            {
                var newSpawnData = new SpawnCapsuleData()
                {
                    EntityPrefab     = _spawnCapsuleData.EntityPrefab,
                    FunKey           = _spawnCapsuleData.FunKey,
                    MinSpawnPosition = new float3(12.5f, 0.8f, 12.5f),
                    MaxSpawnPosition = new float3(12.5f, 0.8f, 12.5f),
                    Random           = Random.CreateFromIndex(1),
                    SpawnInterval    = 0.01f,
                    SpawnTimer       = 0.01f,
                };

                SetSingleton(newSpawnData);
                _spawnCapsuleData = GetSingleton <SpawnCapsuleData>();
            }
        }
Пример #2
0
        public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
        {
            var spawnCapsuleData = new SpawnCapsuleData
            {
                SpawnInterval    = SpawnInterval,
                SpawnTimer       = SpawnInterval,
                EntityPrefab     = conversionSystem.GetPrimaryEntity(CapsulePrefab),
                FunKey           = FunKey,
                Random           = Random.CreateFromIndex(0),
                MinSpawnPosition = MinSpawnPosition,
                MaxSpawnPosition = MaxSpawnPosition
            };

            dstManager.AddComponentData(entity, spawnCapsuleData);
        }
Пример #3
0
 protected override void OnStartRunning()
 {
     _spawnCapsuleData = GetSingleton <SpawnCapsuleData>();
 }