var GamePlayer = require("GamePlayer"); var Define = require("Define"); var ProtocolGameServer = require("ProtocolGameServer"); var BRTPSoundFun = require("BRTPSoundFun"); var Global = require("Global"); var UIHelper = require("UIHelper"); import { CServerItem } from 'CServerItem' var voice = { localId: "", serverId: "", }; cc.Class({ extends: GamePlayer, //extends: cc.Component, properties: { sprHeadIcon:cc.Sprite, sprVipIcon:cc.Sprite, // VIP框 btnHead:cc.Button, sprEmptyHeadIcon:cc.Sprite, labScoreWin:cc.Label, labScoreLose:cc.Label, labName:cc.Label, sprOffineFlag:cc.Sprite, sprScoreBg:cc.Sprite, spriteFrame:{ default:null, type:cc.SpriteFrame }, //牌的显示和操作 cardNode: { default:null, type:cc.Node }, goldPrefabArr: { //金豆预制数组 default: [], type: [cc.Prefab] }, iIndex:-1, _myScore:0, _chairID:-1, }, // LIFE-CYCLE CALLBACKS: onLoad: function() { this.sprVipIcon.sizeMode = cc.Sprite.SizeMode.CUSTOM; this.sprVipIcon.node.width = 120; this.sprVipIcon.node.height = 120; this.sprVipIcon.node.scale = 1; }, init: function(index) { }, resetCard:function() { this.node.getChildByName("scoreAni").active = false; this.node.getChildByName("bombOpenAniNode").active = false; this.node.getChildByName("bomb").active = false; }, resetView: function() { this.node.getChildByName("ChatNode").getChildByName("BiaoqingNode").active = false; this.node.getChildByName("scoreAni").active = false; this.node.stopAllActions(); }, hideVoice: function() { this.node.getChildByName("ChatNode").getChildByName("VoiceNode").active = false; }, addScore: function(lScore,bAni) { this.node.getChildByName("addInfoNode").active = true; var pos = this.node.getChildByName("addInfoNode").getPosition(); var goldNode = this.node.getChildByName("addInfoNode").getChildByName("goldNode"); var posDe = goldNode.getPosition(); var scoreNode = this.node.getChildByName("addInfoNode").getChildByName("scoreNode"); if(bAni) { //音效 BRTPSoundFun.playEffectEX(BRTPSoundFun.EX_SCORE); if (CServerItem.get().mGameServer.ServerType == 1) //金豆场金豆 { var count_10w = parseInt(lScore/100000); var count_1w = parseInt((lScore-count_10w*100000)/10000); var count_1000 = parseInt((lScore-count_10w*100000-count_1w*10000)/1000); var count_100 = parseInt((lScore-count_10w*100000-count_1w*10000-count_1000*1000)/100); for(let i=0; i { scoreNode.getChildByName("score").getComponent(cc.Label).string = lScore; scoreNode.active = true; scoreNode.getChildByName("fen").active = isshow; }, this))); } else { if (CServerItem.get().mGameServer.ServerType == 1) //金豆场金豆 { var count_10w = parseInt(lScore/100000); var count_1w = parseInt((lScore-count_10w*100000)/10000); var count_1000 = parseInt((lScore-count_10w*100000-count_1w*10000)/1000); var count_100 = parseInt((lScore-count_10w*100000-count_1w*10000-count_1000*1000)/100); for(let i=0; i= 4 && vipID <= 7) { // if(this.iIndex == 0) { node.getComponent(cc.Sprite).spriteFrame = cc.vv.globalUserInfo.getVIPSpriteFrameByFaceID(vipID); node.active = true; // } }else{ node.active = false; } }, setChairID: function(chairID){ this._chairID = chairID }, getChairID: function(){ return this._chairID; }, getnickName: function() { return this.labName.string }, upPlayerHead: function() { var self=this; if (this.getHeadHttp() != "") { // 设置头像 this.sprHeadIcon.getComponent("urlSpriteFrame").loadAvatar(this.getHeadHttp(),null, {width:100, height:100}); } else { this.sprHeadIcon.spriteFrame = this.spriteFrame; this.sprHeadIcon.node.width = 100; this.sprHeadIcon.node.height = 100; } let vipID = this.getVIPLevel(); if(vipID >= 4 && vipID <= 7) { this.sprVipIcon.spriteFrame = cc.vv.globalUserInfo.getVIPSpriteFrameByFaceID(vipID); this.sprVipIcon.node.active = true; }else{ this.sprVipIcon.node.active = false; } }, getHeadIcon: function(ret) { if(ret) { return this.sprHeadIcon.spriteFrame; } if (this.getHeadHttp() != "") { return this.sprHeadIcon.spriteFrame; } return null; }, showTalkState: function(data) { if (data.Type == ProtocolGameServer.CMD_GR_C_TableTalk.TALK_TYPE) { } if (data.Type == ProtocolGameServer.CMD_GR_C_TableTalk.TYPE_WORD) { this.runPaoMaDeng(data.String); } if (data.Type == ProtocolGameServer.CMD_GR_C_TableTalk.TYPE_DEFINE) { var strArr = data.String.split(":",2); BRTPSoundFun.playEffectDefineString(strArr[0]); this.runPaoMaDeng(strArr[1]); } if (data.Type == ProtocolGameServer.CMD_GR_C_TableTalk.TYPE_BIAOQING) { this.node.getChildByName("ChatNode").getChildByName("BiaoqingNode").active = true; var cpgAni = this.node.getChildByName("ChatNode").getChildByName("BiaoqingNode").getComponent(sp.Skeleton); var aniName = data.String.substr(0,2); cpgAni.setAnimation(0,aniName,false); } }, showVoice: function(data) { this.node.getChildByName("ChatNode").getChildByName("VoiceNode").active = true; var self = this; var voice1 = this.node.getChildByName("ChatNode").getChildByName("VoiceNode").getChildByName("Voice1"); var voice2 = this.node.getChildByName("ChatNode").getChildByName("VoiceNode").getChildByName("Voice2"); voice1.active = false; voice2.active = false; var time = 0; var Voice1Visible = function() { voice1.active = true; voice1.runAction(cc.sequence(cc.delayTime(0.6),cc.callFunc(Voice1NoVisible))); } var Voice2Visible = function() { time += 0.6; voice2.active = true; voice2.runAction(cc.sequence(cc.delayTime(0.6),cc.callFunc(Voice2NoVisible))); } var Voice1NoVisible = function() { if (time > 5) { return; } voice1.active = false; voice1.runAction(cc.sequence(cc.delayTime(0.6),cc.callFunc(Voice1Visible))); } var Voice2NoVisible = function() { time += 0.6; if (time > 5) { self.node.getChildByName("ChatNode").getChildByName("VoiceNode").active = false; } else { voice2.active = false; voice2.runAction(cc.sequence(cc.delayTime(0.6),cc.callFunc(Voice2Visible))); } } voice.serverId = data.SerVerID; voice1.runAction(cc.callFunc(Voice1Visible)); voice2.runAction(cc.sequence(cc.delayTime(0.3),cc.callFunc(Voice2Visible))); }, runPaoMaDeng: function(content) { var chatBubble = this.node.getChildByName("ChatNode").getChildByName("ChatBubble"); chatBubble.active = true; chatBubble.opacity = 255; chatBubble.stopAllActions(); var label = chatBubble.getChildByName("msg"); label.active = true; label.getComponent(cc.Label).string = content; chatBubble.height = label.height + 33; var fadeOut = cc.sequence(cc.delayTime(4),cc.fadeOut(2.0)); chatBubble.runAction(fadeOut); }, setScore: function(score) { this._myScore = score; var ScoreImagic = this.node.getChildByName("PlayerInfo").getChildByName("ScoreImagic"); var strScore = this.changeScore(Global.formatString2Score(score)); ScoreImagic.getChildByName("Score").getComponent(cc.Label).string = strScore; }, getScore: function() { return this._myScore; }, addScoreAni: function(score) { if(score == 0){ return; } var s = Math.abs(score); var strScore = this.changeScore(s); var scoreAni = this.node.getChildByName("scoreAni"); if(score < 0) { scoreAni.getChildByName("scoreWinLabel").active = false; scoreAni.getChildByName("scoreLoseLabel").active = true; scoreAni.getChildByName("scoreLoseLabel").getChildByName("label").getComponent(cc.Label).string = "-"+strScore; } else if(score > 0) { scoreAni.getChildByName("scoreWinLabel").active = true; scoreAni.getChildByName("scoreLoseLabel").active = false; scoreAni.getChildByName("scoreWinLabel").getChildByName("label").getComponent(cc.Label).string = "+"+strScore; } scoreAni.active = true; scoreAni.getComponent(cc.Animation).play("showScoreAni"); }, setHost: function(isHost) { this.sprHostFlag.node.active = isHost; }, setStatusHu: function(isHu) { this.node.getChildByName("Status_Hu").active = isHu; }, setOffline: function(isOffline) { // this.sprOffineFlag.node.active = isOffline; }, setReady: function(isReady) { this.sprReadyFlag.node.active = isReady; }, resetSeatPos: function(pos) { this.node.getChildByName("PlayerHead").position = pos; }, playMoveAction: function(pos) { var moveto = cc.moveTo(1,pos); this.node.getChildByName("PlayerHead").runAction(moveto); }, startGameNoTime: function(pos) { this.node.getChildByName("PlayerHead").setPosition(pos); }, playWinAni: function() { const aniNode = this.node.getChildByName("WinAni"); if(aniNode) { aniNode.active = true; aniNode.getComponent(sp.Skeleton).setAnimation(0, "a1", false); // aniNode.getComponent(sp.Skeleton).setTrackCompleteListener( // () => { // aniNode.active = false; // } // ); } }, changeScore (score,isEnglish) { var strScore = score.toString(); if(score >= 100000000000) //千亿 { strScore = strScore.slice(0,4); // strScore = parseInt(strScore) / 10; if(isEnglish) { strScore = strScore + "y" } else { strScore = strScore + "亿" } } else if(score >= 10000000000) //百亿 { strScore = strScore.slice(0,3); // strScore = parseInt(strScore) / 10; if(isEnglish) { strScore = strScore + "y" } else { strScore = strScore + "亿" } } else if(score >= 1000000000) //十亿 { strScore = strScore.slice(0,3); strScore = parseInt(strScore) / 10; if(isEnglish) { strScore = strScore + "y" } else { strScore = strScore + "亿" } } else if(score >= 100000000) //亿 { strScore = strScore.slice(0,3); strScore = parseInt(strScore) / 100; if(isEnglish) { strScore = strScore + "y" } else { strScore = strScore + "亿" } } else if(score >= 10000000) //千万 { strScore = strScore.slice(0,4); if(isEnglish) { strScore = strScore + "w" } else { strScore = strScore + "万" } } /*else if(score >= 1000000) //百万 { strScore = strScore.slice(0,3); if(isEnglish) { strScore = strScore + "w" } else { strScore = strScore + "万" } }*/ // else if(score >= 100000) //十万 // { // strScore = strScore.slice(0,3); // strScore = parseInt(strScore) / 10; // if(isEnglish) // { // strScore = strScore + "w" // } // else // { // strScore = strScore + "万" // } // } else { strScore = parseFloat(score).toFixed(2); } return strScore; }, });