import WaiMaiQingDan_Config from "./WaiMaiQingDan_Config"; import Common5 from "../../../Platform/th/Common5"; import EventMgr from "../../../FrameWork/Event/EventMgr"; import { ryw_Event } from "../../../FrameWork/Event/EventEnum"; import Game from "../../../Scripts/Game"; import Common from "../../../FrameWork/Util/Common"; const {ccclass, property} = cc._decorator; enum CaiDanStatus{ Up, Down } @ccclass export default class WaiMaiQingDan extends cc.Component { gameId:number = 0; gameInfo = null; touchZIdex = 999; curDanHao = 0;//当前单号 onLoad () { Common.Type = 0; Common.subLevel = 0; Common.GameSubTipConfigs=[Common5.gameConfig.zmGameConfig[Common5.selectGameNum].toolTip] Common.GameSubAnswerConfigs=[Common5.gameConfig.zmGameConfig[Common5.selectGameNum].answer] EventMgr.onEvent_custom(ryw_Event.timeOut, (tab) => { Game.ins.showFail(); }, this); this.gameId = Common5.gameConfig.zmGameConfig[Common5.selectGameNum].gameId this.gameInfo = WaiMaiQingDan_Config.getInstance().getGoodsInfo(this.gameId) } start () { this.initAllGoodsInfo() } //初始化所有物品 initAllGoodsInfo(){ let goodsNodeTab = this.node.getChildByName("goodsNode").children for(var i=0;i{ composeSpine.active = false }) } //检查是否合成后的物品还可以合成(是的话,更改合成后的属性) checkIsCanComposeAgain(targetNode,composeStr){ for(var key in this.gameInfo.GoodsNode){ if(this.gameInfo.GoodsNode[key].LinkName == composeStr){ targetNode.attributeTab.TypeName = composeStr targetNode.attributeTab.LinkName = this.gameInfo.GoodsNode[key].TypeName targetNode.attributeTab.ComposeStr = this.gameInfo.GoodsNode[key].ComposeStr targetNode.attributeTab.isFinishCompose = false return } } } //移动至外卖盒 moveToWaiMaiXiang(node,flagIndex){ let fixedArea = this.node.getChildByName("waiMaiXiangNode").getChildByName("fixedArea_"+this.curDanHao) this.moveToTargetPosInTime(node,fixedArea,flagIndex) } //指定时间移动到特定位置 moveToTargetPosInTime(curNode,targetNode,flagIndex){ let timeNum = 0.4 //目标节点的本地坐标 let targetLocalPos = targetNode.getPosition() //目标节点的世界坐标 let targetWorldPos = targetNode.parent.convertToWorldSpaceAR(targetLocalPos) //目标节点相对于当前节点父节点的本地坐标 let localPos = curNode.parent.convertToNodeSpaceAR(targetWorldPos) cc.tween(curNode) .to(timeNum,{x:localPos.x,y:localPos.y}) .call(()=>{ Common5.playEffect("success") this.setCaiDanBgUpOrDown(CaiDanStatus.Up) }) .delay(0.2) .call(()=>{ this.setCaiDanFlagVisible(flagIndex) }) .start() } //设置菜单上标记 setCaiDanFlagVisible(flagIndex){ this.node.getChildByName("caiDanNode").getChildByName("caiDanBg").getChildByName("selectFlag_"+flagIndex).active = true this.checkIsFinishTask() } checkIsFinishTask(){ this.curDanHao++ if(this.curDanHao >= this.gameInfo.CaiDanSum){ console.log("完成任务===") Game.ins.showSuccess(); } } setCaiDanBgUpOrDown(status){ let caiDanBg = this.node.getChildByName("caiDanNode").getChildByName("caiDanBg") let offsetY = 0 if(status == CaiDanStatus.Up){ offsetY = 0 }else if(status == CaiDanStatus.Down){ offsetY = -260 } cc.tween(caiDanBg) .to(0.3,{y:offsetY}) .start() } onClickKongBaiArea(){ this.setCaiDanBgUpOrDown(CaiDanStatus.Down) } onClickCaiDanArea(){ this.setCaiDanBgUpOrDown(CaiDanStatus.Up) } }