Skip to content

Commit

Permalink
Added damage display on battle field also for party members
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrdacor committed Dec 18, 2020
1 parent ad499aa commit 3b14006
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions Ambermoon.Core/Battle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ internal class BattleAction
public event Action<PartyMember> PlayerLostTarget;
event Action AnimationFinished;
readonly List<Monster> initialMonsters = new List<Monster>();
readonly Dictionary<int, IRenderText> monsterDamageTexts = new Dictionary<int, IRenderText>();
readonly Dictionary<int, IRenderText> battleFieldDamageTexts = new Dictionary<int, IRenderText>();
public IEnumerable<Monster> Monsters => battleField.Where(c => c?.Type == CharacterType.Monster).Cast<Monster>();
public IEnumerable<Character> Characters => battleField.Where(c => c != null);
public Character GetCharacterAt(int index) => battleField[index];
Expand Down Expand Up @@ -1255,8 +1255,8 @@ void HurtAnimationFinished()
currentlyAnimatedMonster = monster;

PlayBattleEffectAnimation(BattleEffect.HurtMonster, tile, battleTicks, EndHurt);
ShowMonsterDamage((int)tile, damage);
}
ShowBattleFieldDamage((int)tile, damage);
if (target.Ailments.HasFlag(Ailment.Sleep))
RemoveAilment(Ailment.Sleep, target);
target.Damage(damage);
Expand All @@ -1274,7 +1274,7 @@ void HurtAnimationFinished()
});
}

void ShowMonsterDamage(int tile, uint damage)
void ShowBattleFieldDamage(int tile, uint damage)
{
var layer = layout.RenderView.GetLayer(Layer.Text);
var text = layout.RenderView.TextProcessor.CreateText(damage > 999 ? "***" : $"{damage:000}");
Expand All @@ -1291,14 +1291,14 @@ void ShowMonsterDamage(int tile, uint damage)
};
int colorIndex = -1;

if (monsterDamageTexts.ContainsKey(tile))
if (battleFieldDamageTexts.ContainsKey(tile))
{
monsterDamageTexts[tile].Delete();
monsterDamageTexts[tile] = damageText;
battleFieldDamageTexts[tile].Delete();
battleFieldDamageTexts[tile] = damageText;
}
else
{
monsterDamageTexts.Add(tile, damageText);
battleFieldDamageTexts.Add(tile, damageText);
}

game.AddTimedEvent(TimeSpan.FromMilliseconds(150), ChangeColor);
Expand All @@ -1309,12 +1309,12 @@ void ChangeColor()

if (colorIndex == colors.Length)
{
monsterDamageTexts[tile].Delete();
monsterDamageTexts.Remove(tile);
battleFieldDamageTexts[tile].Delete();
battleFieldDamageTexts.Remove(tile);
}
else
{
monsterDamageTexts[tile].TextColor = colors[colorIndex];
battleFieldDamageTexts[tile].TextColor = colors[colorIndex];
game.AddTimedEvent(TimeSpan.FromMilliseconds(150), ChangeColor);
}
}
Expand Down Expand Up @@ -1588,8 +1588,7 @@ void EndHurt()
EndHurt();
}
);
if (target.Type == CharacterType.Monster)
ShowMonsterDamage(GetSlotFromCharacter(target), damage);
ShowBattleFieldDamage(GetSlotFromCharacter(target), damage);
}
}

Expand Down

0 comments on commit 3b14006

Please sign in to comment.