Commit ceee5693 authored by unknown's avatar unknown

食物派对数量限制更好

parent a1720fd6
...@@ -162,7 +162,7 @@ export class FFTPPipAnswerView extends Component { ...@@ -162,7 +162,7 @@ export class FFTPPipAnswerView extends Component {
playDisappearAct(endCb?: Function) { playDisappearAct(endCb?: Function) {
this.mainNode.setPosition(0, this.orgV3.y, this.orgV3.z); this.mainNode.setPosition(0, this.orgV3.y, this.orgV3.z);
tween(this.mainNode) tween(this.mainNode)
.delay(2) .delay(1)
.to(0.5, { position: v3(-3000, this.orgV3.y, this.orgV3.z) }) .to(0.5, { position: v3(-3000, this.orgV3.y, this.orgV3.z) })
.call(() => { .call(() => {
if (typeof endCb == "function") { if (typeof endCb == "function") {
......
...@@ -100,8 +100,8 @@ export class FoodForThePartyCtr extends Component { ...@@ -100,8 +100,8 @@ export class FoodForThePartyCtr extends Component {
//@ts-ignore //@ts-ignore
this.foodVarCount = resData.foodVarCount; this.foodVarCount = resData.foodVarCount;
} }
//@ts-ignore //@ts-ignore
if (resData.foodNumCount) { if (resData.foodNumCount) {
//@ts-ignore //@ts-ignore
this.foodNumCount = resData.foodNumCount; this.foodNumCount = resData.foodNumCount;
} }
...@@ -285,6 +285,7 @@ export class FoodForThePartyCtr extends Component { ...@@ -285,6 +285,7 @@ export class FoodForThePartyCtr extends Component {
names = this.randomCopyNameToNameArr(names); names = this.randomCopyNameToNameArr(names);
names = this.disorderArr(names); names = this.disorderArr(names);
names = this.excludeMoreFood(names); names = this.excludeMoreFood(names);
names = this.addLessFood(names);
console.log(`${this.pips[i].getPipName()}管道的物品`); console.log(`${this.pips[i].getPipName()}管道的物品`);
console.log(names); console.log(names);
this.pips[i].setFoodsImgNames(this.imgHead, names); this.pips[i].setFoodsImgNames(this.imgHead, names);
...@@ -307,8 +308,23 @@ export class FoodForThePartyCtr extends Component { ...@@ -307,8 +308,23 @@ export class FoodForThePartyCtr extends Component {
} }
outCount += 1; outCount += 1;
} }
if(outCount >= 10000){ if (outCount >= 10000) {
console.log(`食物数量限制可能发生死循环`); console.log(`食物数量减少限制可能发生死循环`);
}
return names;
}
addLessFood(names: string[]): string[] {
if (this.foodVarCount >= this.foodNumCount) {
throw new Error("食物种类大于食物数量限制");
}
let outCount = 0;
while (names.length < this.foodNumCount && outCount < 10000) {
names.push(names[Math.floor(Math.random() * names.length)]);
outCount += 1;
}
if (outCount >= 10000) {
console.log(`食物数量增加限制可能发生死循环`);
} }
return names; return names;
} }
......
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