using System; using org.niclasundharald.engine.graphics.primitives; using org.niclasundharald.engine.graphics; using OpenTK; namespace org.niclasundharald.engine { public class BallisticActor : Actor { public BallisticActor(int id) :base(id) { this.Model3D = ModelManager.instance.findModel("ballistisch"); setBuffers("HowFire", "HowHit", "st1"); } int hit = 0; public override void update(float timespan) { base.update(timespan); Velocity += (Physics.Gravitation * timespan); Position += Velocity * timespan; Scale = Matrix4.CreateScale(3.0f); setHeading( Velocity, Physics.Gravitation); Console.WriteLine("BallisticActor update: {0} / {1}",Position,Velocity); updateSoundState(); Console.WriteLine("Playing:" + isPlaying); try{ Vector3 ground = SquaredMap.activeMap.ground(Position.Xy); if (Position.Z <= ground.Z){ if(hit != 1) { playSound("HowHit"); updateSoundState(); hit = 1; } if(!isPlaying) { destroy(); } } } catch (OutOfWorldException e){ if(!isPlaying) destroy(); } } public void fire() { playSound("HowFire"); setDistanceAttenuation(2, 0, 50); } } }