觉醒时刻
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.

735 lines
26 KiB

1 week ago
import { ryw_Event } from "../../FrameWork/Event/EventEnum";
import EventMgr from "../../FrameWork/Event/EventMgr";
import GameReport from "../../FrameWork/Report/ZyZyReport";
import AppPlatform from "../../FrameWork/Util/AppPlatform";
import { DateUtils } from "../../FrameWork/Util/DateUtils";
import Common5 from "../../Platform/th/Common5";
import TaskManager, { MainTaskIdEnum } from "../JuQingChat/TaskManager";
import { AutoShouYiConfig } from "../MainScene/CityPrefab";
import InterfaceManager from "../Manager/InterfaceManager";
import UserManager from "../Manager/UserManager";
import MeiNvZhaoMu from "../MeiNvZhaoMu/MeiNvZhaoMu";
import MeiNvZhaoMuManager, { ZhaoMuGameType } from "../MeiNvZhaoMu/MeiNvZhaoMuManager";
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
import GameBase from "../SCommon/GameBase";
import GetAward from "../SCommon/GetAward";
import DiaoYuConfigManage from "./DiaoYuConfigManage";
import DiaoYuManage from "./DiaoYuManage";
const {ccclass, property} = cc._decorator;
@ccclass
export default class DiaoYu extends GameBase {
@property(cc.Node)
tipsNode: cc.Node = null;
@property(cc.Node)
zhulanNode: cc.Node = null;
@property(cc.Node)
zhulanDialogNode: cc.Node = null;
@property(sp.Skeleton)
diaoYuSp: sp.Skeleton = null;
@property({type:cc.Node, tooltip:'普通鱼钩'})
yugouNode1: cc.Node = null;
@property({type:cc.Node, tooltip:'蚯蚓鱼钩'})
yugouNode2: cc.Node = null;
@property({type:cc.Node, tooltip:'鱼饵鱼钩'})
yugouNode3: cc.Node = null;
@property({type:cc.Node, tooltip:'猪肝鱼钩'})
yugouNode4: cc.Node = null;
@property({type:cc.Node, tooltip:'开始钓鱼'})
diaoyuKaishiNode: cc.Node = null;
@property({type:cc.Node, tooltip:'路亚'})
diaoyuLuyaNode: cc.Node = null;
@property(cc.Node)
zhaoMuNode: cc.Node=null;
wulianIndex = 0
currentYugou = '鱼饵'
_dt:number = 0
private dongxi = {
jingzhi: 'jingzhi',
chugan: 'chugan',
chuganhoudaiji: 'chuganhoudaiji',
lagan: 'lagan',
laganzhuan1: 'laganzhuan1',
laganzhuan2: 'laganzhuan2',
laganzhuan3: 'laganzhuan3',
qigan: 'qigan'
}
onDestroy(){
super.onDestroy()
}
onLoad () {
super.onLoad()
this.zhulanNode.active = false;
this.zhulanDialogNode.active = false;
this.zhulanOldPos = this.zhulanNode.getPosition();
}
start () {
Common5.playMusic("CommonRes/sound/稻田钓鱼背景");
this.btns_init();
this.diaoyuBtnInit();
this.refreshZhaoMuTime()
// this.scheduleOnce(this.zhulan_cb, 15);
this.showShouYiNode()
EventMgr.onEvent_custom(ryw_Event.refreshZhaoMuTimes,()=>{
this.showShouYiNode()
this.refreshZhaoMuTime()
},this)
}
zhunbeiTaiganTick = -1;
update (dt) {
this._dt += dt
if(this._dt >= 1.0){
this._dt = 0
this.refreshZhaoMuTime()
}
if(this.isZhunbeiTaigan){
if(this.zhunbeiTaiganTick == -1){
this.zhunbeiTaiganTick = 0
this.zhunbeiTaiganTick += dt;
//Common5.playEffectCustom('diaoyu','sound/钓鱼线瞎跑音效')
}else{
this.zhunbeiTaiganTick += dt;
if(this.zhunbeiTaiganTick >= 2.0){
this.zhunbeiTaiganTick = 0;
//Common5.playEffectCustom('diaoyu','sound/钓鱼线瞎跑音效')
}
}
}else{
this.zhunbeiTaiganTick = -1;
}
}
showShouYiNode(){
let index = 1
let localZhaoMuData = MeiNvZhaoMuManager.getMeiNvZhaoMuData()
let zhaoMuBeiShu = localZhaoMuData[index].zhaoMuBeiShu
let money = AutoShouYiConfig[index].money * zhaoMuBeiShu
this.node.getChildByName('shouYiNode').getChildByName('moneyStr').getComponent(cc.Label).string = `收益:${Common5.getNumberChangeHanzi(money,'1',1)}/秒`
}
zhulanOldPos = null;
zhulan_cb(){
this.zhulanNode.active = true;
this.zhulanNode.opacity = 0;
cc.tween(this.zhulanNode)
.to(1.0,{opacity:255})
.to(2.0,{x:-200, y:this.zhulanOldPos.y-100})
.start()
}
handleZhulan(){
Common5.playEffect("sound/按键点击")
this.reportKey(()=>{
GameReport.BtnsReport('竹篮')
})
this.zhulanNode.active = false;
this.zhulanNode.setPosition(this.zhulanOldPos);
this.zhulanDialogNode.active = true;
}
handleZhulanOpen(){
Common5.playEffect("sound/按键点击")
let tab = {
onClose: (finish)=>{
if (finish) {
Common5.ReportDY("inLevel", "钓鱼-AD-竹篮");
this.zhulanDialogNode.active = false;
let result = DiaoYuConfigManage.getGoodByProbability('竹篮', 1,true);
this.showResults(result);
// this.scheduleOnce(this.zhulan_cb, 15);
this.reportKey(()=>{
GameReport.ADReport('竹篮打开看看',1)
})
}
else{
this.reportKey(()=>{
GameReport.ADReport('竹篮打开看看',0)
})
Common5.showTips_custom("广告未观看完");
}
},onFailed:()=>{
}
}
AppPlatform.playVideo_custom(tab)
}
handleZhulanClose(){
Common5.playEffect("sound/按键点击")
this.zhulanDialogNode.active = false;
// this.scheduleOnce(this.zhulan_cb, 15);
this.reportKey(()=>{
GameReport.BtnsReport('狠心丢弃')
})
}
showResults(result){
let num = result.length;
let arr = []
let isHave1711 = false
for(let i=0;i<num;i++){
arr.push({goodId:result[i].goodId,goodNum: result[i].goodNum})
if(result[i].goodId == 1711){
isHave1711 = true
}
}
console.log(arr, 'arr++++++++====')
// console.log('邵阳123')
// arr = [{goodId:1740,goodNum:1},{goodId:1320,goodNum:1},{goodId:1314,goodNum:1},{goodId:1319,goodNum:1},{goodId:1322,goodNum:1}]
PrefabManage.loadPrefabByType(GameType.GetAward,null,(prefabNode)=>{
prefabNode.getComponent(GetAward).initView(arr, ()=>{
//完成任务525
let mainTaskInfo:any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
if(isHave1711 && mainId == MainTaskIdEnum.MainTask_525){
TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_525)
}
});
})
}
setYugouStatus(name){
let data = DiaoYuManage.getYuerByName(name);
let data1 = DiaoYuConfigManage.getDiaoyuYuerConfigByName(name);
let yugouNode = this.yugouNode1
let needTimes = 0;
if(name == '鱼钩'){
yugouNode = this.yugouNode1;
}
if(name == '蚯蚓'){
yugouNode = this.yugouNode2;
needTimes = 1;
}
if(name == '鱼饵'){
yugouNode = this.yugouNode3;
needTimes = 2
}
if(name == '猪肝'){
yugouNode = this.yugouNode4;
}
if(data.unlock){
yugouNode.getChildByName('sp').active = false;
yugouNode.getChildByName('price').active = true;
yugouNode.getChildByName('times').active = false;
yugouNode.getChildByName('price').getComponent(cc.Label).string = Common5.getNumberChangeHanzi(data1.price) + ''
if(data.freeTimes > 0){
yugouNode.getChildByName('times').active = true;
yugouNode.getChildByName('times').getComponent(cc.Label).string = '免费次数' + data.freeTimes;
}
}else{
yugouNode.getChildByName('sp').active = true;
yugouNode.getChildByName('price').active = false;
if(needTimes > 0){
yugouNode.getChildByName('times').active = true;
yugouNode.getChildByName('times').getComponent(cc.Label).string = '('+data.spTimes + '/' + needTimes+')'
}else{
yugouNode.getChildByName('times').active = false;
}
}
}
btns_init(setSKin=true){
this.yugouNode1.getChildByName('selected').active = false;
this.yugouNode2.getChildByName('selected').active = false;
this.yugouNode3.getChildByName('selected').active = false;
this.yugouNode4.getChildByName('selected').active = false;
this.setYugouStatus('鱼钩');
this.setYugouStatus('蚯蚓');
this.setYugouStatus('鱼饵');
this.setYugouStatus('猪肝');
if(this.currentYugou == '' || this.currentYugou == '鱼钩'){
this.currentYugou = '鱼钩'
if(setSKin){
this.setYugouSkin('鱼钩');
}
this.yugouNode1.getChildByName('selected').active = true;
}
if(this.currentYugou == '蚯蚓' && this.yugouNode2.getChildByName('sp').active){
this.currentYugou = '鱼钩'
if(setSKin){
this.setYugouSkin('鱼钩');
}
this.yugouNode1.getChildByName('selected').active = true;
}else if(this.currentYugou == '蚯蚓'){
this.yugouNode2.getChildByName('selected').active = true;
}
if(this.currentYugou == '鱼饵' /*&& this.yugouNode3.getChildByName('sp').active*/){
this.currentYugou = '鱼饵'
if(setSKin){
this.setYugouSkin('鱼饵');
}
this.yugouNode1.getChildByName('selected').active = true;
}
// else if(this.currentYugou == '鱼饵'){
// this.yugouNode3.getChildByName('selected').active = true;
// }
if(this.currentYugou == '猪肝' && this.yugouNode4.getChildByName('sp').active){
this.currentYugou = '鱼钩'
if(setSKin){
this.setYugouSkin('鱼钩');
}
this.yugouNode1.getChildByName('selected').active = true;
}else if(this.currentYugou == '猪肝'){
this.yugouNode4.getChildByName('selected').active = true;
}
}
setYugouSkin(name){
let data = DiaoYuConfigManage.getDiaoyuYuerConfigByName(name);
this.diaoYuSp.setSkin(data.spinSkin);
this.diaoYuSp.setAnimation(1, this.dongxi.jingzhi, true);
}
handleYugouClick(){
Common5.playEffect("sound/按键点击")
if(this.isDiaoyu){
return;
}
this.reportKey(()=>{
GameReport.BtnsReport('鱼钩')
})
this.currentYugou = '鱼钩';
this.setYugouSkin('鱼钩');
this.yugouNode1.getChildByName('selected').active = true;
this.yugouNode2.getChildByName('selected').active = false;
this.yugouNode3.getChildByName('selected').active = false;
this.yugouNode4.getChildByName('selected').active = false;
this.btns_init();
}
handleQiuyingClick(){
Common5.playEffect("sound/按键点击")
if(this.isDiaoyu){
return;
}
if(this.yugouNode2.getChildByName('sp').active){
let tab = {
onClose: (finish)=>{
if (finish) {
this.reportKey(()=>{
GameReport.ADReport('蚯蚓',1)
})
Common5.ReportDY("inLevel", "钓鱼-AD-蚯蚓");
let data = DiaoYuManage.getYuerByName('蚯蚓');
data.spTimes += 1;
DiaoYuManage.setYuerSpTimesByName('蚯蚓', data.spTimes);
DiaoYuManage.setYuerUnlockByName('蚯蚓', true);
}
else{
this.reportKey(()=>{
GameReport.ADReport('蚯蚓',0)
})
Common5.showTips_custom("广告未观看完");
}
this.btns_init();
},onFailed:()=>{
}
}
AppPlatform.playVideo_custom(tab)
}else{
this.currentYugou = '蚯蚓';
this.setYugouSkin('蚯蚓');
this.reportKey(()=>{
GameReport.BtnsReport('蚯蚓')
})
this.yugouNode3.getChildByName('selected').active = true;
this.yugouNode1.getChildByName('selected').active = false;
this.yugouNode2.getChildByName('selected').active = false;
this.yugouNode4.getChildByName('selected').active = false;
this.btns_init();
}
}
// 鱼饵 需要看2次视频解锁
handleYuerClick(){
Common5.playEffect("sound/按键点击")
if(this.isDiaoyu){
return;
}
if(this.yugouNode3.getChildByName('sp').active){
let tab = {
onClose: (finish)=>{
if (finish) {
this.reportKey(()=>{
GameReport.ADReport('鱼饵',1)
})
Common5.ReportDY("inLevel", "钓鱼-AD-鱼饵");
let data = DiaoYuManage.getYuerByName('鱼饵');
data.spTimes += 1;
DiaoYuManage.setYuerSpTimesByName('鱼饵', data.spTimes);
if(data.spTimes >= 2){
DiaoYuManage.setYuerUnlockByName('鱼饵', true);
}
}
else{
this.reportKey(()=>{
GameReport.ADReport('鱼饵',0)
})
Common5.showTips_custom("广告未观看完");
}
this.btns_init();
},onFailed:()=>{
}
}
AppPlatform.playVideo_custom(tab)
}else{
this.currentYugou = '鱼饵';
this.setYugouSkin('鱼饵');
this.reportKey(()=>{
GameReport.BtnsReport('鱼饵')
})
this.btns_init();
this.yugouNode3.getChildByName('selected').active = true;
this.yugouNode1.getChildByName('selected').active = false;
this.yugouNode2.getChildByName('selected').active = false;
this.yugouNode4.getChildByName('selected').active = false;
}
}
// 猪肝按钮点击
handleZhuganClick(){
Common5.playEffect("sound/按键点击")
if(this.isDiaoyu){
return;
}
if(this.yugouNode4.getChildByName('sp').active){
let tab = {
onClose: (finish)=>{
if (finish) {
Common5.ReportDY("inLevel", "钓鱼-AD-猪肝");
// 设置猪肝解锁,并设置免费次数 5
DiaoYuManage.setYuerUnlockByName('猪肝', true);
DiaoYuManage.setYuerFreeTimesByName('猪肝', 5);
this.reportKey(()=>{
GameReport.ADReport('猪肝',1)
})
}
else{
this.reportKey(()=>{
GameReport.ADReport('猪肝',0)
})
Common5.showTips_custom("广告未观看完");
}
this.btns_init();
},onFailed:()=>{
}
}
AppPlatform.playVideo_custom(tab)
}else{
this.currentYugou = '猪肝';
this.setYugouSkin('猪肝');
this.reportKey(()=>{
GameReport.BtnsReport('猪肝')
})
this.yugouNode4.getChildByName('selected').active = true;
this.yugouNode1.getChildByName('selected').active = false;
this.yugouNode2.getChildByName('selected').active = false;
this.yugouNode3.getChildByName('selected').active = false;
}
}
// 关闭提示框
handleCloseTips(){
Common5.playEffect("sound/按键点击")
this.tipsNode.active = false;
}
diaoyuBtnInit(){
this.diaoyuKaishiNode.active = true;
this.diaoyuLuyaNode.active = true;
}
zhunbeiBtnSet(){
this.diaoyuKaishiNode.active = false;
this.diaoyuLuyaNode.active = false;
}
taiganBtnSet(){
this.diaoyuKaishiNode.active = false;
this.diaoyuLuyaNode.active = false;
//钓鱼
this.handleTaigan()
}
private zhunbeiBeginTime = -1
private isDiaoyu = false;
private isLuya = false;
taigan_schedule_cb(){
this.isDiaoyu = false;
this.isLuya = false;
this.diaoyuBtnInit();
this.isDiaoyu = false;
this.btns_init();
this.diaoYuSp.setAnimation(1, this.dongxi.jingzhi, true)
this.isZhunbeiTaigan = false;
cc.audioEngine.stopAllEffects();
this.setYugouSkin(this.currentYugou);
this.tipsNode.active = true;
this.tipsNode.getChildByName('tips').getChildByName('lbl').getComponent(cc.Label).horizontalAlign = cc.Label.HorizontalAlign.CENTER
this.tipsNode.getChildByName('tips').getChildByName('lbl').getComponent(cc.Label).string = '鱼跑了';
}
begin_diaoyu(){
this.zhunbeiBeginTime = -1;
// 甩干
this.diaoYuSp.setAnimation(1, this.dongxi.chugan, false);
this.diaoYuSp.timeScale = 1
// 等待
// let rushuiTime = 3 * Math.random();
// if(rushuiTime < 1.5){
// rushuiTime = 1.5;
// }
let xiaofuTime = 2.0
let rushuiTime = 1
cc.tween(this.diaoYuSp.node)
.delay(1.3)
.call(()=>{
this.diaoYuSp.timeScale = 0.5
// 进入甩干待机状态
this.diaoYuSp.setAnimation(1, this.dongxi.chuganhoudaiji, true);
Common5.playEffectCustom('diaoyu','sound/钓鱼鱼饵入水')
})
.delay(rushuiTime)
.call(()=>{
Common5.playEffectCustom('diaoyu','sound/钓鱼浮漂下沉咬钩')
this.diaoYuSp.setAnimation(1, this.dongxi.lagan, false);
this.zhunbeiBeginTime = Date.now();
})
.delay(1.0)
.call(()=>{
this.isZhunbeiTaigan = true;
this.scheduleOnce(this.taiganBtnSet, 2);
//this.endPointNode.active = true;
let randomx = Common5.getRandomNum(0,3)
if(randomx==0){
this.diaoYuSp.setAnimation(1, this.dongxi.laganzhuan1, false);
}else if(randomx==1){
this.diaoYuSp.setAnimation(1, this.dongxi.laganzhuan2, false);
}else if(randomx==2){
this.diaoYuSp.setAnimation(1, this.dongxi.laganzhuan3, false);
}
})
.start()
}
private isZhunbeiTaigan = false;
private isTaigan = false;
handleTaigan(){
Common5.playEffect("sound/按键点击")
this.unschedule(this.taigan_schedule_cb);
if(this.isTaigan){
//this.endPointNode.active = false;
return;
}
this.reportKey(()=>{
GameReport.BtnsReport('抬竿')
})
this.isZhunbeiTaigan = false;
cc.audioEngine.stopAllEffects();
this.isTaigan = true;
if( 1 == 1 ){
this.diaoYuSp.setAnimation(1, this.dongxi.qigan, false)
let result = null
if(this.isLuya){
// this.currentYugou = '路亚'
result = InterfaceManager.getMangheGoodsListByType('Diaoyu',3,true)//DiaoYuConfigManage.getGoodByProbability('路亚', num,true);
}else{
result = InterfaceManager.getMangheGoodsListByType('Diaoyu',1,false)//DiaoYuConfigManage.getGoodByProbability(this.currentYugou, num,false);
}
// for(let i = 0; i<result.length;i++){
// let goodsId = result[i].goodId
// Common5.getSpriteFrameFromBundlePro("GoodIcon","icon/"+ goodsId)
// }
cc.tween(this.diaoYuSp.node)
.delay(2.0)
.call(()=>{
// if(result.length==5){
// this.wulianIndex = 0
// let num = result.length;
// let arr = []
// for(let i=0;i<num;i++){
// arr.push({goodId:result[i].goodId,goodNum: 1})
// }
// this.showResults(arr)
// }else{
this.showResults(result);
// }
this.diaoyuBtnInit();
this.isDiaoyu = false;
this.isTaigan = false;
this.btns_init();
//this.endPointNode.active = false;
this.diaoYuSp.setAnimation(1, this.dongxi.jingzhi, true);
console.log(this.currentYugou, 'this.currentYugou+++++++11+====')
this.setYugouSkin(this.currentYugou);
})
.start();
}
}
// 开始钓鱼
handleDiaoyu(){
Common5.playEffect("sound/按键点击")
if(this.isDiaoyu){
return;
}
this.reportKey(()=>{
GameReport.BtnsReport('开始钓鱼')
})
// this.currentYugou = '鱼饵'
this.isLuya = false;
this.isDiaoyu = true;
this.zhunbeiBeginTime = -1;
let dataConfig = DiaoYuConfigManage.getDiaoyuYuerConfigByName(this.currentYugou);
if(dataConfig.price > UserManager.getCurMoney()){
this.tipsNode.active = true;
this.tipsNode.getChildByName('tips').getChildByName('lbl').getComponent(cc.Label).horizontalAlign = cc.Label.HorizontalAlign.LEFT
this.tipsNode.getChildByName('tips').getChildByName('lbl').getComponent(cc.Label).string = '没钱钓什么鱼,赶紧搞钱去吧。';
this.isDiaoyu = false;
return;
}
// 开始钓鱼 减钱
if(dataConfig.price > 0){
// UserManager.subMoney(dataConfig.price);
}
// 设置免费次数
if(this.currentYugou == '猪肝'){
let data = DiaoYuManage.getYuerByName(this.currentYugou)
data.freeTimes -= 1;
if(data.freeTimes == 0){
DiaoYuManage.setYuerUnlockByName(this.currentYugou, false)
}
DiaoYuManage.setYuerFreeTimesByName(this.currentYugou, data.freeTimes);
this.btns_init(false);
}
this.begin_diaoyu();
}
handleDiaoyuLuya(){
Common5.playEffect("sound/按键点击")
if(this.isDiaoyu){
return;
}
let tab = {
onClose: (finish)=>{
if (finish) {
Common5.ReportDY("inLevel", "松花江-AD-五连竿");
this.isLuya = true;
this.isDiaoyu = true;
this.diaoYuSp.setSkin('luyayugou')
this.begin_diaoyu();
this.reportKey(()=>{
GameReport.ADReport('松花江五连竿',1)
})
}
else{
this.reportKey(()=>{
GameReport.ADReport('松花江五连竿',0)
})
Common5.showTips_custom("广告未观看完");
}
},onFailed:()=>{
}
}
AppPlatform.playVideo_custom(tab)
}
refreshZhaoMuTime(){
let localZhaoMuData = MeiNvZhaoMuManager.getMeiNvZhaoMuData()
let maxTime = localZhaoMuData[ZhaoMuGameType.SongHuaJiang].zhaoMuTime
let zhaoMuBeiShu = localZhaoMuData[ZhaoMuGameType.SongHuaJiang].zhaoMuBeiShu
// let maxUnlockIndex = localZhaoMuData[ZhaoMuGameType.SongHuaJiang].maxUnlockIndex
if(maxTime > 0){
//按钮上人物显示第一个
// let config = MeiNvZhaoMuManager.getConfigById(ZhaoMuGameType.XiaShuiDao,0)
// this.zhaoMuNode.getChildByName('tipSpr').active = false
this.zhaoMuNode.getChildByName('renSpine').active = true
// this.zhaoMuNode.getChildByName('renSpine').getComponent(sp.Skeleton).setAnimation(0,'半身呼吸',true)
// this.zhaoMuNode.getChildByName('renSpine').getComponent(sp.Skeleton).setSkin(config.skinIndex)
this.zhaoMuNode.getChildByName('timeStr').getComponent(cc.Label).string = `${DateUtils.formatTime_custom(maxTime)}`
this.zhaoMuNode.getChildByName('tipSpr').getChildByName('shouYiStr').getComponent(cc.Label).string = `收益x${zhaoMuBeiShu}`
}else{
// this.zhaoMuNode.getChildByName('tipSpr').active = true
this.zhaoMuNode.getChildByName('renSpine').active = false
this.zhaoMuNode.getChildByName('timeStr').getComponent(cc.Label).string = ``
// this.zhaoMuNode.getChildByName('shouYiStr').getComponent(cc.Label).string = `秘书招聘`
this.zhaoMuNode.getChildByName('tipSpr').getChildByName('shouYiStr').getComponent(cc.Label).string = `收益 x N`
}
}
zhaomuClickEvent(){
Common5.playEffect("CommonRes/sound/按键点击")
this.enterReportKey(GameType.MeiNvZhaoMu)
PrefabManage.loadPrefabByType(GameType.MeiNvZhaoMu,null,(prefabNode)=>{
prefabNode.getComponent(MeiNvZhaoMu).initView(ZhaoMuGameType.SongHuaJiang)
})
}
}