Commit ceee5693 authored by unknown's avatar unknown

食物派对数量限制更好

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