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.
161 lines
4.9 KiB
161 lines
4.9 KiB
1 week ago
|
// 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 Common5 from "../../Platform/th/Common5";
|
||
|
|
||
|
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
|
||
|
|
||
|
const {ccclass, property} = cc._decorator;
|
||
|
|
||
|
@ccclass
|
||
|
export default class GuideScript extends cc.Component {
|
||
|
@property(cc.Label)
|
||
|
dialogStr: cc.Label = null;
|
||
|
|
||
|
|
||
|
curDialogIndex:number = 0
|
||
|
isCanClickNext:boolean = true
|
||
|
duihuaIndex:number = 0
|
||
|
duihuaStr: cc.Node = null;
|
||
|
endLog = true
|
||
|
curStr = ''
|
||
|
callFunc = null
|
||
|
dialogStrTab= [
|
||
|
"我在江湖叱诧风云,今朝入狱,回想此生,有太多遗憾......",
|
||
|
"那年父母意外离世,数万赔偿金使我迷失,从此踏上不归路",
|
||
|
"奶奶突发急病,我忙于享乐耽误送医,导致她永久离开......",
|
||
|
"对妹妹疏忽照顾,导致被拐,从此再未相见"
|
||
|
]
|
||
|
|
||
|
|
||
|
start () {
|
||
|
this.showStartGame()
|
||
|
}
|
||
|
|
||
|
showStartGame(){
|
||
|
let startLayer = this.node.getChildByName('startLayer')
|
||
|
startLayer.active = true
|
||
|
this.isCanClickNext = true
|
||
|
|
||
|
let sprArray = startLayer.getChildByName('sprArray')
|
||
|
let node_ = sprArray.children[this.curDialogIndex]
|
||
|
let recoveryPos = node_.getPosition()
|
||
|
node_.setPosition(cc.v2(recoveryPos.x-500, recoveryPos.y))
|
||
|
node_.active = true
|
||
|
|
||
|
let wenzikuang = node_.getChildByName('文字框')
|
||
|
let wzk = startLayer.getChildByName('文字框')
|
||
|
wzk.active = false
|
||
|
cc.tween(node_)
|
||
|
.to(1, {x:recoveryPos.x, y:recoveryPos.y},{easing:'elasticOut'})
|
||
|
.call(()=>{
|
||
|
Common5.setNodeToTargetPos(wzk, wenzikuang)
|
||
|
wzk.active = true
|
||
|
this.showDialogStr()
|
||
|
})
|
||
|
.start()
|
||
|
}
|
||
|
|
||
|
|
||
|
showDialogStr(){
|
||
|
this.isCanClickNext = false
|
||
|
let curStr = ""
|
||
|
let curIndex = 0
|
||
|
let str = this.dialogStrTab[this.curDialogIndex++]
|
||
|
this.dialogStr.string = str
|
||
|
|
||
|
let startLayer = this.node.getChildByName('startLayer')
|
||
|
let wzk = startLayer.getChildByName('文字框')
|
||
|
wzk.getChildByName('下一条').active = true
|
||
|
// let callFunc = ()=>{
|
||
|
// curStr += str[curIndex++]
|
||
|
// this.dialogStr.string = curStr
|
||
|
// if(curIndex >= str.length){
|
||
|
// this.scheduleOnce(()=>{
|
||
|
// let startLayer = this.node.getChildByName('startLayer')
|
||
|
// let wzk = startLayer.getChildByName('文字框')
|
||
|
// wzk.getChildByName('下一条').active = true
|
||
|
// },1)
|
||
|
// }
|
||
|
// }
|
||
|
// this.schedule(callFunc, 0.04, str.length-1)
|
||
|
// this.callFunc = callFunc
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
onBtnNextClick(){
|
||
|
if(this.isCanClickNext){
|
||
|
return
|
||
|
}
|
||
|
|
||
|
if(this.curDialogIndex >= this.dialogStrTab.length && this.endLog){
|
||
|
this.endLog = false
|
||
|
this.isCanClickNext = true
|
||
|
|
||
|
this.node.removeFromParent()
|
||
|
this.node.destroy()
|
||
|
PrefabManage.loadPrefabByType(GameType.GuideEnd)
|
||
|
|
||
|
|
||
|
}else{
|
||
|
this.isCanClickNext = true
|
||
|
|
||
|
this.dialogStr.string = ''
|
||
|
let startLayer = this.node.getChildByName('startLayer')
|
||
|
let wzk = startLayer.getChildByName('文字框')
|
||
|
wzk.getChildByName('下一条').active = false
|
||
|
this.showStartGame()
|
||
|
|
||
|
}
|
||
|
// if(this.curDialogIndex >= this.dialogStrTab.length && this.endLog){
|
||
|
// console.log('下一个预制体GuideEnd')
|
||
|
|
||
|
// this.unschedule(this.callFunc)
|
||
|
// this.isCanClickNext = true
|
||
|
// this.dialogStr.string = this.curStr
|
||
|
// this.endLog = false
|
||
|
// this.scheduleOnce(()=>{
|
||
|
|
||
|
// this.node.removeFromParent()
|
||
|
// this.node.destroy()
|
||
|
// PrefabManage.loadPrefabByType(GameType.GuideEnd)
|
||
|
// },1.0)
|
||
|
|
||
|
// return
|
||
|
// }else{
|
||
|
|
||
|
// this.unschedule(this.callFunc)
|
||
|
// this.isCanClickNext = true
|
||
|
// this.dialogStr.string = this.curStr
|
||
|
// this.scheduleOnce(()=>{
|
||
|
|
||
|
// this.dialogStr.string = ''
|
||
|
// let startLayer = this.node.getChildByName('startLayer')
|
||
|
// let wzk = startLayer.getChildByName('文字框')
|
||
|
// wzk.getChildByName('下一条').active = false
|
||
|
// this.showStartGame()
|
||
|
// },1.0)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
// }
|
||
|
}
|
||
|
|
||
|
|
||
|
skipJuqing(){
|
||
|
this.unschedule(this.callFunc)
|
||
|
this.node.removeFromParent()
|
||
|
this.node.destroy()
|
||
|
PrefabManage.loadPrefabByType(GameType.GuideEnd)
|
||
|
}
|
||
|
|
||
|
// update (dt) {}
|
||
|
}
|