斗地主-(二)

来源:互联网 发布:自制网络验证系统 编辑:程序博客网 时间:2024/04/28 07:03
斗地主的主角就是牌,所以把牌定义为一个类。
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[] {"黑桃","红桃","梅花","方块"};        //从小到大 3,4,5,6,7,8,9,10,J=11,Q=12,K=13,A=14,2=15 没有大小王//        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];    }}
0 0
原创粉丝点击