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.
294 lines
9.3 KiB
294 lines
9.3 KiB
/**
|
|
* Author:shaoyang
|
|
* Date:2023/03/22
|
|
* Desc:恭喜获得通用弹框
|
|
*/
|
|
|
|
import GameReport from "../../FrameWork/Report/ZyZyReport";
|
|
import AppPlatform from "../../FrameWork/Util/AppPlatform";
|
|
import Common5 from "../../Platform/th/Common5";
|
|
import BagManager, { GoodsProperty, GoodsLocalProperty } from "../Manager/BagManager";
|
|
import UserManager from "../Manager/UserManager";
|
|
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
|
|
import ZhaoHuanTai from "../ZhaoHuanTai/ZhaoHuanTai";
|
|
|
|
const {ccclass, property} = cc._decorator;
|
|
|
|
export enum GetAward_BtnStatus{
|
|
ChuShou,
|
|
BeiBao,
|
|
BuYao,
|
|
LingQu
|
|
}
|
|
@ccclass
|
|
export default class GetAward extends cc.Component {
|
|
|
|
@property(cc.Node)
|
|
lingquNode: cc.Node = null;
|
|
|
|
|
|
@property(cc.Node)
|
|
iconNode: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
content1: cc.Node = null;
|
|
|
|
@property(cc.Label)
|
|
priceNum: cc.Label = null;
|
|
|
|
@property(cc.Node)
|
|
layOutBtn1: cc.Node = null;
|
|
|
|
btnClickCallFunc = null
|
|
curUiCfg:GoodsProperty = null;
|
|
goodIdData = null
|
|
allGoodsPrice = 0
|
|
curentContent:cc.Node = null
|
|
goodIDArray = [];
|
|
goodIds = null
|
|
|
|
isHavePro = false
|
|
start () {
|
|
this.curentContent = this.content1
|
|
Common5.playRemoteAudioEffect("remotesound/effect/游戏点击音效")
|
|
}
|
|
|
|
initView(goodIds, callFunc?){
|
|
this.btnClickCallFunc = callFunc
|
|
this.goodIdData = goodIds
|
|
//console.log(goodIds, 'this.allGoodsPrice++++')
|
|
|
|
this.goodIds = goodIds
|
|
for(let i = 0; i<goodIds.length;i++){
|
|
let data = goodIds[i]
|
|
let goodData = BagManager.getGoodsProperty(data.goodId)
|
|
this.allGoodsPrice+=(data.goodNum*goodData.priceNum)
|
|
if((data.goodId >= 1701 && data.goodId <= 1750) || (data.goodId >= 3700 && data.goodId <= 3739)){
|
|
this.isHavePro = true
|
|
}
|
|
}
|
|
|
|
this.showGoodsInfos(this.goodIds)
|
|
this.priceNum.string = '物品价值:'+ Common5.getNumberChangeHanzi(this.allGoodsPrice)
|
|
|
|
|
|
if(this.isHavePro){
|
|
this.node.getChildByName('layBtnNode').getChildByName('lingqu').active = true
|
|
this.node.getChildByName('layBtnNode').getChildByName('maichu').active = false
|
|
|
|
}else{
|
|
this.node.getChildByName('layBtnNode').getChildByName('lingqu').active = false
|
|
this.node.getChildByName('layBtnNode').getChildByName('maichu').active = true
|
|
|
|
}
|
|
this.node.scale = 0.1
|
|
cc.tween(this.node)
|
|
.to(1.0, {scale:1},{easing:'elasticOut'})
|
|
.start()
|
|
}
|
|
|
|
|
|
|
|
refreshIconNode(node, goodsId, goodsNum){
|
|
let iconSpr = node.getChildByName('spr')
|
|
let goodsNumNode = node.getChildByName('goodsNum')
|
|
goodsNumNode.getComponent(cc.Label).string = goodsNum+''
|
|
//Common5.getSpriteFrameFromBundle("CommonRes","GoodIcon/texture/icon/"+ goodsId, iconSpr.getComponent(cc.Sprite));
|
|
Common5.addUrlSprite_custom("GoodIcon/texture/icon/"+ goodsId, iconSpr.getComponent(cc.Sprite))
|
|
|
|
let goodsName = node.getChildByName('goodsName').getComponent(cc.Label)
|
|
let goodData = BagManager.getGoodsProperty(goodsId)
|
|
goodsName.string = goodData.goodName
|
|
}
|
|
|
|
showGoodsInfos(goodIds){
|
|
this.goodIDArray = goodIds
|
|
|
|
for(let i = 0; i<goodIds.length;i++){
|
|
let data = goodIds[i]
|
|
|
|
let iconNode = cc.instantiate(this.iconNode)
|
|
iconNode.setPosition(cc.v2(0,0))
|
|
|
|
iconNode.parent = this.content1
|
|
iconNode.active = true
|
|
if(data.goodNum){
|
|
let goodsNum = data.goodNum
|
|
this.refreshIconNode(iconNode, data.goodId, goodsNum)
|
|
}else{
|
|
let goodsNum = 1
|
|
this.refreshIconNode(iconNode, data, goodsNum)
|
|
}
|
|
}
|
|
|
|
this.lingquNode.active = true
|
|
}
|
|
|
|
|
|
lingquClickEvent(event){
|
|
//Common5.playEffect("sound/按键点击")
|
|
|
|
this.reportKey(()=>{
|
|
GameReport.BtnsReport('直接领取')
|
|
})
|
|
|
|
let goodIds = this.goodIds
|
|
|
|
for(let i = 0; i<goodIds.length;i++){
|
|
let data = goodIds[i]
|
|
if(data.goodId == 9999){
|
|
|
|
//let goodData = BagManager.getGoodsProperty(data.goodId)
|
|
let priceNum = data.goodNum
|
|
UserManager.addMoney(priceNum, event.target)
|
|
|
|
// let _num = data.goodNum || 1
|
|
// let bagConfig:GoodsLocalProperty = {
|
|
// goodId:goodData.goodId,
|
|
// goodNum:_num,
|
|
|
|
|
|
// }
|
|
// BagManager.addBagList(bagConfig)
|
|
|
|
|
|
}else{
|
|
let goodData = BagManager.getGoodsProperty(data.goodId)
|
|
|
|
let _num = data.goodNum || 1
|
|
let bagConfig:GoodsLocalProperty = {
|
|
goodId:goodData.goodId,
|
|
goodNum:_num,
|
|
|
|
|
|
}
|
|
BagManager.addBagList(bagConfig)
|
|
|
|
// let zhuzis = [3730, 3731, 3732, 3733, 3734, 3735, 3736]
|
|
// if (zhuzis.includes(data.goodId)) {
|
|
// PrefabManage.loadPrefabByType(GameType.ZhaoHuanTai,null,(node)=>{
|
|
// node.getComponent(ZhaoHuanTai).init(data.goodId)
|
|
// })
|
|
// }
|
|
}
|
|
|
|
}
|
|
PrefabManage.showTextTips('物品已放入背包')
|
|
|
|
this.onCloseAward()
|
|
}
|
|
|
|
onCloseAward(){
|
|
this.btnClickCallFunc && this.btnClickCallFunc()
|
|
this.node.removeFromParent()
|
|
this.node.destroy()
|
|
|
|
}
|
|
|
|
|
|
fenxiangClickEvent(){
|
|
//Common5.playEffect("sound/按键点击")
|
|
|
|
}
|
|
|
|
|
|
|
|
getRewardClickEvent(event){
|
|
let target = event.target
|
|
//Common5.playEffect("sound/按键点击")
|
|
UserManager.addMoney(this.allGoodsPrice,target)
|
|
this.onCloseAward()
|
|
}
|
|
|
|
|
|
getDoubleRewardClickEvent(event){
|
|
let target = event.target
|
|
UserManager.addMoney(this.allGoodsPrice,target)
|
|
this.onCloseAward()
|
|
|
|
// let target = event.target
|
|
// //Common5.playEffect("sound/按键点击")
|
|
// let tab = {
|
|
// onClose: (finish)=>{
|
|
// if (finish) {
|
|
// Common5.ReportDY("inLevel", "物品奖励-AD-双倍领取");
|
|
|
|
// this.reportKey(()=>{
|
|
// GameReport.ADReport('双倍领取',1)
|
|
// })
|
|
|
|
// let goodIds = this.goodIds
|
|
|
|
// for(let i = 0; i<goodIds.length;i++){
|
|
// let data = goodIds[i]
|
|
// if(data.goodId == 9999){
|
|
// //let goodData = BagManager.getGoodsProperty(data.goodId)
|
|
// let priceNum = data.goodNum
|
|
// UserManager.addMoney(priceNum*2, event.target)
|
|
|
|
// // let _num = data.goodNum || 1
|
|
// // let bagConfig:GoodsLocalProperty = {
|
|
// // goodId:goodData.goodId,
|
|
// // goodNum:_num*2,
|
|
|
|
|
|
// // }
|
|
// // BagManager.addBagList(bagConfig)
|
|
// }else{
|
|
// let goodData = BagManager.getGoodsProperty(data.goodId)
|
|
// let _num = data.goodNum || 1
|
|
// let bagConfig:GoodsLocalProperty = {
|
|
// goodId:goodData.goodId,
|
|
// goodNum:_num*2,
|
|
// }
|
|
// BagManager.addBagList(bagConfig)
|
|
|
|
// }
|
|
|
|
// }
|
|
// PrefabManage.showTextTips('物品已放入背包')
|
|
|
|
|
|
|
|
// this.onCloseAward()
|
|
// }else{
|
|
// this.reportKey(()=>{
|
|
// GameReport.ADReport('双倍领取',0)
|
|
// })
|
|
// Common5.showTips_custom("广告未观看完");
|
|
// }
|
|
// },onFailed:()=>{
|
|
|
|
// }
|
|
// }
|
|
// AppPlatform.playVideo_custom(tab)
|
|
}
|
|
|
|
|
|
specialSave(){
|
|
let goodIDArray = this.goodIDArray
|
|
// for(let i = 0; i<goodIDArray.length;i++){
|
|
// let data = goodIDArray[i]
|
|
// let goodData = BagManager.getGoodsProperty(data.goodId)
|
|
// let goodName = goodData.goodName
|
|
// let goodsNum = data.goodNum
|
|
// let jinzhuanIndex = goodName.indexOf('金砖')
|
|
// let shengxiaoIndex = goodName.indexOf('生肖')
|
|
// let zhongziIndex = goodName.indexOf('种子')
|
|
// if(shengxiaoIndex>=0){
|
|
// UserManager.setShengXiaoList(data.goodId)
|
|
// }else if(jinzhuanIndex>=0){
|
|
// UserManager.addGoldNum(goodsNum)
|
|
// }else if(zhongziIndex>=0){
|
|
// //UserManager.addGoldNum(goodsNum)
|
|
// InterfaceManager.setXuyuanDataStateZhongzi()
|
|
// }
|
|
// }
|
|
}
|
|
|
|
protected reportKey(sendCall:Function){
|
|
GameReport.SetCurGame('恭喜获得');
|
|
sendCall()
|
|
}
|
|
|
|
}
|
|
|