using System; using org.budnhead.graphics.primitives; using org.budnhead.graphics; using org.budnhead.exceptions; using org.budnhead.tools; using OpenTK; namespace org.budnhead.core { public class BallisticActor : Actor { BallisticActorStates actorState; public BallisticActor(int id) :base(id) { this.actorState = BallisticActorStates.FLYING; this.Model3D = ResourceLibrary.getResource("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); } public override void update(float timespan) { base.update(timespan); switch (actorState){ case BallisticActorStates.FLYING: Velocity.Value += (Physics.Gravitation * timespan); Position.Value += Velocity.Value * timespan; setHeading( Velocity.Value, Physics.Gravitation); try { Vector3 ground = SquaredMap.activeMap.ground(Position.Value.Xy); if (Position.Value.Z <= ground.Z){ Console.WriteLine("BallisticActor hit ground!"); actorState = BallisticActorStates.HIT; playSound("HowHit"); } } catch (OutOfWorldException owe){ Console.WriteLine("BallisticActor disappeared at {0} [{1}]",Position,Velocity); actorState = BallisticActorStates.DISAPPEARED; } break; case BallisticActorStates.HIT: case BallisticActorStates.DISAPPEARED: Model3D = null; if (!soundPlaying()){ destroy(); } break; } } public void fire() { //playSound("HowFire"); } } }