Commit 910da6a4 authored by haiyoucuv's avatar haiyoucuv

init

parent 69ead5e9
......@@ -73,7 +73,7 @@ export class FoodManger extends Component {
*/
addFood(x?: number, y?: number, energy: number = 1) {
const maxW = Global.MAP_HEIGHT / 2 - 100;
const maxW = Global.MAP_WIDTH / 2 - 100;
const maxH = Global.MAP_HEIGHT / 2 - 100;
// 如果没有指定位置,随机生成位置
......
......@@ -35,10 +35,16 @@ export class LuckyBagManager extends Component {
}
start() {
this.flushItems();
this.flush();
}
flushItems() {
check() {
if (this.node.children.length <= 0) {
this.flush();
}
}
flush() {
const { luckNum } = gameStore.gameInfo || {};
const { currentAcquireNum } = gameStore.startInfo || {};
......@@ -48,9 +54,10 @@ export class LuckyBagManager extends Component {
}
add(num: number = 1) {
if (!num || num <= 0) return;
const maxW = Global.MAP_HEIGHT / 2 - 100;
const maxH = (Global.MAP_HEIGHT / 2 - 100);
const maxW = Global.MAP_WIDTH / 2 - 100;
const maxH = Global.MAP_HEIGHT / 2 - 100;
for (let i = 1; i <= num; i++) {
const x = math.randomRange(-maxW, maxW);
......
import { _decorator } from "cc";
import { PropBase } from "./PropBase";
import { Snake } from "../Snake";
import { LuckyBagManager } from "../Manager/LuckyBagManager";
const { ccclass, property } = _decorator;
......@@ -12,6 +13,7 @@ export class LuckyBag extends PropBase {
};
recycle() {
LuckyBagManager.ins.check();
this.node.removeFromParent();
this.node.destroy();
// propPool.put(this.node);
......
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