// 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 cc.Class({ extends: cc.Component, properties: { // foo: { // // ATTRIBUTES: // default: null, // The default value will be used only when the component attaching // // to a node for the first time // type: cc.SpriteFrame, // optional, default is typeof default // serializable: true, // optional, default is true // }, // bar: { // get () { // return this._bar; // }, // set (value) { // this._bar = value; // } // }, }, // LIFE-CYCLE CALLBACKS: onLoad () { // console.log("结算页面看见"); }, start() { utils.isMobile(function () { Manager.Settlementlayout = this; }.bind(this)); if (soundM.sound!=null) { soundM.sound.playSettlement(); } let datalayout = this.datalayout = UtilsPrefabs.getNode("datalayout", this.node); //本次得分 let Score = this.Score = UtilsPrefabs.getNode("Score", datalayout); //飞过什么星球 let star = UtilsPrefabs.getNode("star", datalayout); //距离面板 let DistanceLayout = this.DistanceLayout = UtilsPrefabs.getNode("DistanceLayout", datalayout); //距离 let distance = this.distance = UtilsPrefabs.getNode("distance", DistanceLayout); //距离单位 let distanceUnit = this.distanceUnit = UtilsPrefabs.getNode("distanceUnit", DistanceLayout); //准确度 let Accuracy = this.Accuracy = UtilsPrefabs.getNode("Accuracy", datalayout); //速度 let speed = this.speed = UtilsPrefabs.getNode("speed", datalayout); //力量 let power = this.power = UtilsPrefabs.getNode("power", datalayout); //三个前后的操作 let layout = this.layout = UtilsPrefabs.getNode("layout", this.node); let noData = this.noData = UtilsPrefabs.getNode("noData", this.node); //04月25日,单位改为万公里了 this.StarDistnaces = [ //"月球", 15210, //"火星", 22794, //"木星", 77833, //"土星", 142700, //"天王星", 287099, //"海王星", 450400, //"黑洞" 591352, //"飞出太阳系" 600000, //飞出银河系 24598080000000] //排行榜 里面的 名次 头像 名字 分数 设置 for (var i = 0; i < layout.children.length; i++) { let children = layout.children[i]; //第几名 let Ranking = UtilsPrefabs.getNode("Ranking", children); //头像 let ic = UtilsPrefabs.getNode("ic", children); //名字 let name = UtilsPrefabs.getNode("name", children); //分数 let Fraction = UtilsPrefabs.getNode("Fraction", children); } //再来一次 let restButton = UtilsPrefabs.getNode("restButton", this.node); let Settlement_more =this.Settlement_more= UtilsPrefabs.getNode("Settlement_more", this.node); UtilsPrefabs.setOn(Settlement_more, function () { if (this.MoreButtonClick != null) { this.MoreButtonClick(); } }.bind(this)); UtilsPrefabs.setOn(restButton, function () { this.goMain(); }.bind(this)); this.initstar(); this.initData(); //设置前后中 for (var i = 0; i < RankingListData.aroundArr.length; i++) { if (RankingListData.aroundArr[i] !=null) { if (RankingListData.UserId == RankingListData.aroundArr[i].userId) { this.checkrank(RankingListData.aroundArr, i, i - 1, i + 1); break; } } } }, setNoData : function(b){ this.Settlement_more.active = b; this.layout.active = b; if (!b) { this.noData.active = true; }else{ this.noData.active = false; } }, goMain : function(){ utils.isMobile(function () { Manager.sceneType = 1; Manager.restartGame(); }.bind(this)); if (soundM.sound!=null) { soundM.sound.stop(soundM.sound.Settlement_ClipID); } //返回 主页面 utils.toLoadScene("main") }, initstar: function () { let star = UtilsPrefabs.getNode("star", this.datalayout); this.stars = []; let starlist = star; this.stars.push(UtilsPrefabs.getNode("s1", starlist)); this.stars.push(UtilsPrefabs.getNode("s2", starlist)); this.stars.push(UtilsPrefabs.getNode("s3", starlist)); this.stars.push(UtilsPrefabs.getNode("s4", starlist)); this.stars.push(UtilsPrefabs.getNode("s5", starlist)); this.stars.push(UtilsPrefabs.getNode("s6", starlist)); this.stars.push(UtilsPrefabs.getNode("s7", starlist)); this.stars.push(UtilsPrefabs.getNode("s8", starlist)); this.stars.push(UtilsPrefabs.getNode("s99", starlist)); this.stars.push(UtilsPrefabs.getNode("s100", starlist)); this.setStar(UserInfo.PlayerGameData.currtag); }, checkrank: function (listdata, x, y, z) { let playerx = UtilsPrefabs.getNode("playerx", this.layout); let playery = UtilsPrefabs.getNode("playery", this.layout); let playerz = UtilsPrefabs.getNode("playerz", this.layout); // console.log("我就想看看前中后数组是啥 listdata "+ JSON.stringify(listdata)); // console.log("我就想看看前中后数组是啥 x "+ JSON.stringify(x)); // console.log("我就想看看前中后数组是啥 y "+ JSON.stringify(y)); // console.log("我就想看看前中后数组是啥 z "+ JSON.stringify(z)); // console.log("我就想看看前中后数组是啥 listdata[x] "+ listdata[x]); // console.log("我就想看看前中后数组是啥 listdata[y] "+ listdata[y]); // console.log("我就想看看前中后数组是啥 listdata[z] "+ listdata[z]); if (listdata[x] != null) { this.getRankListNode(playerx,listdata[x]); RankingListData.myRank = listdata[x]; if (RankingListData.myRank.rank == 0) { this.setNoData(false); }else{ this.setNoData(true); } } if (listdata[y] != null) { this.getRankListNode(playery,listdata[y]); } if (listdata[z] != null) { this.getRankListNode(playerz,listdata[z]); } }, getRankListNode: function (node,listdata) { node.active = true; let Ranking = UtilsPrefabs.getNode("Ranking", node); let ic = UtilsPrefabs.getNode("ic", node); let name = UtilsPrefabs.getNode("name", node); let Fraction = UtilsPrefabs.getNode("Fraction", node); Ranking.active = true; name.active = true; Fraction.active = true; Ranking.getComponent(cc.Label).string = "第"+listdata.rank+"名"; name.getComponent(cc.Label).string = listdata.nickName; Fraction.getComponent(cc.Label).string = listdata.score; utils.loadHttpSpriteFrame(listdata.portraits, ic.getComponent(cc.Sprite)); }, setStar: function (currtag) { if (currtag == 99 || currtag == 100) { if (currtag == 99) { this.stars[8].active = true; } else if (currtag == 100) { this.stars[9].active = true; } } else { this.stars[currtag].active = true; } }, setmoreButtonClickListeniner: function (MoreButtonClick) { this.MoreButtonClick = MoreButtonClick; }, MoreButtonClick: function () { }, initData: function () { utils.getShareData(function (data) { this.Score.getComponent(cc.Label).string = data.power this.power.getComponent(cc.Label).string = data.everypowers_average this.speed.getComponent(cc.Label).string = data.speend_average this.Accuracy.getComponent(cc.Label).string = data.types_average + "%" console.log("系数", data.power * UserInfo.PlayerGameData.coefficient); // this.distance.getComponent(cc.Label).string = parseInt(data.power * UserInfo.PlayerGameData.coefficient) + "" this.SetDistance(UserInfo.PlayerGameData.currtag,data.power); }.bind(this)); // this.playername.getComponent(cc.Label).string = UserInfo.Player.name }, SetDistance: function (currtag,power) { var distance = 0; var distanceUnit ="万公里"; var a = 0; //普通星球 if (currtag>=0 && currtag<=6) { distance = this.StarDistnaces[currtag]; } //太阳系 else if (currtag == 99) { distance = this.StarDistnaces[7]; } //银河系 else if (currtag == 100) { distance = this.StarDistnaces[8]; } a = power/10000; a = Math.floor(a * 100) / 100;//保留两位小数点 distance = distance+a; // distance = 24598080000000 this.distance.getComponent(cc.Label).string = distance.toString(); this.distanceUnit.getComponent(cc.Label).string = distanceUnit; }, // update (dt) {}, });