lots of stuff: harvester, acceptsore, half-destroyed buildings, building sounds
This commit is contained in:
@@ -8,6 +8,7 @@ using OpenRa.FileFormats;
|
||||
using OpenRa.Game.GameRules;
|
||||
using OpenRa.Game.Graphics;
|
||||
using System.Drawing;
|
||||
using OpenRa.Game.Traits;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
@@ -105,10 +106,22 @@ namespace OpenRa.Game
|
||||
|
||||
Game.world.AddFrameEndTask(w => w.Remove(this));
|
||||
|
||||
if (Owner == Game.LocalPlayer)
|
||||
if (Owner == Game.LocalPlayer && !traits.Contains<Building>())
|
||||
Game.PlaySound("unitlst1.aud", false);
|
||||
|
||||
/* todo: explosion */
|
||||
if (traits.Contains<Building>())
|
||||
{
|
||||
Game.PlaySound("kaboom22.aud", false);
|
||||
// todo: spawn explosion sprites
|
||||
}
|
||||
}
|
||||
|
||||
var halfStrength = unitInfo.Strength / 2;
|
||||
if (Health < halfStrength && (Health + damage) >= halfStrength)
|
||||
{
|
||||
/* we just went below half health! */
|
||||
foreach (var nd in traits.WithInterface<INotifyDamage>())
|
||||
nd.Damaged(this, DamageState.Half);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,5 +24,6 @@ namespace OpenRa.Game
|
||||
public static Cursor MoveBlocked { get { return new Cursor("move-blocked"); } }
|
||||
public static Cursor Attack { get { return new Cursor("attack"); } }
|
||||
public static Cursor Deploy { get { return new Cursor("deploy"); } }
|
||||
public static Cursor Enter { get { return new Cursor("enter"); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="GameRules\TechTree.cs" />
|
||||
<Compile Include="OrderManager.cs" />
|
||||
<Compile Include="Traits\AcceptsOre.cs" />
|
||||
<Compile Include="Traits\Activities\DeployMcv.cs" />
|
||||
<Compile Include="Actor.cs" />
|
||||
<Compile Include="Bullet.cs" />
|
||||
@@ -129,6 +130,7 @@
|
||||
<Compile Include="Graphics\TreeCache.cs" />
|
||||
<Compile Include="Traits\AttackTurreted.cs" />
|
||||
<Compile Include="Traits\Building.cs" />
|
||||
<Compile Include="Traits\Harvester.cs" />
|
||||
<Compile Include="Traits\InfantrySquad.cs" />
|
||||
<Compile Include="Traits\McvDeploy.cs" />
|
||||
<Compile Include="Traits\Mobile.cs" />
|
||||
|
||||
@@ -111,5 +111,10 @@ namespace OpenRa.Game
|
||||
{
|
||||
return new Order(subject, "BuildUnit", null, null, int2.Zero, unitName, Cursor.Default);
|
||||
}
|
||||
|
||||
public static Order DeliverOre(Actor subject, Actor target)
|
||||
{
|
||||
return new Order(subject.Owner, "DeliverOre", subject, target, int2.Zero, null, Cursor.Enter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,6 +218,8 @@ namespace OpenRa.Game
|
||||
* (25 * 60) /* frames per min */ /* todo: build acceleration, if we do that */
|
||||
/ 1000;
|
||||
|
||||
time = .05f * time; /* temporary hax so we can build stuff fast for test */
|
||||
|
||||
Action complete = null;
|
||||
if (IsAutoCompleting(group)) complete = () => Build(item);
|
||||
|
||||
|
||||
22
OpenRa.Game/Traits/AcceptsOre.cs
Normal file
22
OpenRa.Game/Traits/AcceptsOre.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class AcceptsOre
|
||||
{
|
||||
public AcceptsOre(Actor self)
|
||||
{
|
||||
/* create the free harvester! */
|
||||
Game.world.AddFrameEndTask(
|
||||
w =>
|
||||
{
|
||||
var harvester = new Actor("harv", self.Location + new int2(1, 2), self.Owner);
|
||||
harvester.traits.Get<Mobile>().facing = 64;
|
||||
w.Add(harvester);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
24
OpenRa.Game/Traits/Harvester.cs
Normal file
24
OpenRa.Game/Traits/Harvester.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class Harvester : IOrder
|
||||
{
|
||||
public Order Order(Actor self, int2 xy, bool lmb, Actor underCursor)
|
||||
{
|
||||
if (underCursor != null
|
||||
&& underCursor.Owner == self.Owner
|
||||
&& underCursor.traits.Contains<AcceptsOre>())
|
||||
return OpenRa.Game.Order.DeliverOre(self, underCursor);
|
||||
|
||||
/* todo: harvest order when on ore */
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Harvester(Actor self) { }
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ using OpenRa.Game;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class RenderBuilding : RenderSimple, INotifyRemoved
|
||||
class RenderBuilding : RenderSimple, INotifyDamage
|
||||
{
|
||||
const int SmallBibStart = 1;
|
||||
const int LargeBibStart = 5;
|
||||
@@ -51,6 +51,21 @@ namespace OpenRa.Game.Traits
|
||||
yield return Pair.New(anim.Image, 24f * (float2)self.Location);
|
||||
}
|
||||
|
||||
public void Removed(Actor self) { DoBib(self, true); }
|
||||
public void Damaged(Actor self, DamageState state)
|
||||
{
|
||||
switch( state )
|
||||
{
|
||||
case DamageState.Normal:
|
||||
anim.PlayRepeating("idle"); /* todo: make interaction?? this should only get called on half->ok */
|
||||
break;
|
||||
case DamageState.Half:
|
||||
anim.PlayRepeating("damaged-idle");
|
||||
Game.PlaySound("kaboom1.aud", false); /* todo: maybe sep. sound stuff from visual ?? */
|
||||
break;
|
||||
case DamageState.Dead:
|
||||
DoBib(self, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,10 @@ using IjwFramework.Types;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
enum DamageState { Normal, Half, Dead };
|
||||
|
||||
interface ITick { void Tick(Actor self); }
|
||||
interface IRender { IEnumerable<Pair<Sprite, float2>> Render(Actor self); }
|
||||
interface IOrder { Order Order(Actor self, int2 xy, bool lmb, Actor underCursor); }
|
||||
interface INotifyRemoved { void Removed(Actor self); }
|
||||
interface INotifyDamage { void Damaged(Actor self, DamageState ds); }
|
||||
}
|
||||
|
||||
@@ -50,6 +50,14 @@ namespace OpenRa.Game
|
||||
mobile.QueueActivity( new Traits.Activities.DeployMcv() );
|
||||
break;
|
||||
}
|
||||
case "DeliverOre":
|
||||
{
|
||||
var mobile = order.Subject.traits.Get<Mobile>();
|
||||
mobile.QueueActivity(new Mobile.MoveTo(order.TargetActor.Location + new int2(1, 2)));
|
||||
mobile.QueueActivity(new Mobile.Turn(64));
|
||||
/* todo: actual deliver activity! */
|
||||
break;
|
||||
}
|
||||
case "PlaceBuilding":
|
||||
{
|
||||
Game.world.AddFrameEndTask( _ =>
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace OpenRa.Game
|
||||
public event Action<Actor> ActorRemoved = a =>
|
||||
{
|
||||
a.Health = 0; /* make sure everyone sees it as dead */
|
||||
foreach (var nr in a.traits.WithInterface<INotifyRemoved>())
|
||||
nr.Removed(a);
|
||||
foreach (var nr in a.traits.WithInterface<INotifyDamage>())
|
||||
nr.Damaged(a, DamageState.Dead);
|
||||
};
|
||||
|
||||
public void Tick()
|
||||
@@ -36,8 +36,9 @@ namespace OpenRa.Game
|
||||
Renderer.waterFrame += 0.00125f * Game.timestep;
|
||||
Game.viewport.Tick();
|
||||
|
||||
foreach (Action<World> a in frameEndActions) a(this);
|
||||
frameEndActions.Clear();
|
||||
var acts = frameEndActions;
|
||||
frameEndActions = new List<Action<World>>();
|
||||
foreach (var a in acts) a(this);
|
||||
}
|
||||
|
||||
public IEnumerable<Actor> Actors { get { return actors; } }
|
||||
|
||||
@@ -42,7 +42,7 @@ Description=Artillery
|
||||
Traits=Mobile, RenderUnit
|
||||
[HARV]
|
||||
Description=Ore Truck
|
||||
Traits=Mobile, RenderUnit
|
||||
Traits=Mobile, Harvester, RenderUnit
|
||||
[MCV]
|
||||
Description=Mobile Construction Vehicle
|
||||
Traits=Mobile, McvDeploy, RenderUnit
|
||||
@@ -242,7 +242,7 @@ Footprint=xxx xxx xxx
|
||||
Produces=Building
|
||||
[PROC]
|
||||
Description=Ore Refinery
|
||||
Traits=Building, RenderBuilding
|
||||
Traits=Building, RenderBuilding, AcceptsOre
|
||||
Dimensions=3,3
|
||||
Footprint=_x_ xxx x==
|
||||
[SILO]
|
||||
|
||||
Reference in New Issue
Block a user