combat actually works

This commit is contained in:
Chris Forbes
2009-10-21 21:34:34 +13:00
parent 659c3669e7
commit 4382a10568
9 changed files with 81 additions and 30 deletions

View File

@@ -22,34 +22,34 @@ namespace OpenRa.Game.GameRules
if( fieldType == typeof( int ) )
return int.Parse( x );
else if( fieldType == typeof( float ) )
return float.Parse( x );
else if (fieldType == typeof(float))
return float.Parse(x.Replace("%","")) * (x.Contains( '%' ) ? 0.01f : 1f);
else if( fieldType == typeof( string ) )
else if (fieldType == typeof(string))
return x;//.ToLowerInvariant();
else if( fieldType.IsEnum )
return Enum.Parse( fieldType, x );
else if (fieldType.IsEnum)
return Enum.Parse(fieldType, x);
else if( fieldType == typeof( bool ) )
return ParseYesNo( x );
else if (fieldType == typeof(bool))
return ParseYesNo(x);
else if( fieldType.IsArray )
else if (fieldType.IsArray)
{
var parts = x.Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries );
var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
var ret = Array.CreateInstance( fieldType.GetElementType(), parts.Length );
for( int i = 0 ; i < parts.Length ; i++ )
ret.SetValue( GetValue( fieldType.GetElementType(), parts[ i ].Trim() ), i );
var ret = Array.CreateInstance(fieldType.GetElementType(), parts.Length);
for (int i = 0; i < parts.Length; i++)
ret.SetValue(GetValue(fieldType.GetElementType(), parts[i].Trim()), i);
return ret;
}
else if( fieldType == typeof( int2 ) )
else if (fieldType == typeof(int2))
{
var parts = x.Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries );
return new int2( int.Parse( parts[ 0 ] ), int.Parse( parts[ 1 ] ) );
var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
return new int2(int.Parse(parts[0]), int.Parse(parts[1]));
}
else
throw new InvalidOperationException( "FieldLoader: don't know how to load field of type " + fieldType.ToString() );
throw new InvalidOperationException("FieldLoader: don't know how to load field of type " + fieldType.ToString());
}
static bool ParseYesNo( string p )

View File

@@ -7,17 +7,17 @@ using IjwFramework.Types;
namespace OpenRa.Game.GameRules
{
public enum ArmorType
{
none = 0,
wood = 1,
light = 2,
heavy = 3,
concrete = 4,
}
public class UnitInfo
{
public enum ArmorType
{
none = 0,
wood = 1,
light = 2,
heavy = 3,
concrete = 4,
}
public readonly string Name;
public readonly string Description = "";

View File

@@ -10,11 +10,13 @@ namespace OpenRa.Game.GameRules
class WarheadInfo
{
public readonly int Spread = 1;
public readonly string Verses = "100%,100%,100%,100%,100%";
public readonly float[] Verses = { 1, 1, 1, 1, 1 };
public readonly bool Wall = false;
public readonly bool Wood = false;
public readonly bool Ore = false;
public readonly int Explosion = 0;
public readonly int InfDeath = 0;
public float EffectivenessAgainst(ArmorType at) { return Verses[ (int)at ]; }
}
}