示例#1
0
 public Weapon(IReal wielder, Specs payload, Vector3 offset)
     : this(wielder, payload)
 {
     Angle  = (float)Math.Atan2(offset.Y, offset.X);
     Length = new Vector2(offset.X, offset.Y).Length();
     Depth  = offset.Z;
 }
示例#2
0
 public Weapon(IReal wielder, Specs payload, float depth)
     : this(wielder, payload)
 {
     Angle  = 0.0f;
     Length = 0.0f;
     Depth  = depth;
 }
示例#3
0
 public MountedTurret(IReal wielder, Specs payload, Vector3 offset,
                      float turnSpeed, float eleSpeed)
     : base(wielder, payload, offset)
 {
     TurnSpeed = turnSpeed;
     EleSpeed  = eleSpeed;
 }
示例#4
0
 public MountedTurret(IReal wielder, Specs payload, float depth,
                      float turnSpeed, float eleSpeed)
     : base(wielder, payload, depth)
 {
     TurnSpeed = turnSpeed;
     EleSpeed  = eleSpeed;
 }
Check(
    IReal item
)
{
    ValueReferenceException.Map(
        f => f.Parameter( "item" ),
        f => f.Down().Parameter( "item" ),
        () => Create().Check( item ) );
}
示例#6
0
 public Sprite(IReal parent)
 {
     Parent   = parent;
     Textures = new List <Rectangle>();
     for (int i = 0; i < 4; i++)
     {
         Textures.Add(new Rectangle(i * 32, 0, 32, 32));
     }
 }
示例#7
0
GetHashCode(
    IReal x
)
{
    NonNull.CheckParameter( x, "x" );
    return
        typeof( IReal ).GetHashCode()
        ^ x.GetValue().GetHashCode();
}
示例#8
0
Create(
    IReal value
    ///< - <tt>NonNull</tt>
    ///  - <tt>NonFractional</tt>
)
{
    NonNull.CheckParameter( value, "value" );
    NonFractional.CheckParameter( value, "value" );
    return new DecimalInteger( value.GetValue() );
}
CheckParameter(
    IReal   item,
    string  paramName
)
{
    ValueReferenceException.Map(
        f => f.Up().Parameter( paramName ),
        f => f.Down().Parameter( "item" ),
        () => Check( item ) );
}
示例#10
0
Equals(
    IReal x,
    IReal y
)
{
    if( x == null && y == null ) return true;
    if( x == null || y == null ) return false;
    if( object.ReferenceEquals( x, y ) ) return true;
    return x.GetValue() == y.GetValue();
}
示例#11
0
Compare(
    IReal x,
    IReal y
)
{
    if( x == null && y == null ) return 0;
    if( x == null ) return -1;
    if( y == null ) return 1;
    if( object.ReferenceEquals( x, y ) ) return 0;
    return x.GetValue().CompareTo( y.GetValue() );
}
示例#12
0
        protected void Fire(IReal shooter, Vector3 pos, Vector3 vel, Specs spec)
        {
            Shooter       = shooter;
            Position      = pos;
            Velocity      = vel;
            Specification = spec;

            Gravitized = spec.Gravitized;
            Elasticity = spec.Elasticity;
            Aero       = spec.Aero;
            Active     = true;
            Bounces    = 0;
        }
示例#13
0
        public static void Fire(IReal shooter, Vector3 pos, float angle, float elevation, Specs spec)
        {
            // TODO: really wish this could be implemented in the manager somehow
            Munition toFire;

            if (Registry.MunMan.Stored.Count > 0)
            {
                toFire = Registry.MunMan.Stored[0];
            }
            else
            {
                toFire = new Munition();
            }

            toFire.Fire(shooter, pos, Gizmo.VectorFromAngles(angle, elevation, spec.MuzzleVel), spec);
            Registry.MunMan.Add(toFire);
        }
示例#14
0
DividedBy(
    this IReal  dis,
    IReal       that
    ///< - <tt>NonZero</tt>
)
{
    NonNull.CheckParameter( dis, "dis" );
    NonNull.CheckParameter( that, "that" );
    NonZero.CheckParameter( that, "that" );
    return Create( dis.GetValue() / that.GetValue() );
}
示例#15
0
Times(
    this IReal  dis,
    IReal       that
)
{
    NonNull.CheckParameter( dis, "dis" );
    NonNull.CheckParameter( that, "that" );
    return Create( dis.GetValue() * that.GetValue() );
}
示例#16
0
 public Sprite(IReal parent, List <Rectangle> textures)
 {
     Parent   = parent;
     Textures = textures;
 }
示例#17
0
 protected Weapon(IReal wielder, Specs payload)
 {
     Wielder = wielder;
     Payload = payload;
 }
示例#18
0
Test_InRange(
    RType< IReal >  t,
    IReal           min,
    IReal           max,
    bool            skipout
)
{
    Print( "null passes" );
    t.Check( null );
    Print( "Smaller fails" );
    if( !skipout )
        Expect(
            e => RTypeException.Match( e,
                (vr,f) => vr.Equals( f.Down().Parameter( "item" ) ),
                rt => rt.Equals( t ) ),
            () => t.Check( min.Minus( Real.Create( 1m ) ) ) );
    Print( "Min passes" );
    t.Check( min );
    Print( "In range passes" );
    t.Check( Real.Create( 10 ) );
    Print( "Max passes" );
    t.Check( max );
    Print( "Bigger fails" );
    if( !skipout )
        Expect(
            e => RTypeException.Match( e,
                (vr,f) => vr.Equals( f.Down().Parameter( "item" ) ),
                rt => rt.Equals( t ) ),
            () => t.Check( max.Plus( Real.Create( 1m ) ) ) );
}