BRTPCard.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. const Tile_Color = cc.Enum({
  2. COLOR_DIAMOND:1,
  3. COLOR_CLUB:2,
  4. COLOR_HEART:3,
  5. COLOR_SPADE:4,
  6. });
  7. const Tile_Num = cc.Enum({
  8. Num_A:1,
  9. Num_2:2,
  10. Num_3:3,
  11. Num_4:4,
  12. Num_5:5,
  13. Num_6:6,
  14. Num_7:7,
  15. Num_8:8,
  16. Num_9:9,
  17. });
  18. //module.exports = {
  19. // Card_Color:Card_Color,
  20. // Card_Num:Card_Num,
  21. //};
  22. cc.Class({
  23. extends: cc.Component,
  24. properties: {
  25. m_nCardId:0,
  26. },
  27. statics:{
  28. MakeCardID : function(Color,Num){
  29. return (Color<<4) + Num;
  30. },
  31. //CreateCard : function(type, Id){
  32. // return cc.instantiate(this.PreHandCard0);
  33. //},
  34. },
  35. setId:function(id) {
  36. this.m_nCardId = id;
  37. },
  38. tileId:function () {
  39. return this.m_nCardId;
  40. },
  41. tileColor:function () {
  42. return ((this.m_nCardId>>4) & 0x0F);
  43. },
  44. tileNum:function () {
  45. return (this.m_nCardId & 0x0F);
  46. },
  47. tileName:function () {
  48. const colorname = ["方块","梅花","红桃","黑桃"] ;
  49. var name = "";
  50. var color = this.Tile_Color();
  51. var num = this.tileNum();
  52. switch (color) {
  53. case Tile_Color.COLOR_DIAMOND:
  54. case Tile_Color.COLOR_CLUB:
  55. case Tile_Color.COLOR_HEART:
  56. case Tile_Color.COLOR_SPADE:
  57. {
  58. name = colorname[color] + num.toString();
  59. }
  60. break;
  61. default:
  62. break;
  63. }
  64. return name;
  65. },
  66. // update (dt) {},
  67. });