feat: update gameplay

main
tiendat3699 2024-03-13 11:36:19 +07:00
parent 6e8f0aa965
commit 8f4734cee6
7 changed files with 22 additions and 9 deletions

View File

@ -17749,7 +17749,8 @@
}, },
"weight": 100, "weight": 100,
"weightStepOnGoal": 0, "weightStepOnGoal": 0,
"maxWeight": 100 "maxWeight": 100,
"maxObjects": -1
}, },
{ {
"__type__": "weightedObject", "__type__": "weightedObject",
@ -17759,7 +17760,8 @@
}, },
"weight": 0, "weight": 0,
"weightStepOnGoal": 5, "weightStepOnGoal": 5,
"maxWeight": 30 "maxWeight": 30,
"maxObjects": 2
}, },
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
@ -17809,7 +17811,7 @@
"y": -1200, "y": -1200,
"z": 0 "z": 0
}, },
"_timePlay": 120, "_timePlay": 90,
"_startSound": { "_startSound": {
"__uuid__": "6452248b-259c-4844-b0e1-70f47d69955e", "__uuid__": "6452248b-259c-4844-b0e1-70f47d69955e",
"__expectedType__": "cc.AudioClip" "__expectedType__": "cc.AudioClip"

View File

@ -74,7 +74,6 @@ export class GameManager extends Component {
} }
private addScore(score: number, type: ScoreType, position: Vec3) { private addScore(score: number, type: ScoreType, position: Vec3) {
score = this._isMultiBall ? score * 2 : score;
this._score += score; this._score += score;
const floatingScore = this._FloatingScorePool.get(this._floatingTextContainer, FloatingText); const floatingScore = this._FloatingScorePool.get(this._floatingTextContainer, FloatingText);
floatingScore.show(`+${score}`, position, score >= 100 ? 1.5 : 1, score >= 100 ? 1 : 0.7); floatingScore.show(`+${score}`, position, score >= 100 ? 1.5 : 1, score >= 100 ? 1 : 0.7);
@ -124,7 +123,7 @@ export class GameManager extends Component {
} }
public async goal(bonusScore: number, position: Vec3) { public async goal(bonusScore: number, position: Vec3) {
this.addScore(bonusScore, ScoreType.Goal, position); this.addScore(this._isMultiBall ? bonusScore * 2 : bonusScore, ScoreType.Goal, position);
this.setCurrentBallInGame(-1); this.setCurrentBallInGame(-1);
if (this._currentBallInGame <= 0) { if (this._currentBallInGame <= 0) {
await Utilities.delay(TimeConfig.DelayGoal); await Utilities.delay(TimeConfig.DelayGoal);

View File

@ -18,6 +18,8 @@ class weightedObject {
public weightStepOnGoal = 0; public weightStepOnGoal = 0;
@property(CCInteger) @property(CCInteger)
public maxWeight = 0; public maxWeight = 0;
@property(CCInteger)
public maxObjects = -1;
} }
@ccclass('SpawnObjectManager') @ccclass('SpawnObjectManager')
@ -67,7 +69,9 @@ export class SpawnObjectManager extends Component {
private spawn() { private spawn() {
if (Object.keys(this._usedPoints).length == this._spawnPoints.length) return; if (Object.keys(this._usedPoints).length == this._spawnPoints.length) return;
var randomPool = Utilities.weightedRandom(this._pools, this._weights); do {
var [randomPool, index] = Utilities.weightedRandom(this._pools, this._weights);
} while (this._objects[index].maxObjects != -1 && randomPool.countActive >= this._objects[index].maxObjects);
do { do {
var randomPoint = this._spawnPoints[randomRangeInt(0, this._spawnPoints.length)]; var randomPoint = this._spawnPoints[randomRangeInt(0, this._spawnPoints.length)];
} while (Object.values(this._usedPoints).indexOf(randomPoint) != -1); } while (Object.values(this._usedPoints).indexOf(randomPoint) != -1);

View File

@ -68,6 +68,7 @@ export class UIController extends Component {
this._overPanel.active = false; this._overPanel.active = false;
break; break;
case GameState.GameOver: case GameState.GameOver:
this._buffFx.stop();
this._playing = false; this._playing = false;
this._overPanel.active = true; this._overPanel.active = true;
this._resultLabel.string = this._scoreLabel.string; this._resultLabel.string = this._scoreLabel.string;

View File

@ -27,7 +27,7 @@ export default class Utilities {
} }
} }
public static weightedRandom<T>(items: T[], weights: number[]): T { public static weightedRandom<T>(items: T[], weights: number[]): [T, number] {
let i = 0; let i = 0;
const weightsClone = [...weights]; const weightsClone = [...weights];
for (i = 1; i < weightsClone.length; i++) { for (i = 1; i < weightsClone.length; i++) {
@ -39,6 +39,6 @@ export default class Utilities {
for (i = 0; i < weightsClone.length; i++) { for (i = 0; i < weightsClone.length; i++) {
if (weightsClone[i] > random) break; if (weightsClone[i] > random) break;
} }
return items[i]; return [items[i], i];
} }
} }

BIN
settings/splash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 KiB

View File

@ -1,3 +1,10 @@
{ {
"__version__": "1.3.4" "__version__": "1.3.4",
"splash-setting": {
"displayRatio": 1,
"totalTime": 2000,
"watermarkLocation": "default",
"autoFit": true,
"url": "C:\\ProgramData\\cocos\\editors\\Creator\\3.7.2\\resources\\app.asar.unpacked\\builtin\\builder\\static\\logo\\logo.png"
}
} }