本文整理汇总了TypeScript中model/player/Player.addProjectile函数的典型用法代码示例。如果您正苦于以下问题:TypeScript addProjectile函数的具体用法?TypeScript addProjectile怎么用?TypeScript addProjectile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了addProjectile函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: fire
public fire(angle : number, position : Vector, velocity : Vector, isMine : boolean, commitFireFn : (fireEnergy : number, fireDelay : number, recoilAcceleration : number) => boolean) : any {
let level = this.level_.getValue();
if (level < 0) {
return null;
}
let fireEnergy = this.getFireEnergy_();
let fireDelay = this.getFireDelay_();
let recoilAcceleration = isMine ? 0 : this.getRecoilAcceleration_();
if (!commitFireFn(fireEnergy, fireDelay, recoilAcceleration)) {
return null;
}
let lifetime = this.getLifetime_();
let damage = this.getDamage_();
let bounceCount = this.getBounceCount_();
let blastRadius = this.getBlastRadius_();
let proxRadius = this.getProxRadius_();
let newVelocity = isMine ? Vector.ZERO : velocity.add(Vector.fromPolar(this.getBombSpeed_(), angle));
let projectile = this.simulation_.modelObjectFactory.newBomb(this.owner_, level, position, newVelocity, lifetime, damage, bounceCount, blastRadius, proxRadius);
this.owner_.addProjectile(projectile);
return {
'type': this.getType(),
'level': level,
'vel': newVelocity.toArray(),
'bounceCount': bounceCount
};
}
开发者ID:krslynx,项目名称:dotproduct,代码行数:31,代码来源:BombBay.ts
示例2: onFired
public onFired(timeDiff : number, position : Vector, velocity : Vector, weaponData : any) {
assert(weaponData['type'] == this.getType(), 'Cannot fire decoy with incorrect weapon type: ' + weaponData['type']);
let lifetime = this.settings_['lifetime'];
let projectile = this.simulation_.modelObjectFactory.newDecoy(this.owner_, this.owner_.getPosition(), this.owner_.getVelocity(), lifetime);
this.owner_.addProjectile(projectile);
for (let i = 0; i < timeDiff; ++i) {
projectile.advanceTime();
}
}
开发者ID:krslynx,项目名称:dotproduct,代码行数:12,代码来源:DecoyWeapon.ts
示例3: fire
public fire(position : Vector, commitFireFn : (fireEnergy : number, fireDelay : number) => boolean) : any {
if (this.count_ <= 0 || !commitFireFn(0 /* fireEnergy */, this.settings_['fireDelay'])) {
return null;
}
--this.count_;
let lifetime = this.settings_['lifetime'];
let projectile = this.simulation_.modelObjectFactory.newDecoy(this.owner_, this.owner_.getPosition(), this.owner_.getVelocity(), lifetime);
this.owner_.addProjectile(projectile);
return {
'type': this.getType()
};
}
开发者ID:krslynx,项目名称:dotproduct,代码行数:14,代码来源:DecoyWeapon.ts
示例4: onFired
public onFired(timeDiff : number, position : Vector, velocity : Vector, weaponData : any) {
assert(weaponData['type'] == this.getType(), 'Cannot fire repel with incorrect weapon type: ' + weaponData['type']);
let lifetime = this.settings_['lifetime'];
let distance = this.settings_['distance'];
let speed = this.settings_['speed'];
let projectile = this.simulation_.modelObjectFactory.newRepel(this.owner_, position, lifetime, distance, speed);
this.owner_.addProjectile(projectile);
for (let i = 0; i < timeDiff; ++i) {
projectile.advanceTime();
}
}
开发者ID:krslynx,项目名称:dotproduct,代码行数:14,代码来源:RepelWeapon.ts
示例5: fire
public fire(angle : number, position : Vector, velocity : Vector, commitFireFn : (fireEnergy : number, fireDelay : number) => boolean) : any {
let fireEnergy = this.getFireEnergy_();
let fireDelay = this.getFireDelay_();
let level = this.level_.getValue();
if (level < 0 || !commitFireFn(fireEnergy, fireDelay)) {
return null;
}
let factory = this.simulation_.modelObjectFactory;
let lifetime = this.getLifetime_();
let damage = this.getDamage_();
let bounceCount = this.getBounceCount_();
let bulletSpeed = this.getBulletSpeed_();
let multifireAngle = (this.multifireState_ == ToggleState.ENABLED) ? this.gunSettings_['multifire']['angle'] : 0;
let bullets = new Array<Bullet>();
if (this.gunSettings_['doubleBarrel']) {
let bulletVelocity = velocity.add(Vector.fromPolar(bulletSpeed, angle));
let leftPosition = position.add(Vector.fromPolar(10, angle - Math.PI / 2));
let rightPosition = position.add(Vector.fromPolar(10, angle + Math.PI / 2));
bullets.push(factory.newBullet(this.owner_, level, leftPosition, bulletVelocity, lifetime, damage, bounceCount));
bullets.push(factory.newBullet(this.owner_, level, rightPosition, bulletVelocity, lifetime, damage, bounceCount));
} else {
let bulletVelocity = velocity.add(Vector.fromPolar(bulletSpeed, angle));
bullets.push(factory.newBullet(this.owner_, level, position, bulletVelocity, lifetime, damage, bounceCount));
}
if (this.multifireState_ == ToggleState.ENABLED) {
let leftVelocity = velocity.add(Vector.fromPolar(bulletSpeed, angle - multifireAngle));
let rightVelocity = velocity.add(Vector.fromPolar(bulletSpeed, angle + multifireAngle));
bullets.push(factory.newBullet(this.owner_, level, position, leftVelocity, lifetime, damage, bounceCount));
bullets.push(factory.newBullet(this.owner_, level, position, rightVelocity, lifetime, damage, bounceCount));
}
for (let i = 0; i < bullets.length; ++i) {
this.owner_.addProjectile(bullets[i]);
}
new BulletGroup(bullets);
return {
'type': this.getType(),
'angle': angle,
'level': level,
'bounceCount': bounceCount,
'multifire': this.multifireState_ == ToggleState.ENABLED
}
}
开发者ID:krslynx,项目名称:dotproduct,代码行数:50,代码来源:Gun.ts
示例6: onFired
public onFired(timeDiff : number, position : Vector, velocity : Vector, weaponData : any) {
assert(weaponData['type'] == this.getType(), 'Cannot fire gun with incorrect weapon type: ' + weaponData['type']);
let factory = this.simulation_.modelObjectFactory;
let level = weaponData['level'];
let angle = weaponData['angle'];
let bounceCount = weaponData['bounceCount'];
let isMultifire = weaponData['multifire'];
// Make sure the level is correct so the following getters use the right value for their calculations.
this.level_.setValue(level);
let lifetime = this.getLifetime_();
let damage = this.getDamage_();
let bulletSpeed = this.getBulletSpeed_();
let multifireAngle = isMultifire ? this.gunSettings_['multifire']['angle'] : 0;
let bullets = new Array<Bullet>();
if (this.gunSettings_['doubleBarrel']) {
let bulletVelocity = velocity.add(Vector.fromPolar(bulletSpeed, angle));
let leftPosition = position.add(Vector.fromPolar(10, angle - Math.PI / 2));
let rightPosition = position.add(Vector.fromPolar(10, angle + Math.PI / 2));
bullets.push(factory.newBullet(this.owner_, level, leftPosition, bulletVelocity, lifetime, damage, bounceCount));
bullets.push(factory.newBullet(this.owner_, level, rightPosition, bulletVelocity, lifetime, damage, bounceCount));
} else {
let bulletVelocity = velocity.add(Vector.fromPolar(bulletSpeed, angle));
bullets.push(factory.newBullet(this.owner_, level, position, bulletVelocity, lifetime, damage, bounceCount));
}
if (isMultifire) {
let leftVelocity = velocity.add(Vector.fromPolar(bulletSpeed, angle - multifireAngle));
let rightVelocity = velocity.add(Vector.fromPolar(bulletSpeed, angle + multifireAngle));
bullets.push(factory.newBullet(this.owner_, level, position, leftVelocity, lifetime, damage, bounceCount));
bullets.push(factory.newBullet(this.owner_, level, position, rightVelocity, lifetime, damage, bounceCount));
}
for (let i = 0; i < bullets.length; ++i) {
this.owner_.addProjectile(bullets[i]);
}
new BulletGroup(bullets);
for (let i = 0; i < timeDiff; ++i) {
for (let j = 0; j < bullets.length; ++j) {
bullets[j].advanceTime();
}
}
}
开发者ID:krslynx,项目名称:dotproduct,代码行数:49,代码来源:Gun.ts
示例7: onFired
public onFired(timeDiff : number, position : Vector, velocity : Vector, weaponData : any) {
assert(weaponData['type'] == this.getType(), 'Cannot fire burst with incorrect weapon type: ' + weaponData['type']);
let shrapnelCount = this.settings_['shrapnelCount'];
let lifetime = this.settings_['lifetime'];
let damage = this.settings_['damage'];
for (let i = 0; i < shrapnelCount; ++i) {
let shrapVel = Vector.fromPolar(this.settings_['speed'], i * 2 * Math.PI / shrapnelCount).add(velocity);
let projectile = this.simulation_.modelObjectFactory.newBurst(this.owner_, position, shrapVel, lifetime, damage);
for (let j = 0; j < timeDiff; ++j) {
projectile.advanceTime();
}
this.owner_.addProjectile(projectile);
}
}
开发者ID:krslynx,项目名称:dotproduct,代码行数:16,代码来源:BurstWeapon.ts
示例8: onFired
public onFired(timeDiff : number, position : Vector, velocity : Vector, weaponData : any) {
assert(weaponData['type'] == this.getType(), 'Cannot fire bomb with incorrect weapon type: ' + weaponData['type']);
let level = weaponData['level'];
let bounceCount = weaponData['bounceCount'];
velocity = Vector.fromArray(weaponData['vel']);
// Make sure the level is correct so the following getters use the right value for their calculations.
this.level_.setValue(level);
let projectile = this.simulation_.modelObjectFactory.newBomb(this.owner_, this.level_.getValue(), position, velocity, this.getLifetime_(), this.getDamage_(), bounceCount, this.getBlastRadius_(), this.getProxRadius_());
for (let i = 0; i < timeDiff; ++i) {
projectile.advanceTime();
}
this.owner_.addProjectile(projectile);
}
开发者ID:krslynx,项目名称:dotproduct,代码行数:16,代码来源:BombBay.ts
示例9: fire
public fire(position : Vector, commitFireFn : (fireEnergy : number, fireDelay : number) => boolean) : any {
if (this.count_ <= 0 || !commitFireFn(0 /* fireEnergy */, this.settings_['fireDelay'])) {
return null;
}
--this.count_;
let shrapnelCount = this.settings_['shrapnelCount'];
let lifetime = this.settings_['lifetime'];
let damage = this.settings_['damage'];
for (let i = 0; i < shrapnelCount; ++i) {
let velocity = Vector.fromPolar(this.settings_['speed'], i * 2 * Math.PI / shrapnelCount).add(this.owner_.getVelocity());
let projectile = this.simulation_.modelObjectFactory.newBurst(this.owner_, this.owner_.getPosition(), velocity, lifetime, damage);
this.owner_.addProjectile(projectile);
}
return {
'type': this.getType()
};
}
开发者ID:krslynx,项目名称:dotproduct,代码行数:20,代码来源:BurstWeapon.ts
注:本文中的model/player/Player.addProjectile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论