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.
474 lines
19 KiB
474 lines
19 KiB
// Learn TypeScript:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
|
|
// Learn Attribute:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
|
|
|
|
import { ryw_Event } from "../../FrameWork/Event/EventEnum";
|
|
import EventMgr from "../../FrameWork/Event/EventMgr";
|
|
import User from "../../FrameWork/User/User";
|
|
import Common5 from "../../Platform/th/Common5";
|
|
import ShouGouHeTong from "../DH/ShouGouHeTong";
|
|
import UiBase from "../GameBase/UiBase";
|
|
import YiMaJiang from "../GameMethodRes/YiMaJiang/YiMaJiang";
|
|
import JuQingManager from "../JuQingChat/JuQingManager";
|
|
import TaskManager, { MainTaskIdEnum } from "../JuQingChat/TaskManager";
|
|
import LevelUpManager from "../Manager/LevelUpManager";
|
|
import MiShuManager from "../Manager/MiShuManager";
|
|
import ShipuManager from "../Manager/ShipuManager";
|
|
import TanWeiManager from "../Manager/TanWeiManager";
|
|
import UserManager from "../Manager/UserManager";
|
|
import ZiChanManager from "../Manager/ZiChanManager";
|
|
import NewGuideScript from "../NewGuide/NewGuideScript";
|
|
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class CityScript extends UiBase {
|
|
|
|
@property(cc.Sprite)
|
|
chenghaoPic: cc.Sprite = null;
|
|
@property(cc.Label)
|
|
levelLab: cc.Label = null;
|
|
@property(cc.Label)
|
|
chenghao: cc.Label = null;
|
|
@property(cc.Label)
|
|
clickMoneyLab: cc.Label = null;
|
|
|
|
// onLoad () {}
|
|
@property(cc.Label)
|
|
secondMoneyLab: cc.Label = null;
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {}
|
|
buildArray = ['后山', '美食城', '拍卖行', '厨师协会', '公益协会', '豪华游轮', '茶场', '钓鱼场', '农贸市场', '花卉基地']
|
|
unlockArray = [MainTaskIdEnum.MainTask_528, -1, MainTaskIdEnum.MainTask_509, MainTaskIdEnum.MainTask_512, -1, -1, MainTaskIdEnum.MainTask_548, MainTaskIdEnum.MainTask_512, MainTaskIdEnum.MainTask_524, MainTaskIdEnum.MainTask_555]
|
|
unlockStrArray = ["28", -1, "9", "12", -1, -1, "48", "12", "24", "55"]
|
|
gameTypeArray = [GameType.XiuXianNongZhuang, false, GameType.Paimaihang, GameType.ChuShiXieHui, GameType.WZ_firstLevelSelectView, GameType.YiMaJiang, GameType.ChaChang, GameType.HJHA, GameType.ShiCaiHuiShou, GameType.BaiCaoJi]
|
|
|
|
// levelLimitArray = [1250,1200,900,9999,1,400,1,700,550,1]
|
|
levelLimitArray = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
|
|
onDestroy(): void {
|
|
cc.audioEngine.stopMusic()
|
|
}
|
|
start() {
|
|
EventMgr.onEvent_custom(ryw_Event.changeScene, () => {
|
|
console.log('changeScene++=City')
|
|
this.node.removeFromParent()
|
|
this.node.destroy()
|
|
}, this)
|
|
|
|
Common5.playRemoteAudioMusic('sound/JuQingBG/城市的背景音')
|
|
let myLevel = User.getMyLevel()
|
|
|
|
let count = this.buildArray.length;
|
|
let i = 0
|
|
let pushArray = []
|
|
this.schedule(() => {
|
|
let nodeName = this.buildArray[i]
|
|
let levelNum = this.levelLimitArray[i]
|
|
let node = this.node.getChildByName(nodeName)
|
|
if (node) {
|
|
let title = node.getChildByName(nodeName)
|
|
let lock = node.getChildByName('lock')
|
|
let lock_task = node.getChildByName('lock_task')
|
|
let getCurTaskId = User.getCurTaskId()
|
|
if (getCurTaskId[0] >= this.unlockArray[i] || this.unlockArray[i] == -1) {
|
|
lock_task.active = false
|
|
if (this.gameTypeArray[i]) {
|
|
pushArray.push(this.gameTypeArray[i])
|
|
}
|
|
} else {
|
|
lock_task.getChildByName("lab").getComponent(cc.Label).string = `任务${this.unlockStrArray[i]}解锁`
|
|
lock_task.active = true
|
|
}
|
|
// Common5.addUrlSprite_custom('CityPrefab/建筑/'+nodeName, node.getComponent(cc.Sprite))
|
|
// Common5.addUrlSprite_custom('CityPrefab/招牌/'+nodeName, title.getComponent(cc.Sprite))
|
|
// if (myLevel >= levelNum) {
|
|
// lock.active = false
|
|
// if (this.gameTypeArray[i]) {
|
|
// pushArray.push(this.gameTypeArray[i])
|
|
// }
|
|
|
|
// } else {
|
|
// lock.active = true
|
|
// // if(nodeName == '巡夜人总部'){
|
|
// // lock.active = false
|
|
// // }
|
|
// // Common5.addUrlSprite_custom('CityPrefab/未解锁建筑/'+nodeName, lock.getComponent(cc.Sprite))
|
|
// let lab2 = lock.getChildByName('lab2')
|
|
// let lab = lock.getChildByName('lab')
|
|
|
|
// lab2.getComponent(cc.Label).string = levelNum + ''
|
|
// // if(nodeName == '远洋渔船'){
|
|
// // lab2.active = false
|
|
// // lab.getComponent(cc.Label).string = '任务解锁'
|
|
// // let taskArray = User.getCurTaskId()
|
|
// // if(taskArray[0]>=MainTaskIdEnum.MainTask_516){
|
|
// // pushArray.push(this.gameTypeArray[i])
|
|
// // lock.active = false
|
|
// // }
|
|
// // }
|
|
|
|
// }
|
|
}
|
|
i++
|
|
if (i == count) {
|
|
this.scheduleOnce(() => {
|
|
//预加载
|
|
PrefabManage.preloadPrefabArray(pushArray)
|
|
}, 0.1)
|
|
}
|
|
}, 0, count - 1, 0)
|
|
|
|
|
|
|
|
this.refreshHead()
|
|
EventMgr.onEvent_custom(ryw_Event.setHeadImg, (img) => {
|
|
this.refreshHead()
|
|
}, this)
|
|
this.refreshChengHao()
|
|
// EventMgr.onEvent_custom(ryw_Event.levelUpChange,()=>{
|
|
// this.refreshChengHao()
|
|
|
|
// },this)
|
|
this.showChatBtnStatus()
|
|
EventMgr.onEvent_custom(ryw_Event.levelUpChange, () => {
|
|
this.refreshChengHao()
|
|
this.showChatBtnStatus()
|
|
}, this)
|
|
this.guideTask()
|
|
|
|
this.updateMainTask()
|
|
EventMgr.onEvent_custom(ryw_Event.updateMainTask, () => {
|
|
this.updateMainTask()
|
|
this.showChatBtnStatus()
|
|
}, this)
|
|
}
|
|
|
|
guideTask() {
|
|
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
|
|
let mainId = mainTaskInfo.Id
|
|
let config = TaskManager.getTaskConfigById(mainId)
|
|
if (mainId == MainTaskIdEnum.MainTask_509) {
|
|
let node = this.node.getChildByName('拍卖行')
|
|
this.guideView([node])
|
|
} else if (mainId == MainTaskIdEnum.MainTask_512) {
|
|
let node = this.node.getChildByName('厨师协会')
|
|
this.guideView([node])
|
|
}
|
|
// else if (mainId == MainTaskIdEnum.MainTask_516 && Common5.TaskGuide516) {
|
|
// Common5.TaskGuide516 = false
|
|
// let node = this.node.getChildByName('远洋渔船').getChildByName('远洋渔船')
|
|
// this.guideView([node])
|
|
// }
|
|
}
|
|
|
|
guideView(nodeArray, opacity = -1) {
|
|
PrefabManage.loadPrefabByType(GameType.GuideMskNode, this.node, (prefab) => {
|
|
// prefab.zIndex = 199
|
|
let guideNodeArray = nodeArray
|
|
let firstNode = guideNodeArray.shift()
|
|
prefab.getComponent(NewGuideScript).setBindNode(firstNode, guideNodeArray)
|
|
if (opacity != -1) {
|
|
prefab.getComponent(NewGuideScript).setOpacityMaskNode(opacity)
|
|
}
|
|
})
|
|
}
|
|
|
|
|
|
showChatBtnStatus() {
|
|
let isHaveTask = false
|
|
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
|
|
let mainId = mainTaskInfo.Id
|
|
if (mainId != MainTaskIdEnum.MainTask_None && mainId) {
|
|
isHaveTask = true
|
|
}
|
|
|
|
|
|
|
|
let taskNode = this.node.getChildByName('任务助手')
|
|
let taskDescNode = taskNode.getChildByName('任务描述')
|
|
let tanhao = taskNode.getChildByName('提示叹号')
|
|
let taskLab = taskDescNode.getChildByName('lab').getComponent(cc.Label)
|
|
let taskConfig = TaskManager.getTaskConfigById(mainId)
|
|
|
|
if (isHaveTask) {
|
|
|
|
//spineNodeTask.getComponent(sp.Skeleton).setAnimation(0,'呼吸',true)
|
|
taskDescNode.active = true
|
|
tanhao.active = true
|
|
taskLab.string = taskConfig.TaskTittle
|
|
taskNode.getComponent('ScaleScripts').startTween()
|
|
} else {
|
|
//spineNodeTask.getComponent(sp.Skeleton).setAnimation(0,'静止',false)
|
|
taskDescNode.active = false
|
|
tanhao.active = false
|
|
taskNode.getComponent('ScaleScripts').stopAnim()
|
|
}
|
|
|
|
|
|
let notNeedBlickTask = [MainTaskIdEnum.MainTask_509, MainTaskIdEnum.MainTask_512, MainTaskIdEnum.MainTask_516_2, MainTaskIdEnum.MainTask_524,
|
|
MainTaskIdEnum.MainTask_528,MainTaskIdEnum.MainTask_537,MainTaskIdEnum.MainTask_540,MainTaskIdEnum.MainTask_548,MainTaskIdEnum.MainTask_552,
|
|
MainTaskIdEnum.MainTask_554_2,MainTaskIdEnum.MainTask_555
|
|
]
|
|
if (mainId != MainTaskIdEnum.MainTask_None && mainId && !notNeedBlickTask.includes(mainId)) {
|
|
this.node.getChildByName("回家").getChildByName("出摊图标").getComponent(sp.Skeleton).setAnimation(0, "呼吸", true)
|
|
} else {
|
|
this.node.getChildByName("回家").getChildByName("出摊图标").getComponent(sp.Skeleton).setAnimation(0, "静止", false)
|
|
}
|
|
}
|
|
|
|
refreshChengHao() {
|
|
let chenghao = LevelUpManager.getChengHao()
|
|
this.chenghao.string = chenghao
|
|
// //this.chenghaoPic.string = chenghao
|
|
// Common5.addUrlSprite_custom('jingjie/' + chenghao, this.chenghaoPic)
|
|
let levelLab = User.getMyLevel()
|
|
this.levelLab.string = levelLab + ''
|
|
|
|
// let str1 = LevelUpManager.getCurClickIncome()
|
|
// let allshouyi1 = MiShuManager.getAllIncomeMishu()
|
|
|
|
// let allshouyi2 = MiShuManager.getAllIncomeDuiyou()
|
|
// let allNum = allshouyi1 + allshouyi2
|
|
|
|
// let beishuSP = ShipuManager.getAllShipuInCome()
|
|
// let beishuTW = TanWeiManager.getAllShipuInCome()
|
|
|
|
// let mzNum = Math.floor(allNum * beishuSP * beishuTW)
|
|
|
|
let str1 = LevelUpManager.getCurClickIncome() //人物点击收益(按等级算的) * 属性秘书加成属性摊位加成 * 出摊界面的点击收益按钮倍数 * 出摊界面的收益翻倍
|
|
let allshouyi1 = MiShuManager.getAllIncomeMishu()//秘书秒赚总收益(包含出摊界面的收益翻倍)
|
|
|
|
// let allshouyi2 = MiShuManager.getAllIncomeDuiyou()//队友秒赚总收益(包含出摊界面的收益翻倍)
|
|
// let allNum = allshouyi1 + allshouyi2
|
|
let allNum = allshouyi1
|
|
|
|
let beishuSP = ShipuManager.getAllShipuInCome()//面点界面的物品秒赚加成
|
|
let beishuTW = TanWeiManager.getAllShipuInCome() //摊位界面的物品点击加成
|
|
|
|
let chenghaoInCome = LevelUpManager.getAllChengHaoinCome() //称号倍数
|
|
|
|
let zichan = ZiChanManager.getZiChanBeiShu()
|
|
|
|
// let mzNum = Math.floor(allNum * beishuSP * beishuTW)
|
|
|
|
// let clickNum = Math.floor(str1 * beishuTW * chenghaoInCome) //点击收益
|
|
// let mzNum = Math.floor(allNum * beishuSP * chenghaoInCome * zichan) //秒赚收益
|
|
let clickNum = Math.floor(str1) //点击收益
|
|
let mzNum = Math.floor(allNum * beishuSP * chenghaoInCome * zichan) //秒赚收益
|
|
|
|
this.clickMoneyLab.string = '' + Common5.getNumberChangeHanzi(clickNum) + '/次'
|
|
this.secondMoneyLab.string = '' + Common5.getNumberChangeHanzi(mzNum) + '/秒'
|
|
|
|
}
|
|
|
|
refreshHead() {
|
|
let headSpr = this.node.getChildByName("head").getChildByName("头像").getComponent(cc.Sprite)
|
|
Common5.addUrlSprite_custom("head/" + User.getHeadImg(), headSpr);
|
|
|
|
}
|
|
|
|
//buildArray = ['后山', '美食城', '拍卖行', '厨师协会', '公益协会', '豪华游轮', '茶场', '钓鱼场', '农贸市场']
|
|
clickItemEvent(event) {
|
|
//Common5.playEffect("sound/按键点击")
|
|
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
|
|
let mainId = mainTaskInfo.Id
|
|
let config = TaskManager.getTaskConfigById(mainId)
|
|
let name = event.target.name
|
|
if (name == '后山') {
|
|
this.clickKKS()
|
|
} else if (name == '美食城') {
|
|
// this.clickQWL()
|
|
PrefabManage.showTextTips("暂未开放")
|
|
} else if (name == '拍卖行') {
|
|
// this.clickGW()
|
|
PrefabManage.loadPrefabByType(GameType.Paimaihang)
|
|
} else if (name == '厨师协会') {
|
|
//
|
|
// PrefabManage.showTextTips('闲杂人等,禁止靠近')
|
|
PrefabManage.loadPrefabByType(GameType.ChuShiXieHui)
|
|
} else if (name == '公益协会') {
|
|
PrefabManage.loadPrefabByType(GameType.WZ_firstLevelSelectView)
|
|
|
|
// let mainTaskInfo:any = TaskManager.getCurUnLockMainTaskInfo()
|
|
// let mainId = mainTaskInfo.Id
|
|
// if(mainId == MainTaskIdEnum.MainTask_523 ){
|
|
// PrefabManage.loadPrefabByType(GameType.GaiZhaoRen)
|
|
// }else{
|
|
// PrefabManage.showTextTips('闲杂人等,禁止靠近')
|
|
// }
|
|
} else if (name == '豪华游轮') {
|
|
// this.clickHJYF()
|
|
PrefabManage.loadPrefabByType(GameType.YiMaJiang, null, (prefabNode) => {
|
|
prefabNode.getComponent(YiMaJiang).initView(0);
|
|
})
|
|
} else if (name == '茶场') {
|
|
// this.clickSLC()
|
|
PrefabManage.loadPrefabByType(GameType.ChaChang)
|
|
} else if (name == '钓鱼场') {
|
|
this.clickDY()
|
|
} else if (name == '农贸市场') {
|
|
// this.clickFLJ()
|
|
if (mainId == MainTaskIdEnum.MainTask_524) {
|
|
if (User.getMoney() >= config.taskNum) {
|
|
UserManager.subMoney(config.taskNum)
|
|
PrefabManage.loadPrefabByType(GameType.ShouGouHeTong, null, (node) => {
|
|
node.getComponent(ShouGouHeTong).init(config.taskNum)
|
|
})
|
|
TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_524)
|
|
TaskManager.setCurTask(MainTaskIdEnum.MainTask_525)
|
|
} else {
|
|
PrefabManage.showTextTips("金钱不够")
|
|
}
|
|
} else if (mainId > MainTaskIdEnum.MainTask_524) {
|
|
PrefabManage.loadPrefabByType(GameType.ShiCaiHuiShou)
|
|
} else {
|
|
PrefabManage.showTextTips("暂未收购")
|
|
}
|
|
} else if (name == '花卉基地') {
|
|
PrefabManage.loadPrefabByType(GameType.BaiCaoJi)
|
|
// this.clickFLJ()
|
|
}
|
|
}
|
|
|
|
clickKKS() {
|
|
PrefabManage.loadPrefabByType(GameType.XiuXianNongZhuang)
|
|
}
|
|
|
|
clickQWL() {
|
|
PrefabManage.loadPrefabByType(GameType.QinWangLing)
|
|
}
|
|
|
|
clickGW() {
|
|
PrefabManage.loadPrefabByType(GameType.HuXinGongYuan)
|
|
}
|
|
|
|
clickHJYF() {
|
|
PrefabManage.loadPrefabByType(GameType.HuangJinYuFu)
|
|
}
|
|
|
|
clickDY() {
|
|
PrefabManage.loadPrefabByType(GameType.HJHA)
|
|
}
|
|
|
|
clickFLJ() {
|
|
PrefabManage.loadPrefabByType(GameType.FanLaji)
|
|
}
|
|
|
|
clickSLC() {
|
|
PrefabManage.loadPrefabByType(GameType.ShouLieChang)
|
|
}
|
|
|
|
|
|
bagBtnClick() {
|
|
//Common5.playEffect("sound/按键点击")
|
|
PrefabManage.loadPrefabByType(GameType.BeiBao)
|
|
}
|
|
|
|
chatLimitLevelClick() {
|
|
//Common5.playEffect("sound/按键点击")
|
|
PrefabManage.showTextTips('达到对应等级后方可解锁进入')
|
|
}
|
|
|
|
cliclLockTaskClick() {
|
|
//Common5.playEffect("sound/按键点击")
|
|
PrefabManage.showTextTips('等待任务解锁')
|
|
}
|
|
|
|
chatListClick() {
|
|
JuQingManager.openJuQingOrChat('WX')
|
|
}
|
|
|
|
taskClickEvent() {
|
|
//Common5.playEffect("sound/按键点击")
|
|
let customTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
|
|
if (customTaskInfo && Object.keys(customTaskInfo).length > 0 && customTaskInfo.Id != MainTaskIdEnum.MainTask_None) {
|
|
PrefabManage.loadPrefabByType(GameType.TaskInfoNode, this.node)
|
|
|
|
} else {
|
|
let taskIdArray = User.getCurTaskId()
|
|
console.log(taskIdArray[0], taskIdArray[1], 'taskIdArray+cityPrefab+++++===')
|
|
if (User.getCurTaskId()[0] == MainTaskIdEnum.MainTask_555 && User.getCurTaskId()[1] == 1) {
|
|
PrefabManage.showTextTips('敬请期待')
|
|
} else {
|
|
PrefabManage.showTextTips('当前无任务')
|
|
}
|
|
}
|
|
}
|
|
|
|
clickChuTan() {
|
|
//Common5.playEffect("sound/按键点击")
|
|
this.closeUi()
|
|
PrefabManage.loadPrefabByType(GameType.MainHall)
|
|
}
|
|
|
|
|
|
clickSettingBtnEvent() {
|
|
//Common5.playEffect("sound/按键点击")
|
|
PrefabManage.loadPrefabByType(GameType.PeopleLevelUp)
|
|
}
|
|
|
|
onTouchShouGou(event, customEventData) {
|
|
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
|
|
let mainId = mainTaskInfo.Id
|
|
let config = TaskManager.getTaskConfigById(mainId)
|
|
let node = event.target
|
|
if (customEventData == "农贸市场" && mainId == MainTaskIdEnum.MainTask_524) {
|
|
if (User.getMoney() >= config.taskNum) {
|
|
node.active = false
|
|
UserManager.subMoney(config.taskNum)
|
|
PrefabManage.loadPrefabByType(GameType.ShouGouHeTong, null, (node) => {
|
|
node.getComponent(ShouGouHeTong).init(config.taskNum)
|
|
})
|
|
} else {
|
|
PrefabManage.showTextTips("金钱不够")
|
|
}
|
|
} else if (customEventData == "美食城" && mainId == MainTaskIdEnum.MainTask_550_2) {
|
|
// if (User.getMoney() >= config.taskNum) {
|
|
// node.active = false
|
|
// UserManager.subMoney(config.taskNum)
|
|
// TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_550_2)
|
|
// TaskManager.setCurTask(MainTaskIdEnum.MainTask_551_1)
|
|
// } else {
|
|
// PrefabManage.showTextTips("金钱不够")
|
|
// }
|
|
}
|
|
}
|
|
|
|
updateMainTask() {
|
|
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
|
|
let mainId = mainTaskInfo.Id
|
|
let config = TaskManager.getTaskConfigById(mainId)
|
|
if (mainId == MainTaskIdEnum.MainTask_510) {
|
|
let node = this.node.getChildByName('回家')
|
|
this.guideView([node])
|
|
// this.node.getChildByName("农贸市场").getChildByName("收购").active = true
|
|
} else if (mainId == MainTaskIdEnum.MainTask_550_2) {
|
|
// this.node.getChildByName("美食城").getChildByName("收购").active = true
|
|
}
|
|
|
|
//红点
|
|
let childs = ['后山', '厨师协会', '公益协会', '美食城', '拍卖行', '豪华游轮', '花卉基地', '钓鱼场', '茶场', '农贸市场']
|
|
for (let i = 0; i < childs.length; i++) {
|
|
let redPoint = this.node.getChildByName(childs[i]).getChildByName("红点")
|
|
if (!redPoint) {
|
|
continue
|
|
}
|
|
if (config && config.ButtonTips && config.ButtonTips.includes(childs[i])) {
|
|
redPoint.active = true
|
|
} else {
|
|
redPoint.active = false
|
|
}
|
|
}
|
|
|
|
//刷新称号
|
|
let chenghao = LevelUpManager.getChengHao()
|
|
this.chenghao.string = chenghao
|
|
}
|
|
|
|
// update (dt) {}
|
|
}
|
|
|