123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- const BattleRoomPlayerIcon = require("BattleRoomPlayerIcon")
- const BattleRoomSelectCell = require("BattleRoomSelectCell")
- const ViewBase = require("ViewBase")
- const SequenCreateView = require('SequenCreateView');
- cc.Class({
- extends: ViewBase,
- properties: {
- imageBg: {
- default: null,
- type: cc.Sprite,
- serializable: true,
- },
- textStatus: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- textPreviewNum: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- textRoundNum: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- textGold: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- buttonWatch: {
- default: null,
- type: cc.Button,
- serializable: true,
- },
- buttonFight: {
- default: null,
- type: cc.Button,
- serializable: true,
- },
- goldLayout: {
- default: null,
- type: cc.Node,
- serializable: true,
- },
- playerTop: {
- default: null,
- type: cc.Node,
- serializable: true,
- },
- playerBottom: {
- default: null,
- type: cc.Node,
- serializable: true,
- },
- player1: {
- default: null,
- type: BattleRoomPlayerIcon,
- serializable: true,
- },
- player2: {
- default: null,
- type: BattleRoomPlayerIcon,
- serializable: true,
- },
- player3: {
- default: null,
- type: BattleRoomPlayerIcon,
- serializable: true,
- },
- scrollViewBox: {
- default: null,
- type: cc.ScrollView,
- serializable: true,
- },
- },
- onLoad () {
- this.players = [
- this.player1,
- this.player2,
- this.player3,
- ];
- this.sequenCreateBoxs = new SequenCreateView().initRoot(this);
- },
- setButtonSubShow(b) {
- this.buttonSub.node.active = b;
- },
- resetData(data) {
- this.data = data;
- this.refreshView();
- },
- refreshView() {
- if (this.data == null) {
- return;
- }
- this.textStatus.string = this.data.status == 0 ? "等待中" : (this.data.status == 1 ? "进行中" : "结束");
- this.textGold.string = G.PlayerUtils.getPrice(this.getBoxsPrice());
- this.textPreviewNum.string = this.data.playCount + "人观看";
- this.textRoundNum.string = this.data.battleBoxList.length + "回合";
- this.playerTop.active = this.data.playerList.length >= 3;
- for (let i = 0; i < 3; i++) {
- let playerIcon = this.players[i];
- let playerData = this.data.playerList.length > i ? this.data.playerList[i] : null;
- playerIcon.resetData(playerData);
- }
- this.refreshBoxs();
- },
- refreshBoxs() {
- let self = this;
- this.sequenCreateBoxs.addDatas(this.data.battleBoxList);
- this.sequenCreateBoxs.startCreate(JMC.UIEnum.BattleRoomSelectCell, this.scrollViewBox.content, function(node, index, data) {
- let boxItem = node.getComponent(BattleRoomSelectCell);
- boxItem.setIndex(index);
- boxItem.setData(data);
- boxItem.setButtonSubShow(false)
- });
- },
- getBoxsPrice() {
- let price = 0;
- for (let b of this.data.battleBoxList) {
- let cfg = G.CfgMgr.battleBoxConfig.getByMainKey(b);
- price += cfg.price;
- }
- return price;
- },
- onClickCell() {
- if (this.onClickCb) {
- this.onClickCb(this.index, this.data)
- }
- },
- });
|