git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1306 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
21
OpenRa.Game/Harvester.cs
Normal file
21
OpenRa.Game/Harvester.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
class Harvester : Unit
|
||||
{
|
||||
static Sequence idle = SequenceProvider.GetSequence("harv", "idle");
|
||||
|
||||
public override Sprite[] CurrentImages
|
||||
{
|
||||
get { return new Sprite[] { idle.GetSprite(facing) }; }
|
||||
}
|
||||
|
||||
public Harvester(int2 cell, int palette)
|
||||
: base(cell, palette, new float2(12,12))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,6 @@ namespace OpenRa.Game
|
||||
Sidebar sidebar;
|
||||
Viewport viewport;
|
||||
|
||||
ISelectable myUnit;
|
||||
|
||||
static Size GetResolution(Settings settings)
|
||||
{
|
||||
Size desktopResolution = Screen.PrimaryScreen.Bounds.Size;
|
||||
@@ -41,7 +39,9 @@ namespace OpenRa.Game
|
||||
Location = Point.Empty;
|
||||
Visible = true;
|
||||
|
||||
renderer = new Renderer(this, GetResolution(settings), true);
|
||||
bool windowed = !settings.GetValue("fullscreeen", false);
|
||||
|
||||
renderer = new Renderer(this, GetResolution(settings), windowed);
|
||||
|
||||
map = new Map(new IniFile(File.OpenRead("../../../" + settings.GetValue("map", "scm12ea.ini"))));
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace OpenRa.Game
|
||||
world.Add( new Mcv( new int2( 5, 5 ), 3 ) );
|
||||
world.Add( new Mcv( new int2( 7, 5 ), 2 ) );
|
||||
Mcv mcv = new Mcv( new int2( 9, 5 ), 1 );
|
||||
myUnit = mcv;
|
||||
world.myUnit = mcv;
|
||||
world.Add( mcv );
|
||||
world.Add( new Refinery( new int2( 7, 5 ), 2 ) );
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace OpenRa.Game
|
||||
{
|
||||
int x = (int)( ( e.X + viewport.Location.X ) / 24 );
|
||||
int y = (int)( ( e.Y + viewport.Location.Y ) / 24 );
|
||||
myUnit.Order( new int2( x, y ) ).Apply();
|
||||
world.myUnit.Order( new int2( x, y ) ).Apply();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ namespace OpenRa.Game
|
||||
{
|
||||
class Mcv : Unit
|
||||
{
|
||||
static Range<int> mcvRange = UnitSheetBuilder.GetUnit( "mcv" );
|
||||
static Sequence sequence = SequenceProvider.GetSequence("mcv", "idle");
|
||||
|
||||
public Mcv( int2 location, int palette )
|
||||
: base( location, palette )
|
||||
: base(location, palette, new float2(12, 12))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ namespace OpenRa.Game
|
||||
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;
|
||||
}
|
||||
@@ -38,7 +41,7 @@ namespace OpenRa.Game
|
||||
|
||||
public override Sprite[] CurrentImages
|
||||
{
|
||||
get { return new Sprite[] { UnitSheetBuilder.sprites[ facing + mcvRange.Start ] }; }
|
||||
get { return new Sprite[] { sequence.GetSprite(facing) }; }
|
||||
}
|
||||
|
||||
public override IOrder Order( int2 xy )
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
<Compile Include="Actor.cs" />
|
||||
<Compile Include="Animation.cs" />
|
||||
<Compile Include="Building.cs" />
|
||||
<Compile Include="Harvester.cs" />
|
||||
<Compile Include="Log.cs" />
|
||||
<Compile Include="PathFinder.cs" />
|
||||
<Compile Include="Sequence.cs" />
|
||||
@@ -72,6 +73,7 @@
|
||||
<Compile Include="TerrainRenderer.cs" />
|
||||
<Compile Include="Tree.cs" />
|
||||
<Compile Include="TreeCache.cs" />
|
||||
<Compile Include="Truck.cs" />
|
||||
<Compile Include="Unit.cs" />
|
||||
<Compile Include="UnitSheetBuilder.cs" />
|
||||
<Compile Include="Util.cs" />
|
||||
|
||||
@@ -35,5 +35,15 @@ namespace OpenRa.Game
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool GetValue(string key, bool defaultValue)
|
||||
{
|
||||
bool result;
|
||||
|
||||
if (!bool.TryParse(GetValue(key, defaultValue.ToString()), out result))
|
||||
result = defaultValue;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
21
OpenRa.Game/Truck.cs
Normal file
21
OpenRa.Game/Truck.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
class Truck : Unit
|
||||
{
|
||||
static Sequence sequence = SequenceProvider.GetSequence("truk", "idle");
|
||||
|
||||
public Truck(int2 cell, int palette)
|
||||
: base(cell, palette, float2.Zero)
|
||||
{
|
||||
}
|
||||
|
||||
public override Sprite[] CurrentImages
|
||||
{
|
||||
get { return new Sprite[] { sequence.GetSprite(facing) }; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,14 @@ namespace OpenRa.Game
|
||||
protected TickFunc currentOrder = null;
|
||||
protected TickFunc nextOrder = null;
|
||||
|
||||
public Unit( int2 cell, int palette )
|
||||
protected readonly float2 renderOffset;
|
||||
|
||||
public Unit( int2 cell, int palette, float2 renderOffset )
|
||||
{
|
||||
fromCell = toCell = cell;
|
||||
this.renderOffset = renderOffset;
|
||||
// HACK: display the mcv centered in it's cell;
|
||||
renderLocation = ( cell * 24 ).ToFloat2() - new float2( 12, 12 );
|
||||
renderLocation = ( cell * 24 ).ToFloat2() - renderOffset;
|
||||
this.palette = palette;
|
||||
}
|
||||
|
||||
@@ -106,7 +109,7 @@ namespace OpenRa.Game
|
||||
else
|
||||
location = 24 * fromCell.ToFloat2();
|
||||
|
||||
renderLocation = location - new float2( 12, 12 ); // HACK: center mcv in it's cell
|
||||
renderLocation = location - renderOffset;
|
||||
|
||||
renderLocation = renderLocation.Round();
|
||||
};
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace OpenRa.Game
|
||||
SpriteRenderer spriteRenderer;
|
||||
Renderer renderer;
|
||||
Viewport viewport;
|
||||
public ISelectable myUnit;
|
||||
|
||||
public World(Renderer renderer, Viewport viewport)
|
||||
{
|
||||
|
||||
@@ -48,4 +48,22 @@
|
||||
<sequence name="make" start="0" length="*" src="procmake" />
|
||||
</unit>
|
||||
|
||||
<!-- mcv -->
|
||||
|
||||
<unit name="mcv">
|
||||
<sequence name="idle" start="0" length="*"/>
|
||||
</unit>
|
||||
|
||||
<!-- truck -->
|
||||
|
||||
<unit name="truk">
|
||||
<sequence name="idle" start="0" length="*"/>
|
||||
</unit>
|
||||
|
||||
<!-- harv -->
|
||||
|
||||
<unit name="harv">
|
||||
<sequence name="idle" start="0" length="32"/>
|
||||
</unit>
|
||||
|
||||
</sequences>
|
||||
|
||||
Reference in New Issue
Block a user