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.
499 lines
18 KiB
499 lines
18 KiB
// Learn TypeScript:
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
|
|
// Learn Attribute:
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
|
|
|
|
|
|
import { ryw_Event } from "../../FrameWork/Event/EventEnum";
|
|
import EventMgr from "../../FrameWork/Event/EventMgr";
|
|
import GameReport from "../../FrameWork/Report/ZyZyReport";
|
|
import User, { RoomBtnIndexEnum } from "../../FrameWork/User/User";
|
|
import AppPlatform from "../../FrameWork/Util/AppPlatform";
|
|
import Common5 from "../../Platform/th/Common5";
|
|
import MaoYiFenHong from "../GameMethodRes/MaoYiFenHong/MaoYiFenHong";
|
|
import MaoYiFenHongManager from "../GameMethodRes/MaoYiFenHong/MaoYiFenHongManager";
|
|
import JuQingManager from "../JuQingChat/JuQingManager";
|
|
import TaskManager, { MainTaskIdEnum } from "../JuQingChat/TaskManager";
|
|
import BagManager from "../Manager/BagManager";
|
|
import InterfaceManager from "../Manager/InterfaceManager";
|
|
import UserManager from "../Manager/UserManager";
|
|
import NewGuideScript from "../NewGuide/NewGuideScript";
|
|
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
|
|
import GameBase from "../SCommon/GameBase";
|
|
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
let QiPaoStrTab = [
|
|
'<color=#303457>医疗费用需要</c><color=#F0461D>100</c><color=#303457>万</color>',
|
|
'<color=#303457>拍卖肝病药物配方需要</c><color=#F0461D>200</c><color=#303457>万</color>',
|
|
'<color=#303457>被娱乐人敲诈需要</c><color=#F0461D>1000</c><color=#303457>万</color>',
|
|
'<color=#303457>股市收购钱氏集团需要</c><color=#F0461D>5000</c><color=#303457>万</color>',
|
|
'<color=#303457>股市收购傅氏医疗需要</c><color=#F0461D>5</c><color=#303457>亿</color>',
|
|
'<color=#303457>筹集资金进入拍卖行需要</c><color=#F0461D>20</c><color=#303457>亿</color>',
|
|
'<color=#303457>股市收购傅氏股票需要</c><color=#F0461D>50</c><color=#303457>亿</color>',
|
|
'<color=#303457>股市安氏集团需要</c><color=#F0461D>100</c><color=#303457>亿</color>',
|
|
'<color=#303457>股市收购龙氏集团需要</c><color=#F0461D>1000</c><color=#303457>亿</color>',
|
|
'<color=#303457>恢复集团运营需要</c><color=#F0461D>2000</c><color=#303457>亿</color>',
|
|
'<color=#303457>筹备拍卖资金需要</c><color=#F0461D>5000</c><color=#303457>亿</color>',
|
|
]
|
|
|
|
@ccclass
|
|
export default class DaoYeShouGou extends GameBase {
|
|
@property(cc.Node)
|
|
diTuNode: cc.Node = null;
|
|
// @property([cc.SpriteFrame])
|
|
// diTuSpFrame: cc.SpriteFrame[]=[]
|
|
@property(cc.Label)
|
|
dingDanMing: cc.Label = null;
|
|
|
|
// @property(cc.Node)
|
|
// shougouNode: cc.Node = null;
|
|
// @property(cc.Node)
|
|
// shougouTaskNode: cc.Node = null;
|
|
@property(cc.Node)
|
|
iconNode: cc.Node = null;
|
|
// @property(cc.Node)
|
|
// iconNodeTask: cc.Node = null;
|
|
@property(cc.Node)
|
|
contentLayout: cc.Node = null;
|
|
@property(cc.Node)
|
|
huoyuanNode: cc.Node = null;
|
|
|
|
@property(cc.Label)
|
|
allPrice: cc.Label = null;
|
|
|
|
@property(cc.RichText)
|
|
qiPaoRichText: cc.RichText = null;
|
|
// @property(cc.Node)
|
|
// tittleSpr: cc.Node = null;
|
|
|
|
// @property([cc.SpriteFrame])
|
|
// tittleSpFrame: cc.SpriteFrame[]=[]
|
|
|
|
allPriceNum = 0
|
|
startBuyPercent = 10
|
|
isYuanBaoJieSuan: boolean = false
|
|
onLoad() {
|
|
super.onLoad()
|
|
}
|
|
|
|
onDestroy() {
|
|
super.onDestroy()
|
|
|
|
}
|
|
|
|
|
|
isTask = false
|
|
// tempNode: cc.Node = null
|
|
isCanJiaohuo = true
|
|
start() {
|
|
this.scheduleOnce(() => {
|
|
PrefabManage.preloadPrefabByType(GameType.MaoYiFenHong)
|
|
})
|
|
// //倒爷引导完毕
|
|
// if(User.getFirstStepIndex() == 5){
|
|
// User.setFirstStepIndex(6)
|
|
// }else if(User.getFirstStepIndex() == 7){
|
|
// User.setFirstStepIndex(8)
|
|
// }
|
|
//任务倒爷
|
|
this.refreshView()
|
|
|
|
this.scheduleOnce(() => {
|
|
let node_: cc.Node = this.contentLayout.children[0]
|
|
if (node_) {
|
|
this.showFirst(node_.getChildByName('lay'))
|
|
}
|
|
|
|
}, 0.1)
|
|
|
|
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
|
|
let mainId = mainTaskInfo.Id
|
|
if (mainId == MainTaskIdEnum.MainTask_404) {
|
|
if (BagManager.getBagGoodNums(3012) > 0 && BagManager.getBagGoodNums(3013) > 0 &&
|
|
BagManager.getBagGoodNums(3014) > 0 && BagManager.getBagGoodNums(3015) > 0) {
|
|
let node = this.node.getChildByName('shougouNode').getChildByName("jiaohuoBtn");
|
|
this.guideView([node]);
|
|
}
|
|
}
|
|
|
|
}
|
|
guideView(nodeArray) {
|
|
PrefabManage.loadPrefabByType(GameType.GuideMskNode, this.node, (prefab) => {
|
|
let guideNodeArray = nodeArray
|
|
let firstNode = guideNodeArray.shift()
|
|
prefab.getComponent(NewGuideScript).setBindNode(firstNode, guideNodeArray)
|
|
})
|
|
}
|
|
refreshView() {
|
|
this.contentLayout.removeAllChildren()
|
|
this.contentLayout.destroyAllChildren()
|
|
this.allPriceNum = 0
|
|
let daoyeGoodList = InterfaceManager.getDaoyeList()
|
|
if (daoyeGoodList.length > 0) {
|
|
this.dingDanMing.string = BagManager.getJuQingGoodConfig(daoyeGoodList[0].goodId).chanQu
|
|
let index = User.getDaoyeIndex()
|
|
this.qiPaoRichText.string = QiPaoStrTab[index - 1]
|
|
}
|
|
|
|
for (let i = 0; i < daoyeGoodList.length; i++) {
|
|
|
|
if (daoyeGoodList[i].buyPercent) {
|
|
this.startBuyPercent = daoyeGoodList[i].buyPercent
|
|
}
|
|
|
|
let node_: cc.Node = cc.instantiate(this.iconNode)
|
|
node_.active = true
|
|
node_.parent = this.contentLayout
|
|
if (this.isTask) {
|
|
this.taskRefeshNode(node_, daoyeGoodList[i].goodId)
|
|
} else {
|
|
this.comRefeshNode(node_, daoyeGoodList[i].goodId)
|
|
}
|
|
node_.attr({ goodId: daoyeGoodList[i].goodId })
|
|
node_.getChildByName('lay').attr({ goodId: daoyeGoodList[i].goodId })
|
|
}
|
|
|
|
|
|
this.allPrice.string = '收购总价:' + Common5.getNumberChangeHanzi(this.allPriceNum, '1', 1)
|
|
}
|
|
|
|
|
|
taskRefeshNode(node_, goodId) {
|
|
let goodConfig = BagManager.getGoodsProperty(goodId)
|
|
let userGoodData = BagManager.getBagGoodConfig(goodId)
|
|
|
|
let name = goodConfig.goodName
|
|
let buyNum = goodConfig.buyNum
|
|
|
|
let haveNum = 0
|
|
if (userGoodData) {
|
|
haveNum = userGoodData.goodNum
|
|
}
|
|
|
|
let nameLab = node_.getChildByName('lay').getChildByName('name').getComponent(cc.Label)
|
|
let numLab = node_.getChildByName('num').getComponent(cc.RichText)
|
|
|
|
|
|
nameLab.string = name
|
|
if (haveNum >= buyNum) {
|
|
numLab.string = '<color=#67C119>' + buyNum + '</c><color=#67C119>/' + buyNum + '</color>'
|
|
} else {
|
|
this.isCanJiaohuo = false
|
|
numLab.string = '<color=#D65C44>' + haveNum + '</c><color=#67C119>/' + buyNum + '</color>'
|
|
}
|
|
|
|
}
|
|
|
|
comRefeshNode(node_, goodId) {
|
|
let goodConfig = BagManager.getGoodsProperty(goodId)
|
|
let userGoodData = BagManager.getBagGoodConfig(goodId)
|
|
|
|
let name = goodConfig.goodName
|
|
let buyNum = goodConfig.buyNum
|
|
let priceNum = goodConfig.priceNum
|
|
let percentNum = this.startBuyPercent
|
|
let shougoujia = priceNum//Math.floor(priceNum*percentNum/100+priceNum)
|
|
let allPrice = shougoujia * buyNum
|
|
this.allPriceNum += allPrice
|
|
let haveNum = 0
|
|
if (userGoodData) {
|
|
haveNum = userGoodData.goodNum
|
|
}
|
|
|
|
let nameLab = node_.getChildByName('lay').getChildByName('name').getComponent(cc.Label)
|
|
let numLab = node_.getChildByName('num').getComponent(cc.RichText)
|
|
let priceLab = node_.getChildByName('lay2').getChildByName('price').getComponent(cc.Label)
|
|
let percentLab = node_.getChildByName('lay2').getChildByName('percent').getComponent(cc.Label)
|
|
let shougoujiaLab = node_.getChildByName('shougoujia').getComponent(cc.Label)
|
|
|
|
nameLab.string = name
|
|
if (haveNum >= buyNum) {
|
|
numLab.string = '<color=#67C119>' + buyNum + '</c><color=#67C119>/' + buyNum + '</color>'
|
|
} else {
|
|
this.isCanJiaohuo = false
|
|
numLab.string = '<color=#D65C44>' + haveNum + '</c><color=#67C119>/' + buyNum + '</color>'
|
|
}
|
|
|
|
priceLab.string = Common5.getNumberChangeHanzi(priceNum, '1', 1) + ''
|
|
percentLab.string = percentNum + '%'
|
|
shougoujiaLab.string = Common5.getNumberChangeHanzi(shougoujia, '1', 1) + ''
|
|
}
|
|
|
|
showFirst(target) {
|
|
let goodId = target.goodId
|
|
let wenhao = target.getChildByName('问号')
|
|
let huoYuan = BagManager.getJuQingGoodConfig(goodId).huoYuan//InterfaceManager.getGoodInGame(goodId)
|
|
|
|
this.huoyuanNode.active = true
|
|
this.huoyuanNode.getChildByName('lab').getComponent(cc.Label).string = huoYuan
|
|
|
|
let posi = Common5.getNodeToTargetPos(this.huoyuanNode, wenhao)
|
|
this.huoyuanNode.setPosition(cc.v2(posi.x + 10, posi.y + 65))
|
|
|
|
}
|
|
|
|
clickHuoyuan(event) {
|
|
let target = event.target
|
|
let goodId = target.goodId
|
|
let wenhao = target.getChildByName('问号')
|
|
let huoYuan = BagManager.getJuQingGoodConfig(goodId).huoYuan//InterfaceManager.getGoodInGame(goodId)
|
|
|
|
this.huoyuanNode.active = true
|
|
this.huoyuanNode.getChildByName('lab').getComponent(cc.Label).string = huoYuan
|
|
|
|
let posi = Common5.getNodeToTargetPos(this.huoyuanNode, wenhao)
|
|
this.huoyuanNode.setPosition(cc.v2(posi.x + 10, posi.y + 65))
|
|
|
|
this.huoyuanNode.stopAllActions()
|
|
cc.tween(this.huoyuanNode)
|
|
.show()
|
|
.delay(3.0)
|
|
.hide()
|
|
.start()
|
|
}
|
|
|
|
|
|
tihuoClickEvent() {
|
|
if (this.isCanJiaohuo) {
|
|
let daoyeGoodList = User.getDaoyeGoodList()
|
|
for (let i = 0; i < daoyeGoodList.length; i++) {
|
|
let buyNum = daoyeGoodList[i].buyNum
|
|
let goodId = daoyeGoodList[i].goodId
|
|
BagManager.subBagList(goodId, buyNum)
|
|
}
|
|
let list = []
|
|
User.setDaoyeGoodList(list)
|
|
User.setDaoyeJiaoHuo(true)
|
|
User.setDaoyeShuaXin(0)
|
|
|
|
if (this.isYuanBaoJieSuan) {
|
|
UserManager.addYuanBao(this.allPriceNum)
|
|
} else {
|
|
UserManager.addMoney(this.allPriceNum)
|
|
}
|
|
EventMgr.emitEvent_custom(ryw_Event.updateDaoYe);
|
|
|
|
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
|
|
let mainId = mainTaskInfo.Id
|
|
if (mainId == MainTaskIdEnum.MainTask_404) {
|
|
TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_404)
|
|
TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_405)
|
|
User.setRoomBtnIndex(4)
|
|
} else if (mainId == MainTaskIdEnum.MainTask_707) {
|
|
// TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_707)
|
|
// TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_708)
|
|
} else if (mainId == MainTaskIdEnum.MainTask_907) {
|
|
// TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_907)
|
|
// TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_908)
|
|
} else if (mainId == MainTaskIdEnum.MainTask_1602) {
|
|
// TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_1602)
|
|
// TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_1603)
|
|
} else if (mainId == MainTaskIdEnum.MainTask_2004) {
|
|
// TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_2004)
|
|
// TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_2005)
|
|
}
|
|
|
|
this.node.removeFromParent()
|
|
this.node.destroy()
|
|
|
|
// if(MaoYiFenHongManager.checkIsZhiDingTask()){
|
|
PrefabManage.loadPrefabByType(GameType.MaoYiFenHong, null, (prefabNode) => {
|
|
prefabNode.getComponent(MaoYiFenHong).initView(0)
|
|
})
|
|
// }
|
|
|
|
} else {
|
|
PrefabManage.showTextTips('数量不够交货')
|
|
}
|
|
}
|
|
tihuoTaskClickEvent() {
|
|
if (this.isCanJiaohuo) {
|
|
let daoyeGoodList = User.getDaoyeGoodList()
|
|
for (let i = 0; i < daoyeGoodList.length; i++) {
|
|
let buyNum = daoyeGoodList[i].buyNum
|
|
let goodId = daoyeGoodList[i].goodId
|
|
BagManager.subBagList(goodId, buyNum)
|
|
}
|
|
let list = []
|
|
User.setDaoyeGoodList(list)
|
|
User.setDaoyeJiaoHuo(true)
|
|
User.setDaoyeShuaXin(0)
|
|
|
|
// let subTaskInfo:any = TaskManager.getCurUnLockSubTaskInfo()
|
|
// let mainTaskInfo:any = TaskManager.getCurUnLockMainTaskInfo()
|
|
// let mainId = mainTaskInfo.Id
|
|
|
|
// //解锁DH_12
|
|
// if(mainId == MainTaskIdEnum.MainTask_204){
|
|
// JuQingManager.unLockNewJuQing('DH_12')
|
|
// }
|
|
|
|
this.node.removeFromParent()
|
|
this.node.destroy()
|
|
} else {
|
|
PrefabManage.showTextTips('数量不够交货')
|
|
}
|
|
}
|
|
|
|
yijiaClickEvent() {
|
|
// Common5.playEffect("sound/按键点击")
|
|
if (this.startBuyPercent >= 410) {
|
|
PrefabManage.showTextTips('已经是最大议价')
|
|
return
|
|
}
|
|
let tab = {
|
|
onClose: (finish) => {
|
|
if (finish) {
|
|
Common5.ReportDY("inLevel", '倒爷-AD-加价出售');
|
|
|
|
this.startBuyPercent += 80
|
|
let daoyeGoodList = User.getDaoyeGoodList()
|
|
for (let i = 0; i < daoyeGoodList.length; i++) {
|
|
daoyeGoodList[i].buyPercent = this.startBuyPercent
|
|
}
|
|
User.setDaoyeGoodList(daoyeGoodList)
|
|
|
|
this.refreshView()
|
|
}
|
|
else {
|
|
this.reportKey(() => {
|
|
GameReport.ADReport('加价出售', 0)
|
|
})
|
|
Common5.showTips_custom("广告未观看完");
|
|
}
|
|
|
|
}, onFailed: () => {
|
|
|
|
}
|
|
}
|
|
AppPlatform.playVideo_custom(tab)
|
|
}
|
|
|
|
refreshViewAddPrice() {
|
|
|
|
//this.allPriceNum = 0
|
|
let daoyeGoodList = User.getDaoyeGoodList()
|
|
|
|
|
|
|
|
let tempIndex = 0
|
|
let tempPrice = 0
|
|
let arrayList = null
|
|
console.log(this.allPriceNum, 'this.allPriceNum ++++++===')
|
|
while (tempPrice < this.allPriceNum) {
|
|
//
|
|
if (tempIndex >= 50) {
|
|
console.log('没有比这个高的了')
|
|
break
|
|
}
|
|
let list = InterfaceManager.getDaoyeList()
|
|
tempPrice = 0
|
|
arrayList = list
|
|
for (let i = 0; i < list.length; i++) {
|
|
let goodConfig = BagManager.getGoodsProperty(list[i].goodId)
|
|
let buyNum = goodConfig.buyNum
|
|
let priceNum = goodConfig.priceNum
|
|
let percentNum = this.startBuyPercent
|
|
let shougoujia = Math.floor(priceNum * percentNum / 100 + priceNum)
|
|
let allPrice = shougoujia * buyNum
|
|
tempPrice += allPrice
|
|
}
|
|
|
|
|
|
|
|
tempIndex++
|
|
console.log(tempPrice, 'tempPrice++++++===')
|
|
console.log(tempIndex, 'tempIndex++++++===')
|
|
}
|
|
|
|
this.allPriceNum = 0
|
|
let tempList = []
|
|
for (let i = 0; i < arrayList.length; i++) {
|
|
let obj = {
|
|
goodId: arrayList[i].goodId,
|
|
buyNum: arrayList[i].buyNum,
|
|
buyPercent: 10,
|
|
gameType: arrayList[i].gameType
|
|
}
|
|
// obj.goodId = arrayList[i].goodId
|
|
// obj.buyNum = BagManager.getGoodsProperty(arrayList[i].goodId).buyNum
|
|
tempList[tempList.length] = obj
|
|
}
|
|
User.setDaoyeJiaoHuo(false)
|
|
User.setDaoyeGoodList(tempList)
|
|
daoyeGoodList = tempList
|
|
|
|
|
|
|
|
this.contentLayout.removeAllChildren()
|
|
this.contentLayout.destroyAllChildren()
|
|
for (let i = 0; i < daoyeGoodList.length; i++) {
|
|
|
|
if (daoyeGoodList[i].buyPercent) {
|
|
this.startBuyPercent = daoyeGoodList[i].buyPercent
|
|
}
|
|
|
|
let node_: cc.Node = cc.instantiate(this.iconNode)
|
|
node_.active = true
|
|
node_.parent = this.contentLayout
|
|
if (this.isTask) {
|
|
this.taskRefeshNode(node_, daoyeGoodList[i].goodId)
|
|
} else {
|
|
this.comRefeshNode(node_, daoyeGoodList[i].goodId)
|
|
}
|
|
node_.attr({ goodId: daoyeGoodList[i].goodId })
|
|
node_.getChildByName('lay').attr({ goodId: daoyeGoodList[i].goodId })
|
|
}
|
|
|
|
|
|
this.allPrice.string = '收购总价:' + Common5.getNumberChangeHanzi(this.allPriceNum, '1', 1)
|
|
|
|
}
|
|
|
|
|
|
refreshShouGouList() {
|
|
// Common5.playEffect("sound/按键点击")
|
|
|
|
let daoyeRefreshIndex = User.getDaoyeShuaXin()
|
|
if (daoyeRefreshIndex >= 3) {
|
|
PrefabManage.showTextTips('已达最大刷新次数,提交订单可以重置刷新次数')
|
|
return
|
|
}
|
|
let tab = {
|
|
onClose: (finish) => {
|
|
if (finish) {
|
|
Common5.ReportDY("inLevel", '倒爷-AD-刷新收购单');
|
|
|
|
daoyeRefreshIndex++
|
|
User.setDaoyeShuaXin(daoyeRefreshIndex)
|
|
User.setDaoyeJiaoHuo(false)
|
|
let tempList = []
|
|
|
|
User.setDaoyeGoodList(tempList)
|
|
//刷新收购单加价
|
|
this.refreshViewAddPrice()
|
|
this.scheduleOnce(() => {
|
|
let node_: cc.Node = this.contentLayout.children[0]
|
|
if (node_) {
|
|
this.showFirst(node_.getChildByName('lay'))
|
|
}
|
|
}, 0.1)
|
|
}
|
|
else {
|
|
this.reportKey(() => {
|
|
GameReport.ADReport('倒爷刷新收购单', 0)
|
|
})
|
|
Common5.showTips_custom("广告未观看完");
|
|
}
|
|
|
|
}, onFailed: () => {
|
|
|
|
}
|
|
}
|
|
AppPlatform.playVideo_custom(tab)
|
|
}
|
|
}
|
|
|