Commit 0486f6a6 authored by Friends233's avatar Friends233

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

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