咸鱼的反击
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.
 
 
 

729 lines
26 KiB

// Learn TypeScript:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
import User from "../../FrameWork/User/User";
import Common5 from "../../Platform/th/Common5";
import UserManager from "../Manager/UserManager";
import AppPlatform from "../../FrameWork/Util/AppPlatform";
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
import BagManager, { GoodsLocalProperty } from "../Manager/BagManager";
import TaskManager, { MainTaskIdEnum } from "../JuQingChat/TaskManager";
import ShipuManager from "../Manager/ShipuManager";
const {ccclass, property} = cc._decorator;
@ccclass
export default class Jianding extends cc.Component {
@property(cc.Label)
goodsName: cc.Label = null;
@property(cc.Label)
priceLab: cc.Label = null;
@property(cc.Node)
iconNode: cc.Node = null;
@property(cc.Node)
mabuSpine: cc.Node = null;
@property(cc.Node)
jiandingBtn: cc.Node = null;
@property(cc.Node)
jiandingVideoBtn: cc.Node = null;
@property(cc.Label)
jiandingBtnChiShu: cc.Label = null;
@property(cc.Node)
doubleMaichuBtn: cc.Node = null;
@property(cc.Node)
qipaoNode: cc.Node = null;
@property(cc.Node)
maichuTiQianBtn: cc.Node = null;
fangRuBeiBaoBtn: cc.Node = null;
maichuBtn: cc.Node = null;
arrayNode: cc.Node[] = [];
zhenPin: cc.Node = null;
yanpin: cc.Node = null;
dierci: cc.Node = null;
diyici: cc.Node = null;
jiandingqian: cc.Node = null;
kuangwu: cc.Node = null;
jiandingChishu = null
goodsConfig = null
// LIFE-CYCLE CALLBACKS:
curPrice:number = 0
recoverPosi = null
resultGoodId:number = 0
bagItemConfig:{goodId:number,jiandingChishu:number, zhenjiawupin:number, fenlei:number, goodNum:number, priceNum:number} = null;
onLoad (){
this.zhenPin = this.iconNode.getChildByName('zhenpin')
this.yanpin = this.iconNode.getChildByName('yanpin')
this.kuangwu = this.iconNode.getChildByName('kuangwu')
this.dierci = this.iconNode.getChildByName('dierci')
this.diyici = this.iconNode.getChildByName('diyici')
this.jiandingqian = this.iconNode.getChildByName('jiandingqian')
this.recoverPosi = this.mabuSpine.getPosition()
}
start () {
this.maichuBtn = this.node.getChildByName('maichuBtn')
this.fangRuBeiBaoBtn = this.node.getChildByName('fangRuBeiBaoBtn')
let appraisalIndex = User.getAppraisalIndex()
if(appraisalIndex>0){
this.jiandingVideoBtn.active = false
this.jiandingBtn.active = true
this.jiandingBtnChiShu.string = appraisalIndex+''
}else{
this.jiandingVideoBtn.active = true
this.jiandingBtn.active = false
}
this.maichuBtn.active = false
this.fangRuBeiBaoBtn.active = false
}
refreshData(jiandingChishu, goodsConfig,bagItemConfig){
this.jiandingChishu = jiandingChishu
this.bagItemConfig = bagItemConfig
this.goodsName.string = '古玩'
this.goodsConfig = goodsConfig
console.log(jiandingChishu,'jiandingChishu++====')
console.log(this.goodsConfig,'this.goodsConfig++====')
if(jiandingChishu>3){
//
//console.log('jiandingChishu++=大于3===')
}else{
}
let price = this.goodsConfig.buyPrice
let aaa = Common5.getNumberChangeHanzi( price ,'1')
aaa = aaa as string
this.curPrice = price
this.priceLab.string = aaa
Common5.addUrlSprite_custom(goodsConfig.spriteArray + '/鉴定前', this.jiandingqian.getComponent(cc.Sprite))
if(goodsConfig.id<18){
this.scheduleOnce(()=>{
//Common5.getSpriteFrameFromBundle("GameRes", goodsConfig.spriteArray + '/鉴定第一次' , this.diyici.getComponent(cc.Sprite));
Common5.addUrlSprite_custom(goodsConfig.spriteArray + '/鉴定第一次', this.diyici.getComponent(cc.Sprite))
},0.2)
this.scheduleOnce(()=>{
//Common5.getSpriteFrameFromBundle("GameRes", goodsConfig.spriteArray + '/鉴定第二次' , this.dierci.getComponent(cc.Sprite));
Common5.addUrlSprite_custom(goodsConfig.spriteArray + '/鉴定第二次', this.dierci.getComponent(cc.Sprite))
},0.4)
this.scheduleOnce(()=>{
//Common5.getSpriteFrameFromBundle("GameRes", goodsConfig.spriteArray + '/赝品' , this.yanpin.getComponent(cc.Sprite));
Common5.addUrlSprite_custom(goodsConfig.spriteArray + '/赝品', this.yanpin.getComponent(cc.Sprite))
},0.6)
this.scheduleOnce(()=>{
//Common5.getSpriteFrameFromBundle("GameRes", goodsConfig.spriteArray + '/真品' , this.zhenPin.getComponent(cc.Sprite));
Common5.addUrlSprite_custom(goodsConfig.spriteArray + '/真品', this.zhenPin.getComponent(cc.Sprite))
},0.8)
}
this.arrayNode = [this.jiandingqian, this.diyici, this.dierci]
this.scheduleOnce(()=>{
if(jiandingChishu!=null){
if(jiandingChishu == 0){
this.jiandingqian.active = true
this.dierci.active = true
this.diyici.active = true
}else if(jiandingChishu == 1){
this.jiandingqian.active = false
this.dierci.active = true
this.diyici.active = true
}else if(jiandingChishu == 2){
this.jiandingqian.active = false
this.diyici.active = false
this.dierci.active = true
}
}
},0.1)
}
getIsZhongjiang(){
let GuWanShiChang = [50,50]//Common5.GameProbabillityConfig.GuWanShiChang.common
let index_ = Common5.getProbabilityResultIndex(GuWanShiChang)
//console.log( index_, 'index_+++11==')
if(index_ == 0){
//中奖
return true
}else if(index_ == 1){
//没有中奖
return false
}
}
getIsZhongjiang2(zhongjianggai){
let index_ = Common5.getProbabilityResultIndex([zhongjianggai,100-zhongjianggai])
//console.log( index_, 'index_+++==')
//console.log( index_, 'index_+++22==')
if(index_ == 1){
//没有中奖
return false
}else if(index_ == 0){
//中奖
return true
}
}
jiandingClick(event){
let target = event.target
////Common5.playEffect("ui")
//Common5.playEffect("sound/按键点击")
if(this.jiandingBtn['isAun']){
return
}
Common5.ReportDY("inLevel", '古玩市场-免费鉴定');
if(!this.jiandingBtn['isAun']){
this.jiandingBtn['isAun'] = true
}
let jiandingChishu = this.jiandingChishu
if(jiandingChishu == 3){
PrefabManage.showTextTips('当前物品不需要鉴定', 1)
return
}
this.jiandingChishu = this.jiandingChishu+1
//每天抹布次数建-
let appraisalIndex = User.getAppraisalIndex()
appraisalIndex = appraisalIndex - 1
User.setAppraisalIndex(appraisalIndex)
this.jiandingBtnChiShu.string = appraisalIndex+''
if(appraisalIndex == 0){
this.jiandingBtn.active = false
this.jiandingVideoBtn.active = true
this.doubleMaichuBtn.active = false
if(this.jiandingChishu>=3){
this.jiandingVideoBtn.active = false
}
}else{
}
jiandingChishu = this.jiandingChishu
let goodId = this.goodsConfig.id
//播放动画
let posiData = this.goodsConfig.chachuPosiArray[jiandingChishu-1]
let posi = cc.v2(posiData[0],posiData[1])
let realTingProbability = this.goodsConfig.realTingProbability //概率
let isSpine = this.goodsConfig.isSpine
this.mabuSpine.setPosition(posi)
this.mabuSpine.getComponent(sp.Skeleton).setAnimation(0,"ma",false)
this.mabuSpine.getComponent(sp.Skeleton).setCompleteListener(()=>{
let miaoshu = this.goodsConfig.saleTalk[jiandingChishu-1]
// this.qipaoNode.scale = 0.01
// this.qipaoNode.active = true
// let label_ = this.qipaoNode.getChildByName('qipaoLab').getComponent(cc.Label)
// label_.string = ''
// cc.tween(this.qipaoNode )
// .to(0.3,{scale:1})
// .call(()=>{
// label_.string = miaoshu
// })
// .start()
this.mabuSpine.setPosition( this.recoverPosi)
let node_ = this.arrayNode[jiandingChishu-1]
this.jiandingBtn['isAun'] = false
node_.active = false
if(jiandingChishu == 1){
this.node.getChildByName('suixie1').active = true
}
if(jiandingChishu == 2){
this.node.getChildByName('suixie2').active = true
}
if(jiandingChishu == 3){
this.node.getChildByName('suixie3').active = true
// this.scheduleOnce(()=>{
// this.qipaoNode.active = false
// },2)
}
this.curPrice = this.goodsConfig.salePrices[jiandingChishu-1]
this.bagItemConfig.jiandingChishu = this.jiandingChishu
if(jiandingChishu==2){
this.maichuTiQianBtn.active = true
}else{
this.maichuTiQianBtn.active = false
}
if(jiandingChishu>=3){
//检验真伪
this.jiandingBtn.active = false
// this.maichuBtn.active = true
// this.doubleMaichuBtn.active = true
this.fangRuBeiBaoBtn.active = true
let zhenPrice = this.goodsConfig.salePrices[2]
let jiaPrice = this.goodsConfig.jiahuoPrice
if(realTingProbability == 50){
let iszhong = this.getIsZhongjiang()
for(let i = 0;i< this.arrayNode.length;i++){
let node_ = this.arrayNode[i]
node_.active = false
}
if(iszhong){
this.bagItemConfig.zhenjiawupin = 1
this.curPrice = zhenPrice
this.resultGoodId = this.goodsConfig.zhenGoodId
this.yanpin.active = false
this.zhenPin.active = true
miaoshu = this.goodsConfig.saleTalk[jiandingChishu-1]
this.goodsName.string = this.goodsConfig.goodName
}else{
this.goodsName.string = "假"+this.goodsConfig.goodName
this.bagItemConfig.zhenjiawupin = 0
this.curPrice = jiaPrice
this.resultGoodId = this.goodsConfig.jiaGoodId
this.yanpin.active = true
this.zhenPin.active = false
miaoshu = this.goodsConfig.saleTalk[3]
}
}else{
let iszhong = this.getIsZhongjiang2(realTingProbability)
if(iszhong){
this.goodsName.string = this.goodsConfig.goodName
this.bagItemConfig.zhenjiawupin = 1
this.curPrice = zhenPrice
this.resultGoodId = this.goodsConfig.zhenGoodId
this.yanpin.active = false
this.zhenPin.active = true
miaoshu = this.goodsConfig.saleTalk[jiandingChishu-1]
// if(isSpine){
// this.yanpin.active = false
// this.zhenPin.active = false
// this.kuangwu.active = true
// }
}else{
this.goodsName.string = "假"+this.goodsConfig.goodName
this.bagItemConfig.zhenjiawupin = 0
this.curPrice = jiaPrice
this.resultGoodId = this.goodsConfig.jiaGoodId
this.yanpin.active = true
this.zhenPin.active = false
miaoshu = this.goodsConfig.saleTalk[3]
}
}
//背包数据更新 FIX ME
}else{
this.bagItemConfig.zhenjiawupin = 3
}
//补丁(菜谱鉴定一次必出)
if(goodId == 18 && jiandingChishu == 1){
if(BagManager.getBagGoodNums(1725)<=0 && Common5.guwanchengADNum>0){
let config = {
priceNum:0,
goodId:1725,
goodName:'清炖饕餮蹄'
}
this.curPrice = config.priceNum
this.jiandingBtn.active = false
this.jiandingVideoBtn.active = false
this.fangRuBeiBaoBtn.active = true
this.resultGoodId = config.goodId
this.goodsName.string = config.goodName
Common5.addUrlSprite_custom('GoodIcon/texture/icon/'+config.goodId , this.diyici.getComponent(cc.Sprite))
}else{
let index = Math.floor(Math.random()* Common5.caiPuConfigs.length)
let config = Common5.caiPuConfigs[index]
this.curPrice = config.priceNum
this.jiandingBtn.active = false
this.jiandingVideoBtn.active = false
this.fangRuBeiBaoBtn.active = true
this.resultGoodId = config.goodId
this.goodsName.string = config.goodName
Common5.addUrlSprite_custom('GoodIcon/texture/icon/'+config.goodId , this.diyici.getComponent(cc.Sprite))
}
}else if(goodId>=19 && jiandingChishu == 1){
this.curPrice = this.goodsConfig.salePrices[jiandingChishu-1]
this.resultGoodId = this.goodsConfig.zhenGoodId
this.jiandingBtn.active = false
this.jiandingVideoBtn.active = false
this.fangRuBeiBaoBtn.active = true
this.goodsName.string = this.goodsConfig.goodName
Common5.addUrlSprite_custom('GoodIcon/texture/icon/'+this.resultGoodId , this.diyici.getComponent(cc.Sprite))
}
this.bagItemConfig.priceNum = this.curPrice
// User.updataBagGoodsList(this.bagItemConfig)
console.log( this.curPrice )
let aaa = Common5.getNumberChangeHanzi( this.curPrice ,'1',1)
aaa = aaa as string
this.priceLab.string = aaa
})
}
getNoRepeatCaipu(){
let mainTaskInfo:any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
if(mainId != MainTaskIdEnum.MainTask_525){
return -1
}
let caiPuConfigs = Common5.caiPuConfigs
let repeatArray = []
let taskCaiGouDan=[1832,1804, 1808,1820,1821]
for(let i = 0;i<taskCaiGouDan.length; i++){
let id = taskCaiGouDan[i]
if(BagManager.getBagGoodNums(id)>0 && repeatArray.indexOf(id)<0 ){
repeatArray.push(id)
}
}
if(taskCaiGouDan.length == repeatArray.length){
return -1
}
let chooseGood = -1
for(let i = 0;i<taskCaiGouDan.length; i++){
let id = taskCaiGouDan[i]
if(repeatArray.indexOf(id) < 0){
chooseGood = id
}
}
for(let i = 0;i<caiPuConfigs.length; i++){
let data = caiPuConfigs[i]
if(data.goodId == chooseGood){
return i
}
}
return -1
}
maichuClick(event){
//Common5.playEffect("sound/按键点击")
let target = event.target
////Common5.playEffect("ui")
UserManager.addMoney(this.curPrice, target)
this.node.removeFromParent()
}
tiqianMaichuVDClick(event){
//Common5.playEffect("sound/按键点击")
let target = event.target
////Common5.playEffect("ui")
//Common5.playEffect("sound/按键点击")
let tab = {
onClose: (finish)=>{
if (finish) {
Common5.ReportDY("inLevel", "古玩市场-AD-提前卖出");
UserManager.addMoney(this.curPrice, target)
Common5.guwanchengADNum++
this.node.removeFromParent()
}else{
Common5.showTips_custom("广告未观看完");
}
},onFailed:()=>{
}
}
AppPlatform.playVideo_custom(tab)
}
doubleMaichuClick(event){
let target = event.target
////Common5.playEffect("ui")
//Common5.playEffect("sound/按键点击")
let tab = {
onClose: (finish)=>{
if (finish) {
Common5.ReportDY("inLevel", "古玩市场-AD-翻倍卖出");
UserManager.addMoney(this.curPrice*2, target)
Common5.guwanchengADNum++
this.node.removeFromParent()
}else{
Common5.showTips_custom("广告未观看完");
}
},onFailed:()=>{
}
}
AppPlatform.playVideo_custom(tab)
}
onBtnFangRuBeiBaoClick(){
//Common5.playEffect("sound/按键点击")
let bagConfig:GoodsLocalProperty = {
goodId:this.resultGoodId,
goodNum:1,
}
BagManager.addBagList(bagConfig)
ShipuManager.setShipuUnLock()
// let mainTaskInfo:any = TaskManager.getCurUnLockMainTaskInfo()
// let mainId = mainTaskInfo.Id
// if(mainId == MainTaskIdEnum.MainTask_541){
// let goodArray = [1735,1736,1737,1738,1739]
// let haveAll = BagManager.isHaveAllGood(goodArray)
// if(haveAll){
// }
// }else if(mainId == MainTaskIdEnum.MainTask_567){
// let goodArray = [1759]
// let haveAll = BagManager.isHaveAllGood(goodArray)
// if(haveAll){
// TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_567)
// }
// }else if(mainId == MainTaskIdEnum.MainTask_525){
// let goodArray = [1832,1804,1808,1820,1821]
// let haveAll = BagManager.isHaveAllGood(goodArray)
// if(haveAll){
// TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_525)
// TaskManager.setCurTask(MainTaskIdEnum.MainTask_525_2)
// return
// }
// let allCaidanNum = 0
// for(let i = 0; i<goodArray.length;i++){
// let goodConfig = BagManager.getGoodsProperty(goodArray[i])
// let name = goodConfig.goodName
// if(BagManager.getBagGoodNums(goodArray[i])>0){
// allCaidanNum+=1
// }
// }
// if(allCaidanNum>=5){
// TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_525)
// TaskManager.setCurTask(MainTaskIdEnum.MainTask_525_2)
// }
// }
this.node.removeFromParent()
this.node.destroy()
}
VideoClick(){
//Common5.playEffect("sound/按键点击")
////Common5.playEffect("ui")
if(this.jiandingVideoBtn['isAun']){
return
}
if(!this.jiandingVideoBtn['isAun']){
this.jiandingVideoBtn['isAun'] = true
}
let tab = {
onClose: (finish)=>{
if(finish) {
//Common5.showTips_custom("开始抽奖");
//this.mabuChachu()
Common5.guwanchengADNum++
Common5.ReportDY("inLevel", '古玩市场-AD-获取次数');
User.setAppraisalIndex(5)
let appraisalIndex = User.getAppraisalIndex()
if(appraisalIndex>0){
this.jiandingVideoBtn.active = false
this.jiandingBtn.active = true
this.jiandingBtnChiShu.string = appraisalIndex+''
}else{
this.jiandingVideoBtn.active = true
this.jiandingBtn.active = false
}
}
else{
this.jiandingVideoBtn['isAun'] = false
Common5.showTips_custom("广告未观看完");
}
},onFailed:()=>{
}
}
AppPlatform.playVideo_custom(tab)
}
mabuChachu(){
if(this.jiandingChishu == 3){
PrefabManage.showTextTips('当前物品不需要鉴定', 1)
return
}
this.jiandingChishu = this.jiandingChishu+1
let jiandingChishu = this.jiandingChishu
//播放动画
let posiData = this.goodsConfig.chachuPosiArray[jiandingChishu-1]
let posi = cc.v2(posiData[0],posiData[1])
let realTingProbability = this.goodsConfig.realTingProbability //概率
// let refreshData
this.mabuSpine.setPosition(posi)
this.mabuSpine.getComponent(sp.Skeleton).setAnimation(0,"ma",false)
this.mabuSpine.getComponent(sp.Skeleton).setCompleteListener(()=>{
let miaoshu = this.goodsConfig.saleTalk[jiandingChishu-1]
// this.qipaoNode.scale = 0.01
// this.qipaoNode.active = true
// let label_ = this.qipaoNode.getChildByName('qipaoLab').getComponent(cc.Label)
// label_.string = ''
// cc.tween(this.qipaoNode )
// .to(0.3,{scale:1})
// .call(()=>{
// label_.string = miaoshu
// })
// .start()
this.mabuSpine.setPosition( this.recoverPosi)
let node_ = this.arrayNode[jiandingChishu-1]
this.jiandingVideoBtn['isAun'] = false
node_.active = false
if(jiandingChishu == 1){
this.node.getChildByName('suixie1').active = true
}
if(jiandingChishu == 2){
this.node.getChildByName('suixie2').active = true
}
if(jiandingChishu == 3){
this.node.getChildByName('suixie3').active = true
this.scheduleOnce(()=>{
this.qipaoNode.active = false
},2)
}
this.curPrice = this.goodsConfig.salePrices[jiandingChishu-1]
this.bagItemConfig.jiandingChishu = this.jiandingChishu
if(jiandingChishu==2){
this.maichuTiQianBtn.active = true
}else{
this.maichuTiQianBtn.active = false
}
if(jiandingChishu>=3){
//检验真伪
let goodId = this.goodsConfig.id
let zhenPrice = this.goodsConfig.salePrices[2]
let jiaPrice = this.goodsConfig.jiahuoPrice
if(realTingProbability == 50){
let iszhong = this.getIsZhongjiang()
for(let i = 0;i< this.arrayNode.length;i++){
let node_ = this.arrayNode[i]
node_.active = false
}
if(iszhong){
this.curPrice = zhenPrice
this.resultGoodId = this.goodsConfig.zhenGoodId
this.bagItemConfig.zhenjiawupin = 1
this.yanpin.active = false
this.zhenPin.active = true
miaoshu = this.goodsConfig.saleTalk[jiandingChishu-1]
this.goodsName.string = this.goodsConfig.goodName
}else{
this.goodsName.string = "假"+this.goodsConfig.goodName
this.curPrice = jiaPrice
this.resultGoodId = this.goodsConfig.jiaGoodId
this.yanpin.active = true
this.zhenPin.active = false
this.bagItemConfig.zhenjiawupin = 0
miaoshu = this.goodsConfig.saleTalk[3]
}
}else{
let iszhong = this.getIsZhongjiang2(realTingProbability)
//console.log('chufa+++===')
if(iszhong){
this.bagItemConfig.zhenjiawupin = 1
this.curPrice = zhenPrice
this.resultGoodId = this.goodsConfig.zhenGoodId
this.yanpin.active = false
this.zhenPin.active = true
miaoshu = this.goodsConfig.saleTalk[jiandingChishu-1]
this.goodsName.string = this.goodsConfig.goodName
}else{
this.goodsName.string = "假"+this.goodsConfig.goodName
this.bagItemConfig.zhenjiawupin = 0
this.curPrice = jiaPrice
this.resultGoodId = this.goodsConfig.jiaGoodId
this.yanpin.active = true
this.zhenPin.active = false
miaoshu = this.goodsConfig.saleTalk[3]
}
}
}else{
this.bagItemConfig.zhenjiawupin = 3
}
this.bagItemConfig.priceNum = this.curPrice
let aaa = Common5.getNumberChangeHanzi( this.curPrice ,'1')
aaa = aaa as string
this.priceLab.string = aaa
})
}
// update (dt) {}
}