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"); for (int n=0;n < this.Model3D.vertexes.Length;n++){ this.Model3D.colors[n] = new Vector4(1.0f,0.2f + (0.5f * this.Model3D.vertexes[n].Z / -4.0f),0,1.0f); } this.Model3D.rebind(); setBuffers("HowFire", "HowHit"); setDistanceAttenuation(2, 200, 800); } byte 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"); } } }