Created
March 16, 2016 17:45
-
-
Save chuwilliamson/3b26cb29cd573e3dc3ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
public interface IDamager | |
{ | |
/// <summary> | |
/// OUTGOING DAMAGE | |
/// </summary> | |
/// <returns>return how much damage was SENT</returns> | |
float Damage { get; } | |
} | |
public interface IDamageable //do damage and take damage | |
{ | |
/// <summary> | |
/// INCOMING DAMAGE | |
/// </summary> | |
/// Perform damage on an object, it is the implementing class's responsibility to perform the | |
/// damage mitigation | |
void TakeDamage(int amount); | |
} | |
public interface Iitem | |
{ | |
int doItem(IStat s); | |
} | |
public interface IStat | |
{ | |
int hp { get; set; } | |
int resource { get; set; } | |
} | |
public class Rogue : IStat | |
{ | |
Rogue() | |
{ | |
inventory.Add(potion1); | |
inventory.Add(potion2); | |
} | |
public int hp | |
{ | |
get | |
{ | |
throw new NotImplementedException(); | |
} | |
set | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
public int resource | |
{ | |
get | |
{ | |
throw new NotImplementedException(); | |
} | |
set | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
public List<Iitem> inventory; | |
HealthPotion potion1 = new HealthPotion(1); | |
HealthPotion potion2 = new HealthPotion(25); | |
EnergyPotion thistleTea = new EnergyPotion(25); | |
} | |
public class EnergyPotion : Iitem | |
{ | |
EnergyPotion(int val) | |
{ | |
value = val; | |
} | |
int value; | |
public int doItem(IStat s) | |
{ | |
return s.resource + value; | |
} | |
} | |
public class HealthPotion : Iitem | |
{ | |
int value; | |
public HealthPotion(int healthAmount) | |
{ | |
value = healthAmount; | |
} | |
public int doItem(IStat stat) | |
{ | |
return stat.hp + value; | |
} | |
} | |
public class Game | |
{ | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example usage of interfaces for guy goudeau