Skip to content

Instantly share code, notes, and snippets.

@smkplus
Last active April 10, 2020 09:18
Show Gist options
  • Select an option

  • Save smkplus/1abf4e67148879f00fb10e2d8e18b7a9 to your computer and use it in GitHub Desktop.

Select an option

Save smkplus/1abf4e67148879f00fb10e2d8e18b7a9 to your computer and use it in GitHub Desktop.
using System;
using UnityEngine;
public class Warrior : MonoBehaviour
{
public int Armor { get; set; }
public int Life { get; set; }
public virtual void Attack()
{
// Attack to closest enemy
}
public virtual void TakeDamage(int damage)
{
Life -= Math.Max(0, damage - Armor);
}
}
public class Mage : Warrior
{
public int MagicProtection { get; set; }
public override void Attack()
{
// Throw a Fire to target
}
public void Hex()
{
// Convert target to sheep
}
public override void TakeDamage(int damage)
{
Life -= Math.Max(0, damage - Armor - MagicProtection);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment