|
@@ -3,6 +3,7 @@ import {Data, Mgr} from '../GameControl'
|
|
|
import {GuideUI} from '../ui/public/GuideUI'
|
|
|
import {PathUtils} from '../utils/PathUtils'
|
|
|
import {ACT_TYPE, GAME_TYPE, PLAY_STATE} from '../enums/Enum'
|
|
|
+import {DrawBoard} from '../uiutils/DrawBoard'
|
|
|
|
|
|
const {ccclass, property} = cc._decorator
|
|
|
|
|
@@ -128,19 +129,86 @@ class CustomActionUnion {
|
|
|
|
|
|
@ccclass
|
|
|
export default class GuideRule extends cc.Component {
|
|
|
- guideUI: GuideUI
|
|
|
- dataJson: any
|
|
|
+ @property({
|
|
|
+ displayName: '节点执行顺序',
|
|
|
+ })
|
|
|
+ actionTag: number = 0
|
|
|
+ @property({
|
|
|
+ displayName: '节点队列执行',
|
|
|
+ })
|
|
|
+ nodeSequence: boolean = false
|
|
|
@property({type: [CustomActionUnion], displayName: '动作组'})
|
|
|
actions: CustomActionUnion[] = []
|
|
|
@property({type: [CustomAudio], displayName: '声音'})
|
|
|
audios: CustomAudio[] = []
|
|
|
@property({displayName: '跳转页数'})
|
|
|
jumpPage: number = -1
|
|
|
+ @property({
|
|
|
+ displayName: '画线节点',
|
|
|
+ })
|
|
|
+ isGraphics: boolean = false
|
|
|
+ @property({
|
|
|
+ displayName: '画线宽带',
|
|
|
+ visible() {
|
|
|
+ return this.isGraphics
|
|
|
+ },
|
|
|
+ })
|
|
|
+ drawLineWidth: number = 0
|
|
|
+ @property({
|
|
|
+ displayName: '画线颜色',
|
|
|
+ visible() {
|
|
|
+ return this.isGraphics
|
|
|
+ },
|
|
|
+ })
|
|
|
+ drawColor: cc.Color = cc.Color.WHITE
|
|
|
+ @property({
|
|
|
+ displayName: '画线起点(圆心)',
|
|
|
+ visible() {
|
|
|
+ return this.isGraphics
|
|
|
+ },
|
|
|
+ })
|
|
|
+ drawStartPos: cc.Vec2 = cc.v2(0, 0)
|
|
|
+ @property({
|
|
|
+ displayName: '画线终点',
|
|
|
+ visible() {
|
|
|
+ return this.isGraphics
|
|
|
+ },
|
|
|
+ })
|
|
|
+ drawEndPos: cc.Vec2 = cc.v2(0, 0)
|
|
|
+ @property({
|
|
|
+ displayName: '画线半径',
|
|
|
+ min: 0,
|
|
|
+ visible() {
|
|
|
+ return this.isGraphics
|
|
|
+ },
|
|
|
+ })
|
|
|
+ drawRadius: number = 0
|
|
|
+
|
|
|
+ guideUI: GuideUI
|
|
|
+ dataJson: any
|
|
|
playState: PLAY_STATE = PLAY_STATE.start
|
|
|
async initUI(data: any) {
|
|
|
this.dataJson = data
|
|
|
this.reset()
|
|
|
- if (data.particle && !CC_EDITOR) {
|
|
|
+ let {
|
|
|
+ particle,
|
|
|
+ ani = '',
|
|
|
+ tex = '',
|
|
|
+ jumpPage = -1,
|
|
|
+ actions = [],
|
|
|
+ audios = [],
|
|
|
+ isGraphics = false,
|
|
|
+ drawStartPos = cc.v2(0, 0),
|
|
|
+ drawEndPos = cc.v2(0, 0),
|
|
|
+ drawRadius = 0,
|
|
|
+ drawLineWidth = 0,
|
|
|
+ drawColor = '#ffffff',
|
|
|
+ actionTag = 0,
|
|
|
+ nodeSequence = false,
|
|
|
+ } = data
|
|
|
+ this.actionTag = actionTag
|
|
|
+ this.nodeSequence = nodeSequence
|
|
|
+ if (particle && !CC_EDITOR) {
|
|
|
this.node.removeComponent(cc.Sprite)
|
|
|
let particleSystem = this.node.addComponent(cc.ParticleSystem)
|
|
|
particleSystem.playOnLoad = true
|
|
@@ -155,58 +223,97 @@ export default class GuideRule extends cc.Component {
|
|
|
if (!this.node.getComponent(cc.Sprite)) this.node.addComponent(cc.Sprite)
|
|
|
}
|
|
|
let animation = this.node.getComponent(cc.Animation)
|
|
|
- if (data.ani && !CC_EDITOR) {
|
|
|
+ if (ani && !CC_EDITOR) {
|
|
|
animation.getClips().forEach(clip => {
|
|
|
animation.removeClip(clip, true)
|
|
|
})
|
|
|
let clip: cc.AnimationClip = await this.guideUI.loadSync(
|
|
|
Data.game.gameBundle,
|
|
|
- PathUtils.addGP('guide/' + data.ani, '', 1),
|
|
|
+ PathUtils.addGP('guide/' + ani, '', 1),
|
|
|
cc.AnimationClip,
|
|
|
)
|
|
|
animation.addClip(clip)
|
|
|
}
|
|
|
- if (data.tex) this.guideUI.loadSemeImg(PathUtils.addGP('guide/' + data.tex, '', 1), this.node)
|
|
|
- if (data.jumpPage) this.jumpPage = data.jumpPage
|
|
|
+ if (tex) this.guideUI.loadSemeImg(PathUtils.addGP('guide/' + tex, '', 1), this.node)
|
|
|
+ this.jumpPage = jumpPage
|
|
|
this.actions = []
|
|
|
- if (data.actions) {
|
|
|
- for (let i = 0; i < data.actions.length; i++) {
|
|
|
- let action: any = data.actions[i]
|
|
|
- let customActionUnion: CustomActionUnion = new CustomActionUnion()
|
|
|
- customActionUnion.isSequence = action.isSequence
|
|
|
- if (action.repeat) customActionUnion.repeat = action.repeat
|
|
|
- if (action.endDelay) customActionUnion.endDelay = action.endDelay
|
|
|
- if (action.startDelay) customActionUnion.startDelay = action.startDelay
|
|
|
- customActionUnion.actions = []
|
|
|
- for (let i = 0; i < action.actions.length; i++) {
|
|
|
- let customAction: CustomAction = new CustomAction()
|
|
|
- let customActionData = action.actions[i]
|
|
|
- customAction.actionType = customActionData.actionType
|
|
|
- if (customActionData.pos != undefined)
|
|
|
- customAction.pos = cc.v2(customActionData.pos.x, customActionData.pos.y)
|
|
|
- if (customActionData.scale != undefined) {
|
|
|
- customAction.scale = cc.v2(customActionData.scale.x, customActionData.scale.y)
|
|
|
- }
|
|
|
- if (customActionData.rotate != undefined) customAction.rotate = customActionData.rotate
|
|
|
- if (customActionData.height != undefined) customAction.height = customActionData.height
|
|
|
- if (customActionData.jumpTimes != undefined) customAction.jumpTimes = customActionData.jumpTimes
|
|
|
- if (customActionData.opacity != undefined) customAction.opacity = customActionData.opacity
|
|
|
- if (customActionData.endOpacity != undefined) customAction.endOpacity = customActionData.endOpacity
|
|
|
- if (customActionData.runTime != undefined) customAction.runTime = customActionData.runTime
|
|
|
- if (customActionData.startDelay != undefined) customAction.startDelay = customActionData.startDelay
|
|
|
- if (customActionData.endDelay != undefined) customAction.endDelay = customActionData.endDelay
|
|
|
- if (customActionData.audios != undefined) {
|
|
|
- customAction.audios = this.getCustomAudioObj(customActionData)
|
|
|
- }
|
|
|
- customAction.isSequence = customActionData.isSequence
|
|
|
- if (customActionData.repeat) customAction.repeat = customActionData.repeat
|
|
|
- customActionUnion.actions.push(customAction)
|
|
|
- }
|
|
|
- this.actions.push(customActionUnion)
|
|
|
+ for (let i = 0; i < actions.length; i++) {
|
|
|
+ let {isSequence = true, repeat = 0, endDelay = 0, startDelay = 0} = actions[i]
|
|
|
+ let customActionUnion: CustomActionUnion = new CustomActionUnion()
|
|
|
+ customActionUnion.isSequence = isSequence
|
|
|
+ customActionUnion.repeat = repeat
|
|
|
+ customActionUnion.endDelay = endDelay
|
|
|
+ customActionUnion.startDelay = startDelay
|
|
|
+ customActionUnion.actions = []
|
|
|
+ let action = actions[i]
|
|
|
+ for (let i = 0; i < action.actions.length; i++) {
|
|
|
+ let customAction: CustomAction = new CustomAction()
|
|
|
+ let {
|
|
|
+ actionType = 0,
|
|
|
+ pos = cc.v2(0, 0),
|
|
|
+ scale = cc.v2(0, 0),
|
|
|
+ rotate = 0,
|
|
|
+ height = 0,
|
|
|
+ jumpTimes = 0,
|
|
|
+ opacity = 0,
|
|
|
+ endOpacity = 255,
|
|
|
+ runTime = 0,
|
|
|
+ startDelay = 0,
|
|
|
+ endDelay = 0,
|
|
|
+ isSequence = true,
|
|
|
+ repeat = 0,
|
|
|
+ audios = [],
|
|
|
+ } = action.actions[i]
|
|
|
+ customAction.actionType = actionType
|
|
|
+ customAction.pos = cc.v2(pos.x, pos.y)
|
|
|
+ customAction.scale = cc.v2(scale.x, scale.y)
|
|
|
+ customAction.rotate = rotate
|
|
|
+ customAction.height = height
|
|
|
+ customAction.jumpTimes = jumpTimes
|
|
|
+ customAction.opacity = opacity
|
|
|
+ customAction.endOpacity = endOpacity
|
|
|
+ customAction.runTime = runTime
|
|
|
+ customAction.startDelay = startDelay
|
|
|
+ customAction.endDelay = endDelay
|
|
|
+ customAction.audios = this.getCustomAudioObj(audios)
|
|
|
+ customAction.isSequence = isSequence
|
|
|
+ customAction.repeat = repeat
|
|
|
+ customActionUnion.actions.push(customAction)
|
|
|
}
|
|
|
+ this.actions.push(customActionUnion)
|
|
|
+ }
|
|
|
+ this.audios = this.getCustomAudioObj(audios)
|
|
|
+ this.drawRadius = drawRadius
|
|
|
+ this.drawEndPos = cc.v2(drawEndPos.x, drawEndPos.y)
|
|
|
+ this.drawStartPos = cc.v2(drawStartPos.x, drawStartPos.y)
|
|
|
+ this.drawLineWidth = drawLineWidth
|
|
|
+ this.drawColor = cc.Color.WHITE.fromHEX(drawColor)
|
|
|
+ this.isGraphics = isGraphics
|
|
|
+ let sprite = this.node.getComponent(cc.Sprite)
|
|
|
+ if (isGraphics) {
|
|
|
+ let pos = cc.v2(drawEndPos.x + 640, drawEndPos.y + 400)
|
|
|
+ let posStart = cc.v2(drawStartPos.x + 640, drawStartPos.y + 400)
|
|
|
+ let db = new DrawBoard(1280, 800, 1)
|
|
|
+ db.setLineWidth(drawLineWidth)
|
|
|
+ db.setColor(this.drawColor.r, this.drawColor.g, this.drawColor.b, this.drawColor.a)
|
|
|
+ if (this.drawRadius > 0) {
|
|
|
+ db.circle(posStart.x, posStart.y, drawRadius)
|
|
|
+ db.setColor(0, 0, 0, 0)
|
|
|
+ db.circle(posStart.x, posStart.y, drawRadius - drawLineWidth)
|
|
|
+ } else {
|
|
|
+ db.line(posStart.x, posStart.y, pos.x, pos.y)
|
|
|
+ }
|
|
|
+ //将数据传递给贴图对象
|
|
|
+ sprite.sizeMode = cc.Sprite.SizeMode.CUSTOM
|
|
|
+ this.node.width = db.width
|
|
|
+ this.node.height = db.height
|
|
|
+ let texture = new cc.RenderTexture()
|
|
|
+ texture.initWithSize(db.width, db.height, cc.RenderTexture.DepthStencilFormat.RB_FMT_S8)
|
|
|
+ sprite.spriteFrame = new cc.SpriteFrame(texture)
|
|
|
+ texture.initWithData(db.getData(), cc.Texture2D.PixelFormat.RGBA8888, db.width, db.height)
|
|
|
+ } else {
|
|
|
+ sprite.sizeMode = cc.Sprite.SizeMode.TRIMMED
|
|
|
}
|
|
|
- this.audios = []
|
|
|
- if (data.audios) this.audios = this.getCustomAudioObj(data)
|
|
|
}
|
|
|
reset() {
|
|
|
this.node.stopAllActions()
|
|
@@ -233,9 +340,9 @@ export default class GuideRule extends cc.Component {
|
|
|
}
|
|
|
getCustomAudioObj(data) {
|
|
|
let audios = []
|
|
|
- for (let i = 0; i < data.audios.length; i++) {
|
|
|
+ for (let i = 0; i < data.length; i++) {
|
|
|
let customAudio: CustomAudio = new CustomAudio()
|
|
|
- let audioData = data.audios[i]
|
|
|
+ let audioData = data[i]
|
|
|
customAudio.audioDelay = audioData.audioDelay
|
|
|
customAudio.audioName = audioData.audioName
|
|
|
audios.push(customAudio)
|
|
@@ -392,7 +499,7 @@ export default class GuideRule extends cc.Component {
|
|
|
}
|
|
|
allUnionActionArr[allUnionActionIndex].tween.push(unionTween)
|
|
|
}
|
|
|
- let allUnionAction = t()
|
|
|
+ let allUnionAction = t().delay(this.dataJson.actionTagDelayTime)
|
|
|
for (let manyUnionAction of allUnionActionArr) {
|
|
|
if (manyUnionAction.lastUnionSequence || manyUnionAction.tween.length <= 1) {
|
|
|
for (let tempAction of manyUnionAction.tween) {
|