Frickin' Lasers

This commit is contained in:
Paul Chote
2010-02-06 18:35:46 +13:00
parent 709fc39546
commit b559d69d4e
8 changed files with 117 additions and 3 deletions

View 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;
}
}
}

View File

@@ -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;
}
}

View File

@@ -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" />

View File

@@ -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() ) );

View File

@@ -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"));
}

View File

@@ -132,4 +132,14 @@
<sequence name="critical-active" start="5" length="5" />
<sequence name="make" start="0" length="*" src="tmplmake" />
</unit>
<!-- Obelisk of Light -->
<unit name="obli">
<sequence name="idle" start="0" length="1" />
<sequence name="damaged-idle" start="4" length="1" />
<sequence name="critical-idle" start="8" length="1" />
<sequence name="active" start="0" length="4" />
<sequence name="damaged-active" start="4" length="4" />
<sequence name="critical-active" start="4" length="4" />
<sequence name="make" start="0" length="13" src="oblimake" />
</unit>
</sequences>

View File

@@ -323,3 +323,31 @@ TMPL:
Armor: light
Crewed: yes
Sight: 4
OBLI:
RequiresPower:
Inherits: ^Building
Buildable:
Icon:obliicnh
TechLevel: 4
Prerequisites: hq
Owner: soviet
Cost: 1500
Description: Obelisk of Light
LongDesc: Advanced base defense. Requires power\nto operate.\n Strong vs Tanks, Infantry\n Weak vs Aircraft
Building:
Power: -150
Footprint: _ x
Dimensions: 1,2
HP: 200
Armor: light
Crewed: no
Sight: 5
Turreted:
RenderBuildingCharge:
ChargeAudio: obelpowr.aud
AttackTurreted:
PrimaryWeapon: Laser
FireDelay: 8
AutoTarget:
-RenderBuilding:

View File

@@ -1,6 +1,7 @@
[WeaponTypes]
MachineGun
Laser
; NOTE: WEAPON PROPERTIES ARE NOT EXPOSED BY TIBED; THESE ARE ALL MADE UP
[MachineGun]
@@ -13,6 +14,18 @@ Warhead=SA
Report=GUN13
Anim=MINIGUN
[Laser]
Damage=100
ROF=120
Range=8.5
Projectile=Invisible
Speed=100
Warhead=Super
Report=obelray1
Charges=yes
RenderAsLaser=true
BeamRadius=2
UsePlayerColor=true
[ProjectileTypes]
@@ -25,9 +38,15 @@ Image=none
[WarheadTypes]
SA
Super
[SA]
Spread=3
Verses=100%,50%,60%,25%,25%
Explosion=2
InfDeath=1
InfDeath=1
[Super]
Spread=1
Verses=100%,100%,100%,100%,100%
InfDeath=5