新增entityprocessor管理实体解析器

This commit is contained in:
YHH
2020-06-08 21:53:09 +08:00
parent a048a8ac29
commit 11af0a31a7
17 changed files with 386 additions and 66 deletions

View File

@@ -4,7 +4,10 @@ class SpawnerSystem extends EntityProcessingSystem {
}
public processEntity(entity: Entity){
let spawner = entity.getComponent<SpawnComponent>();
let spawner = entity.getComponent<SpawnComponent>(SpawnComponent);
if (!spawner)
return;
if (spawner.numAlive <= 0)
spawner.enabled = true;
@@ -13,11 +16,13 @@ class SpawnerSystem extends EntityProcessingSystem {
console.log("cooldown", spawner.cooldown);
if (spawner.cooldown == -1){
spawner.cooldown = Math.random() * 60;
spawner.cooldown /= 4;
}
spawner.cooldown -= 0.001;
spawner.cooldown -= Time.deltaTime;
if (spawner.cooldown <= 0){
spawner.cooldown = Math.random() * 60;
// CreateEnemy
spawner.numSpawned ++;
spawner.numAlive ++;