斗地主的主角就是牌,所以把牌定义为一个类。
using UnityEngine;
using System.Collections;
public class Poke {
private int color ;
public int Color {
get {
return color;
}
}
private int size;
public int Size {
get {
return size;
}
}
private Sprite image;
public Sprite Image {
get {
return image;
}
}
private int index;
public int Index {
get {
return index;
}
set {
index = value;
}
}
public Poke (int color ,int size,Sprite image)
{
this.color = color;
this.size = size;
this.image = image;
}
public string OutPut()
{
string [] pokeColor = new string[] {"黑桃","红桃","梅花","方块"};
string [] pokeNumber = new string[] {"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
if (size == 16 ) {
return "小王";
}
if (size == 17) {
return "大王";
}
return pokeColor [color - 1] + pokeNumber [size - 3];
}
}