unitinfo.InitialFacing etc

This commit is contained in:
Chris Forbes
2009-11-29 14:56:09 +13:00
parent cc2ef432b4
commit 9860b35030
9 changed files with 63 additions and 48 deletions

View File

@@ -53,6 +53,7 @@ namespace OpenRa.Game.GameRules
public readonly string SecondaryAnim = null;
public readonly bool MuzzleFlash = false;
public readonly int SelectionPriority = 10;
public readonly int InitialFacing = 128;
public UnitInfo(string name) { Name = name; }

View File

@@ -23,7 +23,7 @@ namespace OpenRa.Game.Graphics
Size tileSize = new Size( Game.CellSize, Game.CellSize );
SheetBuilder.ForceNewSheet();
// SheetBuilder.ForceNewSheet();
var tileMapping = new Cache<TileReference, Sprite>(
x => SheetBuilder.Add(Rules.TileSet.GetBytes(x), tileSize));

View File

@@ -82,6 +82,7 @@
<Compile Include="OrderManager.cs" />
<Compile Include="Ore.cs" />
<Compile Include="PathSearch.cs" />
<Compile Include="ProductionItem.cs" />
<Compile Include="Support\Stopwatch.cs" />
<Compile Include="Support\PerfHistory.cs" />
<Compile Include="Traits\AcceptsOre.cs" />

View File

@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
namespace OpenRa.Game
@@ -47,8 +46,7 @@ namespace OpenRa.Game
public void GiveCash( int num )
{
// TODO: increase cash
Cash += num; // TODO: slowly
Cash += num;
}
public bool TakeCash( int num )
@@ -97,45 +95,4 @@ namespace OpenRa.Game
production[ group ] = item;
}
}
class ProductionItem
{
public readonly string Item;
public readonly int TotalTime;
public readonly int TotalCost;
public int RemainingTime { get; private set; }
public int RemainingCost { get; private set; }
public bool Paused = false, Done = false;
public Action OnComplete;
public ProductionItem( string item, int time, int cost, Action onComplete )
{
Item = item;
RemainingTime = TotalTime = time;
RemainingCost = TotalCost = cost;
OnComplete = onComplete;
}
public void Tick( Player player )
{
if (Done)
{
if (OnComplete != null) OnComplete();
return;
}
if( Paused ) return;
var costThisFrame = RemainingCost / RemainingTime;
if( costThisFrame != 0 && !player.TakeCash( costThisFrame ) ) return;
RemainingCost -= costThisFrame;
RemainingTime -= 1;
if( RemainingTime > 0 ) return;
Done = true;
}
}
}

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OpenRa.Game
{
class ProductionItem
{
public readonly string Item;
public readonly int TotalTime;
public readonly int TotalCost;
public int RemainingTime { get; private set; }
public int RemainingCost { get; private set; }
public bool Paused = false, Done = false;
public Action OnComplete;
public ProductionItem(string item, int time, int cost, Action onComplete)
{
Item = item;
RemainingTime = TotalTime = time;
RemainingCost = TotalCost = cost;
OnComplete = onComplete;
}
public void Tick(Player player)
{
if (Done)
{
if (OnComplete != null) OnComplete();
return;
}
if (Paused) return;
var costThisFrame = RemainingCost / RemainingTime;
if (costThisFrame != 0 && !player.TakeCash(costThisFrame)) return;
RemainingCost -= costThisFrame;
RemainingTime -= 1;
if (RemainingTime > 0) return;
Done = true;
}
}
}

View File

@@ -17,9 +17,7 @@ namespace OpenRa.Game.Traits
public virtual int CreationFacing( Actor self, Actor newUnit )
{
if( newUnit.traits.Contains<Helicopter>() )
return 20;
return 128;
return newUnit.unitInfo.InitialFacing;
}
public bool Produce( Actor self, UnitInfo producee )

View File

@@ -12,6 +12,7 @@ namespace OpenRa.Game.Traits
public Turreted(Actor self)
{
turretFacing = self.unitInfo.InitialFacing;
}
public void Tick( Actor self )

View File

@@ -36,6 +36,8 @@ namespace OpenRa.Game
Log.Write( "Player \"{0}\" builds {1}", order.Player.PlayerName, building.Name );
Game.world.Add( new Actor( building.Name, order.TargetLocation - GameRules.Footprint.AdjustForBuildingSize( building ), order.Player ) );
if (order.Player == Game.LocalPlayer)
Game.PlaySound("build5.aud", false);
order.Player.FinishProduction(Rules.UnitCategory[building.Name]);
} );

View File

@@ -123,10 +123,12 @@ HIND
Description=Mig Attack Plane
BuiltAt=afld
Traits=Unit, Mobile, RenderUnit
InitialFacing=192
[YAK]
Description=Yak Attack Plane
BuiltAt=afld
Traits=Unit, Mobile, RenderUnit
InitialFacing=192
[TRAN]
Description=Transport Helicopter
PrimaryOffset=0,14,0,-4
@@ -134,15 +136,18 @@ SecondaryOffset=0,-14,0,-2
BuiltAt=hpad
Traits=Unit, Helicopter, RenderUnitRotor
SecondaryAnim=rotor2
InitialFacing=20
[HELI]
Description=Longbow
BuiltAt=hpad
Traits=Unit, Helicopter, RenderUnitRotor
PrimaryOffset=0,0,0,-2
InitialFacing=20
[HIND]
Description=Hind
BuiltAt=hpad
Traits=Unit, Helicopter, RenderUnitRotor
InitialFacing=20
@@ -262,12 +267,14 @@ Traits=Building, Turreted, RenderBuildingTurreted
Dimensions=1,1
Footprint=x
SelectionPriority=3
InitialFacing=50
[AGUN]
Description=AA Gun
Traits=Building, Turreted, RenderBuildingTurreted
Dimensions=1,2
Footprint=_ x
SelectionPriority=3
InitialFacing=224
[FTUR]
Description=Flame Turret
Traits=Building, RenderBuilding