12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- var GameProtocol = require("CachetaGameProtocol");
- import ScenceManager from 'HNScenceManager';
- cc.Class({
- extends: cc.Component,
- editor: {
- menu: 'Game/Cacheta/Card'
- },
- properties: {
- atlasCards:
- {
- default:null,
- type:cc.SpriteAtlas
- },
- m_nCardId:0,
- Joker:false, //是否百搭
- },
- setId:function(id,MagicIdArr,picked) {
- this.m_nCardId = id;
- this.Joker = false;
- // let jsGame = ScenceManager.Instance().getGameComponent();
- // cc.log(typeof MagicIdArr)
- if(MagicIdArr == null || MagicIdArr == undefined) {
- MagicIdArr = [];
- }
- if (this.atlasCards) {
- var color = this.cardColor() + 1;
- var num = this.cardNum();
- var sprName = "handmah_" + color + num;
- if (this.m_nCardId == 0) {
- sprName = "handmah_" + 0 + 0;
- }
- var frame = this.atlasCards.getSpriteFrame(sprName);
- // if(jsGame && jsGame.cardAtlas) {
- // frame = jsGame.cardAtlas.getSpriteFrame(sprName)
- // }
- if (frame == null) {
- }
- this.node.getComponent(cc.Sprite).spriteFrame = frame;
- if(this.m_nCardId == 0 || MagicIdArr.length == 0){
- this.node.getChildByName("MagicCard").active = false;
- }else{
- if(MagicIdArr[0] == id || MagicIdArr[1] == id){
- this.node.getChildByName("MagicCard").active = true;
- this.Joker = true;
- }else{
- this.node.getChildByName("MagicCard").active = false;
- }
- let pickNode = this.node.getChildByName("picked");
- if(pickNode){
- pickNode.active = (picked == 1);
- }
- }
- }
- },
- isJoker(){
- return this.Joker;
- },
- cardId:function () {
- return this.m_nCardId;
- },
- cardColor:function () {
- return ((this.m_nCardId>>4) & 0x0F);
- },
- cardNum:function () {
- return (this.m_nCardId & 0x0F);
- },
- getCardColor:function (CardId) {
- return ((CardId>>4) & 0x0F);
- },
- getCardNum:function (CardId) {
- return (CardId & 0x0F);
- },
- });
|