Created
October 14, 2014 14:59
-
-
Save kyubuns/05d9c36ef2ffae04d02f to your computer and use it in GitHub Desktop.
Hoge
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 UnityEngine; | |
using System; | |
using System.Collections; | |
public class Model | |
{ | |
public Action<string> OnChange; | |
protected void Changed(string propertyName) | |
{ | |
if(OnChange != null) OnChange(propertyName); | |
} | |
} |
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 UnityEngine; | |
public class RPGStatusModel : Model | |
{ | |
public RPGStatusModel(string name, int hp, int mp, int attack) | |
{ | |
this.Name = name; | |
this.HP = hp; | |
this.MP = mp; | |
this.Attack = attack; | |
} | |
private string name; | |
public string Name | |
{ | |
get { return name; } | |
set { name = value; Changed("Name"); } | |
} | |
private int hp; | |
public int HP | |
{ | |
get { return hp; } | |
set { hp = Mathf.Max(0, value); Changed("HP"); } | |
} | |
private int mp; | |
public int MP | |
{ | |
get { return mp; } | |
set { mp = Mathf.Max(0, value); Changed("MP"); } | |
} | |
public int attack; | |
public int Attack | |
{ | |
get { return attack; } | |
set { attack = value; Changed("Attack"); } | |
} | |
public void Damage() | |
{ | |
HP--; | |
Debug.Log(string.Format("Damage HP:{0}", HP)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment