Commit 3a0764c8 authored by spc's avatar spc

1

parent eb1968b2
......@@ -4,6 +4,8 @@ import { Target } from "../Components/Target";
import { EPropType } from "../Common/Enums";
import { MainGame } from "../MainGame";
import gameStore from "../../../store/gameStore";
import { showToast } from "db://assets/Module/UIFast";
import { _asyncThrottle } from "../../../Utils/Utils";
const { ccclass } = _decorator;
@ccclass('DoubleExpPropBtn')
......@@ -17,14 +19,28 @@ export class DoubleExpPropBtn extends PropBtn {
}
async doUse() {
if (this.propNum > 0 && MainGame.ins.player.isLife && await gameStore.useProps('sp_experience_card')) {
doUse = _asyncThrottle(async () => {
if (!MainGame.ins.player.isLife) {
return
}
if (this.propNum <= 0) {
showToast('请在首页【游戏道具】中购买')
return
}
if (gameStore.gameInfo.useSpCount >= gameStore.startInfo.eachUseLimitTimes) {
showToast("本局使用道具达到上限")
return
}
if (await gameStore.useProps('sp_experience_card')) {
gameStore.gameInfo.useSpCount += 1
super.doUse();
this.propNum -= 1;
MainGame.ins.player.useDouble()
this.startCd();
}
}
})
}
......
......@@ -2,6 +2,8 @@ import { _decorator, Component, Node, tween } from "cc";
import { PropBtn } from "../Components/PropBtn";
import { MainGame } from "../MainGame";
import gameStore from "../../../store/gameStore";
import { showToast } from "db://assets/Module/UIFast";
import { _asyncThrottle } from "../../../Utils/Utils";
const { ccclass, property } = _decorator;
@ccclass('GrowPropBtn')
......@@ -13,14 +15,28 @@ export class GrowPropBtn extends PropBtn {
}
async doUse() {
if (this.propNum > 0 && MainGame.ins.player.isLife && await gameStore.useProps('sp_add_length')) {
doUse = _asyncThrottle(async () => {
if (!MainGame.ins.player.isLife) {
return
}
if (this.propNum <= 0) {
showToast('请在首页【游戏道具】中购买')
return
}
if (gameStore.gameInfo.useSpCount >= gameStore.startInfo.eachUseLimitTimes) {
showToast("本局使用道具达到上限")
return
}
if (await gameStore.useProps('sp_add_length')) {
gameStore.gameInfo.useSpCount += 1
super.doUse();
this.propNum -= 1;
MainGame.ins.player.useGrow()
this.startCd();
}
}
})
}
......
......@@ -5,6 +5,8 @@ import { Target } from "../Components/Target";
import { EPropType } from "../Common/Enums";
import { MainGame } from "../MainGame";
import gameStore from "../../../store/gameStore";
import { showToast } from "db://assets/Module/UIFast";
import { _asyncThrottle } from "../../../Utils/Utils";
const { ccclass } = _decorator;
......@@ -17,14 +19,27 @@ export class ShieldPropBtn extends PropBtn {
}
async doUse() {
if (this.propNum > 0 && MainGame.ins.player.isLife && await gameStore.useProps('sp_shield_card')) {
doUse = _asyncThrottle(async () => {
if (!MainGame.ins.player.isLife) {
return
}
if (this.propNum <= 0) {
showToast('请在首页【游戏道具】中购买')
return
}
if (gameStore.gameInfo.useSpCount >= gameStore.startInfo.eachUseLimitTimes) {
showToast("本局使用道具达到上限")
return
}
if (await gameStore.useProps('sp_shield_card')) {
gameStore.gameInfo.useSpCount += 1
super.doUse();
this.propNum -= 1;
MainGame.ins.player.useDefense()
this.startCd();
}
}
})
}
......
......@@ -5,6 +5,8 @@ import { Global } from "../Global";
import { Target } from "../Components/Target";
import { EPropType } from "../Common/Enums";
import gameStore from "../../../store/gameStore";
import { showToast } from "db://assets/Module/UIFast";
import { _asyncThrottle } from "../../../Utils/Utils";
const { ccclass, property } = _decorator;
@ccclass('SpeedPropBtn')
......@@ -17,14 +19,28 @@ export class SpeedPropBtn extends PropBtn {
}
async doUse() {
if (this.propNum > 0 && MainGame.ins.player.isLife && await gameStore.useProps('sp_agility_card')) {
doUse = _asyncThrottle(async () => {
if (!MainGame.ins.player.isLife) {
return
}
if (this.propNum <= 0) {
showToast('请在首页【游戏道具】中购买')
return
}
if (gameStore.gameInfo.useSpCount >= gameStore.startInfo.eachUseLimitTimes) {
showToast("本局使用道具达到上限")
return
}
if (await gameStore.useProps('sp_agility_card')) {
gameStore.gameInfo.useSpCount += 1
super.doUse();
this.propNum -= 1;
MainGame.ins.player.useSpeed()
this.startCd();
}
}
})
}
......
......@@ -651,6 +651,7 @@ export class Snake extends Component {
* 使用加速道具
*/
useSpeed() {
this.clearSpeed()
this.moveScale = 2;
this.isSpeed = true;
this.scheduleOnce(this.clearSpeed, Global.PROP_SPEED_DUR_TIME)
......@@ -674,6 +675,7 @@ export class Snake extends Component {
useDouble() {
this.clearDouble()
this.doubleStatus = true;
this.scheduleOnce(this.clearDouble, Global.PROP_DOUBLE_EXP_DUR_TIME)
......
......@@ -31,6 +31,7 @@ export interface IStartInfo {
currentDressUp: "sp_decoration_default" | "sp_skin_snake_year", // sp_decoration_default装扮默认皮肤,sp_skin_snake_year装扮蛇皮肤
startId: number, // 游戏记录ID
slideScore: number, // 校验滑块的分数值
eachUseLimitTimes: number //每局可使用道具限制数量
}
......@@ -40,7 +41,8 @@ class GameStore {
length: 0,
killNum: 0,
luckNum: 0,
composeSpList: {}
composeSpList: {},
useSpCount: 0
};
startInfo: IStartInfo = null;
......@@ -65,6 +67,7 @@ class GameStore {
killNum: 0,
luckNum: 0,
composeSpList: {},
useSpCount: 0
};
return success;
......
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