refinery comes with a harvester
git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1344 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -10,9 +10,16 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
abstract class Actor
|
abstract class Actor
|
||||||
{
|
{
|
||||||
|
protected readonly Game game;
|
||||||
|
|
||||||
public abstract float2 RenderLocation { get; }
|
public abstract float2 RenderLocation { get; }
|
||||||
public Player owner;
|
public Player owner;
|
||||||
public abstract Sprite[] CurrentImages { get; }
|
public abstract Sprite[] CurrentImages { get; }
|
||||||
public virtual void Tick(Game game, int t) { }
|
public virtual void Tick(Game game, int t) { }
|
||||||
|
|
||||||
|
protected Actor(Game game)
|
||||||
|
{
|
||||||
|
this.game = game;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ namespace OpenRa.Game
|
|||||||
protected Animation animation;
|
protected Animation animation;
|
||||||
protected int2 location;
|
protected int2 location;
|
||||||
|
|
||||||
public Building( string name, int2 location, Player owner )
|
public Building( string name, int2 location, Player owner, Game game )
|
||||||
|
: base( game )
|
||||||
{
|
{
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
class ConstructionYard : Building
|
class ConstructionYard : Building
|
||||||
{
|
{
|
||||||
public ConstructionYard( int2 location, Player owner )
|
public ConstructionYard( int2 location, Player owner, Game game )
|
||||||
: base( "fact", location, owner )
|
: base( "fact", location, owner, game )
|
||||||
{
|
{
|
||||||
animation.PlayThen( "make", delegate { animation.PlayRepeating( "build" ); } );
|
animation.PlayThen( "make", delegate { animation.PlayRepeating( "build" ); } );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace OpenRa.Game
|
|||||||
treeCache = new TreeCache(renderer.Device, map);
|
treeCache = new TreeCache(renderer.Device, map);
|
||||||
|
|
||||||
foreach (TreeReference treeReference in map.Trees)
|
foreach (TreeReference treeReference in map.Trees)
|
||||||
world.Add(new Tree(treeReference, treeCache, map));
|
world.Add(new Tree(treeReference, treeCache, map, this));
|
||||||
|
|
||||||
pathFinder = new PathFinder(map, terrain.tileSet);
|
pathFinder = new PathFinder(map, terrain.tileSet);
|
||||||
|
|
||||||
@@ -48,12 +48,12 @@ namespace OpenRa.Game
|
|||||||
buildingCreation.Add( "fact",
|
buildingCreation.Add( "fact",
|
||||||
delegate( int2 location, Player owner )
|
delegate( int2 location, Player owner )
|
||||||
{
|
{
|
||||||
return new ConstructionYard( location, owner );
|
return new ConstructionYard( location, owner, this );
|
||||||
} );
|
} );
|
||||||
buildingCreation.Add( "proc",
|
buildingCreation.Add( "proc",
|
||||||
delegate( int2 location, Player owner )
|
delegate( int2 location, Player owner )
|
||||||
{
|
{
|
||||||
return new Refinery( location, owner );
|
return new Refinery( location, owner, this );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
string[] buildings = { "powr", "apwr", "weap", "barr", "atek", "stek", "dome" };
|
string[] buildings = { "powr", "apwr", "weap", "barr", "atek", "stek", "dome" };
|
||||||
@@ -66,7 +66,7 @@ namespace OpenRa.Game
|
|||||||
buildingCreation.Add( name,
|
buildingCreation.Add( name,
|
||||||
delegate( int2 location, Player owner )
|
delegate( int2 location, Player owner )
|
||||||
{
|
{
|
||||||
return new Building( name, location, owner );
|
return new Building( name, location, owner, this );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
class Harvester : Unit
|
class Harvester : Unit
|
||||||
{
|
{
|
||||||
public Harvester( int2 cell, Player owner )
|
public Harvester( int2 cell, Player owner, Game game )
|
||||||
: base( "harv", cell, owner, new float2( 12, 12 ) )
|
: base( "harv", cell, owner, new float2( 12, 12 ), game )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,12 +45,11 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
SequenceProvider.ForcePrecache();
|
SequenceProvider.ForcePrecache();
|
||||||
|
|
||||||
game.world.Add( new Mcv( new int2( 5, 5 ), game.players[ 3 ] ) );
|
game.world.Add( new Mcv( new int2( 5, 5 ), game.players[ 3 ], game ) );
|
||||||
game.world.Add( new Mcv( new int2( 7, 5 ), game.players[ 2 ] ) );
|
game.world.Add( new Mcv( new int2( 7, 5 ), game.players[ 2 ], game ) );
|
||||||
Mcv mcv = new Mcv( new int2( 9, 5 ), game.players[ 1 ] );
|
Mcv mcv = new Mcv( new int2( 9, 5 ), game.players[ 1 ], game );
|
||||||
game.world.orderGenerator = mcv;
|
game.world.orderGenerator = mcv;
|
||||||
game.world.Add( mcv );
|
game.world.Add( mcv );
|
||||||
game.world.Add( new Refinery( new int2( 7, 5 ), game.players[ 2 ] ) );
|
|
||||||
|
|
||||||
sidebar = new Sidebar(Race.Soviet, renderer, game);
|
sidebar = new Sidebar(Race.Soviet, renderer, game);
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
class Mcv : Unit
|
class Mcv : Unit
|
||||||
{
|
{
|
||||||
public Mcv( int2 location, Player owner )
|
public Mcv( int2 location, Player owner, Game game )
|
||||||
: base( "mcv", location, owner, new float2( 12, 12 ) )
|
: base( "mcv", location, owner, new float2( 12, 12 ), game )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,11 +25,7 @@ namespace OpenRa.Game
|
|||||||
world.AddFrameEndTask( delegate
|
world.AddFrameEndTask( delegate
|
||||||
{
|
{
|
||||||
world.Remove( this );
|
world.Remove( this );
|
||||||
world.Add( new ConstructionYard( fromCell - new int2( 1, 1 ), owner ) );
|
world.Add( new ConstructionYard( fromCell - new int2( 1, 1 ), owner, game ) );
|
||||||
world.Add( new Refinery( fromCell - new int2( 1, -2 ), owner ) );
|
|
||||||
|
|
||||||
world.orderGenerator = new Harvester( fromCell - new int2( 0, -4 ), owner );
|
|
||||||
world.Add( (Actor)world.orderGenerator );
|
|
||||||
} );
|
} );
|
||||||
currentOrder = null;
|
currentOrder = null;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,9 +9,21 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
class Refinery : Building
|
class Refinery : Building
|
||||||
{
|
{
|
||||||
public Refinery( int2 location, Player owner )
|
public Refinery( int2 location, Player owner, Game game )
|
||||||
: base( "proc", location, owner )
|
: base( "proc", location, owner, game )
|
||||||
{
|
{
|
||||||
|
animation.PlayThen("make", delegate
|
||||||
|
{
|
||||||
|
animation.PlayRepeating("idle");
|
||||||
|
|
||||||
|
game.world.AddFrameEndTask(delegate
|
||||||
|
{
|
||||||
|
Unit harvester = new Harvester(location + new int2(1, 2), owner, game);
|
||||||
|
harvester.facing = 8;
|
||||||
|
game.world.Add(harvester);
|
||||||
|
game.world.orderGenerator = harvester;
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,6 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
public IOrder Order( Game game, int2 xy )
|
public IOrder Order( Game game, int2 xy )
|
||||||
{
|
{
|
||||||
game.world.uiOverlay.KillOverlay();
|
|
||||||
// todo: check that space is free
|
// todo: check that space is free
|
||||||
return new PlaceBuildingOrder( this, xy );
|
return new PlaceBuildingOrder( this, xy );
|
||||||
}
|
}
|
||||||
@@ -175,6 +174,7 @@ namespace OpenRa.Game
|
|||||||
game.world.Add( newBuilding( xy, building.owner ) );
|
game.world.Add( newBuilding( xy, building.owner ) );
|
||||||
}
|
}
|
||||||
game.world.orderGenerator = null;
|
game.world.orderGenerator = null;
|
||||||
|
game.world.uiOverlay.KillOverlay();
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
int2 location;
|
int2 location;
|
||||||
|
|
||||||
public Tree(TreeReference r, TreeCache renderer, Map map)
|
public Tree(TreeReference r, TreeCache renderer, Map map, Game game)
|
||||||
|
: base( game )
|
||||||
{
|
{
|
||||||
location = new int2( r.Location ) - map.Offset;
|
location = new int2( r.Location ) - map.Offset;
|
||||||
currentImages = new Sprite[] { renderer.GetImage(r.Image) };
|
currentImages = new Sprite[] { renderer.GetImage(r.Image) };
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
protected Animation animation;
|
protected Animation animation;
|
||||||
|
|
||||||
protected int facing = 0;
|
public int facing = 0;
|
||||||
protected int2 fromCell, toCell;
|
protected int2 fromCell, toCell;
|
||||||
protected int moveFraction, moveFractionTotal;
|
protected int moveFraction, moveFractionTotal;
|
||||||
|
|
||||||
@@ -18,7 +18,8 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
protected readonly float2 renderOffset;
|
protected readonly float2 renderOffset;
|
||||||
|
|
||||||
public Unit( string name, int2 cell, Player owner, float2 renderOffset )
|
public Unit( string name, int2 cell, Player owner, float2 renderOffset, Game game )
|
||||||
|
: base( game )
|
||||||
{
|
{
|
||||||
fromCell = toCell = cell;
|
fromCell = toCell = cell;
|
||||||
this.renderOffset = renderOffset;
|
this.renderOffset = renderOffset;
|
||||||
|
|||||||
Reference in New Issue
Block a user