Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ShotController : ZilchComponent
- {
- var DiagonalBulletSpeed : Real = 10 * Math.Sin(Math.ToRadians(45));
- var BulletDamageModifier : Real = 1.0;
- function Initialize(init : CogInitializer)
- {
- Zero.Connect(this.Owner, Events.ShootUp, this.OnShootUp);
- Zero.Connect(this.Owner, Events.ShootDown, this.OnShootDown);
- Zero.Connect(this.Owner, Events.ShootLeft, this.OnShootLeft);
- Zero.Connect(this.Owner, Events.ShootRight, this.OnShootRight);
- Zero.Connect(this.Owner, Events.ShootUpLeft, this.OnShootUpLeft);
- Zero.Connect(this.Owner, Events.ShootUpRight, this.OnShootUpRight);
- Zero.Connect(this.Owner, Events.ShootDownLeft, this.OnShootDownLeft);
- Zero.Connect(this.Owner, Events.ShootDownRight, this.OnShootDownRight);
- Zero.Connect(this.Space, Events.LogicUpdate, this.OnLogicUpdate);
- }
- function OnLogicUpdate(event : UpdateEvent)
- {
- this.BulletDamageModifier = this.Owner.PlayerController.BulletDamageMod;
- }
- function OnShootUp(event : Event)
- {
- var bullet = this.Space.CreateAtPosition(Archetype.PlayerBullet, this.Owner.Transform.Translation + Real3(0.0, 0.0, 0.0));
- bullet.RigidBody.Velocity = Real3(0, 10, 0);
- bullet.DamageOnCollide.Damage *= this.BulletDamageModifier;
- }
- function OnShootDown(event : Event)
- {
- var bullet = this.Space.CreateAtPosition(Archetype.PlayerBullet, this.Owner.Transform.Translation);
- bullet.RigidBody.Velocity = Real3(0, -10, 0);
- bullet.DamageOnCollide.Damage *= this.BulletDamageModifier;
- }
- function OnShootLeft(event : Event)
- {
- var bullet = this.Space.CreateAtPosition(Archetype.PlayerBullet, this.Owner.Transform.Translation);
- bullet.RigidBody.Velocity = Real3(-10, 0, 0);
- bullet.DamageOnCollide.Damage *= this.BulletDamageModifier;
- }
- function OnShootRight(event : Event)
- {
- var bullet = this.Space.CreateAtPosition(Archetype.PlayerBullet, this.Owner.Transform.Translation);
- bullet.RigidBody.Velocity = Real3(10, 0, 0);
- bullet.DamageOnCollide.Damage *= this.BulletDamageModifier;
- }
- function OnShootUpLeft(event : Event)
- {
- var bullet = this.Space.CreateAtPosition(Archetype.PlayerBullet, this.Owner.Transform.Translation);
- bullet.RigidBody.Velocity = Real3(-this.DiagonalBulletSpeed, this.DiagonalBulletSpeed, 0);
- bullet.DamageOnCollide.Damage *= this.BulletDamageModifier;
- }
- function OnShootUpRight(event : Event)
- {
- var bullet = this.Space.CreateAtPosition(Archetype.PlayerBullet, this.Owner.Transform.Translation);
- bullet.RigidBody.Velocity = Real3(this.DiagonalBulletSpeed, this.DiagonalBulletSpeed, 0);
- bullet.DamageOnCollide.Damage *= this.BulletDamageModifier;
- }
- function OnShootDownLeft(event : Event)
- {
- var bullet = this.Space.CreateAtPosition(Archetype.PlayerBullet, this.Owner.Transform.Translation);
- bullet.RigidBody.Velocity = Real3(-this.DiagonalBulletSpeed, -this.DiagonalBulletSpeed, 0);
- bullet.DamageOnCollide.Damage *= this.BulletDamageModifier;
- }
- function OnShootDownRight(event : Event)
- {
- var bullet = this.Space.CreateAtPosition(Archetype.PlayerBullet, this.Owner.Transform.Translation);
- bullet.RigidBody.Velocity = Real3(this.DiagonalBulletSpeed, -this.DiagonalBulletSpeed, 0);
- bullet.DamageOnCollide.Damage *= this.BulletDamageModifier;
- }
- }
Add Comment
Please, Sign In to add comment