git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1323 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -54,7 +54,8 @@ namespace OpenRa
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static float2 operator *(float a, float2 b) { return new float2(a * b.X, a * b.Y); }
|
public static float2 operator *(float a, float2 b) { return new float2(a * b.X, a * b.Y); }
|
||||||
public static float2 operator /(float2 a, float2 b) { return new float2(a.X / b.X, a.Y / b.Y); }
|
public static float2 operator *( float2 a, float2 b ) { return new float2( a.X * b.X, a.Y * b.Y ); }
|
||||||
|
public static float2 operator /( float2 a, float2 b ) { return new float2( a.X / b.X, a.Y / b.Y ); }
|
||||||
|
|
||||||
public static readonly float2 Zero = new float2(0, 0);
|
public static readonly float2 Zero = new float2(0, 0);
|
||||||
|
|
||||||
|
|||||||
@@ -26,12 +26,8 @@ namespace OpenRa.Game
|
|||||||
// TODO: check that there's actually some ore in this cell :)
|
// TODO: check that there's actually some ore in this cell :)
|
||||||
|
|
||||||
// face in one of the 8 directions
|
// face in one of the 8 directions
|
||||||
int desiredFacing = ( facing + 1 ) & 28;
|
if( Turn( ( facing + 1 ) & ~3 ) )
|
||||||
if( facing != desiredFacing )
|
|
||||||
{
|
|
||||||
Turn( desiredFacing );
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
currentOrder = delegate { };
|
currentOrder = delegate { };
|
||||||
if( nextOrder == null )
|
if( nextOrder == null )
|
||||||
|
|||||||
@@ -18,23 +18,20 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
nextOrder = delegate( Game game, double t )
|
nextOrder = delegate( Game game, double t )
|
||||||
{
|
{
|
||||||
int desiredFacing = 12;
|
if( Turn( 12 ) )
|
||||||
if( facing != desiredFacing )
|
return;
|
||||||
Turn( desiredFacing );
|
|
||||||
else
|
|
||||||
{
|
|
||||||
World world = game.world;
|
|
||||||
world.AddFrameEndTask( delegate
|
|
||||||
{
|
|
||||||
world.Remove( this );
|
|
||||||
world.Add( new ConstructionYard( fromCell - new int2( 1, 1 ), palette ) );
|
|
||||||
world.Add( new Refinery( fromCell - new int2( 1, -2 ), palette ) );
|
|
||||||
|
|
||||||
world.myUnit = new Harvester(fromCell - new int2(0, -4), palette);
|
World world = game.world;
|
||||||
world.Add((Actor)world.myUnit);
|
world.AddFrameEndTask( delegate
|
||||||
} );
|
{
|
||||||
currentOrder = null;
|
world.Remove( this );
|
||||||
}
|
world.Add( new ConstructionYard( fromCell - new int2( 1, 1 ), palette ) );
|
||||||
|
world.Add( new Refinery( fromCell - new int2( 1, -2 ), palette ) );
|
||||||
|
|
||||||
|
world.myUnit = new Harvester( fromCell - new int2( 0, -4 ), palette );
|
||||||
|
world.Add( (Actor)world.myUnit );
|
||||||
|
} );
|
||||||
|
currentOrder = null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace OpenRa.Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
static float2[] fvecs = Util.MakeArray<float2>( 32,
|
static float2[] fvecs = Util.MakeArray<float2>( 32,
|
||||||
delegate( int i ) { return -float2.FromAngle( i / 16.0f * (float)Math.PI ); } );
|
delegate( int i ) { return -float2.FromAngle( i / 16.0f * (float)Math.PI ) * new float2( 1f, 1.3f ); } );
|
||||||
|
|
||||||
int GetFacing( float2 d )
|
int GetFacing( float2 d )
|
||||||
{
|
{
|
||||||
@@ -37,7 +37,7 @@ namespace OpenRa.Game
|
|||||||
return facing;
|
return facing;
|
||||||
|
|
||||||
int highest = -1;
|
int highest = -1;
|
||||||
float highestDot = -1.0f;
|
float highestDot = -1.0f
|
||||||
|
|
||||||
for( int i = 0 ; i < fvecs.Length ; i++ )
|
for( int i = 0 ; i < fvecs.Length ; i++ )
|
||||||
{
|
{
|
||||||
@@ -74,12 +74,8 @@ namespace OpenRa.Game
|
|||||||
if( nextOrder != null )
|
if( nextOrder != null )
|
||||||
destination = toCell;
|
destination = toCell;
|
||||||
|
|
||||||
int desiredFacing = GetFacing( toCell - fromCell );
|
if( Turn( GetFacing( toCell - fromCell ) ) )
|
||||||
if( facing != desiredFacing )
|
|
||||||
{
|
|
||||||
Turn( desiredFacing );
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
moveFraction += (int)( t * ( Speed * 100 ) );
|
moveFraction += (int)( t * ( Speed * 100 ) );
|
||||||
if( moveFraction < moveFractionTotal )
|
if( moveFraction < moveFractionTotal )
|
||||||
@@ -108,10 +104,14 @@ namespace OpenRa.Game
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Turn( int desiredFacing )
|
protected bool Turn( int desiredFacing )
|
||||||
{
|
{
|
||||||
|
if( facing == desiredFacing )
|
||||||
|
return false;
|
||||||
|
|
||||||
int df = ( desiredFacing - facing + 32 ) % 32;
|
int df = ( desiredFacing - facing + 32 ) % 32;
|
||||||
facing = ( facing + ( df > 16 ? 31 : 1 ) ) % 32;
|
facing = ( facing + ( df > 16 ? 31 : 1 ) ) % 32;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual IOrder Order( int2 xy )
|
public virtual IOrder Order( int2 xy )
|
||||||
|
|||||||
Reference in New Issue
Block a user