123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- var GamePlayer = require("GamePlayer");
- var Define = require("Define");
- var Global = require("Global");
- var UIHelper = require("UIHelper");
- import { CServerItem } from 'CServerItem'
- import ScenceManager from 'HNScenceManager'
- cc.Class({
- extends: GamePlayer,
- //extends: cc.Component,
- properties: {
- sprHeadIcon:cc.Sprite, //头像
- sprVipIcon:cc.Sprite, // VIP框
- btnHead:cc.Button,
- sprEmptyHeadIcon:cc.Sprite,
- labScore:cc.Label, //分数
- labName:cc.Label, //昵称
- //sprHostFlag:cc.Sprite, //房主标记
- sprOffineFlag:cc.Sprite, //离线标记
- //sprZhuangFlag:cc.Sprite, //庄标记
- spriteFrame:{ //头像图片
- default:null,
- type:cc.SpriteFrame
- },
- iIndex:-1,
- _CurGameScene:null,
- _myScore:0,
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad: function() {
- this._isGameEnd = false;
- 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) {
-
- },
- playerEnter: function() {
- this.labName.node.active = true;
- this.sprEmptyHeadIcon.node.active = false;
- this.sprHeadIcon.node.active = true;
- this.btnHead.node.userID = this.getUserID();
- this.btnHead.node.gameID = this.getGameID();
- this._CurGameScene = ScenceManager.Instance().getGameComponent();
- },
- playerLeave:function() {
- this.node.removeFromParent();
- },
- upPlayerState: function() {
- // this.setReady(this.getUserStatus() == Define.US_READY);
- this.setOffline(this.getUserStatus() == Define.US_OFFLINE);
- if (this.getUserStatus() == Define.US_OFFLINE) {
- //置灰
- // this.sprHeadIcon.node.color = cc.Color.GRAY;
- }
- else {
- //复原
- this.sprHeadIcon.node.color = cc.Color.WHITE;
- }
- },
- upPlayerInfo: function() {
- if (this.getNickName() != "") {
- var str = this.getNickName();
- this.labName.string = Global.subStr(str, 15);
- }
- // vip 头像框
- let vipID = this.getVIPLevel();
- let node = this.sprVipIcon;
- Global.print("upPlayerInfo")
- if(vipID >= 4 && vipID <= 7) {
- // if(this.iIndex == 0) {
- node.getComponent(cc.Sprite).spriteFrame = cc.vv.globalUserInfo.getVIPSpriteFrameByFaceID(vipID);
- node.active = true;
- // }
- }else{
- node.active = false;
- }
- if (CServerItem.get().mGameServer.ServerType == 1)
- {
- this.setScore(this.getUserScore());
- }
- },
- getnickName: function()
- {
- return this.labName.string
- },
- upPlayerHead: function() {
- 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();
- let node = this.sprVipIcon;
- Global.print("upPlayerHead")
- if(vipID >= 4 && vipID <= 7) {
- // if(this.iIndex == 0) {
- node.getComponent(cc.Sprite).spriteFrame = cc.vv.globalUserInfo.getVIPSpriteFrameByFaceID(vipID);
- node.active = true;
- // }
- }else{
- node.active = false;
- }
- },
- getHeadIcon: function(ret) {
- if(ret)
- {
- return this.sprHeadIcon.spriteFrame;
- }
- if (this.getHeadHttp() != "") {
- return this.sprHeadIcon.spriteFrame;
- }
- return null;
- },
- setScore: function(score) {
- this._myScore = score;
- var strScore = this.changeScore(Global.formatString2Score(score));
- this.labScore.string = strScore;
- },
- getScore: function() {
- return this._myScore;
- },
- setHost: function(isHost) {
- //this.sprHostFlag.node.active = isHost;
- },
- setZhuang: function(isZhuang) {
- //this.sprZhuangFlag.node.active = isZhuang;
- },
- isZhuang: function(isZhuang) {
- //return this.sprZhuangFlag.node.active;
- },
- setStatusHu: function(isHu) {
- this.node.getChildByName("Status_Hu").active = isHu;
- },
- // setMa: function(isMa) {
- // this.sprMaFlag.node.active = isMa;
- // },
- 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);
- },
- start () {
-
- },
- });
|