import NetManage from "../manages/NetManage"; var Utils = require('Utils'); const { UIBase } = require("../UI/UIBase"); cc.Class({ extends: UIBase, properties: { headIcon:{ default:null, type:cc.Sprite }, playName:{ default:null, type:cc.Label }, totalKill:{ default:null, type:cc.Label }, totalGame:{ default:null, type:cc.Label }, totalWin:{ default:null, type:cc.Label }, WinRate:{ default:null, type:cc.Label }, MostKill:{ default:null, type:cc.Label }, AverageKill:{ default:null, type:cc.Label }, MostDMG:{ default:null, type:cc.Label }, AverageDMG:{ default:null, type:cc.Label }, nd_star:{ default:null, type:cc.Node } }, init(data){ // data : user account --> get user info according to user account NetManage.getUeserInfo(data,(res)=>{ this.account_id = data; this.playerData = res; this.playName.string = this.playerData.info.name; Utils.setitem(this,this.playerData.info.head_id,this.headIcon); // this.totalKill.string = this.playerData.info.history_seasons[0].total_kills; this.totalGame.string = this.playerData.info.history_seasons[0].game_times; this.totalWin.string = this.playerData.info.history_seasons[0].win_times; this.WinRate.string = `${this.playerData.info.history_seasons[0].win_rate}%`; // this.MostKill.string = this.playerData.info.history_seasons[0].max_kills; this.AverageKill.string = this.playerData.info.history_seasons[0].avg_kills; this.MostDMG.string = this.playerData.info.history_seasons[0].max_damage_out; this.AverageDMG.string = this.playerData.info.history_seasons[0].avg_damage_out; // this.theStar( Number(this.playerData.info.history_seasons[0].star_kills) / 100, Number(this.playerData.info.history_seasons[0].star_damage) / 100, Number(this.playerData.info.history_seasons[0].star_alive) / 100, Number(this.playerData.info.history_seasons[0].star_recover) / 100, Number(this.playerData.info.history_seasons[0].star_win) / 100 ); }) }, start () { }, onClose(){ this.node.destroy() }, onClickAddFriend(){ cc.uiHelper.showTips("Send friend request!"); cc.chatMgr.sendmsg('CMFriendApply', { friend_id: this.account_id, msg: '', }); }, onClickAddBlackList(){ cc.uiHelper.showTips("Add to blacklist"); cc.chatMgr.sendmsg('CMFriendDeleteBlack', { account_id: this.account_id, }); }, theStar(r1, r2, r3, r4, r5) { var temp = [r1, r2, r3, r4, r5]; var leng = 108 / 2; var ctx = this.nd_star.getComponent(cc.Graphics); for (var i = 0; i < 5; i++) { let dir = cc.v2( Math.cos((-i * 72 + 90) * (Math.PI / 180)), Math.sin((-i * 72 + 90) * (Math.PI / 180)) ); dir = dir.normalize(); let pos = cc.v2(dir.x * temp[i] * leng, dir.y * temp[i] * leng); if (i == 0) { ctx.moveTo(pos.x, pos.y); } else { ctx.lineTo(pos.x, pos.y); } } ctx.close(); ctx.stroke(); ctx.fill(); }, }); export var playerInfoUI = "prefabs/tips/playerinfo"