新增entityprocessor管理实体解析器
This commit is contained in:
@@ -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 ++;
|
||||
|
||||
Reference in New Issue
Block a user