public override void ReceiveDamage(Entity entity)
        {
            var message = string.Format("{0} attacked {1}.", entity.Name, Name);

            string postMessage;

            if (!IsDefending)
            {
                var value = (int)entity.Damage() - (Stats.Defense * 2);
                postMessage  = " -" + value;
                postMessage += value >= (HealthMeter.MaxHealth / 2) ? " CRITICAL" : "";
                ConsolePrinter.PrintMessage(message + postMessage, false);
                HealthMeter.ReceiveDamage(value);

                if (CheckDeath())
                {
                    Die(entity);
                }
                else
                {
                    OnBeingAttacked.Invoke(entity as Hero);
                }
            }
            else
            {
                postMessage = "..but " + Name + " defended.";
                ConsolePrinter.PrintMessage(message + postMessage, false);

                HealthMeter.ReceiveDamage(0);
                IsDefending = false;
            }
        }
Beispiel #2
0
 public static void HandleBeingAttacked(GameObject npcGameObject)
 {
     OnBeingAttacked?.Invoke(npcGameObject);
 }