var SDKManage = require("SDKManage") var NetManage = require("NetManage") var playerData = require("playerData") var gameConfig = require("gameConfig") var vipColorConfig = require("vipColorConfig") var Main = require("Main"); function etos() { return "" } var colortb = { // 1 世界 2好友 3战队 o别人 m自己 "o1": "#00ff00", "m1": "#00ffff", "o2": "#00ff00", "m2": "#00ffff", "o3": "#00ff00", "m3": "#00ffff", } var battlecolor = "#00ffff" cc.Class({ extends: cc.Component, properties: { ly_up: { default: null, type: cc.Layout, }, lb_name: { default: null, type: cc.Label, }, lb_talk: { default: null, type: cc.RichText, }, sp_head: { default: null, type: cc.Sprite, }, sp_head_back: { default: null, type: cc.Sprite, }, sp_sex: { default: null, type: cc.Sprite, }, sp_vip: { default: null, type: cc.Sprite, }, sp_rank: { default: null, type: cc.Sprite, }, sp_lv: { default: null, type: cc.Sprite, }, nd_talkbg: { default: null, type: cc.Node, }, }, // LIFE-CYCLE CALLBACKS: // onLoad () {}, start() { this.iidex = 0 }, update(dt) { if (this.type == 1) { this.node.x -= dt * 100; if (this.node.x < -600) { this.node.active = false; //console.log("text destroy") } } else { this.showtime += dt; if (this.showtime > 5) { this.node.active = false; } } }, changeText(sender, data, type) { console.log("ChangeMsg========",data); this.sdata = data this.type = type this.sender = sender this.showtime = 0 if (this.type == 1) { this.node.x = 600 this.nd_talkbg.active = false } else { this.node.x = 0 this.nd_talkbg.active = true } this.node.active = true this.setdata(this.sender, this.sdata) }, showsenderinfo(userdata) { var self = this self.sp_vip.spriteFrame = null var vg = gameConfig.vipConfig[userdata.vip_lv] if (!vg) { return } if (userdata.vip_lv != 0) { cc.loader.loadRes("textures/icons/public/vip" + userdata.vip_lv, cc.SpriteFrame, function(err, res) { if (!err && self.isValid) { self.sp_vip.spriteFrame = res; } }); } var coltring = vipColorConfig[vg.color] this.lb_name.string = userdata.nickname this.lb_name.node.color = coltring var id = userdata.head if (!id) { id = 0 } cc.loader.loadRes("textures/icons/headbg/head_bg" + id, cc.SpriteFrame, function(err, res) { if (!err && self.isValid) { self.sp_head_back.spriteFrame = res; } }); var avatar_id = 18201 var sex = 'm' if (userdata.sex == 1) { sex = 'f' } if (userdata.avatar_url && Number(userdata.avatar_url) >= 18000 && Number(userdata.avatar_url) <= 19000) { avatar_id = userdata.avatar_url } this.lastavatar = avatar_id cc.loader.loadRes("textures/icons/public/" + gameConfig.wai_itemConfig[avatar_id].icon, cc.SpriteFrame, function(err, res) { if (!err && self.isValid) { self.sp_head.spriteFrame = res; } }); var score = userdata.user_value1.low var level_list = playerData.getSeasonArr() var fg for (var i = 0; i < level_list.length; i++) { if (score <= level_list[i].max_point || level_list[i].max_point == -1) { fg = level_list[i] break } } if (!fg) { return } cc.loader.loadRes("textures/icons/public/" + fg.icon, cc.SpriteFrame, function(err, res) { if (!err && self.isValid) { if (self.sp_rank) { self.sp_rank.spriteFrame = res; } } }); if (fg.level != '') { cc.loader.loadRes("textures/icons/public/" + fg.level, cc.SpriteFrame, function(err, res) { if (!err && self.isValid) { if (self.sp_lv) { self.sp_lv.spriteFrame = res; } } }); } cc.loader.loadRes("textures/icons/public/" + sex, cc.SpriteFrame, function(err, res) { if (!err && self.isValid) { self.sp_sex.spriteFrame = res; } }); }, onBtnShowInfo() { var flag = 0 for (var i = 0; i < playerData.friend_list.length; i++) { if (playerData.friend_list[i].base_data['account_id'] == this.account_id) { flag = 1 } } playerData.friend_accountid = this.account_id playerData.friend_rank = this.rank cc.Notifier.emit('showplayerinfo', flag) }, setdata(sender, data) { //this.chat_channel = data.chat_channel var userdata = sender.base_data this.showsenderinfo(userdata) this.account_id = userdata.account_id // if (this.account_id == SDKManage.account_id) { //todo 通过id 判断是否自己 // this.setmode(true) // } else { // this.setmode(false) // } var str = data var reg = /\(e\d+\)/gi; str = str.replace(reg, etos) this.lb_talk.string = "" + str + "" this.nd_talkbg.width = this.lb_talk._linesWidth[0] + 30 this.nd_talkbg.height = this.lb_talk._labelHeight }, });