public void ComputeRealDamage(DamageKeyFrame KeyFrame) { DamageOld = DamageCurrent = ComputeDamage(KeyFrame); DamageNext = 0; TextSize = fntDamage.MeasureString(DamageCurrent.ToString()); }
protected override VisibleAnimationObjectKeyFrame CopyAsVisibleAnimationObjectKeyFrame(AnimationClass.AnimationLayer ActiveLayer) { DamageKeyFrame NewAnimatedBitmapKeyFrame = new DamageKeyFrame(); NewAnimatedBitmapKeyFrame.UpdateFrom(this); NewAnimatedBitmapKeyFrame._Damage = _Damage; return(NewAnimatedBitmapKeyFrame); }
public override void UpdateAnimationObject(int KeyFrame) { Progress = 0; //An Event is being executed. if (NextEvent != null) { Progress = (KeyFrame - EventKeyFrameOld) / (float)(NextEventKeyFrame - EventKeyFrameOld); int OldDamageCurrent = DamageCurrent; DamageCurrent = DamageOld + (int)(DamageChangeValue * Progress); if (Owner != null) { Owner.DamageEnemyUnit(DamageCurrent - OldDamageCurrent); } UpdateAnimationSprite(KeyFrame); } DamageKeyFrame ActiveKeyFrame; VisibleAnimationObjectKeyFrame ActiveAnimationSpriteKeyFrame; if (DicAnimationKeyFrame.TryGetValue(KeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = (DamageKeyFrame)ActiveAnimationSpriteKeyFrame; //If that animation has already been used, skip it. if (ActiveKeyFrame.IsUsed) { return; } int NextKeyFrame = ActiveKeyFrame.NextKeyFrame; OnNewKeyFrameAnimationSprite(ActiveKeyFrame); ComputeRealDamage(ActiveKeyFrame); if (DicAnimationKeyFrame.TryGetValue(NextKeyFrame, out ActiveAnimationSpriteKeyFrame)) { DamageKeyFrame NextActiveKeyFrame = (DamageKeyFrame)ActiveAnimationSpriteKeyFrame; if (NextActiveKeyFrame.IsProgressive) { OnProgressiveNextKeyFrameAnimationSprite(NextActiveKeyFrame, KeyFrame, NextKeyFrame); ComputeNextDamage(NextActiveKeyFrame); } else { NextEvent = null; } } if (Owner != null && (!ActiveKeyFrame.IsProgressive || KeyFrame == SpawnFrame)) { Owner.DamageEnemyUnit(DamageCurrent); } } }
private int ComputeDamage(DamageKeyFrame KeyFrame) { int DamageDealt = GetDamageFromText(KeyFrame.Damage); string[] DamageSplit = KeyFrame.Damage.Split('/'); if (DamageSplit.Length == 1) { return(DamageDealt); } else if (DamageSplit.Length == 2) { return((int)(DamageDealt / Convert.ToDouble(DamageSplit[1], System.Globalization.CultureInfo.InvariantCulture))); } return(0); }
private DamageTimeline(BinaryReader BR, ContentManager Content) : base(BR, TimelineType) { _SpawnFrame = BR.ReadInt32(); _DeathFrame = BR.ReadInt32(); fntDamage = Content.Load <SpriteFont>("Fonts/Battle Damage"); fntDamage.Spacing = -5; int DicAnimationSpriteKeyFrameCount = BR.ReadInt32(); for (int E = 0; E < DicAnimationSpriteKeyFrameCount; E++) { int Key = BR.ReadInt32(); DamageKeyFrame NewAnimatedBitmapKeyFrame = new DamageKeyFrame(BR); DicAnimationKeyFrame.Add(Key, NewAnimatedBitmapKeyFrame); } }
public void ComputeNextDamage(DamageKeyFrame KeyFrame) { DamageNext = ComputeDamage(KeyFrame); TextSize = fntDamage.MeasureString(DamageNext.ToString()); int DamageDifference = DamageNext - DamageCurrent; DamageChangeValue = DamageDifference; string DamageString = DamageNext.ToString(); RoundTrip = new int[Math.Max(DamageString.Length, DamageCurrent.ToString().Length)]; for (int i = DamageString.Length - 1; i >= 0; --i) { if (DamageDifference > 0) { RoundTrip[i] = DamageDifference; DamageDifference /= 10; } else { RoundTrip[i] = 0; } } }