开局破防了
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.

591 lines
20 KiB

2 months ago
import EventMgr from "../../../FrameWork/Event/EventMgr";
import { ryw_Event } from "../../../FrameWork/Event/EventEnum";
import Common5 from "../../../Platform/th/Common5";
import Game from "../../../Scripts/Game";
import Common from "../../../FrameWork/Util/Common";
import DaDianScript from "../../../FrameWork/Base/DaDianScript";
import WordGameBaseComponent from "../../../FrameWork/Base/WordGameBaseComptent";
const {ccclass, property} = cc._decorator;
enum PeopleStatus{
jupang,
zhongpang,
jushou,
}
// "toolTip": "1.将钱拖动到三轮车\n2.将钱拖动到柴火堆",
// "answer": "n\n\n7.将爷爷拖动到垃圾桶上\n8.爷爷拖动到垃圾桶上之后,再将钱拖动到垃圾桶上\n\n\n\n\n13.将钱拖动到右墙\n14.将钱拖动到墙上的海报\n15.将钱拖动到老鼠洞\n16.将钱拖动到鸡身上",
let answer = [
'将电视桌上的玫瑰拖到浴缸里,再把人物拖到浴缸里', //0
'将吸尘器拖动到人身上',//1
'将菜刀拖动到人物腋毛处',//2
'将割下的腋毛拖动到缝纫机上,变成假发后拖动给女生',//3
'将织毛衣拖动女生腿上',//4
'将遥控器拖动到电视机上',//5
'将刀拖动到墙上的裂缝处,刮下石灰后将石灰拖给女生脸上',//6
'将剪刀拖动到墙上海报处剪下衣服后,将衣服拖给女生',//7
]
let duihuaConfig = [
'我定要把前男友的未婚妻比下去',
'还是瑜伽垫睡着舒服,不管了,先睡一觉',
'随便一个淡妆都这么好看',
'物理减肥效果真好',
'洗完澡身上都是玫瑰香',
'现在舒服多了',
'曾经你对我爱答不理,如今的我让你高攀不起',
'这不得将他们拿捏',
'这个发型太适合我了',
'这么帅的教练,我感觉浑身充满了力量',
]
//
// '我现在还穿不下',
@ccclass
export default class ChouNvNiXI extends WordGameBaseComponent{
@property(cc.Node)
maskNode:cc.Node = null;
@property(cc.Node)
mapNode:cc.Node = null;
@property(cc.Node)
yemao1:cc.Node = null;
@property(cc.Node)
yemao2:cc.Node = null;
gameInfo = null
bundle = null
mapNodeFixedScale:number = 0.6//固定缩放(图片太大了)
touchStartTime:number = 0//触摸开始时间
originalTouchDistance:number = 0 //起始双指触摸间距
lastScale:number = 1//上次缩放值
curScale:number = 1//当前缩放值
touchId1:number = -1
touchId2:number = -2
curFinishNum:number = 0
isStepRight:boolean = true
isKaiChuang:boolean = false
yeyeMove = false
yeyeAnmo: boolean = false;
nainaiIsTang = false
isAnmoNan: boolean = false;
doorGetMoney = false
chadianMax = 13
curPeopleState = PeopleStatus.jupang
isGuaTuimao = false
isGuaYeMao = false
isXiZao = false
isFaceDouDou = false
ischeck = true;
iscaidaoGuahui = false
iscaidaoYemao = false
dtTime: number=0;
onLoad(){
DaDianScript.userEnterDaDian()
Common.Type = 3;
Common.subLevel = 0;
Common.GameSubTipConfigs=answer//[Common5.gameConfig.zmGameConfig[Common5.selectGameNum].toolTip]
// Common.GameSubAnswerConfigs=[Common5.gameConfig.zmGameConfig[Common5.selectGameNum].answer]
this.bundle = Common5.gameConfig.zmGameConfig[Common5.selectGameNum].bundle
EventMgr.onEvent_custom(ryw_Event.timeOut, (tab) => {
Game.ins.showFail();
}, this);
}
start(){
super.start();
cc.macro.ENABLE_MULTI_TOUCH = true;
this.initMapNodeTouchEvent()
// Common5.playMusicCustom('pingkurenjia','sound/背景音')
this.mapNode.getChildByName('手机').active = true
EventMgr.onEvent_custom(ryw_Event.DirectTouchMoveCheck, (data_) => {
}, this);
EventMgr.onEvent_custom(ryw_Event.NormalTouchEndCheck, (data_) => {
}, this);
EventMgr.onEvent_custom(ryw_Event.NormalTouchMoveCheck, (data_) => {
this.normalTouchCallback(data_.targetNode);
}, this);
Common5.playEffectCustom("chounvnixi", 'sound/手机提示音');
}
normalTouchCallback(targetNode){
if( targetNode.name == '瑜伽垫卷'){
//this.showQiPao('还是瑜伽垫睡着舒服,不管了,先睡一觉')
Common5.playEffectCustom("chounvnixi", "sound/chounvnixi/还是瑜伽垫睡着舒服,不管了,先睡一觉");
this.scheduleOnce(()=>{
Game.ins.showFail();
},2.0)
}else if( targetNode.name == '花朵1'){
this.mapNode.getChildByName('浴缸spine').active = true
this.mapNode.getChildByName('浴缸spine').getComponent(sp.Skeleton).setAnimation(0, '玫瑰', false)
}else if( targetNode.name == 'renwu'){
this.unlockLevel(0)
this.mapNode.getChildByName('浴缸spine').active = true
this.mapNode.getChildByName('浴缸spine').getComponent(sp.Skeleton).setAnimation(0, '洗澡', false)
this.mapNode.getChildByName('浴缸spine').getComponent(sp.Skeleton).setCompleteListener(()=>{
this.mapNode.getChildByName('renwu1').getChildByName('renwu').active = true
this.showQiPao('洗完澡身上都是玫瑰香')
})
this.isXiZao = true
}else if( targetNode.name == '菜刀'){
let checkNode = targetNode.checkNode
if(checkNode.name == 'yemaoCheck'){
if(this.iscaidaoYemao){
this.mapNode.getChildByName('菜刀').active = true
return
}
Common5.playEffectCustom("chounvnixi", 'sound/刀割腋毛');
this.iscaidaoYemao = true
//腋毛动画
this.mapNode.getChildByName('菜刀腋毛spine').active = true
this.scheduleOnce(()=>{
this.mapNode.getChildByName('菜刀腋毛spine').active = false
let yamaoMove = this.mapNode.getChildByName('腋毛move')
let posi = Common5.getNodeToTargetPos(this.yemao1, yamaoMove )
cc.tween(this.yemao1)
.to(1,{x:posi.x, y:posi.y, angle:720})
.call(()=>{
this.yemao1.active = false
})
.start()
let posi2 = Common5.getNodeToTargetPos(this.yemao2, yamaoMove )
cc.tween(this.yemao2)
.to(1,{x:posi2.x, y:posi2.y, angle:720})
.call(()=>{
this.yemao2.active = false
})
.start()
this.scheduleOnce(()=>{
yamaoMove.active = true
},1.1)
this.mapNode.getChildByName('菜刀').active = true
this.showQiPao('现在舒服多了')
this.unlockLevel(2)
},2.0)
}else if(checkNode.name == 'qiangpiCheck'){
//墙壁灰动画
if(this.iscaidaoGuahui){
this.mapNode.getChildByName('菜刀').active = true
return
}
Common5.playEffectCustom("chounvnixi", 'sound/刀割腋毛');
this.iscaidaoGuahui = true
this.mapNode.getChildByName('菜刀灰spine').active = true
this.scheduleOnce(()=>{
this.mapNode.getChildByName('菜刀灰spine').active = false
let shihuiMove:cc.Node = this.mapNode.getChildByName('石灰move')
let shihui = this.mapNode.getChildByName('石灰')
shihui.active = true
shihui.scale = 0.5
cc.tween(shihui)
.to(1,{x:shihuiMove.getPosition().x, y:shihuiMove.getPosition().y ,scale:1})
.call(()=>{
shihui.active = false
shihuiMove.active = true
})
.start()
this.mapNode.getChildByName('菜刀').active = true
},2.0)
}
}else if(targetNode.name == '腋毛move'){
let zhuozi = this.mapNode.getChildByName('缝纫机桌子')
zhuozi.active = true
console.log('缝纫机桌子')
cc.tween(zhuozi)
.to(0.1, {angle:-5})
.to(0.1, {angle:5})
.union()
.repeat(5)
.call(()=>{
zhuozi.angle = 0
this.mapNode.getChildByName('假发').active = true
})
.start()
}else if(targetNode.name == '电视遥控器'){
this.mapNode.getChildByName('教练spine').active = true
this.mapNode.getChildByName('教练spine').getComponent(sp.Skeleton).setAnimation(0, '登场', false)
this.mapNode.getChildByName('教练spine').getComponent(sp.Skeleton).setCompleteListener(()=>{
this.mapNode.getChildByName('教练check').active = true
})
}else if(targetNode.name == '吸尘器'){
this.unlockLevel(1)
this.scheduleOnce(()=>{
this.refreshPeopleStates()
this.showQiPao('物理减肥效果真好')
this.mapNode.getChildByName('吸尘器spine').active = false
},2.0)
}else if(targetNode.name == '剪刀'){
this.scheduleOnce(()=>{
this.mapNode.getChildByName('剪刀spine').active = false
let qunzi = this.mapNode.getChildByName('裙子')
let qunziMove = this.mapNode.getChildByName('裙子move')
qunzi.active = true
this.mapNode.getChildByName('海报').active = false
this.mapNode.getChildByName('海报裁剪').active = true
cc.tween(qunzi)
.to(1,{x:qunziMove.getPosition().x, y:qunziMove.getPosition().y ,scale:0.8})
.call(()=>{
qunzi.active = false
qunziMove.active = true
})
.start()
},2.0)
}else if(targetNode.name == '石灰move'){
this.isFaceDouDou = true
this.unlockLevel(6)
this.showQiPao('随便一个淡妆都这么好看')
}else if(targetNode.name == '毛线球'){
this.isGuaTuimao = true
this.showQiPao('这不得将他们拿捏')
this.unlockLevel(4)
}else if(targetNode.name == '假发'){
this.isGuaYeMao = true
this.unlockLevel(3)
this.showQiPao('这个发型太适合我了')
}else if(targetNode.name == '裙子move'){
let checkNode = targetNode.checkNode
if(checkNode.name == 'renwuCheck' && this.ischeck == false){
this.mapNode.getChildByName('renwu1').active = false
this.mapNode.getChildByName('完美状态').active = true
this.unlockLevel(7)
this.showQiPao('曾经你对我爱答不理,如今的我让你高攀不起')
this.scheduleOnce(()=>{
this.showQiPao('渣男,看我不让你后悔死')
this.scheduleOnce(()=>{
Game.ins.showSuccess()
},3.0)
},4.0)
}else{
this.showQiPao('我现在还穿不下')
this.mapNode.getChildByName('裙子move').active = true
}
}
}
//初始化触摸监听
initMapNodeTouchEvent(){
this.initMouseEvent();
this.mapNode.on(cc.Node.EventType.TOUCH_START, this.touchStart_mapNode,this)
this.mapNode.on(cc.Node.EventType.TOUCH_MOVE, this.touchMove_mapNode,this)
this.mapNode.on(cc.Node.EventType.TOUCH_CANCEL, this.touchEnd_mapNode,this)
this.mapNode.on(cc.Node.EventType.TOUCH_END, this.touchEnd_mapNode,this)
let prefabWidth = this.mapNode.width
let prefabHeight = this.mapNode.height
let maskWidth = this.maskNode.width
let maskHeight = this.maskNode.height
let widthScale = maskWidth/prefabWidth
let heightScale = maskHeight/prefabHeight
if(prefabWidth<prefabHeight){
this.mapNodeFixedScale = widthScale
}else{
this.mapNodeFixedScale = heightScale
}
this.mapNode.scale = this.mapNodeFixedScale
this.curScale = this.mapNodeFixedScale
this.lastScale = this.mapNodeFixedScale
}
touchStart_mapNode(event){
Common5.playEffect("click")
if(this.touchId1 < 0){
this.touchId1 = event.touch.getID()
}else if(this.touchId2 < 0){
this.touchId2 = event.touch.getID()
}
if(this.touchId1 >= 0 && this.touchId2 >= 0){
// console.log("邵阳1—双点触摸开始")
}
this.touchStartTime = Date.now()
}
touchMove_mapNode(event){
let touches = event.getTouches()
if(touches.length == 2){ //缩放
if(this.originalTouchDistance == 0){
this.originalTouchDistance = this.getDistance(touches[0].getLocation(),touches[1].getLocation())
}
//获取双指移动数据
let curDistance = this.getDistance(touches[0].getLocation(),touches[1].getLocation())
let tempScale = curDistance/this.originalTouchDistance
let y = 0.5*tempScale + 0.5
let scale = y * this.lastScale
if(scale < this.mapNodeFixedScale){
scale = this.mapNodeFixedScale
}else if(scale > 3){
scale = 3
}else{
}
this.mapNode.scale = scale
this.curScale = scale
this.goToBoundary();
}else if(touches.length == 1){ //拖动
let delta = event.getDelta()
this.mapNode.x += delta.x
this.mapNode.y += delta.y
// console.log(this.mapNode.scale,this.mapNode.x,this.mapNode.y);
this.goToBoundary()
}
}
touchEnd_mapNode(event){
console.log('touchEnd===')
let dateNow = Date.now()
if(dateNow - this.touchStartTime > 0.2 * 1000){
}else{
// this.isFind = false;
let touchPos = event.getLocation();
this.checkIsInAreaNewVersion(touchPos)
}
if(event.touch.getID() == this.touchId1){
this.touchId1 = -1
}else if(event.touch.getID() == this.touchId2){
this.touchId2 = -2
}
if(this.touchId1 < 0 && this.touchId2 < 0){
this.originalTouchDistance = 0
this.lastScale = this.curScale
// this.goToBoundary()
}
}
//距离
getDistance(startPos,endPos){
var pos = cc.v2(startPos.x - endPos.x,startPos.y - endPos.y)
var dis = Math.sqrt(pos.x * pos.x + pos.y * pos.y)
return dis
}
//检测边界
goToBoundary(){
let widthMask = this.maskNode.width
let heightMask = this.maskNode.height
let widthMap = this.mapNode.width*this.curScale
let heightMap = this.mapNode.height*this.curScale
//右边界
if(this.mapNode.x + widthMap/2 <= widthMask/2){
this.mapNode.x = widthMask/2 - widthMap/2
//左边界
}else if(this.mapNode.x - widthMap/2>= -widthMask/2){
this.mapNode.x = -widthMask/2 + widthMap/2
}
//上边界
if(this.mapNode.y + heightMap/2 <= heightMask/2){
this.mapNode.y = heightMask/2 - heightMap/2
//下边界
}else if(this.mapNode.y - heightMap/2 >= -heightMask/2){
this.mapNode.y = -heightMask/2 + heightMap/2
}
}
initMouseEvent(){
this.mapNode.on(cc.Node.EventType.MOUSE_WHEEL,function(event){//监听名称+事件参数
console.log(event);
let tmpscale = this.mapNode.scale;
if (event._scrollY > 0){
if (this.mapNode.scale < 3){
tmpscale+=0.2;
this.mapNode.scale = tmpscale
this.curScale = tmpscale
this.lastScale = tmpscale
}
}
else {
if (this.mapNode.scale > this.mapNodeFixedScale){
tmpscale-=0.2;
this.mapNode.scale = tmpscale
this.curScale = tmpscale
this.lastScale = tmpscale
}
}
// console.log(this.mapNode.scale,this.mapNode.x,this.mapNode.y);
this.goToBoundary();
},this);
}
//检测node是否进入target区域(新版)
checkIsInAreaNewVersion(pos){
}
showQiPao(str){
let qipaoNode = this.mapNode.getChildByName('气泡框2')
qipaoNode.scale = 0
qipaoNode.active = true
qipaoNode.stopAllActions()
qipaoNode.getChildByName("lab").getComponent(cc.Label).string = str
if (str) {
Common5.playEffectCustom("chounvnixi", "sound/chounvnixi/"+str);
}
cc.tween(qipaoNode)
.to(0.2,{scale:1})
.call(()=>{
})
.delay(2)
.to(0.2,{scale:0})
.start()
}
checkIsFinish(){
if(this.curFinishNum >= this.chadianMax){
console.log('结算+++===')
this.scheduleOnce(()=>{
if(this.curFinishNum >= this.chadianMax){
if(this.isStepRight){
Game.ins.showSuccess()
}else{
Game.ins.showFail()
}
}
},3.0)
}
}
unlockLevel(sublevel){
Game.ins.tipUnlock(sublevel)
}
clickPeople(){
this.mapNode.getChildByName('手机').active = false
this.showQiPao('我定要把前男友的未婚妻比下去')
}
clickJiaolianPeople(){
this.mapNode.getChildByName('教练spine').active = false
this.mapNode.getChildByName('教练check').active = false
this.refreshPeopleStates()
this.unlockLevel(5)
this.showQiPao('这么帅的教练,我感觉浑身充满了力量')
}
refreshPeopleStates(){
if(this.curPeopleState == PeopleStatus.jupang){
this.curPeopleState = PeopleStatus.zhongpang
this.mapNode.getChildByName('renwu1').getChildByName('renwu').getChildByName('胖').active = false
this.mapNode.getChildByName('renwu1').getChildByName('renwu').getChildByName('中胖').active = true
this.mapNode.getChildByName('renwu1').getChildByName('renwu').getChildByName('换衣服前瘦').active = false
}else if(this.curPeopleState == PeopleStatus.zhongpang){
this.curPeopleState = PeopleStatus.jushou
this.mapNode.getChildByName('renwu1').getChildByName('renwu').getChildByName('胖').active = false
this.mapNode.getChildByName('renwu1').getChildByName('renwu').getChildByName('中胖').active = false
this.mapNode.getChildByName('renwu1').getChildByName('renwu').getChildByName('换衣服前瘦').active = true
//腋毛
this.yemao1.active = false
}
}
protected update(dt: number): void {
if(this.ischeck){
this.dtTime+=dt
if(this.dtTime>=0.1){
this.dtTime = 0
if(this.curPeopleState == PeopleStatus.jushou && this.isFaceDouDou && this.isGuaTuimao && this.isGuaYeMao && this.isXiZao){
this.mapNode.getChildByName('renwulanCheck').active = false
this.mapNode.getChildByName('renwuCheck').active = true
this.mapNode.getChildByName('yujiaCheck').active = false
this.ischeck = false
}
}
}
}
}