git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1296 993157c7-ee19-0410-b2c4-bb4e9862e678

This commit is contained in:
(no author)
2007-07-17 12:52:43 +00:00
parent 6bb26d95e1
commit 5bb5fc32fe
7 changed files with 55 additions and 43 deletions

View File

@@ -14,12 +14,22 @@ namespace OpenRa.Game
public Animation( string name )
{
this.name = name;
PlayToEnd( "idle" );
Play( "idle" );
}
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 );
frame = 0;
@@ -30,20 +40,11 @@ namespace OpenRa.Game
{
frame = currentSequence.Length - 1;
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;
public void Tick( double t )
{

30
OpenRa.Game/Building.cs Normal file
View 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; }
}
}
}

View File

@@ -5,25 +5,12 @@ using BluntDirectX.Direct3D;
namespace OpenRa.Game
{
class ConstructionYard : Actor
class ConstructionYard : Building
{
Animation animation = new Animation( "fact" );
public ConstructionYard(float2 location, int palette)
public ConstructionYard( int2 location, int palette )
: base( "fact", location, palette )
{
this.renderLocation = location;
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 );
animation.PlayThen( "make", delegate { animation.PlayRepeating( "build" ); } );
}
}
}

View File

@@ -67,6 +67,7 @@ namespace OpenRa.Game
Mcv mcv = new Mcv( new int2( 9, 5 ), 1 );
myUnit = mcv;
world.Add( mcv );
world.Add( new Refinery( new int2( 7, 5 ), 2 ) );
sidebar = new Sidebar(Race.Soviet, renderer, viewport);
}

View File

@@ -133,7 +133,8 @@ namespace OpenRa.Game
world.AddFrameEndTask(delegate
{
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;
}

View File

@@ -42,6 +42,7 @@
<ItemGroup>
<Compile Include="Actor.cs" />
<Compile Include="Animation.cs" />
<Compile Include="Building.cs" />
<Compile Include="Log.cs" />
<Compile Include="Sequence.cs" />
<Compile Include="ConstructionYard.cs" />

View File

@@ -7,20 +7,11 @@ using System.Drawing;
namespace OpenRa.Game
{
class Refinery : Actor
class Refinery : Building
{
Animation a = new Animation( "proc" );
public Refinery(float2 location, int palette)
public Refinery(int2 location, int palette)
: base( "proc", location, palette )
{
a.PlayToEnd( "idle" );
this.renderLocation = location;
this.palette = palette;
}
public override Sprite[] CurrentImages
{
get { return a.Images; }
}
}
}