Merge pull request #4006 from pchote/alternate-stand-animations

Alternate stand animations
This commit is contained in:
Matthias Mailänder
2013-10-26 00:54:13 -07:00
5 changed files with 45 additions and 29 deletions

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
@@ -8,10 +8,10 @@
*/
#endregion
using OpenRA.Mods.RA.Effects;
using OpenRA.Traits;
using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Effects;
using OpenRA.Mods.RA.Move;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Render
{
@@ -19,7 +19,8 @@ namespace OpenRA.Mods.RA.Render
{
public readonly int MinIdleWaitTicks = 30;
public readonly int MaxIdleWaitTicks = 110;
public readonly string[] IdleAnimations = {};
public readonly string[] IdleAnimations = { };
public readonly string[] StandAnimations = { "stand" };
public override object Create(ActorInitializer init) { return new RenderInfantry(init.self, this); }
}
@@ -33,11 +34,11 @@ namespace OpenRA.Mods.RA.Render
Moving,
Waiting,
IdleAnimating
};
}
protected bool dirty = false;
RenderInfantryInfo Info;
RenderInfantryInfo info;
string idleSequence;
int idleDelay;
Mobile mobile;
@@ -49,7 +50,7 @@ namespace OpenRA.Mods.RA.Render
protected virtual bool AllowIdleAnimation(Actor self)
{
return Info.IdleAnimations.Length > 0;
return info.IdleAnimations.Length > 0;
}
public AnimationState State { get; private set; }
@@ -57,8 +58,8 @@ namespace OpenRA.Mods.RA.Render
public RenderInfantry(Actor self, RenderInfantryInfo info)
: base(self, MakeFacingFunc(self))
{
Info = info;
anim.PlayFetchIndex(NormalizeInfantrySequence(self, "stand"), () => 0);
this.info = info;
anim.PlayFetchIndex(NormalizeInfantrySequence(self, info.StandAnimations.Random(Game.CosmeticRandom)), () => 0);
State = AnimationState.Waiting;
mobile = self.Trait<Mobile>();
@@ -86,13 +87,14 @@ namespace OpenRA.Mods.RA.Render
if ((State == AnimationState.Moving || dirty) && !mobile.IsMoving)
{
State = AnimationState.Waiting;
anim.PlayFetchIndex(NormalizeInfantrySequence(self, "stand"), () => 0);
anim.PlayFetchIndex(NormalizeInfantrySequence(self, info.StandAnimations.Random(Game.CosmeticRandom)), () => 0);
}
else if ((State != AnimationState.Moving || dirty) && mobile.IsMoving)
{
State = AnimationState.Moving;
anim.PlayRepeating(NormalizeInfantrySequence(self, "run"));
}
dirty = false;
}
@@ -100,13 +102,13 @@ namespace OpenRA.Mods.RA.Render
{
if (State != AnimationState.Idle && State != AnimationState.IdleAnimating)
{
anim.PlayFetchIndex(NormalizeInfantrySequence(self, "stand"), () => 0);
anim.PlayFetchIndex(NormalizeInfantrySequence(self, info.StandAnimations.Random(Game.CosmeticRandom)), () => 0);
State = AnimationState.Idle;
if (Info.IdleAnimations.Length > 0)
if (info.IdleAnimations.Length > 0)
{
idleSequence = Info.IdleAnimations.Random(self.World.SharedRandom);
idleDelay = self.World.SharedRandom.Next(Info.MinIdleWaitTicks, Info.MaxIdleWaitTicks);
idleSequence = info.IdleAnimations.Random(self.World.SharedRandom);
idleDelay = self.World.SharedRandom.Next(info.MinIdleWaitTicks, info.MaxIdleWaitTicks);
}
}
else if (AllowIdleAnimation(self) && idleDelay > 0 && --idleDelay == 0)
@@ -114,12 +116,11 @@ namespace OpenRA.Mods.RA.Render
if (anim.HasSequence(idleSequence))
{
State = AnimationState.IdleAnimating;
anim.PlayThen(idleSequence,
() =>
{
anim.PlayRepeating(NormalizeInfantrySequence(self, "stand"));
State = AnimationState.Waiting;
});
anim.PlayThen(idleSequence, () =>
{
anim.PlayRepeating(NormalizeInfantrySequence(self, info.StandAnimations.Random(Game.CosmeticRandom)));
State = AnimationState.Waiting;
});
}
}
}
@@ -140,7 +141,7 @@ namespace OpenRA.Mods.RA.Render
{
if (!self.Destroyed)
w.Add(new Corpse(w, self.CenterPosition, GetImage(self),
sequence, Info.PlayerPalette+self.Owner.InternalName));
sequence, info.PlayerPalette + self.Owner.InternalName));
});
}
}

View File

@@ -46,9 +46,9 @@ namespace OpenRA.Mods.RA.Render
{
disguisedAsSprite = spy.disguisedAsSprite;
if (disguisedAsSprite != null)
anim.ChangeImage(disguisedAsSprite, "stand");
anim.ChangeImage(disguisedAsSprite, info.StandAnimations.Random(Game.CosmeticRandom));
else
anim.ChangeImage(GetImage(self), "stand");
anim.ChangeImage(GetImage(self), info.StandAnimations.Random(Game.CosmeticRandom));
UpdatePalette();
}
base.Tick(self);

View File

@@ -19,6 +19,7 @@ E1:
AttackFrontal:
RenderInfantryProne:
IdleAnimations: idle1,idle2,idle3,idle4
StandAnimations: stand, stand2
DetectCloaked:
Range: 2
@@ -46,6 +47,7 @@ E2:
AttackFrontal:
RenderInfantryProne:
IdleAnimations: idle1,idle2
StandAnimations: stand, stand2
Explodes:
Weapon: GrenadierExplode
EmptyWeapon: GrenadierExplode
@@ -76,6 +78,7 @@ E3:
AttackFrontal:
RenderInfantryProne:
IdleAnimations: idle1,idle2
StandAnimations: stand, stand2
DetectCloaked:
Range: 2
@@ -104,6 +107,7 @@ E4:
WithMuzzleFlash:
RenderInfantryProne:
IdleAnimations: idle1,idle2
StandAnimations: stand, stand2
DetectCloaked:
Range: 2
@@ -138,6 +142,7 @@ E5:
-PoisonedByTiberium:
RenderInfantryProne:
IdleAnimations: idle1,idle2
StandAnimations: stand, stand2
DetectCloaked:
Range: 2
@@ -168,6 +173,7 @@ E6:
JustMove: true
RenderInfantryProne:
IdleAnimations: idle1,idle2
StandAnimations: stand, stand2
-GainsExperience:
RMBO:
@@ -201,6 +207,7 @@ RMBO:
AttackFrontal:
RenderInfantryProne:
IdleAnimations: idle1,idle2,idle3
StandAnimations: stand, stand2
AnnounceOnBuild:
AnnounceOnKill:
DetectCloaked:

View File

@@ -53,6 +53,7 @@ E1:
-RenderInfantry:
RenderInfantryProne:
IdleAnimations: idle1,idle2
StandAnimations: stand,stand2
E2:
Inherits: ^Infantry
@@ -82,6 +83,7 @@ E2:
-RenderInfantry:
RenderInfantryProne:
IdleAnimations: idle1,idle2
StandAnimations: stand,stand2
Explodes:
Weapon: UnitExplodeSmall
Chance: 50
@@ -115,6 +117,7 @@ E3:
-RenderInfantry:
RenderInfantryProne:
IdleAnimations: idle1,idle2
StandAnimations: stand,stand2
E4:
Inherits: ^Infantry
@@ -144,6 +147,7 @@ E4:
-RenderInfantry:
RenderInfantryProne:
IdleAnimations: idle1,idle2
StandAnimations: stand,stand2
E6:
Inherits: ^Infantry
@@ -176,6 +180,7 @@ E6:
-RenderInfantry:
RenderInfantryProne:
IdleAnimations: idle1,idle2
StandAnimations: stand,stand2
SPY:
Inherits: ^Infantry
@@ -211,6 +216,7 @@ SPY:
-RenderInfantry:
RenderSpy:
IdleAnimations: idle1,idle2
StandAnimations: stand,stand2
Armament:
Weapon: SilencedPPK
AttackFrontal:
@@ -441,6 +447,7 @@ SHOK:
-RenderInfantry:
RenderInfantryProne:
IdleAnimations: idle1,idle2
StandAnimations: stand,stand2
-CrushableInfantry:
SNIPER:
@@ -475,6 +482,7 @@ SNIPER:
-RenderInfantry:
RenderInfantryProne:
IdleAnimations: idle1,idle2
StandAnimations: stand,stand2
Cloak:
InitialDelay: 250
CloakDelay: 120

View File

@@ -4,7 +4,7 @@ e1:
Facings: 8
stand2:
Start: 8
Length: 8
Facings: 8
stand3:
Start: 128
Length: 16
@@ -141,7 +141,7 @@ e3:
Facings: 8
stand2:
Start: 8
Length: 8
Facings: 8
run:
Start: 16
Length: 6
@@ -203,7 +203,7 @@ e6:
Facings: 8
stand2:
Start: 8
Length: 8
Facings: 8
run:
Start: 16
Length: 6
@@ -373,7 +373,7 @@ e2:
Facings: 8
stand2:
Start: 8
Length: 8
Facings: 8
run:
Start: 16
Length: 6
@@ -481,7 +481,7 @@ spy:
Facings: 8
stand2:
Start: 8
Length: 8
Facings: 8
run:
Start: 16
Length: 6
@@ -636,7 +636,7 @@ e4:
Facings: 8
stand2:
Start: 8
Length: 8
Facings: 8
run:
Start: 16
Length: 6