submarine dive/surface works

This commit is contained in:
Chris Forbes
2009-12-13 13:05:52 +13:00
parent 170ee73b42
commit 5eb373790b
8 changed files with 62 additions and 15 deletions

View File

@@ -1,5 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using OpenRa.Game.GameRules; using OpenRa.Game.GameRules;
using OpenRa.Game.Graphics; using OpenRa.Game.Graphics;

View File

@@ -1,9 +1,6 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenRa.Game.Graphics;
using OpenRa.Game.GameRules; using OpenRa.Game.GameRules;
using OpenRa.Game.Graphics;
namespace OpenRa.Game.Effects namespace OpenRa.Game.Effects
{ {

View File

@@ -1,7 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenRa.Game.Graphics; using OpenRa.Game.Graphics;
namespace OpenRa.Game.Effects namespace OpenRa.Game.Effects

View File

@@ -52,7 +52,7 @@ namespace OpenRa.Game
Rules.LoadRules(mapName, useAftermath); Rules.LoadRules(mapName, useAftermath);
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
players[i] = new Player(i, i, "Multi{0}".F(i), Race.Allies); players[i] = new Player(i, i, "Multi{0}".F(i), Race.Soviet);
localPlayerIndex = localPlayer; localPlayerIndex = localPlayer;

View File

@@ -171,6 +171,7 @@
<Compile Include="Traits\RenderBuildingTurreted.cs" /> <Compile Include="Traits\RenderBuildingTurreted.cs" />
<Compile Include="Traits\RenderBuildingWarFactory.cs" /> <Compile Include="Traits\RenderBuildingWarFactory.cs" />
<Compile Include="Traits\RenderSimple.cs" /> <Compile Include="Traits\RenderSimple.cs" />
<Compile Include="Traits\RenderSubmarine.cs" />
<Compile Include="Traits\RenderUnit.cs" /> <Compile Include="Traits\RenderUnit.cs" />
<Compile Include="Traits\RenderUnitMuzzleFlash.cs" /> <Compile Include="Traits\RenderUnitMuzzleFlash.cs" />
<Compile Include="Traits\RenderUnitReload.cs" /> <Compile Include="Traits\RenderUnitReload.cs" />

View File

@@ -1,8 +1,7 @@
using System; using System;
using System.Linq;
using OpenRa.Game.Effects;
using System.Collections.Generic; using System.Collections.Generic;
using IjwFramework.Types; using IjwFramework.Types;
using OpenRa.Game.Effects;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {

View File

@@ -0,0 +1,54 @@
using System.Collections.Generic;
using OpenRa.Game.Graphics;
namespace OpenRa.Game.Traits
{
class RenderSubmarine : RenderSimple, INotifyAttack, ITick
{
int remainingSurfaceTime = 2; /* setup for initial dive */
public RenderSubmarine(Actor self)
: base(self)
{
anim.PlayFacing("idle", () => self.traits.Get<Unit>().Facing);
}
public void Attacking(Actor self)
{
if (remainingSurfaceTime <= 0)
OnSurface();
remainingSurfaceTime = (int)(Rules.General.SubmergeDelay * 60 / 25);
}
public override IEnumerable<Tuple<Sprite, float2, int>> Render(Actor self)
{
var s = Util.Centered(self, anim.Image, self.CenterLocation);
if (remainingSurfaceTime <= 0)
{
s.c = 8; /* shadow only palette */
if (self.Owner != Game.LocalPlayer)
yield break; /* can't see someone else's submerged subs */
}
yield return s;
}
public override void Tick(Actor self)
{
base.Tick(self);
if (remainingSurfaceTime > 0)
if (--remainingSurfaceTime <= 0)
OnDive();
}
void OnSurface()
{
Sound.Play("subshow1.aud");
}
void OnDive()
{
Sound.Play("subshow1.aud"); /* is this the right sound?? */
}
}
}

View File

@@ -94,7 +94,7 @@ PT
Description=Submarine Description=Submarine
WaterBound=yes WaterBound=yes
BuiltAt=spen BuiltAt=spen
Traits=Unit, Mobile, RenderUnit Traits=Unit, Mobile, RenderSubmarine
[DD] [DD]
Description=Destroyer Description=Destroyer
WaterBound=yes WaterBound=yes