TeslaZap. (Doesn't look much like real-ra, but it's only there for small-N frames, so no-one will notice, right? :)
This commit is contained in:
86
OpenRa.Game/Effects/TeslaZap.cs
Executable file
86
OpenRa.Game/Effects/TeslaZap.cs
Executable file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Game.Graphics;
|
||||
|
||||
namespace OpenRa.Game.Effects
|
||||
{
|
||||
class TeslaZap : IEffect
|
||||
{
|
||||
readonly int2 from, to;
|
||||
readonly Sequence tesla;
|
||||
int timeUntilRemove = 2; // # of frames
|
||||
|
||||
public TeslaZap( int2 from, int2 to )
|
||||
{
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.tesla = SequenceProvider.GetSequence( "litning", "bright" );
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
if( timeUntilRemove <= 0 )
|
||||
Game.world.AddFrameEndTask( w => w.Remove( this ) );
|
||||
--timeUntilRemove;
|
||||
}
|
||||
|
||||
public IEnumerable<Tuple<Sprite, float2, int>> Render()
|
||||
{
|
||||
if( from.X < to.X )
|
||||
return Foo( from, to, tesla );
|
||||
else if( from.X > to.X || from.Y > to.Y )
|
||||
return Foo( to, from, tesla );
|
||||
else
|
||||
return Foo( from, to, tesla );
|
||||
}
|
||||
|
||||
static IEnumerable<Tuple<Sprite, float2, int>> Foo( int2 from, int2 to, Sequence tesla )
|
||||
{
|
||||
int2 d = to - from;
|
||||
if( d.X < 8 )
|
||||
{
|
||||
var prev = new int2( 0, 0 );
|
||||
var y = d.Y;
|
||||
while( y >= prev.Y + 8 )
|
||||
{
|
||||
yield return Tuple.New( tesla.GetSprite( 2 ), (float2)( from + prev - new int2( 0, 8 ) ), 0 );
|
||||
prev.Y += 8;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var prev = new int2( 0, 0 );
|
||||
for( int i = 1 ; i < d.X ; i += 8 )
|
||||
{
|
||||
var y = i * d.Y / d.X;
|
||||
if( y <= prev.Y - 8 )
|
||||
{
|
||||
yield return Tuple.New( tesla.GetSprite( 3 ), (float2)( from + prev - new int2( 8, 16 ) ), 0 );
|
||||
prev.Y -= 8;
|
||||
while( y <= prev.Y - 8 )
|
||||
{
|
||||
yield return Tuple.New( tesla.GetSprite( 2 ), (float2)( from + prev - new int2( 0, 16 ) ), 0 );
|
||||
prev.Y -= 8;
|
||||
}
|
||||
}
|
||||
else if( y >= prev.Y + 8 )
|
||||
{
|
||||
yield return Tuple.New( tesla.GetSprite( 0 ), (float2)( from + prev - new int2( 8, 8 ) ), 0 );
|
||||
prev.Y += 8;
|
||||
while( y >= prev.Y + 8 )
|
||||
{
|
||||
yield return Tuple.New( tesla.GetSprite( 2 ), (float2)( from + prev - new int2( 0, 8 ) ), 0 );
|
||||
prev.Y -= 8;
|
||||
}
|
||||
}
|
||||
else
|
||||
yield return Tuple.New( tesla.GetSprite( 1 ), (float2)( from + prev - new int2( 8, 8 ) ), 0 );
|
||||
|
||||
prev.X += 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,5 +16,7 @@ namespace OpenRa.Game.GameRules
|
||||
public readonly bool Supress = false;
|
||||
public readonly bool TurboBoost = false;
|
||||
public readonly string Warhead = null;
|
||||
|
||||
public readonly bool RenderAsTesla = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@
|
||||
<Compile Include="Chrome.cs" />
|
||||
<Compile Include="Combat.cs" />
|
||||
<Compile Include="Effects\Smoke.cs" />
|
||||
<Compile Include="Effects\TeslaZap.cs" />
|
||||
<Compile Include="Exts.cs" />
|
||||
<Compile Include="GameRules\ActorInfo.cs" />
|
||||
<Compile Include="GameRules\GeneralInfo.cs" />
|
||||
|
||||
@@ -108,7 +108,10 @@ namespace OpenRa.Game.Traits
|
||||
var thisTarget = target;
|
||||
ScheduleDelayedAction(self.Info.FireDelay, () =>
|
||||
{
|
||||
if (Rules.ProjectileInfo[weapon.Projectile].ROT != 0)
|
||||
if( weapon.RenderAsTesla )
|
||||
Game.world.Add( new TeslaZap( firePos, thisTarget.CenterLocation.ToInt2() ) );
|
||||
|
||||
if( Rules.ProjectileInfo[ weapon.Projectile ].ROT != 0 )
|
||||
Game.world.Add(new Missile(weaponName, self.Owner, self,
|
||||
firePos, thisTarget));
|
||||
else
|
||||
|
||||
@@ -10,7 +10,7 @@ Description=Stealth Tank
|
||||
Traits=Unit, Mobile, RenderUnit
|
||||
[TTNK]
|
||||
Description=Tesla Tank
|
||||
Traits=Unit, Mobile, RenderUnitSpinner
|
||||
Traits=Unit, Mobile, AttackBase, RenderUnitSpinner
|
||||
[CTNK]
|
||||
Description=Chrono Tank
|
||||
Traits=Unit, Mobile, RenderUnit
|
||||
@@ -32,7 +32,7 @@ MSUB
|
||||
Description=Missile Submarine
|
||||
WaterBound=yes
|
||||
BuiltAt=spen
|
||||
Traits=Mobile, RenderUnit
|
||||
Traits=Unit, Mobile, RenderUnit
|
||||
|
||||
|
||||
|
||||
@@ -44,12 +44,12 @@ MECH
|
||||
|
||||
[SHOK]
|
||||
Description=Tesla Trooper
|
||||
Traits=InfantrySquad,Mobile
|
||||
Traits=Unit, Mobile, AttackBase, RenderInfantry
|
||||
SquadSize=1
|
||||
|
||||
[MECH]
|
||||
Description=Mechanic
|
||||
Traits=InfantrySquad,Mobile
|
||||
Traits=Unit, Mobile, AttackBase, RenderInfantry
|
||||
SquadSize=1
|
||||
|
||||
|
||||
@@ -62,8 +62,10 @@ TTankZap
|
||||
GoodWrench
|
||||
|
||||
[PortaTesla]
|
||||
RenderAsTesla=true
|
||||
|
||||
[TTankZap]
|
||||
RenderAsTesla=true
|
||||
|
||||
[GoodWrench]
|
||||
|
||||
|
||||
@@ -17,4 +17,54 @@
|
||||
<sequence name="idle" start="0" length="32" />
|
||||
<sequence name="spinner" start="32" length="32" />
|
||||
</unit>
|
||||
<unit name="shok">
|
||||
<sequence name="stand" start="0" length="8" />
|
||||
<sequence name="stand2" start="8" length="8" />
|
||||
<sequence name="run-0" start="16" length="6" />
|
||||
<sequence name="run-1" start="22" length="6" />
|
||||
<sequence name="run-2" start="28" length="6" />
|
||||
<sequence name="run-3" start="34" length="6" />
|
||||
<sequence name="run-4" start="40" length="6" />
|
||||
<sequence name="run-5" start="46" length="6" />
|
||||
<sequence name="run-6" start="52" length="6" />
|
||||
<sequence name="run-7" start="58" length="6" />
|
||||
<sequence name="shoot-0" start="64" length="16" />
|
||||
<sequence name="shoot-1" start="80" length="16" />
|
||||
<sequence name="shoot-2" start="96" length="16" />
|
||||
<sequence name="shoot-3" start="112" length="16" />
|
||||
<sequence name="shoot-4" start="128" length="16" />
|
||||
<sequence name="shoot-5" start="144" length="16" />
|
||||
<sequence name="shoot-6" start="160" length="16" />
|
||||
<sequence name="shoot-7" start="176" length="16" />
|
||||
<sequence name="stand3" start="192" length="16" />
|
||||
<sequence name="crawl-0" start="208" length="4" />
|
||||
<sequence name="crawl-1" start="212" length="4" />
|
||||
<sequence name="crawl-2" start="216" length="4" />
|
||||
<sequence name="crawl-3" start="220" length="4" />
|
||||
<sequence name="crawl-4" start="224" length="4" />
|
||||
<sequence name="crawl-5" start="228" length="4" />
|
||||
<sequence name="crawl-6" start="232" length="4" />
|
||||
<sequence name="crawl-7" start="236" length="4" />
|
||||
<sequence name="standup-0" start="240" length="2" />
|
||||
<sequence name="standup-1" start="242" length="2" />
|
||||
<sequence name="standup-2" start="244" length="2" />
|
||||
<sequence name="standup-3" start="246" length="2" />
|
||||
<sequence name="standup-4" start="248" length="2" />
|
||||
<sequence name="standup-5" start="250" length="2" />
|
||||
<sequence name="standup-6" start="252" length="2" />
|
||||
<sequence name="standup-7" start="254" length="2" />
|
||||
<sequence name="prone-shoot-0" start="256" length="16" />
|
||||
<sequence name="prone-shoot-1" start="272" length="16" />
|
||||
<sequence name="prone-shoot-2" start="288" length="16" />
|
||||
<sequence name="prone-shoot-3" start="304" length="16" />
|
||||
<sequence name="prone-shoot-4" start="320" length="16" />
|
||||
<sequence name="prone-shoot-5" start="336" length="16" />
|
||||
<sequence name="prone-shoot-6" start="352" length="16" />
|
||||
<sequence name="prone-shoot-7" start="368" length="16" />
|
||||
<sequence name="die1" start="416" length="8" />
|
||||
<sequence name="die2" start="424" length="8" />
|
||||
<sequence name="die3" start="432" length="8" />
|
||||
<sequence name="die4" start="440" length="12" />
|
||||
<sequence name="die5" start="452" length="18" />
|
||||
</unit>
|
||||
</sequences>
|
||||
|
||||
@@ -675,4 +675,8 @@
|
||||
<sequence name="shoot-6" start="112" length="8" />
|
||||
<sequence name="shoot-7" start="120" length="8" />
|
||||
</unit>
|
||||
<unit name="litning">
|
||||
<sequence name="bright" start="0" length="4" />
|
||||
<sequence name="dim" start="4" length="4" />
|
||||
</unit>
|
||||
</sequences>
|
||||
@@ -200,7 +200,7 @@ Footprint=x
|
||||
SelectionPriority=3
|
||||
[TSLA]
|
||||
Description=Tesla Coil
|
||||
Traits=Building, RenderBuilding
|
||||
Traits=Building, Turreted, RenderBuilding, AttackTurreted, AutoTarget
|
||||
Dimensions=1,2
|
||||
Footprint=_ x
|
||||
SelectionPriority=3
|
||||
@@ -542,6 +542,8 @@ DogJaw
|
||||
Heal
|
||||
SCUD
|
||||
|
||||
[TeslaZap]
|
||||
RenderAsTesla=true
|
||||
|
||||
|
||||
|
||||
@@ -649,4 +651,4 @@ Move=girlokay
|
||||
|
||||
[EinsteinVoice]
|
||||
Select=einah1,einok1,einyes1
|
||||
Move=einah1,einok1,einyes1
|
||||
Move=einah1,einok1,einyes1
|
||||
|
||||
Reference in New Issue
Block a user