protected override void Fire() { Vector3 forward = PhysicUtils.Forward(cannonsRotation); Vector3 left = PhysicUtils.Left(cannonsRotation); World.InstantiateLaser(CannonsPosition - left, forward, cannonsRotation, emitter); World.InstantiateLaser(CannonsPosition + left, forward, cannonsRotation, emitter); }
private void UpdateOrientation(BodyReference body) { Quaternion rotation = body.Pose.Orientation.ToQuaternion(); forward = -PhysicUtils.Forward(rotation); rightDirection = PhysicUtils.Left(rotation); upDirection = PhysicUtils.Up(rotation); }
protected override void OnInstantiate() { BodyReference body = Body(); System.Numerics.Vector3 velocity = PhysicUtils.Forward(body.Pose.Orientation.ToQuaternion()).ToBEPU() * linearVelocity; body.Velocity.Linear = velocity; engineSound = TGCGame.content.S_TIEEngine.CreateInstance(); engineSound.IsLooped = true; engineSound.Volume = 0.001f; emitter.Velocity = velocity.ToVector3(); TGCGame.soundManager.PlaySound(engineSound, emitter); }
protected void Fire(BodyReference body, GameTime gameTime) { double totalTime = gameTime.TotalGameTime.TotalMilliseconds; if (totalTime < LastFire + FireCooldownTime) { return; } Vector3 position = body.Pose.Position.ToVector3(); Quaternion rotation = body.Pose.Orientation.ToQuaternion(); Vector3 forward = PhysicUtils.Forward(rotation); Quaternion laserOrientation = PhysicUtils.DirectionsToQuaternion(forward, Vector3.Up); World.InstantiateLaser(position, -forward, laserOrientation, Emitter, LaserVolume); LastFire = totalTime; FireCounter++; }
private void FaceXWing(BodyReference body, GameTime gameTime) { Vector3 XWingDirection = World.xwing.Position() - body.Pose.Position.ToVector3(); Quaternion RotationToXWing = new Quaternion(XWingDirection, 1f); RotationToXWing.Normalize(); Quaternion ActualRotation = body.Pose.Orientation.ToQuaternion(); ActualRotation.Normalize(); Quaternion FinalRotation = Quaternion.Slerp(RotationToXWing, ActualRotation, 8 * (float)gameTime.ElapsedGameTime.TotalSeconds); body.Pose.Orientation = FinalRotation.ToBEPU(); Quaternion rotation = body.Pose.Orientation.ToQuaternion(); Vector3 forward = PhysicUtils.Forward(rotation); body.Velocity.Linear = (forward * StandarVelocity).ToBEPU(); }
private void Flee(BodyReference body, GameTime gameTime) { Quaternion DegreeRotation = new Quaternion(new Vector3(0, 1, 0), 1f); DegreeRotation.Normalize(); Quaternion ActualRotation = body.Pose.Orientation.ToQuaternion(); ActualRotation.Normalize(); Quaternion FinalRotation = Quaternion.Slerp(DegreeRotation, ActualRotation, (float)gameTime.ElapsedGameTime.TotalSeconds); body.Pose.Orientation = FinalRotation.ToBEPU(); Quaternion rotation = body.Pose.Orientation.ToQuaternion(); Vector3 forward = PhysicUtils.Forward(rotation); body.Velocity.Linear = (forward * FastVelocity).ToBEPU(); }
protected override void OnInstantiate() { BodyReference body = Body(); body.Velocity.Linear = -PhysicUtils.Forward(body.Pose.Orientation.ToQuaternion()).ToBEPU() * LinearVelocity; }