Advertisement
Guest User

Untitled

a guest
Jun 7th, 2018
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. public class CharacterAttribute : Attribute { /* ... */ }
  2. public enum CharacterAttributeType {
  3.     Health
  4. }
  5.  
  6. public class Character {
  7.     private Dictionary<CharacterAttributeType, CharacterAttribute> attributes;
  8.  
  9.     public CharacterAttribute GetAttribute (CharacterAttributeType type) {
  10.         return this.attributes[type];
  11.     }
  12. }
  13.  
  14. // Adesso sarà possibile monitorare "la morte del personaggio" in questo modo.
  15.  
  16. istanzaPersonaggio.GetAttribute(CharacterAttributeType.Health).OnCurrentChange = (int amount) => {
  17.     if (istanzaPersonaggio.GetAttribute(CharacterAttributeType.Health).Current == 0) {
  18.         /* Morto. */
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement