git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1296 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -14,12 +14,22 @@ namespace OpenRa.Game
|
|||||||
public Animation( string name )
|
public Animation( string name )
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
PlayToEnd( "idle" );
|
Play( "idle" );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sprite[] Images { get { return new Sprite[] { currentSequence.GetSprite( frame ) }; } }
|
public Sprite[] Images { get { return new Sprite[] { currentSequence.GetSprite( frame ) }; } }
|
||||||
|
|
||||||
public void PlayToEnd( string sequenceName )
|
public void Play( string sequenceName )
|
||||||
|
{
|
||||||
|
PlayThen( sequenceName, delegate { } );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PlayRepeating( string sequenceName )
|
||||||
|
{
|
||||||
|
PlayThen( sequenceName, delegate { PlayRepeating( sequenceName ); } );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PlayThen( string sequenceName, MethodInvoker after )
|
||||||
{
|
{
|
||||||
currentSequence = SequenceProvider.GetSequence( name, sequenceName );
|
currentSequence = SequenceProvider.GetSequence( name, sequenceName );
|
||||||
frame = 0;
|
frame = 0;
|
||||||
@@ -30,20 +40,11 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
frame = currentSequence.Length - 1;
|
frame = currentSequence.Length - 1;
|
||||||
tickFunc = delegate { };
|
tickFunc = delegate { };
|
||||||
|
after();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlayRepeating( string sequenceName )
|
|
||||||
{
|
|
||||||
currentSequence = SequenceProvider.GetSequence( name, sequenceName );
|
|
||||||
frame = 0;
|
|
||||||
tickFunc = delegate
|
|
||||||
{
|
|
||||||
frame = ( frame + 1 ) % currentSequence.Length;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
Action<double> tickFunc;
|
Action<double> tickFunc;
|
||||||
public void Tick( double t )
|
public void Tick( double t )
|
||||||
{
|
{
|
||||||
|
|||||||
30
OpenRa.Game/Building.cs
Normal file
30
OpenRa.Game/Building.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenRa.Game
|
||||||
|
{
|
||||||
|
class Building : Actor
|
||||||
|
{
|
||||||
|
protected Animation animation;
|
||||||
|
|
||||||
|
public Building( string name, int2 location, int palette )
|
||||||
|
{
|
||||||
|
this.renderLocation = 24.0f * location.ToFloat2();
|
||||||
|
this.palette = palette;
|
||||||
|
|
||||||
|
animation = new Animation( name );
|
||||||
|
animation.PlayThen( "make", delegate { animation.Play( "idle" ); } );
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Tick( World world, double t )
|
||||||
|
{
|
||||||
|
animation.Tick( t );
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Sprite[] CurrentImages
|
||||||
|
{
|
||||||
|
get { return animation.Images; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,25 +5,12 @@ using BluntDirectX.Direct3D;
|
|||||||
|
|
||||||
namespace OpenRa.Game
|
namespace OpenRa.Game
|
||||||
{
|
{
|
||||||
class ConstructionYard : Actor
|
class ConstructionYard : Building
|
||||||
{
|
{
|
||||||
Animation animation = new Animation( "fact" );
|
public ConstructionYard( int2 location, int palette )
|
||||||
|
: base( "fact", location, palette )
|
||||||
public ConstructionYard(float2 location, int palette)
|
|
||||||
{
|
{
|
||||||
this.renderLocation = location;
|
animation.PlayThen( "make", delegate { animation.PlayRepeating( "build" ); } );
|
||||||
this.palette = palette;
|
|
||||||
animation.PlayToEnd( "make" );
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Sprite[] CurrentImages
|
|
||||||
{
|
|
||||||
get { return animation.Images; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Tick( World world, double t )
|
|
||||||
{
|
|
||||||
animation.Tick( t );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ namespace OpenRa.Game
|
|||||||
Mcv mcv = new Mcv( new int2( 9, 5 ), 1 );
|
Mcv mcv = new Mcv( new int2( 9, 5 ), 1 );
|
||||||
myUnit = mcv;
|
myUnit = mcv;
|
||||||
world.Add( mcv );
|
world.Add( mcv );
|
||||||
|
world.Add( new Refinery( new int2( 7, 5 ), 2 ) );
|
||||||
|
|
||||||
sidebar = new Sidebar(Race.Soviet, renderer, viewport);
|
sidebar = new Sidebar(Race.Soviet, renderer, viewport);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,7 +133,8 @@ namespace OpenRa.Game
|
|||||||
world.AddFrameEndTask(delegate
|
world.AddFrameEndTask(delegate
|
||||||
{
|
{
|
||||||
world.Remove( this );
|
world.Remove( this );
|
||||||
world.Add(new ConstructionYard((fromCell * 24 - new int2(24, 24)).ToFloat2(), palette));
|
world.Add( new ConstructionYard( fromCell - new int2( 1, 1 ), palette ) );
|
||||||
|
world.Add( new Refinery( fromCell - new int2( 1, -2 ), palette ) );
|
||||||
} );
|
} );
|
||||||
currentOrder = null;
|
currentOrder = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Actor.cs" />
|
<Compile Include="Actor.cs" />
|
||||||
<Compile Include="Animation.cs" />
|
<Compile Include="Animation.cs" />
|
||||||
|
<Compile Include="Building.cs" />
|
||||||
<Compile Include="Log.cs" />
|
<Compile Include="Log.cs" />
|
||||||
<Compile Include="Sequence.cs" />
|
<Compile Include="Sequence.cs" />
|
||||||
<Compile Include="ConstructionYard.cs" />
|
<Compile Include="ConstructionYard.cs" />
|
||||||
|
|||||||
@@ -7,20 +7,11 @@ using System.Drawing;
|
|||||||
|
|
||||||
namespace OpenRa.Game
|
namespace OpenRa.Game
|
||||||
{
|
{
|
||||||
class Refinery : Actor
|
class Refinery : Building
|
||||||
{
|
{
|
||||||
Animation a = new Animation( "proc" );
|
public Refinery(int2 location, int palette)
|
||||||
|
: base( "proc", location, palette )
|
||||||
public Refinery(float2 location, int palette)
|
|
||||||
{
|
{
|
||||||
a.PlayToEnd( "idle" );
|
|
||||||
this.renderLocation = location;
|
|
||||||
this.palette = palette;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Sprite[] CurrentImages
|
|
||||||
{
|
|
||||||
get { return a.Images; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user