44 lines
849 B
C#
44 lines
849 B
C#
|
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");
|
|||
|
}
|
|||
|
|
|||
|
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);
|
|||
|
|
|||
|
try{
|
|||
|
Vector3 ground = SquaredMap.activeMap.ground(Position.Xy);
|
|||
|
|
|||
|
if (Position.Z <= ground.Z){
|
|||
|
destroy();
|
|||
|
}
|
|||
|
} catch (OutOfWorldException e){
|
|||
|
destroy();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|