lightened shadow; added rotor shadows to heli; stripped some duplication; still a lot left though

This commit is contained in:
Chris Forbes
2009-11-10 21:12:31 +13:00
parent 14910762c8
commit c00bce8bf8
4 changed files with 32 additions and 8 deletions

View File

@@ -27,14 +27,27 @@ namespace OpenRa.Game.Traits
{
var mobile = self.traits.Get<Mobile>();
yield return Util.Centered(self, anim.Image, self.CenterLocation);
yield return Util.Centered(self, rotorAnim.Image, self.CenterLocation
yield return Util.CenteredShadow(self, anim.Image, self.CenterLocation);
yield return Util.CenteredShadow(self, rotorAnim.Image, self.CenterLocation
+ Util.GetTurretPosition(self, self.unitInfo.PrimaryOffset, 0));
if (self.unitInfo.SecondaryOffset != null)
yield return Util.Centered(self, (secondRotorAnim ?? rotorAnim).Image, self.CenterLocation
yield return Util.CenteredShadow(self, (secondRotorAnim ?? rotorAnim).Image, self.CenterLocation
+ Util.GetTurretPosition(self, self.unitInfo.SecondaryOffset, 0));
var p = self.CenterLocation - new float2( 0, altitude );
yield return Util.Centered(self, anim.Image, p);
yield return Util.Centered(self, rotorAnim.Image, p
+ Util.GetTurretPosition(self, self.unitInfo.PrimaryOffset, 0));
if (self.unitInfo.SecondaryOffset != null)
yield return Util.Centered(self, (secondRotorAnim ?? rotorAnim).Image, p
+ Util.GetTurretPosition(self, self.unitInfo.SecondaryOffset, 0));
}
int altitude = 0;
const int climbRate = 1;
const int cruiseAltitude = 20;
public override void Tick(Actor self)
{
base.Tick(self);
@@ -44,12 +57,18 @@ namespace OpenRa.Game.Traits
var mobile = self.traits.Get<Mobile>();
var isFlying = mobile.HasActivity;
if (isFlying ^ (rotorAnim.CurrentSequence.Name != "rotor"))
if (isFlying && altitude < cruiseAltitude)
altitude = Math.Min(altitude + climbRate, cruiseAltitude);
else if (!isFlying && altitude > 0)
altitude = Math.Max(altitude - climbRate, 0);
if ((altitude >0) ^ (rotorAnim.CurrentSequence.Name != "rotor"))
return;
rotorAnim.PlayRepeatingPreservingPosition(isFlying ? "rotor" : "slow-rotor");
rotorAnim.PlayRepeatingPreservingPosition((altitude>0) ? "rotor" : "slow-rotor");
if (secondRotorAnim != null)
secondRotorAnim.PlayRepeatingPreservingPosition(isFlying ? "rotor2" : "slow-rotor2");
secondRotorAnim.PlayRepeatingPreservingPosition((altitude>0) ? "rotor2" : "slow-rotor2");
}
}
}