import * as RE from 'rogue-engine'; import ShipCannonController from './ShipCannonController.re'; export default class DummyShooter extends RE.Component { cannonController: ShipCannonController elapsed: number = 0 hasShot: boolean = true cooldown: number = 3 awake() { this.cannonController = RE.getComponent(ShipCannonController, this.object3d) as ShipCannonController this.elapsed = 0 this.hasShot = true this.cooldown = 3 } start() { } update() { this.elapsed += RE.Runtime.deltaTime if(this.cooldown > 0) { this.cooldown -= RE.Runtime.deltaTime } if(this.cooldown <= 0) { this.hasShot = false } if(!this.hasShot) { if(Math.floor(this.elapsed) % 5 == 0) { this.cannonController.fireRight = true this.hasShot = true this.cooldown = 3 } if(Math.floor(this.elapsed) % 2 == 0) { this.cannonController.fireForward = true this.hasShot = true this.cooldown = 3 } } } } RE.registerComponent(DummyShooter);