123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- const ViewBase = require('ViewBase');
- const BoxItem = require('BoxItem')
- const ButtonSelect1 = require('ButtonSelect1')
- const BattleRoomPreviweCell = require('BattleRoomPreviweCell')
- const SequenCreateView = require('SequenCreateView');
- cc.Class({
- extends: ViewBase,
- properties: {
- button1: {
- default: null,
- type: ButtonSelect1,
- serializable: true,
- },
- button2: {
- default: null,
- type: ButtonSelect1,
- serializable: true,
- },
- button3: {
- default: null,
- type: ButtonSelect1,
- serializable: true,
- },
- buttonPrice1: {
- default: null,
- type: ButtonSelect1,
- serializable: true,
- },
- buttonPrice2: {
- default: null,
- type: ButtonSelect1,
- serializable: true,
- },
- buttonPrice3: {
- default: null,
- type: ButtonSelect1,
- serializable: true,
- },
- buttonPrice4: {
- default: null,
- type: ButtonSelect1,
- serializable: true,
- },
- scrollViewBox: {
- default: null,
- type: cc.ScrollView,
- serializable: true,
- },
- roomPools: {
- default: null,
- type: cc.Node,
- serializable: true,
- },
- roomContent: {
- default: null,
- type: cc.Layout,
- serializable: true,
- },
- bottomLayout: {
- default: null,
- type: cc.Layout,
- serializable: true,
- },
- layerLayout: {
- default: null,
- type: cc.Layout,
- serializable: true,
- },
- roomPreviewPrefab: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- },
- onLoad () {
- this.buttons = [
- this.button1,
- this.button2,
- this.button3,
- ];
- this.buttonPrices = [
- this.buttonPrice1,
- this.buttonPrice2,
- this.buttonPrice3,
- this.buttonPrice4,
- ];
- this.titleViews = [
- JMC.UIEnum.BattleRoomCreate,
- JMC.UIEnum.BattleRoomCreate,
- JMC.UIEnum.BattleRoomCreate,
- ]
- this.sequenCreateBoxs = new SequenCreateView().initRoot(this);
- this.initBoxs();
- this.onClickPrice(null, "0");
-
- G.PublicMgr.on(JMC.PUBLIC_MSG.ROOM_GET_INFO, JMC.PUBLIC_MSG_ORDER.BATTLE, this.updateRoom, this);
- G.BattleMgr.requestInfo()
- },
- initBoxs() {
- this.sequenCreateBoxs.addDatas(G.CfgMgr.battleBoxConfig.getConfigAll());
- this.sequenCreateBoxs.startCreate(JMC.UIEnum.BoxItem, this.scrollViewBox.content, function(node, index, data) {
- let boxItem = node.getComponent(BoxItem);
- boxItem.setScale(0.73);
- boxItem.setNameScale(1/0.73);
- boxItem.setName(data.name);
- boxItem.setPrice(G.PlayerUtils.getPrice(data.price));
- });
- },
- updateRoom() {
- let rooms = G.BattleMgr.getRoomList()
- for(let room of rooms)
- {
- let roomNode = this.addRoom(room);
- let roomCell = roomNode.getComponent(BattleRoomPreviweCell);
- roomCell.resetData(room);
- }
- this.roomContent.updateLayout();
- this.bottomLayout.updateLayout();
- // this.layerLayout.updateLayout();
- },
-
- addRoom(data) {
- let node = cc.instantiate(this.roomPreviewPrefab);
- this.roomContent.node.addChild(node);
- return node;
- },
- removeRoom(data) {
- },
- updatePriceSelect(index) {
- for (let i = 0; i < this.buttonPrices.length; i++) {
- const b = this.buttonPrices[i];
- b.setSelect(index == i)
- }
- },
- onClickTitle(event, customEventData) {
- let index = parseInt(customEventData)
- G.UIMgr.open(this.titleViews[index]);
- },
- onClickPrice(event, customEventData) {
- let index = parseInt(customEventData)
- this.updatePriceSelect(index)
- },
- });
|