// Learn cc.Class: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html // Learn Attribute: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html var gameConfig = require("gameConfig"); var playerData = require("playerData"); var SDKManage = require("SDKManage"); var NetManage = require("NetManage"); var wxVoice = require("wxVoice"); var vipColorConfig = require("vipColorConfig"); var Main = require("Main"); var Utils = require("Utils"); cc.Class({ extends: cc.Component, properties: { pr_hp: { default: null, type: cc.ProgressBar, }, lb_name: { default: null, type: cc.Label, }, spritepoint: { default: null, type: cc.Sprite, }, sp_vip: { default: null, type: cc.Sprite, }, sp_head: { default: null, type: cc.Sprite, }, sp_headkuang: { default: null, type: cc.Sprite, }, nd_jinyin: { default: null, type: cc.Node, }, nd_follow: { default: null, type: cc.Node, }, nd_followon: { default: null, type: cc.Node, }, nd_followoff: { default: null, type: cc.Node, }, }, // LIFE-CYCLE CALLBACKS: onLoad() { cc.Notifier.on("closeallvoice", this, this.closeallvoice.bind(this)); cc.Notifier.on("dotiaosan", this, this.dotiaosan.bind(this)); cc.Notifier.on("doluodi", this, this.doluodi.bind(this)); }, onDestroy() { cc.Notifier.off("closeallvoice", this); cc.Notifier.off("dotiaosan", this); cc.Notifier.off("doluodi", this); }, doluodi() { this.nd_follow.active = false; }, dotiaosan() { this.nd_followon.scale = 0; }, closeallvoice(v) { this.nd_jinyin.active = v; window.voiceSDK.addBlackList(this.playerid, !this.nd_jinyin.active); }, start() {}, setdata(p, path) { this.nd_jinyin.active = false; this.playerid = p.player_id; this.player = p; this.lb_name.string = p.name; var self = this; cc.loader.loadRes(path + "_2", cc.SpriteFrame, function (err, res) { if (!err && self.isValid) { self.spritepoint.spriteFrame = res; } }); var self = this; var id = p.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_headkuang.spriteFrame = res; } } ); Utils.setitem(this, p.hero_id, this.sp_head); // var avatar_id = 18201 // var sex = 'm' // if (p.sex == 1) { // sex = 'f' // } // var userdata = JSON.parse(p.user_data) // if (userdata.avatar_id && Number(userdata.avatar_id) >= 18000 && Number(userdata.avatar_id) <= 19000) { // avatar_id = userdata.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; // } // }); }, update(dt) { if (this.player) { if (this.player.dead) { this.player.hp = 0; } this.pr_hp.progress = this.player.hp / this.player.maxhp; if (this.player.hp != this.player.maxhp) { cc.gameMgr.memberhurt = true; } if (this.playerid == cc.gameMgr.player.pctrl.follow_target) { this.nd_followoff.active = true; } else { this.nd_followoff.active = false; } this.nd_followon.active = !this.nd_followoff.active; } }, onclickvoice() { this.nd_jinyin.active = !this.nd_jinyin.active; window.voiceSDK.addBlackList(this.playerid, !this.nd_jinyin.active); }, onclickfollow() { cc.gameMgr.player.pctrl.changefollow(this.playerid); }, onclickquxiaofollow() { cc.gameMgr.player.pctrl.changefollow(0); }, });