public static Gun Create(Vec3 firingDirection) { // We need an ID. Otherwise we can not add this to pool. var gun = Entity.Instantiate <Gun>(Vec3.Zero, Quat.Identity); gun.Speed = firingDirection; // This is currently used to register Gun for receiving update calls (Move) which decreases the cool-downtimer. GamePool.AddObjectToPool(gun); return(gun); }
public static LightGun Create(Vec3 firingDirection) { var lightGun = Entity.Instantiate <LightGun> (Vec3.Zero, Quat.Identity); lightGun.Speed = firingDirection; // Weapon is usded by enemy. Prevent from firing immediatelly after spawn. lightGun.CoolDownTime = 0.3f; // This is currently used to register Gun for receiving update calls (Move) which decreases the cool-downtimer. GamePool.AddObjectToPool(lightGun); return(lightGun); }
public static DefaultAmmo Create(Vec3 pos, Vec3 speed, bool isHostile, IParticleEffect weaponTrailParticleEffect, IParticleEffect weaponSmokeParticleEffect) { var ammo = Entity.Instantiate <DefaultAmmo> (pos, Quat.Identity, 0.5f, "objects/default/primitive_sphere.cgf"); ammo.LifeTime = 3f; ammo.Speed = speed; ammo.IsHostile = isHostile; ammo.WeaponSmokeParticleEffect = weaponSmokeParticleEffect; ammo.WeaponBulletParticleEffect = weaponTrailParticleEffect; // Causes geometry not to be rendered, as the entity particle effect is used as bullet ammo.SetSlotFlag(0, EEntitySlotFlags.ENTITY_SLOT_RENDER_NEAREST); ammo.SpawnParticles(); GamePool.AddObjectToPool(ammo); return(ammo); }
/// <summary> /// Spawn this instance. /// </summary> public static Player Create(Vec3 pos) { var player = Entity.Instantiate <Player>(pos, Quat.Identity, 10, PlayerSkin.Geometry); var particleEffect = Env.ParticleManager.FindEffect("spaceship.Trails.fire_trail"); player.LoadParticleEmitter(1, particleEffect, 0.03f); // Get position where to spawn the particle effect. Vec3 jetPosition = player.GetHelperPos(0, "particle_01"); // Rotate particle effect to ensure it's shown at the back of the ship. player.SetTM(1, Matrix34.Create(Vec3.One, Quat.CreateRotationX(Utils.Deg2Rad(270f)), jetPosition)); // Rotate Z-Axis of player ship in degrees. player.Rotation = new Quat(Matrix34.CreateRotationZ(Utils.Deg2Rad(180.0f))); Hud.CurrentHud.SetEnergy(player.MaxLife); GamePool.AddObjectToPool(player); return(player); }
public static DefaultAmmo Create(Vector3 pos, Vector3 speed, bool isHostile, IParticleEffect weaponTrailParticleEffect, IParticleEffect weaponSmokeParticleEffect) { var ammo = Entity.SpawnWithComponent <DefaultAmmo> (pos, Quaternion.Identity, 0.5f); ammo.Entity.LoadGeometry(0, "objects/default/primitive_sphere.cgf"); ammo.Entity.Physics.Physicalize(0, 1, EPhysicalizationType.ePT_Rigid); ammo.LifeTime = 3f; ammo.Speed = speed; ammo.IsHostile = isHostile; ammo.WeaponSmokeParticleEffect = weaponSmokeParticleEffect; ammo.WeaponBulletParticleEffect = weaponTrailParticleEffect; // Causes geometry not to be rendered, as the entity particle effect is used as bullet ammo.Entity.SetSlotFlag(0, EEntitySlotFlags.ENTITY_SLOT_RENDER_NEAREST); ammo.SpawnParticles(); GamePool.AddObjectToPool(ammo); return(ammo); }