chore
parent
1497ad137e
commit
96f20b864f
|
@ -16,7 +16,7 @@ node_modules/
|
||||||
#//////////////////////////
|
#//////////////////////////
|
||||||
# VSCode
|
# VSCode
|
||||||
#//////////////////////////
|
#//////////////////////////
|
||||||
.vscode/
|
# .vscode/
|
||||||
|
|
||||||
#//////////////////////////
|
#//////////////////////////
|
||||||
# WebStorm
|
# WebStorm
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "chrome",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Cocos Creator Launch Chrome against localhost",
|
||||||
|
"url": "http://localhost:7456",
|
||||||
|
"webRoot": "${workspaceFolder}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
|
"files.exclude": {
|
||||||
|
"**/*.meta": true
|
||||||
|
},
|
||||||
|
"search.exclude": {
|
||||||
|
"**/*.meta": true
|
||||||
|
},
|
||||||
|
"cSpell.ignoreWords": ["Poolable", "ccclass", "endregion", "lerp"]
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -8043,7 +8043,7 @@
|
||||||
"propertyPath": [
|
"propertyPath": [
|
||||||
"playOnAwake"
|
"playOnAwake"
|
||||||
],
|
],
|
||||||
"value": false
|
"value": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.TargetInfo",
|
"__type__": "cc.TargetInfo",
|
||||||
|
@ -13700,6 +13700,10 @@
|
||||||
"__uuid__": "1ac12acc-dde3-4d31-9106-dfc30c030d40",
|
"__uuid__": "1ac12acc-dde3-4d31-9106-dfc30c030d40",
|
||||||
"__expectedType__": "cc.AudioClip"
|
"__expectedType__": "cc.AudioClip"
|
||||||
},
|
},
|
||||||
|
"_soundScore": {
|
||||||
|
"__uuid__": "65a023cb-b98f-4470-ba2d-4eba9fe184fe",
|
||||||
|
"__expectedType__": "cc.AudioClip"
|
||||||
|
},
|
||||||
"_starSpeedCurve": {
|
"_starSpeedCurve": {
|
||||||
"__id__": 517
|
"__id__": 517
|
||||||
},
|
},
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1 +0,0 @@
|
||||||
{"ver":"1.1.43","importer":"scene","imported":true,"uuid":"1603dcdc-3263-4117-83c3-30ad0c3bf5a0","files":[".json"],"subMetas":{},"userData":{}}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +0,0 @@
|
||||||
{
|
|
||||||
"ver": "1.1.43",
|
|
||||||
"importer": "scene",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "82e6ef2e-3f9c-4d4e-ab02-dc963e925b88",
|
|
||||||
"files": [
|
|
||||||
".json"
|
|
||||||
],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -15,7 +15,7 @@ export class BoosterBase extends Component implements IPoolable {
|
||||||
protected _collectSound: AudioClip;
|
protected _collectSound: AudioClip;
|
||||||
@property({ type: Animation, visible: true })
|
@property({ type: Animation, visible: true })
|
||||||
private _animation: Animation;
|
private _animation: Animation;
|
||||||
@property()
|
@property(CCString)
|
||||||
public readonly displayName: string = 'CHEESE';
|
public readonly displayName: string = 'CHEESE';
|
||||||
|
|
||||||
@property(CCFloat)
|
@property(CCFloat)
|
||||||
|
|
|
@ -12,7 +12,6 @@ import {
|
||||||
Vec3,
|
Vec3,
|
||||||
AudioClip,
|
AudioClip,
|
||||||
randomRange,
|
randomRange,
|
||||||
math,
|
|
||||||
CCFloat,
|
CCFloat,
|
||||||
clamp01,
|
clamp01,
|
||||||
ParticleSystem,
|
ParticleSystem,
|
||||||
|
@ -243,9 +242,7 @@ export class CumulativeBar extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
private calcPositionOnCircleLine(angle: number) {
|
private calcPositionOnCircleLine(angle: number) {
|
||||||
const rad = math.toRadian(angle);
|
this._currentValuePosition = this._center.getPositionOnCircle(angle, this._radius);
|
||||||
this._currentValuePosition.x = this._center.x + this._radius * -Math.cos(rad);
|
|
||||||
this._currentValuePosition.y = this._center.y + this._radius * Math.sin(rad);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private onBoosterActive(type: BoosterType) {
|
private onBoosterActive(type: BoosterType) {
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"ver": "1.1.0",
|
||||||
|
"importer": "directory",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "28df4abf-05c0-49c1-8d10-2657ddc1df26",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {
|
||||||
|
"compressionType": {},
|
||||||
|
"isRemoteBundle": {}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,209 @@
|
||||||
|
import {
|
||||||
|
Component,
|
||||||
|
IVec2Like,
|
||||||
|
IVec3Like,
|
||||||
|
Label,
|
||||||
|
Node,
|
||||||
|
NodeSpace,
|
||||||
|
Vec2,
|
||||||
|
Vec3,
|
||||||
|
randomRangeInt,
|
||||||
|
toDegree,
|
||||||
|
toRadian,
|
||||||
|
} from 'cc';
|
||||||
|
import ObjectPool from '../Pool/ObjectPool';
|
||||||
|
|
||||||
|
declare module 'cc' {
|
||||||
|
interface Component {
|
||||||
|
setNodeActive(isActive: boolean): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Node {
|
||||||
|
setActive(isActive: boolean): void;
|
||||||
|
setPositionX(x: number): void;
|
||||||
|
setPositionY(y: number): void;
|
||||||
|
setPositionZ(z: number): void;
|
||||||
|
translateX(x: number, ns?: NodeSpace): void;
|
||||||
|
translateY(y: number, ns?: NodeSpace): void;
|
||||||
|
translateZ(z: number, ns?: NodeSpace): void;
|
||||||
|
setScaleX(x: number): void;
|
||||||
|
setScaleY(y: number): void;
|
||||||
|
setScaleZ(z: number): void;
|
||||||
|
releaseToPool(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Vec2 {
|
||||||
|
toVec3(): Vec3;
|
||||||
|
getPositionOnCircle(angle: number, radius?: number): Vec2;
|
||||||
|
getAngleOnCircle(center: IVec2Like): number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Vec3 {
|
||||||
|
toVec2(): Vec2;
|
||||||
|
getPositionOnCircle(angle: number, radius?: number): Vec3;
|
||||||
|
getAngleOnCircle(center: IVec3Like): number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Label {
|
||||||
|
setString(value: string | number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface String {
|
||||||
|
jsonParse(): any;
|
||||||
|
isNullOrWhiteSpace(): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Array<T> {
|
||||||
|
getRandom(): T;
|
||||||
|
getRandom(weights: number[]): T;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//#region COMPONENT
|
||||||
|
|
||||||
|
Component.prototype.setNodeActive = function (isActive: boolean) {
|
||||||
|
this.node.setActive(isActive);
|
||||||
|
};
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region NODE
|
||||||
|
|
||||||
|
Node.prototype.setActive = function (isActive: boolean) {
|
||||||
|
this.active = isActive;
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.setPositionX = function (x: number): void {
|
||||||
|
this.position = new Vec3(x, this.position.y, this.position.z);
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.setPositionY = function (y: number): void {
|
||||||
|
this.position = new Vec3(this.position.x, y, this.position.z);
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.setPositionZ = function (z: number): void {
|
||||||
|
this.position = new Vec3(this.position.x, this.position.y, z);
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.translateX = function (x: number, ns?: NodeSpace): void {
|
||||||
|
this.translate(new Vec3(x, 0), ns);
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.translateY = function (y: number, ns?: NodeSpace): void {
|
||||||
|
this.translate(new Vec3(0, y), ns);
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.translateZ = function (z: number, ns?: NodeSpace): void {
|
||||||
|
this.translate(new Vec3(0, 0, z), ns);
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.setScaleX = function (x: number): void {
|
||||||
|
this.scale = new Vec3(x, this.scale.y, this.scale.z);
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.setScaleY = function (y: number): void {
|
||||||
|
this.scale = new Vec3(this.scale.x, y, this.scale.z);
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.setScaleZ = function (z: number): void {
|
||||||
|
this.scale = new Vec3(this.scale.x, this.scale.y, z);
|
||||||
|
};
|
||||||
|
|
||||||
|
Node.prototype.releaseToPool = function () {
|
||||||
|
ObjectPool.release(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region VEC2
|
||||||
|
|
||||||
|
Vec2.prototype.toVec3 = function () {
|
||||||
|
return new Vec3(this.x, this.y);
|
||||||
|
};
|
||||||
|
|
||||||
|
Vec2.prototype.getPositionOnCircle = function (angle: number, radius?: number) {
|
||||||
|
const rad = toRadian(angle);
|
||||||
|
const r = radius || 1;
|
||||||
|
const x = this.x + r * -Math.cos(rad);
|
||||||
|
const y = this.y + r * Math.sin(rad);
|
||||||
|
return new Vec2(x, y);
|
||||||
|
};
|
||||||
|
|
||||||
|
Vec2.prototype.getAngleOnCircle = function (center: IVec2Like): number {
|
||||||
|
const diffX = this.x - center.x;
|
||||||
|
const diffY = this.y - center.y;
|
||||||
|
const angle = Math.atan2(diffY, diffX);
|
||||||
|
return toDegree(angle) - 90;
|
||||||
|
};
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region VEC3
|
||||||
|
|
||||||
|
Vec3.prototype.toVec2 = function () {
|
||||||
|
return new Vec2(this.x, this.y);
|
||||||
|
};
|
||||||
|
|
||||||
|
Vec3.prototype.getPositionOnCircle = function (angle: number, radius?: number) {
|
||||||
|
const rad = toRadian(angle);
|
||||||
|
const r = radius || 1;
|
||||||
|
const x = this.x + r * -Math.cos(rad);
|
||||||
|
const y = this.y + r * Math.sin(rad);
|
||||||
|
return new Vec3(x, y, this.z);
|
||||||
|
};
|
||||||
|
|
||||||
|
Vec3.prototype.getAngleOnCircle = function (center: IVec3Like): number {
|
||||||
|
const diffX = this.x - center.x;
|
||||||
|
const diffY = this.y - center.y;
|
||||||
|
const angle = Math.atan2(diffY, diffX);
|
||||||
|
return toDegree(angle) - 90;
|
||||||
|
};
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region LABEL
|
||||||
|
|
||||||
|
Label.prototype.setString = function (value: string | number) {
|
||||||
|
if (typeof value == 'number') {
|
||||||
|
this.string = value.toString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.string = value;
|
||||||
|
};
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region STRING
|
||||||
|
|
||||||
|
String.prototype.jsonParse = function () {
|
||||||
|
try {
|
||||||
|
return JSON.parse(this);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
String.prototype.isNullOrWhiteSpace = function () {
|
||||||
|
return !this || !this.trim();
|
||||||
|
};
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region ARRAY
|
||||||
|
|
||||||
|
Array.prototype.getRandom = function (weights?: number[]) {
|
||||||
|
if (weights) {
|
||||||
|
let weightsClone = [...weights];
|
||||||
|
const totalWeight = weightsClone.reduce((a, b) => a + b, 0);
|
||||||
|
let random = Math.random() * totalWeight;
|
||||||
|
const item = this.find((_, i) => (random -= weightsClone[i]) <= 0);
|
||||||
|
return item;
|
||||||
|
} else {
|
||||||
|
return this[randomRangeInt(0, this.length)];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//#endregion
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"ver": "4.0.23",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "ef8a3d0f-bd57-4232-b422-72267aa4f4a7",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
|
@ -74,7 +74,7 @@ export class Enemy extends Component {
|
||||||
this._processDistance = 0;
|
this._processDistance = 0;
|
||||||
this._currentGoal = 0;
|
this._currentGoal = 0;
|
||||||
this._isActive = false;
|
this._isActive = false;
|
||||||
this._collider.node.active = false;
|
this._collider.setNodeActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected update(dt: number): void {
|
protected update(dt: number): void {
|
||||||
|
@ -121,7 +121,7 @@ export class Enemy extends Component {
|
||||||
this._currentGoal++;
|
this._currentGoal++;
|
||||||
if (this._currentGoal == this._requireGoal) {
|
if (this._currentGoal == this._requireGoal) {
|
||||||
this._sprite.node.setScale(Vec3.ZERO);
|
this._sprite.node.setScale(Vec3.ZERO);
|
||||||
this._collider.node.active = true;
|
this._collider.setNodeActive(true);
|
||||||
tween(this._sprite.node.scale)
|
tween(this._sprite.node.scale)
|
||||||
.delay(1)
|
.delay(1)
|
||||||
.to(0.5, Vec3.ONE, {
|
.to(0.5, Vec3.ONE, {
|
||||||
|
|
|
@ -189,15 +189,15 @@ export class Ball extends Component implements IPoolable {
|
||||||
private onBoosterActive() {
|
private onBoosterActive() {
|
||||||
// this._fireParticle.play();
|
// this._fireParticle.play();
|
||||||
this._cheeseModeOn = true;
|
this._cheeseModeOn = true;
|
||||||
this._cheeseModeSprite.node.active = true;
|
this._cheeseModeSprite.setNodeActive(true);
|
||||||
this._normalSprite.node.active = false;
|
this._normalSprite.setNodeActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onBoosterDisable() {
|
private onBoosterDisable() {
|
||||||
// this._fireParticle.stop();
|
// this._fireParticle.stop();
|
||||||
this._cheeseModeOn = false;
|
this._cheeseModeOn = false;
|
||||||
this._cheeseModeSprite.node.active = false;
|
this._cheeseModeSprite.setNodeActive(false);
|
||||||
this._normalSprite.node.active = true;
|
this._normalSprite.setNodeActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private afterPhysicUpdate() {
|
private afterPhysicUpdate() {
|
||||||
|
|
|
@ -4,9 +4,7 @@ import { ScoreObject } from '../Environments/ScoreObject';
|
||||||
import { EventManger } from './EventManger';
|
import { EventManger } from './EventManger';
|
||||||
import GameEvent from '../Events/GameEvent';
|
import GameEvent from '../Events/GameEvent';
|
||||||
import GameState from '../Enum/GameState';
|
import GameState from '../Enum/GameState';
|
||||||
import Utilities from '../Utilities';
|
|
||||||
import ScoreType from '../Enum/ScoreType';
|
import ScoreType from '../Enum/ScoreType';
|
||||||
import Singleton from '../Singleton';
|
|
||||||
import { BoosterBase } from '../Booster/BoosterBase';
|
import { BoosterBase } from '../Booster/BoosterBase';
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
|
@ -90,7 +88,7 @@ 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;
|
||||||
do {
|
do {
|
||||||
var randomPool = Utilities.weightedRandom(this._pools, this._weights);
|
var randomPool = this._pools.getRandom(this._weights);
|
||||||
var index = this._pools.indexOf(randomPool);
|
var index = this._pools.indexOf(randomPool);
|
||||||
} while (this._objects[index].maxObjects != -1 && randomPool.countActive >= this._objects[index].maxObjects);
|
} while (this._objects[index].maxObjects != -1 && randomPool.countActive >= this._objects[index].maxObjects);
|
||||||
|
|
||||||
|
@ -106,7 +104,7 @@ export class SpawnObjectManager extends Component {
|
||||||
private spawnBooster() {
|
private spawnBooster() {
|
||||||
if (Object.keys(this._usedPoints).length == this._spawnPoints.length) return;
|
if (Object.keys(this._usedPoints).length == this._spawnPoints.length) return;
|
||||||
do {
|
do {
|
||||||
var randomPool = Utilities.weightedRandom(this._boosterPools, this._boosterWeights);
|
var randomPool = this._boosterPools.getRandom(this._boosterWeights);
|
||||||
var index = this._boosterPools.indexOf(randomPool);
|
var index = this._boosterPools.indexOf(randomPool);
|
||||||
} while (this._boosters[index].maxObjects != -1 && randomPool.countActive >= this._boosters[index].maxObjects);
|
} while (this._boosters[index].maxObjects != -1 && randomPool.countActive >= this._boosters[index].maxObjects);
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,12 @@ export class ConfirmPanel extends Component {
|
||||||
@property(Label) ticketWaringText: Label = null;
|
@property(Label) ticketWaringText: Label = null;
|
||||||
|
|
||||||
protected onEnable(): void {
|
protected onEnable(): void {
|
||||||
this.ticketWaringText.string = `To continue playing, you will be deducted ${BEConnector.instance.getTicketCanBeMinus()} ticket`;
|
this.ticketWaringText.string = `To continue playing, you will be deducted ${BEConnector.getTicketCanBeMinus()} ticket`;
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickYesButton() {
|
onClickYesButton() {
|
||||||
if (BEConnector.instance.canRelive()) {
|
if (BEConnector.canRelive()) {
|
||||||
BEConnector.instance
|
BEConnector.checkGameScoreTicket()
|
||||||
.checkGameScoreTicket()
|
|
||||||
.then(() => {
|
.then(() => {
|
||||||
GameManager.instance.gameRelive();
|
GameManager.instance.gameRelive();
|
||||||
})
|
})
|
||||||
|
@ -22,11 +21,11 @@ export class ConfirmPanel extends Component {
|
||||||
GameManager.instance.gameOver();
|
GameManager.instance.gameOver();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
BEConnector.instance.postMessage();
|
BEConnector.postMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickNoButton() {
|
onClickNoButton() {
|
||||||
this.node.active = false;
|
this.node.setActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import Utilities from '../Utilities';
|
||||||
import { EventManger } from '../Manager/EventManger';
|
import { EventManger } from '../Manager/EventManger';
|
||||||
import GameEvent from '../Events/GameEvent';
|
import GameEvent from '../Events/GameEvent';
|
||||||
import GameState from '../Enum/GameState';
|
import GameState from '../Enum/GameState';
|
||||||
import { SequenceSound } from '../Environments/SequenceSound';
|
|
||||||
import { SoundManager } from '../Manager/SoundManager';
|
import { SoundManager } from '../Manager/SoundManager';
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
|
@ -30,6 +29,8 @@ export class GameOverPanel extends Component {
|
||||||
|
|
||||||
@property({ type: AudioClip, visible: true })
|
@property({ type: AudioClip, visible: true })
|
||||||
private _soundCollectCoinFx: AudioClip;
|
private _soundCollectCoinFx: AudioClip;
|
||||||
|
@property({ type: AudioClip, visible: true })
|
||||||
|
private _soundScore: AudioClip;
|
||||||
|
|
||||||
@property({ type: geometry.AnimationCurve, visible: true })
|
@property({ type: geometry.AnimationCurve, visible: true })
|
||||||
private _starSpeedCurve: geometry.AnimationCurve = new geometry.AnimationCurve();
|
private _starSpeedCurve: geometry.AnimationCurve = new geometry.AnimationCurve();
|
||||||
|
@ -160,6 +161,7 @@ export class GameOverPanel extends Component {
|
||||||
|
|
||||||
await Utilities.waitUntil(() => this._pool.countActive == 0, 0.1);
|
await Utilities.waitUntil(() => this._pool.countActive == 0, 0.1);
|
||||||
this.yourScore.string = totalScore.toString();
|
this.yourScore.string = totalScore.toString();
|
||||||
|
SoundManager.instance.playSfx(this._soundScore);
|
||||||
Tween.stopAllByTarget(this.yourScore.node);
|
Tween.stopAllByTarget(this.yourScore.node);
|
||||||
tween(this.yourScore.node)
|
tween(this.yourScore.node)
|
||||||
.set({ scale: Vec3.ONE })
|
.set({ scale: Vec3.ONE })
|
||||||
|
|
|
@ -75,10 +75,10 @@ export class TutorialController extends Component {
|
||||||
|
|
||||||
private async playTutorial() {
|
private async playTutorial() {
|
||||||
if (this._canShow) {
|
if (this._canShow) {
|
||||||
this._tapL.active = true;
|
this._tapL.setActive(true);
|
||||||
this._tapR.active = true;
|
this._tapR.setActive(true);
|
||||||
this._tapLEffect.node.active = true;
|
this._tapLEffect.setNodeActive(true);
|
||||||
this._tapREffect.node.active = true;
|
this._tapREffect.setNodeActive(true);
|
||||||
|
|
||||||
tween(this._tapL)
|
tween(this._tapL)
|
||||||
.call(() => this._tapLEffect.clear())
|
.call(() => this._tapLEffect.clear())
|
||||||
|
@ -105,10 +105,10 @@ export class TutorialController extends Component {
|
||||||
Tween.stopAllByTarget(this._tapR);
|
Tween.stopAllByTarget(this._tapR);
|
||||||
this._timer = 0;
|
this._timer = 0;
|
||||||
this._showed = false;
|
this._showed = false;
|
||||||
this._tapLEffect.node.active = false;
|
this._tapLEffect.setNodeActive(false);
|
||||||
this._tapREffect.node.active = false;
|
this._tapREffect.setNodeActive(false);
|
||||||
this._tapL.active = false;
|
this._tapL.setActive(false);
|
||||||
this._tapR.active = false;
|
this._tapR.setActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private startGame() {
|
private startGame() {
|
||||||
|
|
|
@ -35,6 +35,8 @@ export class UIController extends Component {
|
||||||
EventManger.instance.on(GameEvent.BoosterActive, this.onBoosterActive, this);
|
EventManger.instance.on(GameEvent.BoosterActive, this.onBoosterActive, this);
|
||||||
EventManger.instance.on(GameEvent.BoosterDisable, this.onBoosterDisable, this);
|
EventManger.instance.on(GameEvent.BoosterDisable, this.onBoosterDisable, this);
|
||||||
EventManger.instance.on(GameEvent.TicketUpdate, this.onTicketUpdate, this);
|
EventManger.instance.on(GameEvent.TicketUpdate, this.onTicketUpdate, this);
|
||||||
|
|
||||||
|
this._buffFx.setNodeActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async onScore(score: number, points: number, type: ScoreType) {
|
private async onScore(score: number, points: number, type: ScoreType) {
|
||||||
|
@ -68,7 +70,7 @@ export class UIController extends Component {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case GameState.GameOver:
|
case GameState.GameOver:
|
||||||
this._buffFx.stop();
|
this._buffFx.setNodeActive(false);
|
||||||
await Utilities.waitUntil(() => !GameManager.instance.isWaitingUpdateScore);
|
await Utilities.waitUntil(() => !GameManager.instance.isWaitingUpdateScore);
|
||||||
await Utilities.delay(2);
|
await Utilities.delay(2);
|
||||||
this._overPanel.active = true;
|
this._overPanel.active = true;
|
||||||
|
@ -90,7 +92,7 @@ export class UIController extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
public onBoosterActive(type: BoosterType, displayName: string) {
|
public onBoosterActive(type: BoosterType, displayName: string) {
|
||||||
this._buffFx.play();
|
this._buffFx.setNodeActive(true);
|
||||||
StickerManager.instance.showLabel(displayName + '!!!', {
|
StickerManager.instance.showLabel(displayName + '!!!', {
|
||||||
color: new Color('#ffb517'),
|
color: new Color('#ffb517'),
|
||||||
outLineColor: new Color('#ec830a'),
|
outLineColor: new Color('#ec830a'),
|
||||||
|
@ -98,7 +100,7 @@ export class UIController extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
public onBoosterDisable() {
|
public onBoosterDisable() {
|
||||||
this._buffFx.stop();
|
this._buffFx.setNodeActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public starGame() {
|
public starGame() {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import { Vec2, Vec3 } from 'cc';
|
|
||||||
|
|
||||||
export default class Utilities {
|
export default class Utilities {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -28,30 +26,4 @@ export default class Utilities {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vec2ToVec3(Vec2: Vec2): Vec3 {
|
|
||||||
return new Vec3(Vec2.x, Vec2.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vec3ToVec2(Vec3: Vec3): Vec2 {
|
|
||||||
return new Vec2(Vec3.x, Vec3.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static weightedRandom<T>(items: T[], weights: number[]): T {
|
|
||||||
const weightsClone = [...weights];
|
|
||||||
const totalWeight = weightsClone.reduce((a, b) => a + b, 0);
|
|
||||||
let random = Math.random() * totalWeight;
|
|
||||||
const item = items.find((_, i) => (random -= weightsClone[i]) <= 0);
|
|
||||||
return item;
|
|
||||||
// for (i = 1; i < weightsClone.length; i++) {
|
|
||||||
// weightsClone[i] += weights[i - 1];
|
|
||||||
// }
|
|
||||||
|
|
||||||
// let random = Math.random() * weightsClone[weightsClone.length - 1];
|
|
||||||
|
|
||||||
// for (i = 0; i < weightsClone.length; i++) {
|
|
||||||
// if (weightsClone[i] > random) break;
|
|
||||||
// }
|
|
||||||
// return [items[i], i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue