Skip to content

Instantly share code, notes, and snippets.

@kyubuns
Created October 14, 2014 14:59
Show Gist options
  • Save kyubuns/05d9c36ef2ffae04d02f to your computer and use it in GitHub Desktop.
Save kyubuns/05d9c36ef2ffae04d02f to your computer and use it in GitHub Desktop.
Hoge
using UnityEngine;
using System;
using System.Collections;
public class Model
{
public Action<string> OnChange;
protected void Changed(string propertyName)
{
if(OnChange != null) OnChange(propertyName);
}
}
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