import GameModel from "../ts/core/GameModel"; import SKTimeUtil from "../ts/gear_2.3.4/util/SKTimeUtil"; import MsgAlert from "../ts/game/msg/MsgAlert"; import HorsePanel from "../ts/horse/HorsePanel"; import AudioUtil from "../ts/core/AudioUtil"; import ItemUtil from "../ts/core/ItemUtil"; import SKUIUtil from "../ts/gear_2.3.4/util/SKUIUtil"; import Welfare from "../ts/welfare/Welfare"; import Ranking from "../ts/game/role/Ranking"; import VIPUtil from "../ts/game/role/VIPUtil"; import { BattleType } from "../ts/game/battle/Battle"; import FGUtil, { TipAlign } from "../ts/gear_2.3.4/fgui/FGUtil"; import TeamPanel from "../ts/team/TeamPanel"; import RechargeReward from "../ts/rechargeReward/RechargeReward"; import Contact from "../ts/contact/Contact"; import Question from "../ts/question/Question"; import TurnTable from "../ts/turnTable/TurnTable"; import Guide from "../ts/guide/Guide"; import TransformationUtil from "../ts/transformation/TransformationUtil"; import Gang from "../ts/gang/Gang"; import DebateDao from "../ts/debateDao/DebateDao"; import Bag from "../ts/bag/Bag"; import FactionTalent from "../ts/FactionTalent"; import DailyActivity from "../ts/DailyActivity"; import Set from "../ts/set"; import Shop from "../ts/Shop"; import GameMap from "../ts/GameMap"; import Debris from "../ts/debris"; import zhenFa from "../ts/zhenFa/zhenfa"; import myXinwu from "../ts/zhenFa/myXinwu"; import NurtureHome from "../ts/nurture/NurtureHome" import StarHome from "../ts/star/StarHome" import TianTiPanel from "../ts/TianTiPanel/TianTiPanel"; import GameInfo from "../ts/gameinfo/GameInfo" let CPubFunction = require('./PubFunction'); cc.Class({ extends: cc.Component, properties: { TimeLabel: cc.Label, LeftMaskBtn: cc.Node, LeftMaskLayer: cc.Node, ActBtnList1: cc.Node, ActBtnList2: cc.Node, MoreNode: cc.Node, mapNameLabel: cc.Label, pLabel: cc.Label, LevelLabel: cc.Label, petLevel: cc.Label, HPProgress: cc.ProgressBar, MPProgress: cc.ProgressBar, petHPProgress: cc.ProgressBar, petMPProgress: cc.ProgressBar, expProgress: cc.ProgressBar, headicon: cc.Sprite, vipLevel: cc.Sprite, buff1_icon: cc.Sprite, buff2_icon: cc.Sprite, buff3_node: cc.Node, trans_info_node: cc.Node, petheadicon: cc.Sprite, notice: cc.Node, noticeLabel: cc.RichText, friendBtn: cc.Node, teamBtn: cc.Node, bangBtn: cc.Node, friendLayer: cc.Prefab, bagLayer: cc.Prefab, roleLayer: cc.Prefab, petLayer: cc.Prefab, preBattle: cc.Prefab, btlHide: [cc.Node], btmOper: cc.Node, teamList: cc.Node, _isBattle: false, isBattle: { get() { return this._isBattle; }, set(n) { this._isBattle = n; this.setBattleMod(); } }, hongBao: cc.Prefab, TeamUI: cc.Prefab, TalkUI: cc.Prefab, shopUI: cc.Prefab, DailyUI: cc.Prefab, TaskUI: cc.Prefab, RelationApplyUI: cc.Prefab, RelationListUI: cc.Prefab, particlePrefab: cc.Prefab, SetPanel: cc.Prefab, headBorder: cc.Node, petheadBorder: cc.Node }, // LIFE-CYCLE CALLBACKS: ctor() { this.maxHp = 0; this.hp = 0; this.maxMp = 0; this.mp = 0; this.petHp = 0; this.petMp = 0; this.petMaxHp = 0; this.petMaxMp = 0; this.timeTimer = 0; this.maxExp = 0; this.exp = 0; this.notices = []; this.loopNotices = []; this.m_nCurBangPage = 0; this.voice_time = 0; this.voice_type = -1; this.loadTimer = 0; this.recordTimer = 0; this.showTransferLeader = false; }, onLoad() { // cc.macro.ENABLE_MULTI_TOUCH = false //關閉多點觸控 this.buff1_icon.spriteFrame = ItemUtil.getItemIcon(10524); this.buff2_icon.spriteFrame = ItemUtil.getItemIcon(10522); this.chatLogic = cc.find('bottom_left/ui_common_bg_chat_main', this.node).getComponent('UIChatLogic'); this.petheadicon.node.active = false; this.setVIPLevel(); this.setHeadIcon(GameModel.player.resid); // 是否隱藏坐騎菜單 if (GameModel.hideRide) { let horseBtn = this.ActBtnList2.getChildByName("horse_btn"); if (horseBtn) { horseBtn.active = false; } } }, start() { this.gameLogic = this.node.parent.getComponent('GameLogic'); this.expProgress.totalLength = this.expProgress.node.width; this.notice.active = false; this.updateTime(); let self = this; this.timeTimer = SKTimeUtil.loop(() => { self.updateTime(); }, 30 * 1000); this.m_nodBang = null; this.m_nBnagShowType = false; this.isBattle = false; if (GameModel.player.hideIconList.fytz == 0) { // 顯示抽獎轉盤按鈕 var zhuanpan = cc.find('top_left/Mask/layer/zhuanpan', this.node); zhuanpan.active = true zhuanpan.getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "MainUI", "clickZhuanPan", 0)); var effNode = cc.instantiate(this.particlePrefab) effNode.setPosition(-45, 45) effNode.name = "Effect" zhuanpan.addChild(effNode) this.moveParticle(effNode.children[0]) this.moveParticle(effNode.children[1]) // 顯示天梯按鈕 var TianTi = cc.find('top_left/Mask/layer/TianTI', this.node); TianTi.active = true TianTi.getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "MainUI", "clickTianTi", 0)); } // 顯示遊戲攻略按鈕 var gameinfo = cc.find('top_left/Mask/layer/game_info', this.node); gameinfo.active = true gameinfo.getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "MainUI", "clickGameInfo", 0)); if (GameModel.player.hideIconList.special == 0) // 隱藏充值獎勵 cc.find('top_left/Mask/layer/recharge_reward', this.node).active = true else cc.find('top_left/Mask/layer/recharge_reward', this.node).active = false cc.find('top_left/Mask/layer/newbee_guide_btn', this.node).getComponent(cc.Button).clickEvents.push( CPubFunction.CreateEventHandler(this.node, "MainUI", "clickNewBeeGuide", 0)); cc.find('top_left/duobao_btn', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction .CreateEventHandler(this.node, "MainUI", "clickShop", 0)); cc.find('top_left/debris_btn', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction .CreateEventHandler(this.node, "MainUI", "clickDebrisShop", 0)); cc.find('top_left/reward_btn', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction .CreateEventHandler(this.node, "MainUI", "clickReward2", 0)); cc.find('top_left/Mask/layer/rank_btn', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction .CreateEventHandler(this.node, "MainUI", "clickRanking", 0)); cc.find('top_left/Mask/layer/active_btn', this.node).getComponent(cc.Button).clickEvents.push( CPubFunction.CreateEventHandler(this.node, "MainUI", "onDailyUI", 0)); cc.find('top_left/Mask/layer/recharge_reward', this.node).getComponent(cc.Button).clickEvents.push( CPubFunction.CreateEventHandler(this.node, "MainUI", "clickReward", 0)); cc.find('right/TaskTip/btnOpenTaskUI', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction .CreateEventHandler(this.node, "MainUI", "OpenTaskUI", 0)); let worldspeak = cc.find('Canvas/MainUI/bottom_left/ui_common_bg_chat_main/speakbtn'); worldspeak.on(cc.Node.EventType.TOUCH_START, this.onWorldVoiceRecord.bind(this)); worldspeak.on(cc.Node.EventType.TOUCH_CANCEL, this.onWorldVoiceRecord.bind(this)); worldspeak.on(cc.Node.EventType.TOUCH_END, this.onWorldVoiceRecord.bind(this)); let teamspeak = cc.find('Canvas/MainUI/bottom_left/ui_common_bg_chat_main/speakteam'); teamspeak.on(cc.Node.EventType.TOUCH_START, this.onTeamVoiceRecord.bind(this)); teamspeak.on(cc.Node.EventType.TOUCH_CANCEL, this.onTeamVoiceRecord.bind(this)); teamspeak.on(cc.Node.EventType.TOUCH_END, this.onTeamVoiceRecord.bind(this)); let bangspeak = cc.find('Canvas/MainUI/bottom_left/ui_common_bg_chat_main/speakbang'); bangspeak.on(cc.Node.EventType.TOUCH_START, this.onBangVoiceRecord.bind(this)); bangspeak.on(cc.Node.EventType.TOUCH_CANCEL, this.onBangVoiceRecord.bind(this)); bangspeak.on(cc.Node.EventType.TOUCH_END, this.onBangVoiceRecord.bind(this)); let voicenode = cc.find('Canvas/MainUI/Voice'); voicenode.active = false; this.changeHeadBorder(0) this.loadTimer = SKTimeUtil.delay(() => { this.onLoadComplete(); }, 1000); }, changeHeadBorder(id) { SKUIUtil.setHeadBorder(this.headBorder, id) SKUIUtil.setHeadBorder(this.petheadBorder, id) }, onLoadComplete() { GameModel.send('c2s_ask_role_task', {}); GameModel.send("c2s_mail_list", {}); GameModel.send("c2s_mondrop", { roleid: GameModel.player.roleid }); // if (DebateDao.Instance) // DebateDao.Instance.openPlayInfo(0); }, showMondrop(num) { var baolvNode = cc.find('top_left/baolv', this.node); baolvNode.active = false; // cc.find("num", baolvNode).getComponent(cc.Label).string = `現金爆率:${num}%`; }, setBattleMod() { for (let node of this.btlHide) { node.active = !this._isBattle; } let bui = cc.find('Canvas/BattleUILayer/BattleUI'); if (bui) { bui.active = this._isBattle; } let blayer = cc.find('Canvas/BattleLayer'); blayer.active = this._isBattle; if (!this._isBattle) { this.btmOper.x = 0; } }, showBattleEnd(iswin) { this.isBattle = false; if (iswin == false) { MsgAlert.addMsg("戰鬥失敗,再接再厲"); let comTaskTip = cc.find('TaskTip', cc.find('Canvas/MainUI/right')).getComponent('TaskTip'); comTaskTip.stAuto.nKind = 0; comTaskTip.stAuto.nTaskID = 0; } else { MsgAlert.addMsg("戰鬥勝利"); } }, OnTest() { GameModel.send('c2s_create_test_npc', {}); }, onDestroy() { this.timeTimer = SKTimeUtil.cancelLoop(this.timeTimer); this.loadTimer = SKTimeUtil.cancelDelay(this.loadTimer); this.recordTimer = SKTimeUtil.cancelDelay(this.recordTimer); }, updateTime() { let time = new Date(); let h = time.getHours(); if (h < 10) { h = '0' + h; } let m = time.getMinutes(); if (m < 10) { m = '0' + m; } let t = `${h}:${m}`; this.TimeLabel.string = t; }, setMapName(name) { this.mapNameLabel.string = name; }, setPosition(x, y) { this.pLabel.string = `(${x}, ${y})`; }, setMaxHp(maxhp) { this.maxHp = maxhp; this.updateHpMp(); }, setMaxMp(maxmp) { this.maxMp = maxmp; this.updateHpMp(); }, setHp(hp) { this.hp = hp; this.updateHpMp(); }, setMp(mp) { this.mp = mp; this.updateHpMp(); }, updateHpMp() { this.HPProgress.progress = this.hp / this.maxhp; this.MPProgress.progress = this.mp / this.maxMp; }, setPetMaxHp(maxhp) { this.petMaxHp = maxhp; this.updatePetHpMp(); }, setPetMaxMp(maxmp) { this.petMaxMp = maxmp; this.updatePetHpMp(); }, setPetHp(hp) { this.petHp = hp; this.updatePetHpMp(); }, setPetMp(mp) { this.petMp = mp; this.updatePetHpMp(); }, updatePetHpMp() { this.petHPProgress.progress = this.petHp / this.petMaxhp; this.petMPProgress.progress = this.petMp / this.petMaxMp; }, setVIPLevel() { let my = GameModel.player; let vipLevel = VIPUtil.getVipLevel(my.chargesum); if (vipLevel > 0) { let spriteFrame = ItemUtil.getItemIcon(`vip_${vipLevel}`); this.vipLevel.spriteFrame = spriteFrame; this.vipLevel.active = true; } else { this.vipLevel.active = false; } }, setHeadIcon(iconId) { let spriteFrame = GameModel.getRoleHead(iconId); if (spriteFrame) { this.headicon.spriteFrame = spriteFrame; } }, setPetHeadIcon(iconid) { if (!iconid || iconid <= 0) { this.petheadicon.node.active = false; return; } let sp = GameModel.getPetHead(iconid); if (sp) { this.petheadicon.node.active = true; this.petheadicon.spriteFrame = sp; } }, setMaxExp(exp) { this.maxExp = exp; }, setExp(exp, maxexp = 0) { this.exp = exp; if (maxexp != 0) { this.maxExp = maxexp; } this.updateExp(); }, setRoleLevel(level) { this.LevelLabel.string = level; }, setPetLevel(level) { if (this.petheadicon.node.active) { this.petLevel.node.active = true; this.petLevel.string = level; } else { this.petLevel.node.active = false; } }, updateExp() { this.expProgress.progress = this.exp / this.maxExp; }, /*{ RichText }*/ addNotice(msg) { this.notices.push(msg); this.startNotice(); }, playNotice() { if (this.notices && this.notices.length < 1) { this.isPlayNotice = false; this.notice.active = false; return; } this.isPlayNotice = true; this.notice.active = true; this.noticeLabel.node.x = 0; this.noticeLabel.string = this.notices.shift(); this.scheduleOnce(() => { let time = this.noticeLabel.width / 500 * 5; this.noticeLabel.runAction(cc.sequence( cc.moveTo(time, cc.v2(-this.noticeLabel.width - 80, 0)), cc.callFunc(() => { this.playNotice(); }, this) )); }, 0); }, startNotice() { if (this.isPlayNotice) { return; } this.playNotice(); }, // update (dt) {}, onLeftMaskBtnClicked(e, d) { let action = this.LeftMaskLayer.getActionByTag(9874); if (action && !action.isDone()) { return; } let k = Math.abs(this.LeftMaskLayer.y); if (k < 10) { this.LeftMaskBtn.angle = 270; let act = cc.moveTo(0.1, cc.v2(50, this.LeftMaskLayer.height + 5)); act.setTag(9874); this.LeftMaskLayer.runAction(act); } else { this.LeftMaskBtn.angle = 60; let act = cc.moveTo(0.1, cc.v2(50, 0)); act.setTag(9874); this.LeftMaskLayer.runAction(act); } }, onMoreBtnClicked(e, d) { let action = this.ActBtnList1.getActionByTag(9874); if (action && !action.isDone()) { return; } let xlen = 540; let k = Math.abs(this.ActBtnList1.x); let action1 = cc.moveTo(0.1, cc.v2(xlen, 0)); action1.setTag(9874); let act1 = cc.delayTime(0.1); let act2 = cc.moveTo(0.1, cc.v2(0, 0)); let action2 = cc.sequence(act1, act2); action2.setTag(9874); if (k < 10) { this.ActBtnList1.runAction(action1); this.ActBtnList2.runAction(action2); this.MoreNode.runAction(cc.rotateTo(0.2, 45)); } else { this.ActBtnList1.runAction(action2); this.ActBtnList2.runAction(action1); this.MoreNode.runAction(cc.rotateTo(0.2, 0)); } }, //zfy 加入隊伍提示 joinTeamWarn(data) { this.teamBtn.stopAllActions(); this.teamBtn.runAction(cc.repeatForever(cc.sequence(cc.moveTo(0.3, cc.v2(-156, 30)), cc.moveTo(0.3, cc .v2(-156, -6))))); }, onTeam(e, d) { this.teamBtn.stopAllActions(); this.teamBtn.y = -6; // 舊版打開隊伍面板預製體 // CPubFunction.FindAndDeleteNode(this.node, "TeamUI"); // SKUIUtil.createSubNode(this.node, cc.v2(0, 0), this.TeamUI, 'TeamUI'); TeamPanel.Instance.openTeamMainPanel(); }, //zfy 交換隊長 transferTeamDlg(data) { if (this.showTransferLeader) return; this.showTransferLeader = true; var type = GameModel.player.isleader ? 2 : 1 console.log(GameModel.player.isleader, type) let node = GameModel.notice.addTimeMsg2(1, '是否同意交換隊長', () => { GameModel.send('c2s_transfer_team', { roleid: data.roleid, type: type }); this.showTransferLeader = false; }, () => { this.showTransferLeader = false; }, 5); this.scheduleOnce(function() { GameModel.send('c2s_transfer_team', { roleid: data.roleid, type: type }); this.showTransferLeader = false; node.destroy(); }, 5); }, //切磋提示 exchangeViews(data) { let node = GameModel.notice.addMsg(1, '有玩家對您發起了切磋,是否同意戰鬥? ', () => { GameModel.send('c2s_pk', { troleid: data.roleid, type: BattleType.PK, }); }, () => {}, 0); this.scheduleOnce(function() { node.destroy(); }, 15); }, onPackage(e, d) {}, onSetClicked(e, d) { // let set = cc.instantiate(this.SetPanel); // set.parent = cc.find('Canvas'); Set.Instance.openSetMainPanel(); //zfy --打開設置音效 AudioUtil.playAudio('ui/ui_shezhi'); }, updateZhenFa(info) { var panel = this.node.getChildByName("RolePanel") if (!!panel) { panel.getComponent('RolePanel').updatePanel(info) } }, hideZhenFa() { myXinwu.Instance.destroy() var panel = this.node.getChildByName("RolePanel") if (!!panel) { panel.removeFromParent() } }, onRoleHeadClicked(e, d) { let role = cc.instantiate(this.roleLayer); role.name = 'RolePanel'; role.parent = this.node; AudioUtil.playOpenAudio(); }, onPetHeadClicked(e, d) { if (this.node.getChildByName('PetPanel')) { this.node.getChildByName('PetPanel').destroy(); } let pet = cc.instantiate(this.petLayer); pet.name = 'PetPanel'; pet.parent = this.node; AudioUtil.playOpenAudio(); }, onBagBtnClicked(e, d) { Bag.Instance.openBagPanel(); AudioUtil.playAudio('ui/ui_beibao'); return if (this.node.getChildByName('BagPanel')) { this.node.getChildByName('BagPanel').destroy(); } let bag = cc.instantiate(this.bagLayer); bag.name = 'BagPanel'; bag.parent = this.node; // zfy --背包音效 // NBagAlert.shared.show(); AudioUtil.playAudio('ui/ui_beibao'); }, friendsChat(info) { let friendsLayer = this.node.getChildByName('FriendPanel'); if (friendsLayer != null) { friendsLayer.getComponent('FriendPanel').addChatListInfo(info); } else { this.friendBtn.stopAllActions(); this.friendBtn.getChildByName('tip').active = true; this.friendBtn.runAction(cc.repeatForever(cc.sequence(cc.moveTo(0.3, cc.v2(-257, 30)), cc.moveTo( 0.3, cc.v2(-257, -6))))); } }, friendAddTip() { this.friendBtn.stopAllActions(); this.friendBtn.getChildByName('tip').active = true; this.friendBtn.runAction(cc.repeatForever(cc.sequence(cc.moveTo(0.3, cc.v2(-257, 30)), cc.moveTo(0.3, cc .v2(-257, -6))))); }, onFriendBtnClicked(e, d) { this.friendBtn.stopAllActions(); this.friendBtn.y = -6; this.friendBtn.getChildByName('tip').active = false; if (this.node.getChildByName('FriendPanel')) { this.node.getChildByName('FriendPanel').destroy(); } let friend = cc.instantiate(this.friendLayer); friend.name = 'FriendPanel'; friend.parent = this.node; //zfy --打開好友音效 AudioUtil.playOpenAudio(); }, // 點擊坐騎 clickHorse(event, data) { let level = GameModel.player.level; if (level < 60) { MsgAlert.addMsg(`您等級不足60級!`) return; } event.stopPropagation(); HorsePanel.shared.show(this.node); AudioUtil.playAudio('ui/ui_shezhi'); }, clickNurtureHome(event, data) { NurtureHome.shared.show() AudioUtil.playOpenAudio(); }, clickStarHome(event, data) { StarHome.shared.show() AudioUtil.playOpenAudio(); }, //zfy 幫派 joinBangWarn() { // this.bangBtn.stopAllActions(); // this.bangBtn.runAction(cc.repeatForever(cc.sequence(cc.moveBy(0.3, cc.v2(0, 36)), cc.moveBy(0.3, cc.v2(0, -36))))); var eff = cc.find("joinBangEffect", this.bangBtn) if (eff) { return; } var effNode = cc.instantiate(this.particlePrefab) effNode.setPosition(-45, 45) effNode.name = "joinBangEffect" this.bangBtn.addChild(effNode) this.moveParticle(effNode.children[0]) this.moveParticle(effNode.children[1]) }, moveParticle(node) { cc.tween(node) .by(0.5, { y: -90 }) .by(0.5, { x: 90 }) .by(0.5, { y: 90 }) .by(0.5, { x: -90 }) .union() .repeatForever() .start() }, onBangBtnClicked(e, d) { var eff = cc.find("joinBangEffect", this.bangBtn) if (eff) { eff.destroy(); } let bangid = GameModel.player.bangid; if (bangid > 0) { Gang.Instance.openGangPanel(); } else { Gang.Instance.openGangListPanel(); } // FactionTalent.Instance.openFactionTalentPanel(); //zfy --打開幫派音效 AudioUtil.playOpenAudio(); }, onRightLowerBtnClicked(e, d) {}, onMainMapBtnClicked(e, d) { AudioUtil.playOpenAudio(); // GameMap.Instance.openMapPanel() this.gameLogic.showMainMap(); }, onSmallMapBtnClicked(e, d) { AudioUtil.playOpenAudio(); this.gameLogic.showSmallMap(); }, // 點擊碎片商城 clickDebrisShop(event, data) { AudioUtil.playOpenAudio(); Debris.Instance.openShopMainPanel() }, // 點擊多寶 clickShop(event, data) { AudioUtil.playOpenAudio(); Shop.Instance.openShopMainPanel() // SKUIUtil.createSubNode(this.node, cc.v2(0, 0), this.shopUI, 'ShopUI'); }, onClickLink1(p) { console.log(p) }, onClickLink2(p) { console.log(p) }, onClickLink3(p) { console.log(p) }, // 點擊新手引導 clickNewBeeGuide(event, data) { AudioUtil.playOpenAudio(); Guide.Instance.openGuidePanel(); }, clickZhuanPan(event, data) { AudioUtil.playOpenAudio(); var eff = cc.find('top_left/Mask/layer/zhuanpan/Effect', this.node); if (eff) eff.destroy() TurnTable.Instance.openTurnTable(); }, /**點擊天梯 */ clickTianTi(event, data) { AudioUtil.playOpenAudio(); var eff = cc.find('top_left/Mask/layer/TianTI/Effect', this.node); if (eff) eff.destroy() TianTiPanel.Instance.openTianTiPanel(); }, clickGameInfo(event, data) { AudioUtil.playOpenAudio(); GameInfo.Instance.show(); }, // 點擊獎勵 clickReward(event, data) { AudioUtil.playOpenAudio(); // Welfare.Instance.openWelfare() // 改為異步加載,優化卡頓,但會增加打開時長 Welfare.Instance.openWelfareByAsync() }, // 點擊充值獎勵 clickReward2(event, data) { AudioUtil.playOpenAudio(); // Welfare.Instance.openWelfare() // 改為異步加載,優化卡頓,但會增加打開時長 RechargeReward.Instance.openRewardPanel3(); }, onDailyUI(e, d) { AudioUtil.playOpenAudio(); DailyActivity.Instance.openDailyActivityPanel(); return SKUIUtil.createSubNode(this.node, cc.v2(0, 0), this.DailyUI, 'DailyUI'); }, clickTotalCharge(e, d) { AudioUtil.playOpenAudio(); RechargeReward.Instance.openRewardPanel3(); }, //--zfy 請求服務器獲取補償獎勵 // onRewardBtnClicked() { // GameModel.send('c2s_remunerate'); // }, //-zfy 世界紅包界面 // onWorldRewardClick() { // GameModel.send('c2s_world_reward_list'); // }, clickRanking(e, d) { AudioUtil.playOpenAudio(); Ranking.shared.show(); }, CloseUIByName(e, strName) { CPubFunction.FindAndDeleteNode(this.node, strName); }, OpenTaskUI() { console.log("...........OpenTaskUI") CPubFunction.FindAndDeleteNode(this.node, 'TaskUI'); SKUIUtil.createSubNode(this.node, cc.v2(0, 0), this.TaskUI, 'TaskUI'); }, setTeamListInfo() { this.teamList.getComponent('MainUITeamList').setTeamListInfo(); }, changePrisonTime(n) { let prison = cc.find('prisonTime', this.node); if (prison) { if (n <= 0) { prison.active = false; } else { if (GameModel.player.prisonTime <= 0) { prison.active = false; return } prison.active = true; let h = Math.floor(n / 3600) < 10 ? '0' + Math.floor(n / 3600) : Math.floor(n / 3600); let m = Math.floor(n / 60 % 60) < 10 ? '0' + Math.floor(n / 60 % 60) : Math.floor(n / 60 % 60); let s = Math.floor(n % 60) < 10 ? '0' + Math.floor(n % 60) : Math.floor(n % 60); let notice = `${h}:${m}:${s}`; prison.getChildByName('time').getComponent(cc.Label).string = notice; this.scheduleOnce(() => { this.changePrisonTime(n - 1); }, 1); } } }, showHongBaoIcon() { let hongbaoicon = cc.find('top_left/hongbao', this.node); hongbaoicon.active = true; let action = cc.sequence( cc.rotateTo(0.05, 15), cc.rotateTo(0.05, -15), cc.rotateTo(0.05, 15), cc.rotateTo(0.05, -15), cc.rotateTo(0.05, 15), cc.rotateTo(0.05, -15), cc.delayTime(1) ); hongbaoicon.runAction(cc.repeatForever(action)); }, hideHongBaoIcon() { let hongbaoicon = cc.find('top_left/hongbao', this.node); hongbaoicon.stopAllActions(); hongbaoicon.active = false; }, showHongBaoPanel() { this.hideHongBaoIcon(); let node = this.node.getChildByName('WorldRedPocket'); if (node != null) { return; } let hongbaopanel = cc.instantiate(this.hongBao); hongbaopanel.name = 'WorldRedPocket'; hongbaopanel.parent = this.node; }, hideHongBaoPanel() { let hongbaopanel = this.node.getChildByName('WorldRedPocket'); if (hongbaopanel) { hongbaopanel.destroy(); } }, onOpenRelationApplyUI(data) { AudioUtil.playOpenAudio(); let relationApplyUI = SKUIUtil.createSubNode(this.node, cc.v2(0, 0), this.RelationApplyUI, 'RelationApplyUI'); let relationApply = relationApplyUI.getComponent('RelationApplyPanel'); relationApply.initApplyData(data); }, onOpenRelationListUI(data) { AudioUtil.playOpenAudio(); let RelationListUI = SKUIUtil.createSubNode(this.node, cc.v2(0, 0), this.RelationListUI, 'RelationListUI'); let relationListLogic = RelationListUI.getComponent('RelationListPanel'); relationListLogic.initApplyData(data); }, onWorldVoiceRecord(e, d) { if (!CC_JSB) { e.stopPropagation(); return false; } if (e.type == cc.Node.EventType.TOUCH_START) { if (this.voiceRecord) { this.voiceRecord(0); } } else if (e.type == cc.Node.EventType.TOUCH_END || e.type == cc.Node.EventType.TOUCH_CANCEL) { if (this.voiceRecordEnd) { this.voiceRecordEnd(0); } } e.stopPropagation(); }, onTeamVoiceRecord(e, d) { if (!CC_JSB) { e.stopPropagation(); return false; } if (e.type == cc.Node.EventType.TOUCH_START) { this.voiceRecord(1); } else if (e.type == cc.Node.EventType.TOUCH_END || e.type == cc.Node.EventType.TOUCH_CANCEL) { this.voiceRecordEnd(1); } e.stopPropagation(); }, onBangVoiceRecord(e, d) { if (!CC_JSB) { e.stopPropagation(); return false; } if (e.type == cc.Node.EventType.TOUCH_START) { this.voiceRecord(2); } else if (e.type == cc.Node.EventType.TOUCH_END || e.type == cc.Node.EventType.TOUCH_CANCEL) { this.voiceRecordEnd(2); } e.stopPropagation(); }, voiceRecord(vtype) { if (!CC_JSB) { return; } if (this.voice_type != -1) { return; } if (!GameModel.voiceMgr.startRecord()) { return; } this.voice_type = vtype; let voicenode = cc.find('Canvas/MainUI/Voice'); voicenode.active = true; this.recordTimer = SKTimeUtil.delay(() => { this.voiceRecordEnd(); }, 20 * 1000); }, voiceRecordEnd(value) { if (!CC_JSB) { return; } let scaletype = this.voice_type; this.voice_type = -1; this.recordTimer = SKTimeUtil.cancelDelay(this.recordTimer); let voicenode = cc.find('Canvas/MainUI/Voice'); voicenode.active = false; let data = GameModel.voiceMgr.endRecord(); if (data == null) { return; } if (scaletype == -1) return GameModel.send('c2s_game_chat', { scale: scaletype, voice: data, }); }, showTransformationBuff() { var icon = cc.find("role_icon_buff2", this.buff3_node); if (!icon) return; var changeid = 500101; icon.getComponent(cc.Sprite).spriteFrame = ItemUtil.getItemIconBy(ItemUtil.getItemData(changeid)); this.buff3_node.active = true; }, hideTransformationBuff() { this.buff3_node.active = false; }, onTransformationBuffClick() { GameModel.send("c2s_detail_page", { roleid: GameModel.player.roleid }) }, showTransformationInfo(data) { if (!this.trans_info_node) return; var bg = cc.find("widget/bg", this.trans_info_node); var icon = cc.find("widget/icon", this.trans_info_node); var name = cc.find("widget/name", this.trans_info_node); var des = cc.find("widget/des", this.trans_info_node); var changeid = data.cardid; var info = ItemUtil.getItemData(changeid) icon.getComponent(cc.Sprite).spriteFrame = ItemUtil.getItemIconBy(info); name.getComponent(cc.Label).string = info.name; des.getComponent(cc.RichText).string = TransformationUtil.Instance.getCardDesInfoById(changeid, data .endtime); this.trans_info_node.active = true; this.scheduleOnce(() => { bg.height = des.height + 60; }, 0) }, hideTransformationInfo() { this.trans_info_node.active = false; }, showDuoBaoShop() { Shop.Instance.openShopMainPanel() }, updateXWInfo(data) { myXinwu.Instance.updateAttrInfo(data) }, updateNewXWInfo(data) { myXinwu.Instance.updateNewAttrInfo(data) }, updateXWUI(data) { myXinwu.Instance.updateUI(data) }, updateXWAllInfo(data) { myXinwu.Instance.updateXWAllInfo(data) myXinwu.Instance.changeSelect(data) } });