觉醒时刻
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

547 lines
19 KiB

// 储物区
import { ryw_Event } from "../../FrameWork/Event/EventEnum";
import EventMgr from "../../FrameWork/Event/EventMgr";
import GameReport from "../../FrameWork/Report/ZyZyReport";
import User from "../../FrameWork/User/User";
import AppPlatform from "../../FrameWork/Util/AppPlatform";
import Common5 from "../../Platform/th/Common5";
import List from "../../Platform/th/List";
import JuQingManager from "../JuQingChat/JuQingManager";
import TaskManager, { MainTaskIdEnum } from "../JuQingChat/TaskManager";
import BagManager, { GoodsLocalProperty } from "../Manager/BagManager";
import UserManager from "../Manager/UserManager";
import NewGuideScript from "../NewGuide/NewGuideScript";
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
import GameBase from "../SCommon/GameBase";
import GetAward from "../SCommon/GetAward";
import CangKuItem from "./CangKuItem";
const { ccclass, property } = cc._decorator;
let ChuanJiaBaoConfig = [
{ caiMing: '兔印', goodIdTab: [3007], spineStr1: '兔', spineStr2: '1湘b' },
{ caiMing: '象印', goodIdTab: [3021], spineStr1: '象', spineStr2: '2川b' },
{ caiMing: '龟印', goodIdTab: [3040], spineStr1: '龟', spineStr2: '3苏b' },
{ caiMing: '虎印', goodIdTab: [3051], spineStr1: '虎', spineStr2: '4徽b' },
{ caiMing: '凤印', goodIdTab: [3074], spineStr1: '凤', spineStr2: '5浙b' },
{ caiMing: '牛印', goodIdTab: [3733], spineStr1: '牛', spineStr2: '6闽b' },
// { caiMing: '粤菜', goodIdTab: [3097, 3607], spineStr1: '7粤a', spineStr2: '7粤b' },
// { caiMing: '鲁菜', goodIdTab: [3098, 3608], spineStr1: '8鲁a', spineStr2: '8鲁b' }
]
@ccclass
export default class BagScript extends GameBase {
@property(cc.Node)
btnShouKong: cc.Node = null;
@property(cc.Node)
allPriceNode: cc.Node = null;
@property(List)
listG: List = null; //物品
@property(cc.Node)
listGContent: cc.Node = null;
@property(cc.Node)
listS: cc.Node = null; //其它
@property(cc.Node)
listSContent: cc.Node = null;
@property(cc.Node)
chuanJiaBaoSpine: cc.Node = null;
// LIFE-CYCLE CALLBACKS:
@property(List)
listP: List = null; //道具
@property(cc.Node)
listPContent: cc.Node = null;
@property(cc.Node)
descNode: cc.Node = null;
// @property(cc.Node)
// cangBaoTu: cc.Node = null;
curTaskGoodId = null
tiJiaoCallFunc = null
chooseGoodId = null
// onLoad () {}
dataListG = []
dataListS = []
dataListP = []
needHandin = false
maskGuideNode: cc.Node = null
onDestroy() {
if (cc.isValid(this.maskGuideNode)) {
this.maskGuideNode.removeFromParent()
this.maskGuideNode.destroy()
}
super.onDestroy()
}
onLoad() {
super.onLoad()
}
start() {
// //背包默认放入1710
// let good1710 = 1710
// if(BagManager.getBagGoodNums(good1710) == 0){
// let bagConfig:GoodsLocalProperty = {
// goodId:1710,
// goodNum:1,
// }
// BagManager.addBagList(bagConfig)
// }
this.setListG()
// this.setListP()
EventMgr.onEvent_custom(ryw_Event.ViewpPoperty, (goodId, goodNum) => {
this.reportKey(() => {
GameReport.BtnsReport('点击道具')
})
this.chooseGoodId = goodId
console.log(goodId, 'goodId++++++++++++===')
this.descView(goodId, goodNum)
}, this)
EventMgr.onEvent_custom(ryw_Event.updateBagDate, () => {
this.refreshView()
}, this)
this.guideStep()
EventMgr.onEvent_custom(ryw_Event.RefreshJuQingDuiHua, () => {
this.guideStep()
}, this)
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
if (mainId == MainTaskIdEnum.MainTask_202) {
let node = this.node.getChildByName('node').getChildByName('toggleContainer').getChildByName('toggle3');
node.getComponent(cc.Toggle).isChecked = true
this.chooseClickEvent(null, "listS")
this.scheduleOnce(() => {
let node = this.node.getChildByName('node').getChildByName('close')
this.guideView([node]);
}, 2)
}
}
guideStep() {
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
if (mainId == MainTaskIdEnum.MainTask_211 || mainId == MainTaskIdEnum.MainTask_2405) {
let node = this.node.getChildByName('node').getChildByName('toggleContainer').getChildByName('toggle3');
this.guideView([node]);
}
}
guideView(nodeArray) {
if (!cc.isValid(this.maskGuideNode)) {
PrefabManage.loadPrefabByType(GameType.GuideMskNode, this.node, (prefab) => {
let guideNodeArray = nodeArray
this.maskGuideNode = prefab
let firstNode = guideNodeArray.shift()
prefab.getComponent(NewGuideScript).setBindNode(firstNode, guideNodeArray)
})
} else {
this.maskGuideNode.active = true
let guideNodeArray = nodeArray
let firstNode = guideNodeArray.shift()
this.maskGuideNode.getComponent(NewGuideScript).setBindNode(firstNode, guideNodeArray)
}
}
setHandIn(needHandin, taskGoodId, tiJiaoCallFunc) {
this.needHandin = needHandin
this.curTaskGoodId = taskGoodId
this.tiJiaoCallFunc = tiJiaoCallFunc
}
refreshView() {
let goodNum = BagManager.getBagGoodNums(this.chooseGoodId)
if (goodNum <= 0) {
this.descNode.active = false
}
if (this.listG.node.active) {
this.setListG()
}
if (this.listS.active) {
this.setListS()
}
if (this.listP.node.active) {
this.setListP()
}
// if(this.cangBaoTu.active){
// this.setCangBaoTu()
// }
}
descView(goodId, goodNum) {
this.descNode.active = true
let labName = this.descNode.getChildByName('labName').getComponent(cc.Label)
let labDesc = this.descNode.getChildByName('labDesc').getComponent(cc.Label)
let labPrice = this.descNode.getChildByName('labPrice').getComponent(cc.Label)
let icon = this.descNode.getChildByName('icon').getComponent(cc.Sprite)
let _pro = BagManager.getGoodsProperty(goodId)
labName.string = _pro.goodName
let goodDescData = BagManager.getGoodsDesc(goodId)
labDesc.string = goodDescData.descStr
// Common5.getSpriteFrameFromBundle("GoodIcon","icon/"+ goodId, icon);
Common5.setRemoteSpriteFrame(icon, 'GoodIcon/' + goodId)
labPrice.string = '售价:' + Common5.getNumberChangeHanzi(_pro.priceNum * goodNum) + ''
let numLab = this.descNode.getChildByName('numLab').getComponent(cc.Label)
numLab.string = goodNum + ''
if (this.needHandin) {
if (goodId == this.curTaskGoodId) {
this.descNode.getChildByName('tijiaoBtn').active = true
} else {
this.descNode.getChildByName('tijiaoBtn').active = false
}
} else {
this.descNode.getChildByName('tijiaoBtn').active = false
}
}
onBtnCloseClick() {
// Common5.playEffect("sound/按键点击")
this.node.removeFromParent()
this.node.destroy()
}
setListG() {
this.listGContent.removeAllChildren()
let getBagList = BagManager.getBagProList()
//console.log(getBagList, 'getBagList++++++++++++===')
this.dataListG = []
let allPrice = 0
for (let n = 0; n < getBagList.length; n++) {
let goodId = getBagList[n].goodId
let goodData = BagManager.getGoodsProperty(goodId)
allPrice += goodData.priceNum * getBagList[n].goodNum
this.dataListG.push(getBagList[n]);
}
this.allPriceNode.getChildByName('allPrice').getComponent(cc.Label).string = '物品总价:' + Common5.getNumberChangeHanzi(allPrice)
this.listG.numItems = this.dataListG.length;
// if(this.dataListG.length > 0){
// this.btnShouKong.getComponent(cc.Button).interactable = true
// }else{
// this.btnShouKong.getComponent(cc.Button).interactable = false
// }
}
setListS() {
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
// if (mainId == MainTaskIdEnum.MainTask_211) {
// TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_211)
// JuQingManager.unLockNewJuQing('WX_204')
// TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_212)
// this.scheduleOnce(() => {
// let node = this.node.getChildByName('node').getChildByName('close');
// this.guideView([node]);
// }, 2);
// }
let curIndex = -1
for (let i = ChuanJiaBaoConfig.length - 1; i >= 0; i--) {
let goodIdTab = ChuanJiaBaoConfig[i].goodIdTab
let isAllHave = true
for (let j = 0; j < goodIdTab.length; j++) {
if (BagManager.getBagGoodNums(goodIdTab[j]) <= 0) {
isAllHave = false
break
}
}
if (isAllHave) {
curIndex = i
break
}
}
if (curIndex >= 0) {
this.chuanJiaBaoSpine.stopAllActions()
if (curIndex == 7) {
if (mainId == MainTaskIdEnum.MainTask_2405) {
cc.tween(this.chuanJiaBaoSpine)
.call(() => {
this.chuanJiaBaoSpine.getComponent(sp.Skeleton).setAnimation(0, ChuanJiaBaoConfig[curIndex].spineStr1, false)
})
.delay(3)
.call(() => {
this.chuanJiaBaoSpine.getComponent(sp.Skeleton).setAnimation(0, '9b', false)
})
.delay(3)
.call(() => {
this.chuanJiaBaoSpine.getComponent(sp.Skeleton).setAnimation(0, '9c', true)
let goodArray = [{ goodId: 3099, goodNum: 1 }]
PrefabManage.loadPrefabByType(GameType.GetAward, null, (prefabNode) => {
prefabNode.getComponent(GetAward).initView(goodArray, () => {
TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_2405);
TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_2406);
});
})
})
.start()
} else {
cc.tween(this.chuanJiaBaoSpine)
.call(() => {
this.chuanJiaBaoSpine.getComponent(sp.Skeleton).setAnimation(0, '9b', false)
})
.delay(3)
.call(() => {
this.chuanJiaBaoSpine.getComponent(sp.Skeleton).setAnimation(0, '9c', true)
})
.start()
}
} else {
cc.tween(this.chuanJiaBaoSpine)
.call(() => {
this.chuanJiaBaoSpine.getComponent(sp.Skeleton).setAnimation(0, ChuanJiaBaoConfig[curIndex].spineStr1, false)
})
.delay(3)
.call(() => {
// this.chuanJiaBaoSpine.getComponent(sp.Skeleton).setAnimation(0, ChuanJiaBaoConfig[curIndex].spineStr2, true)
})
.start()
}
} else if (curIndex == -1 && BagManager.getBagGoodNums(3001) > 0) {
this.chuanJiaBaoSpine.active = true
this.chuanJiaBaoSpine.getComponent(sp.Skeleton).setAnimation(0, "静止2", false)
} else {
this.chuanJiaBaoSpine.active = false
}
// this.listSContent.removeAllChildren()
// this.dataListS = []
// let getBagList = BagManager.getBagList()
// if(this.needHandin){
// let num = BagManager.getBagGoodNums(this.curTaskGoodId)
// getBagList = [
// {
// goodId: this.curTaskGoodId,
// goodNum: num,
// }
// ]
// }
// for (let n = 0; n < getBagList.length; n++) {
// this.dataListS.push(getBagList[n]);
// }
// this.listS.numItems = this.dataListS.length;
}
setListP() {
this.listPContent.removeAllChildren()
this.dataListP = []
let getBagList = BagManager.getBagTaskProList()
for (let n = 0; n < getBagList.length; n++) {
this.dataListP.push(getBagList[n]);
}
this.listP.numItems = this.dataListP.length;
}
// setCangBaoTu(){
// let isHave1711 = (BagManager.getBagGoodNums(1711) > 0)
// let isHave1712 = (BagManager.getBagGoodNums(1712) > 0)
// if(isHave1711 && isHave1712){
// this.cangBaoTu.getChildByName('碎玉佩1').active = false
// this.cangBaoTu.getChildByName('碎玉佩1灰').active = false
// this.cangBaoTu.getChildByName('碎玉佩2').active = false
// this.cangBaoTu.getChildByName('碎玉佩2灰').active = false
// this.cangBaoTu.getChildByName('碎玉佩3').active = false
// this.cangBaoTu.getChildByName('碎玉佩3灰').active = false
// this.cangBaoTu.getChildByName('完整玉佩').active = true
// }else{
// if(isHave1711){
// this.cangBaoTu.getChildByName('碎玉佩2').active = true
// this.cangBaoTu.getChildByName('碎玉佩2灰').active = false
// }else if(isHave1712){
// this.cangBaoTu.getChildByName('碎玉佩3').active = true
// this.cangBaoTu.getChildByName('碎玉佩3灰').active = false
// }else{
// this.cangBaoTu.getChildByName('碎玉佩2灰').active = true
// this.cangBaoTu.getChildByName('碎玉佩3灰').active = true
// this.cangBaoTu.getChildByName('碎玉佩2').active = false
// this.cangBaoTu.getChildByName('碎玉佩3').active = false
// }
// }
// }
firstXiangQing(numItems, goodId, isCaidan) {
//选中第一个
if (goodId) {
this.descView(goodId, isCaidan)
}
}
chooseClickEvent(event, data) {
if (data == 'listG') {
this.btnShouKong.active = true
this.allPriceNode.active = true
this.listG.node.active = true
this.listS.active = false
this.listP.node.active = false
// this.cangBaoTu.active = false
this.setListG()
} else if (data == 'listS') {
this.btnShouKong.active = false
this.allPriceNode.active = false
this.listS.active = true
this.listG.node.active = false
this.listP.node.active = false
// this.cangBaoTu.active = false
this.setListS()
} else if (data == 'listP') {
this.btnShouKong.active = false
this.allPriceNode.active = false
this.listS.active = false
this.listG.node.active = false
this.listP.node.active = true
// this.cangBaoTu.active = false
this.setListP()
} else if (data == 'listD') {
this.btnShouKong.active = false
this.allPriceNode.active = false
this.listS.active = false
this.listG.node.active = false
this.listP.node.active = false
// this.cangBaoTu.active = true
// this.setCangBaoTu()
}
}
onListGGridRender(item: cc.Node, idx: number) {
//item.getComponent(ListItem).title.getComponent(cc.Label).string = this.data[idx] + '';
let config = this.dataListG[idx]
let danItem: CangKuItem = item.getComponent('CangKuItem')
danItem.initView(config)
}
onListSGridRender(item: cc.Node, idx: number) {
//item.getComponent(ListItem).title.getComponent(cc.Label).string = this.data[idx] + '';
let config = this.dataListS[idx]
let danItem: CangKuItem = item.getComponent('CangKuItem')
danItem.initView(config)
}
onListPGridRender(item: cc.Node, idx: number) {
//item.getComponent(ListItem).title.getComponent(cc.Label).string = this.data[idx] + '';
let config = this.dataListP[idx]
let danItem: CangKuItem = item.getComponent('CangKuItem')
danItem.initView(config)
}
closeDetailClickEvent() {
this.descNode.active = false
}
tijiaoBtnClickEvent() {
//狩猎乌鸡回家提交
// let mainTaskInfo:any = TaskManager.getCurUnLockMainTaskInfo()
// let mainId = mainTaskInfo.Id
// if(User.getGameGuideStepIndex() == 14){
// User.setGameGuideStepIndex(21)
// }
BagManager.subBagList(this.curTaskGoodId)
//更新任务
this.descNode.active = false
this.tiJiaoCallFunc && this.tiJiaoCallFunc()
this.node.removeFromParent()
this.node.destroy()
}
onBtnYiJianShouKong() {
let tab = {
onClose: (finish) => {
if (finish) {
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
Common5.ReportDY("inLevel", `任务${mainId}-AD-背包一键售空`);
let getBagList = BagManager.getBagProList()
// console.log(getBagList, 'getBagList++++++++++++===')
let allPrice = 0
for (let n = 0; n < getBagList.length; n++) {
let _pro = BagManager.getGoodsProperty(getBagList[n].goodId)
// console.log('_pro==',_pro)
allPrice += _pro.priceNum * getBagList[n].goodNum
BagManager.subBagList(getBagList[n].goodId, getBagList[n].goodNum)
}
// console.log('allPrice==',allPrice)
UserManager.addMoney(Math.floor(allPrice * 2.5), this.node);
}
else {
Common5.showTips_custom("广告未观看完");
}
}, onFailed: () => {
}
}
AppPlatform.playVideo_custom(tab)
}
onBtnExitRoomClick() {
// Common5.playEffect("sound/按键点击")
console.log('onBtnExitRoomClick+++++++++===')
this.node.removeFromParent()
this.node.destroy()
EventMgr.emitEvent_custom(ryw_Event.ExitBtnEvent, '');
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
EventMgr.emitEvent_custom(ryw_Event.guideShouHuoJiExit);
}
// update (dt) {}
}