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

350 lines
15 KiB

1 week ago
import { ryw_Event } from "../../../FrameWork/Event/EventEnum";
import EventMgr from "../../../FrameWork/Event/EventMgr";
import GameMgr from "../../../FrameWork/Mgr/GameMgr";
import User, { RoomBtnIndexEnum } from "../../../FrameWork/User/User";
import { DateUtils } from "../../../FrameWork/Util/DateUtils";
import Common5 from "../../../Platform/th/Common5";
import ZhongCanTingManager from "../../GameMethodRes/ZhongCanTing/ZhongCanTingManager";
import ChatManager from "../../JuQingChat/ChatManager";
import JuQingManager from "../../JuQingChat/JuQingManager";
import TaskInfoView from "../../JuQingChat/TaskInfoView";
import TaskManager, { MainTaskIdEnum } from "../../JuQingChat/TaskManager";
import InterfaceManager from "../../Manager/InterfaceManager";
import NewGuideScript from "../../NewGuide/NewGuideScript";
import PrefabManage, { GameType } from "../../PrefabManager/PrefabManage";
import Room3 from "../Room3/Room3";
const { ccclass, property } = cc._decorator;
@ccclass
export default class RoomCommon extends cc.Component {
_dt4: number = 0
maskGuideNode: cc.Node = null
onLoad() {
}
getMainNode() {
return this.node.getChildByName('mainNode')
}
start() {
// Common5.playRemoteAudioMusic(Common5.selectGameInfo.musicUrl)
// Common5.playMusicCustom('CommonRes', 'sound/背景音');
let shouYi = ZhongCanTingManager.getPerSecondShouYi()
this.node.getChildByName('yuanBao').getChildByName('shouYiStr').getComponent(cc.Label).string = `${Common5.getNumberChangeHanzi(shouYi, '1', 1)}/秒`
Common5.getSpriteFrameFromBundle("CommonRes", "texture/" + User.getHeadImg(), this.node.getChildByName("head").getChildByName("头像").getComponent(cc.Sprite));
EventMgr.onEvent_custom(ryw_Event.setHeadImg, (img) => {
Common5.getSpriteFrameFromBundle("CommonRes", "texture/" + img, this.node.getChildByName("head").getChildByName("头像").getComponent(cc.Sprite));
}, this)
// this.showChatBtnStatus()
EventMgr.onEvent_custom(ryw_Event.RefreshJuQingDuiHua, () => {
// this.setNaiNaiSpineStatus()
console.log('myroom收到RefreshJuQingDuiHua===')
this.showChatBtnStatus()
}, this)
EventMgr.onEvent_custom(ryw_Event.SetCommonBtnShow, (bShow) => {
this.setCommonBtnShow(bShow)
}, this)
// let times = User.getChongFanHaoMenTimes()
// if(times > 0){
// this.node.getChildByName('记事本').getChildByName('timeStr').getComponent(cc.Label).string = DateUtils.formatTime_custom(times)
// }
EventMgr.onEvent_custom(ryw_Event.closeJiShiBen, () => {
this.showJiShiBenBtn()
}, this);
EventMgr.onEvent_custom(ryw_Event.updateMainTask, (data) => {
this.showChatBtnStatus()
console.log("更新任务+", data)
let customTaskInfo = data.taskInfo
if (customTaskInfo && Object.keys(customTaskInfo).length > 0 && customTaskInfo.Id != 0 && data.isAutoTanChu) {
this.node.getChildByName("taskInfoNode").getComponent(TaskInfoView).init()
} else {
//PrefabManage.showTextTips('当前无任务')
}
}, this)
this.scheduleOnce(() => {
PrefabManage.preloadPrefabByType(GameType.CityPrefab)
}, 0.2)
}
showJiShiBenBtn() {
let jishibNode = this.node.getChildByName('记事本')
jishibNode.active = true
cc.tween(jishibNode)
.to(0.2, { scale: 1.3 })
.to(0.2, { scale: 1 })
.start()
}
update(dt) {
// this.refreshChongFanHaoMenTime(dt)
}
// refreshChongFanHaoMenTime(dt){
// this._dt4 += dt
// if(this._dt4 >= 1){
// this._dt4 = 0
// let times = User.getChongFanHaoMenTimes()
// if(times > 0){
// this.node.getChildByName('记事本').getChildByName('timeStr').getComponent(cc.Label).string = DateUtils.formatTime_custom(times)
// }
// }
// }
guideStep() {
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
//let indexStr = JuQingManager.getCurJuQingUnLockIndex()
//引导去售货机买葡萄糖
if (mainId == MainTaskIdEnum.MainTask_203) {
let node = this.node.getChildByName('手机')
this.guideView([node])
} else if (mainId == MainTaskIdEnum.MainTask_202) {
let node = this.node.getChildByName('出门')
this.guideView([node])
Common5.ReportDY("inLevel", "任务001-房间二6出门");
}
}
guideView(nodeArray) {
PrefabManage.loadPrefabByType(GameType.GuideMskNode, null, (prefab) => {
let guideNodeArray = nodeArray
this.maskGuideNode = prefab
let firstNode = guideNodeArray.shift()
prefab.getComponent(NewGuideScript).setBindNode(firstNode, guideNodeArray)
})
}
setCommonBtnShow(isBtnShow) {
this.node.getChildByName('领取福利').active = isBtnShow
this.node.getChildByName('任务助手').active = isBtnShow
this.node.getChildByName('记事本').active = isBtnShow
this.node.getChildByName('手机').active = isBtnShow
this.node.getChildByName('我的背包').active = isBtnShow
this.node.getChildByName('daily').active = isBtnShow
this.node.getChildByName('yuanBao').active = isBtnShow
this.node.getChildByName('head').active = isBtnShow
this.node.getChildByName('出门').active = isBtnShow
}
// refreshMyRoomUi(num) {
// if(num == 0){
// this.node.getChildByName('mainNode').getChildByName('待机狗').active = false
// this.node.getChildByName('mainNode').getChildByName('renSpine1').active = true
// this.node.getChildByName('mainNode').getChildByName('renSpine2').active = false
// this.node.getChildByName('mainNode').getChildByName('竹马').active = false
// this.node.getChildByName('mainNode').getChildByName('空被子').active = true
// this.node.getChildByName('mainNode').getChildByName('被子盖').active = false
// }
// }
chumenClickEvent() {
// let gameGuideStep = User.getGameGuideStepIndex()
// if(gameGuideStep == 11){
// User.setGameGuideStepIndex(12)
// }
PrefabManage.loadPrefabByType(GameType.CityPrefab)
// PrefabManage.loadPrefabByType(GameType.HuXinGongYuan)
// InterfaceManager.setDaoyeList('酒瓶回收',1)
if (cc.isValid(this.maskGuideNode)) {
this.maskGuideNode.removeFromParent()
this.maskGuideNode.destroy()
}
let prefabLayer = cc.director.getScene().getChildByName("Canvas").getChildByName('prefabLayer')
if (prefabLayer.getChildByName("taskInfoNode")) {
prefabLayer.getChildByName("taskInfoNode").getComponent(TaskInfoView).onClose()
}
this.node.removeFromParent()
this.node.destroy()
}
clickTaskInfoEvent() {
let customTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
if (customTaskInfo && Object.keys(customTaskInfo).length > 0 && customTaskInfo.Id != MainTaskIdEnum.MainTask_None) {
// PrefabManage.loadPrefabByType(GameType.TaskInfoNode)
this.node.getChildByName("taskInfoNode").getComponent(TaskInfoView).init()
} else {
if (TaskManager.getIsLastTaskFinish()) {
PrefabManage.showTextTips('后续剧情策划挠头制作中,敬请期待!')
} else {
PrefabManage.showTextTips('当前无任务')
}
}
}
clickSettingEvent() {
PrefabManage.loadPrefabByType(GameType.Setting)
}
clickCebianlanEvent() {
// InterfaceManager.setDaoyeList('游艇基地2',1)
// PrefabManage.loadPrefabByType(GameType.GDaoYeShouGou)
// return
PrefabManage.loadPrefabByType(GameType.CeBianLan)
}
clickWXChat() {
JuQingManager.openJuQingOrChat('WX')
}
clickBeibaoEvent() {
PrefabManage.loadPrefabByType(GameType.BeiBao)
}
openJishiBen(event) {
// Common5.playEffect("sound/按键点击");
GameMgr.getInstance_custom().onLoadToSelectScene_custom();
//PrefabManage.loadPrefabByType(GameType.JiShiBen)
}
showChatBtnStatus() {
this.checkJuQingGuanQia()
this.guideStep()
let indexStr = JuQingManager.getCurJuQingUnLockIndex()
if (ChatManager.isChatTypeIncludeEventIndex('WX', indexStr)) {
let spineNode = this.node.getChildByName('手机').getChildByName('手机')
spineNode.getComponent(sp.Skeleton).setAnimation(0, '闪', true)
Common5.playEffect('sound/手机信息')
} else {
let spineNode = this.node.getChildByName('手机').getChildByName('手机')
spineNode.getComponent(sp.Skeleton).setAnimation(0, '静止', false)
}
// if(indexStr == 'DH_1_2'){
// User.setRoomGoodStatus(1)
// }else if(indexStr == 'DH_2'){
// User.setRoomGoodStatus(3)
// }else if(indexStr == 'WX_3'){
// this.showGuoDuLayer()
// }else if(indexStr == 'DH_4'){
// User.setRoomGoodStatus(8)
// }
let isHaveTask = false
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
if (mainId != MainTaskIdEnum.MainTask_None && mainId) {
isHaveTask = true
}
if (isHaveTask) {
// let spineNode = this.node.getChildByName('任务助手').getChildByName('任务')
// spineNode.getComponent(sp.Skeleton).setAnimation(0, '闪', true)
let rednode = this.node.getChildByName('任务助手').getChildByName('红点')
rednode.active = true
cc.tween(rednode)
.sequence(
cc.tween().to(0.5, { opacity: 0 }),
cc.tween().to(0.5, { opacity: 255 }),
)
.repeatForever()
.start()
} else {
// let spineNode = this.node.getChildByName('任务助手').getChildByName('任务')
// spineNode.getComponent(sp.Skeleton).setAnimation(0, '静止', false)
let rednode = this.node.getChildByName('任务助手').getChildByName('红点')
rednode.active = false
}
//city有玩法任务,出门闪烁
let spineNode = this.node.getChildByName('出门').getChildByName('外出')
let taskConfig = TaskManager.getTaskConfigById(mainId)
console.log("taskConfig====", taskConfig)
console.log("User.getRoomBtnIndex()=", User.getRoomBtnIndex())
// if (User.getRoomBtnIndex() == RoomBtnIndexEnum.touzirenjia && this.getMainNode().getChildByName("Room3") ) {
// spineNode.getComponent(sp.Skeleton).setAnimation(0, '静止', false)
// }else if (User.getRoomBtnIndex() == RoomBtnIndexEnum.yiyuan && this.getMainNode().getChildByName("Room4")) {
// spineNode.getComponent(sp.Skeleton).setAnimation(0, '静止', false)
// }else
// if (taskConfig && taskConfig.wanFaRuKouTip && taskConfig.wanFaRuKouTip.length > 0 &&
// (taskConfig.wanFaRuKouTip.indexOf('rk_chuZuChe') >= 0 || taskConfig.wanFaRuKouTip.indexOf('rk_maiHuoLang') >= 0)) {
if (taskConfig && taskConfig.wanFaRuKouTip && taskConfig.wanFaRuKouTip.indexOf('rk_chuZuChe') < 0) {
spineNode.getComponent(sp.Skeleton).setAnimation(0, '闪', true)
} else {
spineNode.getComponent(sp.Skeleton).setAnimation(0, '静止', false)
}
if (taskConfig && taskConfig.wanFaRuKouTip && taskConfig.wanFaRuKouTip.indexOf('rk_room') >= 0) {
spineNode.getComponent(sp.Skeleton).setAnimation(0, '闪', true)
}
if (taskConfig && taskConfig.ChuMenIsBlink) {
spineNode.getComponent(sp.Skeleton).setAnimation(0, '闪', true)
}
// 某些任务触发需要闪
let taskids = [MainTaskIdEnum.MainTask_502]
if (taskids.includes(mainId)) {
spineNode.getComponent(sp.Skeleton).setAnimation(0, '闪', true)
}
if (mainId == MainTaskIdEnum.MainTask_2405) {
let spineNode = this.node.getChildByName('我的背包').getChildByName('背包')
spineNode.getComponent(sp.Skeleton).setAnimation(0, '闪', true)
} else {
let spineNode = this.node.getChildByName('我的背包').getChildByName('背包')
spineNode.getComponent(sp.Skeleton).setAnimation(0, '静止', false)
}
// let num = User.getRoomGoodStatus()
// this.refreshMyRoomUi(num)
// let openBtnSpine = this.node.getChildByName('openBtnSpine')
// let beiBao = this.node.getChildByName('我的背包')
// if (mainId < MainTaskIdEnum.MainTask_211) {
// beiBao.active = false
// } else {
// if (mainId == MainTaskIdEnum.MainTask_211) {
// openBtnSpine.setPosition(cc.v2(0, 0))
// openBtnSpine.active = true
// beiBao.opacity = 0
// beiBao.active = true
// openBtnSpine.getComponent(sp.Skeleton).setAnimation(0, '背包1', false)
// this.scheduleOnce(() => {
// openBtnSpine.getComponent(sp.Skeleton).setAnimation(0, '背包2', false)
// cc.tween(openBtnSpine)
// .to(0.5, { x: beiBao.x, y: beiBao.y })
// .call(() => {
// cc.tween(beiBao)
// .set({scale: 0.5, opacity: 255 })
// .to(0.15, { scale: 0.9 })
// .to(0.15, { scale: 0.8 })
// .start();
// this.guideView([beiBao]);
// openBtnSpine.active = false
// })
// .start()
// }, 1.67)
// } else {
// beiBao.active = true
// }
// }
}
clickDingYue() {
// Common5.playEffect("ui");
PrefabManage.loadPrefabByType(GameType.DingYue)
}
checkJuQingGuanQia() {
// let mainTaskInfo:any = TaskManager.getCurUnLockMainTaskInfo()
// let mainId = mainTaskInfo.Id
// if(mainId == MainTaskIdEnum.MainTask_602 || mainId == MainTaskIdEnum.MainTask_603){
// User.setRoomGoodStatus(2)
// PrefabManage.loadPrefabByType(GameType.JuQingGuanQia2,this.node)
// return
// }
}
setChuMenState(isBlink) {
let spineNode = this.node.getChildByName('出门').getChildByName('外出')
spineNode.getComponent(sp.Skeleton).setAnimation(0, isBlink ? '闪' : '静止', true)
}
}