修复运行时未初始化
This commit is contained in:
@@ -1,34 +1,36 @@
|
||||
class SpawnerSystem extends EntityProcessingSystem {
|
||||
constructor(matcher: Matcher){
|
||||
super(matcher);
|
||||
}
|
||||
|
||||
public processEntity(entity: Entity){
|
||||
let spawner = entity.getComponent<SpawnComponent>(SpawnComponent);
|
||||
if (!spawner)
|
||||
return;
|
||||
|
||||
if (spawner.numAlive <= 0)
|
||||
spawner.enabled = true;
|
||||
|
||||
if (!spawner.enabled)
|
||||
return;
|
||||
|
||||
console.log("cooldown", spawner.cooldown);
|
||||
if (spawner.cooldown == -1){
|
||||
spawner.cooldown = Math.random() * 60;
|
||||
spawner.cooldown /= 4;
|
||||
module system {
|
||||
export class SpawnerSystem extends es.EntityProcessingSystem {
|
||||
constructor(matcher: es.Matcher){
|
||||
super(matcher);
|
||||
}
|
||||
|
||||
spawner.cooldown -= Time.deltaTime;
|
||||
if (spawner.cooldown <= 0){
|
||||
spawner.cooldown = Math.random() * 60;
|
||||
// CreateEnemy
|
||||
spawner.numSpawned ++;
|
||||
spawner.numAlive ++;
|
||||
public processEntity(entity: es.Entity){
|
||||
let spawner = entity.getComponent<component.SpawnComponent>(component.SpawnComponent);
|
||||
if (!spawner)
|
||||
return;
|
||||
|
||||
if (spawner.numAlive > 0)
|
||||
spawner.enabled = false;
|
||||
if (spawner.numAlive <= 0)
|
||||
spawner.enabled = true;
|
||||
|
||||
if (!spawner.enabled)
|
||||
return;
|
||||
|
||||
console.log("cooldown", spawner.cooldown);
|
||||
if (spawner.cooldown == -1){
|
||||
spawner.cooldown = Math.random() * 60;
|
||||
spawner.cooldown /= 4;
|
||||
}
|
||||
|
||||
spawner.cooldown -= es.Time.deltaTime;
|
||||
if (spawner.cooldown <= 0){
|
||||
spawner.cooldown = Math.random() * 60;
|
||||
// CreateEnemy
|
||||
spawner.numSpawned ++;
|
||||
spawner.numAlive ++;
|
||||
|
||||
if (spawner.numAlive > 0)
|
||||
spawner.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user