Commit 0486f6a6 authored by Friends233's avatar Friends233

增加伸绳子速度配置,调整加分逻辑

parent 52de0a2b
......@@ -19,6 +19,9 @@ export const Config = {
/** 摇晃速度 */
rotationSpeed: 1,
/** 爪子伸出去的速度 */
playSpeed: 350,
/** 普通道具移动速度 */
normalPropSpeed: 250,
......
......@@ -16,7 +16,9 @@ const CLIP_STATE = {
/** 出钩 */
PLAY: 'clipPlay',
/** 收回 */
STOP: 'clipStop'
STOP: 'clipStop',
/** 游戏结束 */
GAME_OVER: 'gameOver'
}
@ccclass
......@@ -99,15 +101,10 @@ export default class GameScene extends cc.Component {
/** 爪子碰撞事件 */
onCollEnter({ detail }) {
const other: cc.Collider = detail.other
// 抓到加分道具
if (other.tag == 1) {
this.setStarProc()
}
this.clipTarget = other.node
this.clipSpeed = other.tag == 1 ? Config.bestPropSpeed : Config.normalPropSpeed
other.tag = 0
this.setClipState(CLIP_STATE.STOP)
}
/** 添加节点的事件 */
......@@ -118,8 +115,11 @@ export default class GameScene extends cc.Component {
this.node.on(CUSTOM_EVENT.CLIP_COLLISION, this.onCollEnter, this)
}
/** 设置爪子状态 */
setClipState(state) {
/**
* 设置爪子状态
* @param state CLIP_STATE
*/
setClipState(state, cb) {
const ani = cc.find('clipMask/clipWrp', this.node).getComponent(cc.Animation)
const node = cc.find('clipMask/clipWrp/clip', this.node)
const clip = node.getComponent(cc.Animation)
......@@ -136,6 +136,10 @@ export default class GameScene extends cc.Component {
this.clip.active = false
// 有道具销毁道具
if (this.clipTarget) {
// 加分道具
if (this.clipTarget.getComponent(cc.Collider).tag == 1) {
this.setStarProc()
}
this.clipTarget.getComponent('propMove').die(() => {
this.clipTarget = null
})
......@@ -153,7 +157,12 @@ export default class GameScene extends cc.Component {
// 播放爪子动效
clip.play(state)
break;
case CLIP_STATE.GAME_OVER:
ani.stop()
clip.stop()
break;
}
cb?.()
}
/** 出钩 */
......@@ -165,6 +174,7 @@ export default class GameScene extends cc.Component {
/** 游戏结束 */
gameOver() {
this.isGameOver = true
this.setClipState(CLIP_STATE.GAME_OVER)
this.unschedule(this.startCd)
}
......@@ -182,6 +192,7 @@ export default class GameScene extends cc.Component {
if (!cd || cd <= 0) {
this.setLable('cdIcon/cd', `0s`)
console.log('倒计时结束')
this.gameOver()
this.unschedule(this.startCd)
return
}
......@@ -322,7 +333,7 @@ export default class GameScene extends cc.Component {
this.setClipState(CLIP_STATE.STOP)
return
}
this.clip.y -= dt * this.clipSpeed
this.clip.y -= dt * Config.playSpeed
}
// 爪子回收
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment