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.
114 lines
4.5 KiB
114 lines
4.5 KiB
1 week ago
|
import Common5 from "../../Platform/th/Common5";
|
||
|
import User from "../../FrameWork/User/User";
|
||
|
import TaskManager from "./TaskManager";
|
||
|
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
|
||
|
import BiJiBen from "./BiJiBen";
|
||
|
import ChatManager from "./ChatManager";
|
||
|
import EventMgr from "../../FrameWork/Event/EventMgr";
|
||
|
import { ryw_Event } from "../../FrameWork/Event/EventEnum";
|
||
|
import ChatList from "./ChatList";
|
||
|
|
||
|
const {ccclass, property} = cc._decorator;
|
||
|
@ccclass
|
||
|
export default class JuQingManager{
|
||
|
//打开对话或微信聊天
|
||
|
public static openJuQingOrChat(tag,parentNode?){
|
||
|
let indexStr = this.getCurJuQingUnLockIndex()
|
||
|
let personConfig = this.getPersonJsonByIndexStr(indexStr)
|
||
|
// if(personConfig && tag == personConfig.type){
|
||
|
if(tag == 'WX'){
|
||
|
PrefabManage.loadPrefabByType(GameType.ChatList,cc.director.getScene().getChildByName("Canvas").getChildByName('prefabLayer2'),(prefabNode)=>{
|
||
|
prefabNode.getComponent(ChatList).initView('WX')
|
||
|
})
|
||
|
}else if(tag == 'DH'){
|
||
|
PrefabManage.loadPrefabByType(GameType.JuQingDialog,parentNode)
|
||
|
|
||
|
}else if(tag == 'RJB'){
|
||
|
let type = 'RJB'
|
||
|
let jsonName = 'RiJiBen'
|
||
|
ChatManager.setSingleChatStatus(type,jsonName,indexStr,false)
|
||
|
PrefabManage.loadPrefabByType(GameType.BiJiBen,null,(prefabNode)=>{
|
||
|
prefabNode.getComponent(BiJiBen).enterDialog(jsonName,indexStr,()=>{
|
||
|
console.log("关闭聊天的回调")
|
||
|
})
|
||
|
})
|
||
|
}else if(tag == 'XG'){
|
||
|
PrefabManage.loadPrefabByType(GameType.ChatList,null,(prefabNode)=>{
|
||
|
prefabNode.getComponent(ChatList).initView('XG')
|
||
|
})
|
||
|
}
|
||
|
// }else{
|
||
|
// PrefabManage.showTextTips('打开错误')
|
||
|
// }
|
||
|
}
|
||
|
//根据剧情索引str获取jsonConfig
|
||
|
public static getJuQingJsonByIndexStr(indexStr){
|
||
|
for(let i=0;i<Common5.chatPersonConfig.length;i++){
|
||
|
let eventIndexStr = Common5.chatPersonConfig[i].eventIndexStr
|
||
|
if(eventIndexStr){
|
||
|
for(let j=0;j<eventIndexStr.length;j++){
|
||
|
if(indexStr == eventIndexStr[j]){
|
||
|
let jsonName = Common5.chatPersonConfig[i].jsonName
|
||
|
return Common5.allJuQingChatConfig[jsonName]
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
return null
|
||
|
}
|
||
|
//根据剧情索引str获取personConfig
|
||
|
public static getPersonJsonByIndexStr(indexStr){
|
||
|
for(let i=0;i<Common5.chatPersonConfig.length;i++){
|
||
|
let eventIndexStr = Common5.chatPersonConfig[i].eventIndexStr
|
||
|
if(eventIndexStr){
|
||
|
for(let j=0;j<eventIndexStr.length;j++){
|
||
|
if(indexStr == eventIndexStr[j]){
|
||
|
return Common5.chatPersonConfig[i]
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
return null
|
||
|
}
|
||
|
//根据jsonName获取personConfig
|
||
|
public static getPersonJsonByJsonName(jsonName){
|
||
|
for(let i=0;i<Common5.chatPersonConfig.length;i++){
|
||
|
if(Common5.chatPersonConfig[i].jsonName == jsonName){
|
||
|
return Common5.chatPersonConfig[i]
|
||
|
}
|
||
|
}
|
||
|
return null
|
||
|
}
|
||
|
//设置当前剧情索引
|
||
|
public static setCurJuQingUnLockIndex(indexStr){
|
||
|
User.setCurJuQingUnLockIndex(indexStr)
|
||
|
}
|
||
|
//获取当前剧情索引
|
||
|
public static getCurJuQingUnLockIndex(){
|
||
|
return User.getCurJuQingUnLockIndex()
|
||
|
}
|
||
|
//完成当前剧情
|
||
|
public static finishCurJuQing(curJuQingUnLockIndex,unLockJuQingIndex){
|
||
|
this.unLockNewJuQing(unLockJuQingIndex,true)
|
||
|
TaskManager.juQingFinishEventEmit(curJuQingUnLockIndex)
|
||
|
EventMgr.emitEvent_custom(ryw_Event.RefreshJuQingDuiHua);
|
||
|
}
|
||
|
//解锁新剧情
|
||
|
public static unLockNewJuQing(unLockJuQingIndex,isRefresh?){
|
||
|
if(!unLockJuQingIndex){
|
||
|
unLockJuQingIndex = ''
|
||
|
}else{
|
||
|
let personConfig = this.getPersonJsonByIndexStr(unLockJuQingIndex)
|
||
|
console.log('personConfig==',personConfig)
|
||
|
ChatManager.setSingleChatStatus(personConfig.type,personConfig.jsonName,unLockJuQingIndex,false)
|
||
|
}
|
||
|
this.setCurJuQingUnLockIndex(unLockJuQingIndex)
|
||
|
if(!isRefresh){
|
||
|
EventMgr.emitEvent_custom(ryw_Event.RefreshJuQingDuiHua);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|