コード例 #1
0
        protected void PrintHealedMessage(object sender, FighterHealedEventArgs e)
        {
            IFighter senderAsFighter = sender as IFighter;

            if (senderAsFighter == null)
            {
                throw new ArgumentException("BattleManagerScreenOutputs.PrintHealedMessage should subscribe to IFighters and nothing else");
            }

            var output = e.IsFullHeal ?
                         $"{senderAsFighter.DisplayName}'s HP was fully restored!" :
                         $"{senderAsFighter.DisplayName} was healed for {e.HealAmount} HP!";

            _output.WriteLine(output);
        }
コード例 #2
0
ファイル: Fighter.cs プロジェクト: Jsweeney1000/SimpleRPG
        public int Heal(int amount, bool isFullHeal = false)
        {
            var prevHealth = CurrentHealth;
            int healAmount = 0;

            if (CurrentHealth > 0)
            {
                CurrentHealth += amount;

                if (CurrentHealth > MaxHealth)
                {
                    CurrentHealth = MaxHealth;
                }

                healAmount = CurrentHealth - prevHealth;

                FighterHealedEventArgs e = new FighterHealedEventArgs(healAmount, isFullHeal);
                OnHealed(e);
            }

            return(healAmount);
        }
コード例 #3
0
ファイル: EventLogger.cs プロジェクト: Jsweeney1000/SimpleRPG
 private void _logHealed(object sender, FighterHealedEventArgs e)
 {
     Logs.Add(new EventLog(EventType.Healed, sender, e));
 }
コード例 #4
0
ファイル: Fighter.cs プロジェクト: Jsweeney1000/SimpleRPG
 public void OnHealed(FighterHealedEventArgs e)
 {
     Healed?.Invoke(this, e);
 }