Frickin' Lasers
This commit is contained in:
45
OpenRa.Game/Effects/LaserZap.cs
Normal file
45
OpenRa.Game/Effects/LaserZap.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Graphics;
|
||||
using OpenRa.Traits;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OpenRa.Effects
|
||||
{
|
||||
class LaserZap : IEffect
|
||||
{
|
||||
readonly int2 from, to;
|
||||
readonly int radius;
|
||||
int timeUntilRemove = 10; // # of frames
|
||||
int totalTime = 10;
|
||||
Color color;
|
||||
|
||||
public LaserZap(int2 from, int2 to, int radius, Color color)
|
||||
{
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.color = color;
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
if (timeUntilRemove <= 0)
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
--timeUntilRemove;
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
int alpha = (int)((1-(float)(totalTime-timeUntilRemove)/totalTime)*255);
|
||||
Color rc = Color.FromArgb(alpha,color);
|
||||
|
||||
for (int i = -radius; i < radius; i++)
|
||||
Game.world.WorldRenderer.lineRenderer.DrawLine(from + new int2(i, 0), to + new int2(i, 0), rc, rc);
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,5 +18,8 @@ namespace OpenRa.GameRules
|
||||
public readonly string Warhead = null;
|
||||
|
||||
public readonly bool RenderAsTesla = false;
|
||||
public readonly bool RenderAsLaser = false;
|
||||
public readonly bool UsePlayerColor = true;
|
||||
public readonly int BeamRadius = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
<Compile Include="Effects\Corpse.cs" />
|
||||
<Compile Include="Effects\DelayedAction.cs" />
|
||||
<Compile Include="Effects\FlashTarget.cs" />
|
||||
<Compile Include="Effects\LaserZap.cs" />
|
||||
<Compile Include="Effects\MoveFlash.cs" />
|
||||
<Compile Include="Effects\RepairIndicator.cs" />
|
||||
<Compile Include="Effects\Smoke.cs" />
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using IjwFramework.Types;
|
||||
using OpenRa.Effects;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OpenRa.Traits
|
||||
{
|
||||
@@ -148,7 +149,13 @@ namespace OpenRa.Traits
|
||||
{
|
||||
var srcAltitude = unit != null ? unit.Altitude : 0;
|
||||
var destAltitude = destUnit != null ? destUnit.Altitude : 0;
|
||||
|
||||
|
||||
if ( weapon.RenderAsLaser )
|
||||
{
|
||||
// TODO: This is a hack; should probably use a particular palette index
|
||||
Color bc = (weapon.UsePlayerColor) ? Player.PlayerColors[self.Owner.PaletteIndex].c : Color.Red;
|
||||
self.World.Add(new LaserZap(firePos, thisTarget.CenterLocation.ToInt2(), weapon.BeamRadius, bc));
|
||||
}
|
||||
if( weapon.RenderAsTesla )
|
||||
self.World.Add( new TeslaZap( firePos, thisTarget.CenterLocation.ToInt2() ) );
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace OpenRa.Traits
|
||||
{
|
||||
class RenderBuildingChargeInfo : RenderBuildingInfo
|
||||
{
|
||||
public readonly string ChargeAudio = "tslachg2.aud";
|
||||
public override object Create(Actor self) { return new RenderBuildingCharge(self); }
|
||||
}
|
||||
|
||||
@@ -16,7 +17,7 @@ namespace OpenRa.Traits
|
||||
|
||||
public void Attacking(Actor self)
|
||||
{
|
||||
Sound.Play("tslachg2.aud");
|
||||
Sound.Play(self.Info.Traits.Get<RenderBuildingChargeInfo>().ChargeAudio);
|
||||
anim.PlayThen(GetPrefix(self) + "active",
|
||||
() => anim.PlayRepeating(GetPrefix(self) + "idle"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user