feat: refactor project

main
tiendat3699 2024-03-06 16:28:01 +07:00
parent f03d95d12a
commit a6e330bbca
132 changed files with 7470 additions and 33633 deletions

View File

@ -1,10 +0,0 @@
{
"__type__": "cc.PhysicsMaterial",
"_name": "",
"_objFlags": 0,
"_native": "",
"_friction": 2,
"_rollingFriction": 0,
"_spinningFriction": 0,
"_restitution": 0.5
}

View File

@ -1,11 +0,0 @@
{
"ver": "1.0.1",
"importer": "physics-material",
"imported": true,
"uuid": "e48b2190-6e7f-4293-99c7-18cdcc00d3c3",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +0,0 @@
{
"ver": "1.1.43",
"importer": "scene",
"imported": true,
"uuid": "3ce41ed6-6584-40b1-94f9-8464439aa57d",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +0,0 @@
{
"ver": "1.1.43",
"importer": "scene",
"imported": true,
"uuid": "4c16bf85-f009-4abe-b793-f3a1924392e4",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

View File

@ -1,10 +0,0 @@
export enum EventType {
MainMenu = 'MainMenu',
StartGame = 'StartGame',
PlayGame = 'Playgame',
UpdateScore = 'SendScore',
UpdateStreak = 'UpdateSteak',
UpdateHighestStreak = 'UpdateHighestStreak',
UpdateBall = 'UpdateBall',
EndGame = 'EndGame',
}

View File

@ -1,86 +0,0 @@
import {
_decorator,
Component,
EventKeyboard,
EventMouse,
EventTouch,
Input,
input,
KeyCode,
screen as Screen,
} from 'cc';
import { Flipper } from './Flipper';
const { ccclass, property } = _decorator;
@ccclass('FlipperController')
export class FlipperController extends Component {
@property(Flipper)
public lFlipper: Flipper;
@property(Flipper)
public rFlipper: Flipper;
protected onLoad(): void {
// Mouse input
// input.on(Input.EventType.MOUSE_DOWN, this.HandleFlipperActive, this);
// input.on(Input.EventType.MOUSE_UP, this.HandleFlipperDeActive, this);
// Keyboard
input.on(Input.EventType.KEY_DOWN, this.OnKeyDown, this);
input.on(Input.EventType.KEY_UP, this.OnKeyUp, this);
// Touch
input.on(Input.EventType.TOUCH_START, this.HandleFlipperActiveTouch, this);
input.on(Input.EventType.TOUCH_END, this.HandleFlipperDeActiveTouch, this);
}
//#region Handle mouse/touch input
private HandleFlipperActive(params: EventMouse): void {
if (params.getLocationX() > screen.width / 2) {
this.rFlipper.ActiveFlipper();
} else {
this.lFlipper.ActiveFlipper();
}
}
private HandleFlipperDeActive(params: EventMouse): void {
this.rFlipper.DeActiveFlipper();
this.lFlipper.DeActiveFlipper();
}
private HandleFlipperActiveTouch(params: EventTouch): void {
if (params.getLocationX() > Screen.windowSize.x / 2) {
console.log('right');
this.rFlipper.ActiveFlipper();
} else {
console.log('left');
this.lFlipper.ActiveFlipper();
}
}
private HandleFlipperDeActiveTouch(params: EventTouch): void {
this.rFlipper.DeActiveFlipper();
this.lFlipper.DeActiveFlipper();
}
//#endregion
private OnKeyDown(event: EventKeyboard) {
switch (event.keyCode) {
case KeyCode.ARROW_LEFT:
case KeyCode.KEY_A:
this.lFlipper.ActiveFlipper();
break;
case KeyCode.ARROW_RIGHT:
case KeyCode.KEY_D:
this.rFlipper.ActiveFlipper();
break;
}
}
private OnKeyUp(event: EventKeyboard) {
switch (event.keyCode) {
case KeyCode.ARROW_LEFT:
case KeyCode.KEY_A:
this.lFlipper.DeActiveFlipper();
break;
case KeyCode.ARROW_RIGHT:
case KeyCode.KEY_D:
this.rFlipper.DeActiveFlipper();
break;
}
}
}

View File

@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "e458ed52-5d28-471b-aae5-0916cb2cc344",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -1,255 +0,0 @@
import {
_decorator,
CCInteger,
Component,
Enum,
EventTarget,
instantiate,
Node,
ParticleSystem,
Prefab,
randomRangeInt,
RigidBody2D,
Vec2,
Vec3,
} from 'cc';
import { Ball } from './Ball';
import { EventType } from './Enums';
import { SoundManager } from './SoundManager';
import BEConnector from './BEConnector';
import { UIController } from './UIController';
import { LevelController } from './LevelController';
import Utilities from './Utilities/Utilities';
const { ccclass, property } = _decorator;
window.addEventListener('message', (data) => {
const { data: res } = data;
const objectRes = Utilities.getJson(res);
if (objectRes) {
const { type, value } = objectRes;
if (type === 'newTicket') {
BEConnector.instance.numberTicket += value;
GameplayController.Instance().OnRevive();
}
}
});
export enum GameState {
MainMenu,
StartGame,
PlayGame,
EndGame,
}
@ccclass('GameplayController')
export class GameplayController extends Component {
//#region Singleton
private static instance: GameplayController;
public static Instance(): GameplayController {
if (!GameplayController.instance) {
GameplayController.instance = new Node().addComponent(GameplayController);
}
return GameplayController.instance;
}
protected onLoad(): void {
GameplayController.instance = this;
}
//#endregion
//#region Properties
@property(Prefab)
private ballPrefab: Prefab;
@property([Vec2])
private startPositions: Vec2[] = [];
@property(UIController)
public uiController: UIController = null;
@property(LevelController)
private levelController: LevelController = null;
@property({ readonly: true, type: CCInteger })
public score: number = 0;
@property({ readonly: true, type: CCInteger })
private streak: number = 0;
@property({ readonly: true, type: CCInteger })
public highestStreak: number = 0;
// @property({ readonly: true, type: CCInteger })
@property(CCInteger)
private ball: number = 10;
@property(CCInteger)
private scoreToSpawnObstacle: number = 5;
@property({ type: Enum(GameState) })
public currentGameState: GameState = GameState.MainMenu;
@property(ParticleSystem)
public particle: ParticleSystem = null;
@property(CCInteger)
public startGameCountDown: number = 3;
@property([Node])
private randomEnemies: Node[] = [];
@property(CCInteger)
private maxRandomEnemies = 0;
//#endregion
private _currentRandomEnemies = 0;
public eventMenuGame = new EventTarget();
private _currentBallsInGame = 0;
public eventStartGame = new EventTarget();
public eventPlayGame = new EventTarget();
public eventEndGame = new EventTarget();
public eventSpawnObstacle = new EventTarget();
public eventUpdateScore = new EventTarget();
public eventUpdateStreak = new EventTarget();
public eventUpdateHighestStreak = new EventTarget();
public eventUpdateBall = new EventTarget();
protected start(): void {
BEConnector.instance.authenticate();
this.ChangeGameState(GameState.MainMenu);
this.randomEnemies.forEach((enemy) => (enemy.active = false));
}
public SpawnBall(): Ball {
if (this.currentGameState == GameState.EndGame) return;
const ballClone = instantiate(this.ballPrefab);
ballClone.setParent(this.node);
let randonPos = randomRangeInt(0, this.startPositions.length);
ballClone.setPosition(this.startPositions[randonPos].x, this.startPositions[randonPos].y, 0);
const ball = ballClone.getComponent(Ball);
ball.eventHitObstacle.on('HitObstacle', this.ObstacleHitControl, this);
ball.eventGoal.on('Goal', this.GoalControl, this);
this._currentBallsInGame++;
return ball;
}
public SpawnBallInTime(time: number): void {
if (this.ball <= 0) return;
if (this.currentGameState == GameState.EndGame) return;
this.spawnEnemies();
//this.unscheduleAllCallbacks();
console.log(GameState[this.currentGameState]);
this.scheduleOnce(() => {
const ball = this.SpawnBall();
let dir = randomRangeInt(-1, 2);
while (dir == 0) {
dir = randomRangeInt(-1, 2);
}
const force = new Vec2(dir, 1);
ball.getComponent(RigidBody2D).applyLinearImpulse(force.multiply2f(3, 50), Vec2.ZERO, true);
SoundManager.Instance().PlayOneShot(SoundManager.Instance().whistle);
}, time);
this.SetupObstacle();
}
private spawnEnemies() {
this._currentRandomEnemies = 0;
this.randomEnemies.forEach((enemy) => {
if (this._currentRandomEnemies >= this.maxRandomEnemies) return;
const chance = randomRangeInt(0, 100) <= 50;
enemy.active = chance;
if (chance) this._currentRandomEnemies++;
});
}
//#region Events
public AddScore(score: number): void {
this.score += score;
this.streak++;
this.eventUpdateStreak.emit(EventType.UpdateStreak, this.streak);
if (this.streak > 2) {
let addBall = this.streak - 2;
this.ball += addBall;
}
if (this.highestStreak < this.streak) {
this.highestStreak = this.streak;
this.eventUpdateHighestStreak.emit(EventType.UpdateHighestStreak, this.highestStreak);
}
this.eventUpdateBall.emit(EventType.UpdateBall, this.ball);
this.eventUpdateScore.emit(EventType.UpdateScore, this.score);
SoundManager.Instance().PlayOneShot(SoundManager.Instance().sfxGoal);
}
public LoseStreak(): void {
this.streak = 0;
this.eventUpdateStreak.emit(EventType.UpdateStreak, this.streak);
}
public ChangeGameState(newState: GameState): void {
if (this.currentGameState == newState) return;
this.currentGameState = newState;
this.StateChangeHandle();
}
private StateChangeHandle(): void {
switch (this.currentGameState) {
case GameState.MainMenu:
this.eventMenuGame.emit(EventType.MainMenu);
break;
case GameState.StartGame:
this.eventStartGame.emit(EventType.StartGame);
this.SpawnBallInTime(this.startGameCountDown);
this.levelController?.LevelUp();
BEConnector.instance.ticketMinus('auth');
break;
case GameState.PlayGame:
this.eventUpdateBall.emit(EventType.UpdateBall, this.ball);
this.eventPlayGame.emit(EventType.PlayGame);
break;
case GameState.EndGame:
this.eventEndGame.emit(EventType.EndGame);
BEConnector.instance.postScoreToServer(this.score);
break;
}
}
public SetBall(ball: number): void {
this.ball = ball;
this.eventUpdateBall.emit(EventType.UpdateBall, this.ball);
}
//#endregion
private SetupObstacle(): void {
if (this.score < this.scoreToSpawnObstacle + 2) return;
this.eventSpawnObstacle.emit('SpawnObstacle');
// this.harderObstacle.active = true;
}
private ObstacleHitControl(node: Node): void {
node.active = false;
this.scheduleOnce(function () {
node.active = true;
}, 3);
}
private GoalControl(positon: Vec3): void {
const pos = positon;
pos.z = this.particle.node.position.z;
this.particle.node.setWorldPosition(pos);
this.particle.play();
}
public OnRevive(): void {
this.uiController.ShutEndPnl();
this.ball += 5;
this.eventUpdateBall.emit(EventType.UpdateBall, this.ball);
this.SpawnBallInTime(1);
}
public updateCurrentBallsInGame(value: number) {
this._currentBallsInGame += value;
if (this._currentBallsInGame == 0) {
this.ball--;
this.eventUpdateBall.emit(EventType.UpdateBall, this.ball);
if (this.ball <= 0) this.ChangeGameState(GameState.EndGame);
else this.SpawnBallInTime(1);
}
}
}

View File

@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "b343e78a-054d-4d1a-89b7-a80ea1ae6ef2",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -1,95 +0,0 @@
import { _decorator, CCInteger, Component, Node, randomRangeInt } from 'cc';
import { GameplayController } from './GameplayController';
import { EventType } from './Enums';
const { ccclass, property } = _decorator;
@ccclass('LevelController')
export class LevelController extends Component {
@property(CCInteger)
private maxLevel: number = 5;
@property({ type: CCInteger, readonly: true })
private currentLevel: number = 0;
@property([Node])
private levelObstacles: Node[] = [];
@property([CCInteger])
private levelBalls: number[] = [];
@property([CCInteger])
private scoreToLevelUp: number[] = [];
private isLeveledUp: boolean = false;
protected start(): void {
this.maxLevel = 5;
GameplayController.Instance().eventUpdateScore.on(EventType.UpdateScore, this.HandleLevelUp, this);
}
public HandleLevelUp(score: number): void {
for (let i = this.scoreToLevelUp.length - 1; i >= 0; i--) {
if (score == this.scoreToLevelUp[i] && !this.isLeveledUp) {
this.LevelUp();
this.isLeveledUp = true;
}
}
if (this.currentLevel >= this.maxLevel) {
console.log('Current level is: ' + this.currentLevel + ' while max level is: ' + this.maxLevel);
}
this.scoreToLevelUp.forEach((scoreCheck) => {
if (score == scoreCheck) return;
this.isLeveledUp = false;
});
}
public LevelUp(): void {
if (this.currentLevel >= this.maxLevel) return;
this.currentLevel++;
GameplayController.Instance().SetBall(this.levelBalls[this.currentLevel - 1]);
this.ObstacleControl();
GameplayController.Instance().uiController.currentLevelTxt.string = 'Level: ' + this.currentLevel;
}
public GetCurrentLevel(): number {
return this.currentLevel;
}
private ObstacleControl(): void {
switch (this.currentLevel) {
case 1:
this.levelObstacles.forEach((obstacle) => {
obstacle.active = false;
});
break;
case 2:
this.levelObstacles.forEach((obstacle) => {
obstacle.active = false;
});
this.levelObstacles[0].active = true;
break;
case 3:
this.levelObstacles.forEach((obstacle) => {
obstacle.active = false;
});
this.levelObstacles[1].active = true;
break;
case 4:
this.levelObstacles.forEach((obstacle) => {
obstacle.active = false;
});
this.levelObstacles[2].active = true;
break;
case 5:
this.RandomSetObstacle();
break;
}
}
private RandomSetObstacle(): void {
setTimeout(() => {
let random = randomRangeInt(0, this.levelObstacles.length);
this.levelObstacles.forEach((element) => {
element.active = false;
});
this.levelObstacles[random].active = true;
}, 200);
}
}

View File

@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "f88557af-13ae-4526-a423-6e54702ec00e",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -1,40 +0,0 @@
import { _decorator, Collider2D, Component, Contact2DType, RigidBody2D, Vec2, Node } from 'cc';
import { GameplayController } from './GameplayController';
import Utilities from './Utilities/Utilities';
const { ccclass, property } = _decorator;
@ccclass('MultiBall')
export class MultiBall extends Component {
@property(Collider2D)
private collider: Collider2D;
private trigged = false;
private originBall: Node;
protected onLoad(): void {
this.collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
}
protected lateUpdate(dt: number): void {
if (this.trigged) {
const ballClone = GameplayController.Instance().SpawnBall();
ballClone.node.setWorldPosition(this.node.worldPosition);
this.originBall.setWorldPosition(this.node.worldPosition);
ballClone.getComponent(RigidBody2D).applyLinearImpulse(new Vec2(40, 0), Vec2.ZERO, true);
const rigiball = this.originBall.getComponent(RigidBody2D);
rigiball.linearVelocity = Vec2.ZERO.clone();
rigiball.angularVelocity = 0;
rigiball.applyLinearImpulse(new Vec2(-40, 0), Vec2.ZERO, true);
this.trigged = false;
}
}
private async onBeginContact(selfCollider: Collider2D, otherCollider: Collider2D) {
if (this.trigged) return;
this.collider.enabled = false;
this.originBall = otherCollider.node;
this.trigged = true;
await Utilities.delay(2000);
this.collider.enabled = true;
}
}

View File

@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "d2d9b8f7-3e0b-430e-80bd-06ebb6be1050",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -1,30 +0,0 @@
import { _decorator, CCFloat, Component, Node, tween } from 'cc';
const { ccclass, property, float } = _decorator;
@ccclass('ObstacleController')
export class ObstacleController extends Component {
@property(Node)
private target: Node;
@property([Node])
private waypoints: Node[] = [];
@property(CCFloat)
private speed: number = 0;
protected start() {
//if (this.target !== null)
this.target.setPosition(this.waypoints[this.waypoints.length - 1].position);
this.followPath();
}
private followPath() {
const tweenPath = tween(this.target);
for (let i = 0; i < this.waypoints.length; i++) {
let a = tween(this.target).to(this.speed, { position: this.waypoints[i].getPosition() });
tweenPath.then(a);
}
// tweenPath.union().repeat(10)
tweenPath.union().repeatForever();
tweenPath.start();
}
}

View File

@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "2fd1fad8-05e9-4615-a7b0-fd8bc8acf50f",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -1,41 +0,0 @@
import { _decorator, CCFloat, Component, Node, randomRangeInt, tween, Vec3 } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('ObstacleBehaviour')
export class ObstacleBehaviour extends Component {
@property([Node])
private targets: Node[] = [];
@property([Node])
private waypoints: Node[] = [];
@property(CCFloat)
private speed: number = 0;
@property({ type: Node, readonly: true })
private selectedObstacle: Node = null;
protected onEnable() {
if (this.targets == null || this.targets.length <= 0) return;
let randomInt = randomRangeInt(0, this.targets.length);
this.selectedObstacle = this.targets[randomInt];
this.waypoints.forEach(element => {
element.setPosition(element.position.x, this.selectedObstacle.position.y, element.position.z);
});
this.selectedObstacle.setPosition(this.waypoints[this.waypoints.length - 1].position);
this.followPath(this.selectedObstacle);
}
private followPath(target: Node) {
const tweenPath = tween(target);
for (let i = 0; i < this.waypoints.length; i++) {
let a = tween(target).to(this.speed, { position: this.waypoints[i].getPosition() })
tweenPath.then(a)
}
// tweenPath.union().repeat(10)
tweenPath.union().repeatForever()
tweenPath.start();
}
}

View File

@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "c8e70e72-0099-4110-a714-83f832b7fc49",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -1,33 +0,0 @@
import { _decorator, Component, log, Node, randomRangeInt } from 'cc';
import { ObstacleBehaviour } from './ObstacleBehaviour';
import { GameplayController } from '../GameplayController';
const { ccclass, property } = _decorator;
@ccclass('ObstaclesController')
export class ObstaclesController extends Component {
// @property([ObstacleBehaviour])
// private easyObstacle: ObstacleBehaviour[] = [];
// @property([ObstacleBehaviour])
// private mediumObstacle: ObstacleBehaviour[] = [];
// @property([ObstacleBehaviour])
// private hardObstacle: ObstacleBehaviour[] = [];
@property([Node])
private obstaclesSet: Node[] = [];
protected onEnable(): void {
GameplayController.Instance().eventSpawnObstacle.on("SpawnObstacle", this.RandomSetObstacle, this);
// this.RandomSetObstacle();
}
private RandomSetObstacle(): void {
//let random = randomRangeInt(0, this.obstaclesSet.length);
setTimeout(() => {
let random = randomRangeInt(0, this.obstaclesSet.length);
this.obstaclesSet.forEach(element => {
element.active = false;
});
this.obstaclesSet[random].active = true;
}, 200);
}
}

View File

@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "139dc437-8ddb-409c-b0e9-9fc41ddc4ac3",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -1,36 +0,0 @@
import { _decorator, AudioClip, AudioSource, Component, Node } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('SoundManager')
export class SoundManager extends Component {
private static instance: SoundManager;
public static Instance(): SoundManager {
if (!SoundManager.instance) {
SoundManager.instance = new Node().addComponent(SoundManager);
}
return SoundManager.instance;
}
protected onLoad(): void {
SoundManager.instance = this;
}
@property(AudioSource)
private audioSource: AudioSource;
@property(AudioClip)
public hitGround: AudioClip;
@property(AudioClip)
public hitPlayer: AudioClip;
@property(AudioClip)
public goal: AudioClip;
@property(AudioClip)
public menuTap: AudioClip;
@property(AudioClip)
public sfxGoal: AudioClip;
@property(AudioClip)
public whistle: AudioClip;
public PlayOneShot(clip: AudioClip): void {
this.audioSource.playOneShot(clip);
}
}

View File

@ -1,36 +0,0 @@
import { _decorator, Collider2D, Component, Contact2DType, Node, RigidBody2D, Vec2 } from 'cc';
import Utilities from './Utilities/Utilities';
const { ccclass, property } = _decorator;
@ccclass('Spring')
export class Spring extends Component {
@property(Collider2D)
private collider: Collider2D;
@property(Node)
private gate: Node;
@property(Node)
private lid: Node;
protected onLoad(): void {
this.collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
this.gate.active = false;
}
private async onBeginContact(selfCollider: Collider2D, otherCollider: Collider2D) {
otherCollider.node.setWorldPosition(this.node.worldPosition);
const rigi = otherCollider.getComponent(RigidBody2D);
rigi.linearVelocity = Vec2.ZERO.clone();
rigi.angularVelocity = 0;
const gravity = rigi.gravityScale;
rigi.gravityScale = 0;
this.lid.active = false;
await Utilities.delay(1000);
rigi.gravityScale = gravity;
rigi.applyLinearImpulse(new Vec2(0, 100), Vec2.ZERO, true);
await Utilities.delay(500);
this.lid.active = true;
if (this.gate) {
this.gate.active = true;
}
}
}

View File

@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "6b2f78b4-ee6c-4dff-9719-76165c277e71",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -1,27 +0,0 @@
import { _decorator, Component, Input, input, instantiate, Node, Prefab } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('Test')
export class Test extends Component {
@property(Prefab)
private someThing: Prefab;
someNode: Node;
protected start(): void {
input.on(Input.EventType.MOUSE_DOWN, this.ActiveNode, this);
input.on(Input.EventType.MOUSE_UP, this.DeActiveNode, this);
}
private ActiveNode(): void {
if (this.someNode == null) {
this.someNode = instantiate(this.someThing);
this.someNode.parent = this.node;
this.someNode.setPosition(0, 0, 0);
} else this.someNode.active = true;
}
private DeActiveNode(): void {
this.someNode.active = false;
}
}

View File

@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "4ae0c49c-cfd9-44b1-91ac-b15cd8280af6",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -1,130 +0,0 @@
import { _decorator, Button, Component, director, Label, Node } from 'cc';
import { GameplayController, GameState } from './GameplayController';
import { EventType } from './Enums';
import { SoundManager } from './SoundManager';
const { ccclass, property } = _decorator;
@ccclass('UIController')
export class UIController extends Component {
@property(Node)
private mainMenuPnl: Node;
@property(Button)
private startGameBtn: Button;
@property(Node)
private countdownPnl: Node;
@property(Label)
private countdownTxt: Label;
@property(Node)
private inGamePnl: Node;
@property(Label)
private goalTxt: Label;
@property(Label)
private currentStreakTxt: Label;
@property(Label)
private highestStreakTxt: Label;
@property(Label)
private ballTxt: Label;
@property(Label)
public currentLevelTxt: Label;
@property(Node)
public endGamePnl: Node;
@property(Label)
private yourScoreTxt: Label;
@property(Button)
private replayBtn: Button;
private isGameStarted: boolean;
private countdownTime: number;
private score: number;
private hStreak: number;
protected start(): void {
this.countdownTime = GameplayController.Instance().startGameCountDown;
this.startGameBtn.node.on(Button.EventType.CLICK, this.StartGameClicked, this);
this.replayBtn.node.on(Button.EventType.CLICK, this.RestartClicked, this);
GameplayController.Instance().eventMenuGame.on(EventType.MainMenu, this.ShowGameMenu, this);
GameplayController.Instance().eventStartGame.on(EventType.StartGame, this.StartCountdownEvent, this);
GameplayController.Instance().eventPlayGame.on(EventType.PlayGame, this.StartGameEvent, this);
GameplayController.Instance().eventEndGame.on(EventType.EndGame, this.EndGameEvent, this);
GameplayController.Instance().eventUpdateScore.on(EventType.UpdateScore, this.UpdateScore, this);
GameplayController.Instance().eventUpdateStreak.on(EventType.UpdateStreak, this.UpdateStreak, this);
GameplayController.Instance().eventUpdateHighestStreak.on(
EventType.UpdateHighestStreak,
this.UpdateHighestStreak,
this,
);
GameplayController.Instance().eventUpdateBall.on(EventType.UpdateBall, this.UpdateBall, this);
}
protected update(dt: number): void {
if (!this.isGameStarted) return;
if (this.countdownTime < 0) {
if (GameplayController.Instance().currentGameState != GameState.PlayGame) {
GameplayController.Instance().ChangeGameState(GameState.PlayGame);
}
return;
}
this.countdownTime -= dt;
this.countdownTxt.string = Math.round(this.countdownTime).toString();
}
//#region Event listeners
private ShowGameMenu(): void {
this.mainMenuPnl.active = true;
}
private StartCountdownEvent(): void {
this.mainMenuPnl.active = false;
this.countdownPnl.active = true;
this.isGameStarted = true;
}
private StartGameEvent(): void {
this.countdownPnl.active = false;
this.inGamePnl.active = true;
}
private UpdateScore(score: number): void {
console.log('Score: ' + score);
this.score = score;
this.goalTxt.string = 'Goal: ' + score.toString();
}
private UpdateStreak(streak: number): void {
console.log('Streak: ' + streak);
this.currentStreakTxt.string = 'Streak: ' + streak.toString();
}
private UpdateHighestStreak(streak: number): void {
console.log('Highest Streak: ' + streak);
this.hStreak = streak;
this.highestStreakTxt.string = 'Highest Streak: ' + streak.toString();
}
private UpdateBall(ball: number): void {
console.log('Ball: ' + ball);
this.ballTxt.string = 'Ball: ' + ball.toString();
}
private EndGameEvent(): void {
this.inGamePnl.active = false;
this.endGamePnl.active = true;
if (this.score + this.hStreak * 2 > 0) this.yourScoreTxt.string = (this.score + this.hStreak * 2).toString();
else this.yourScoreTxt.string = '0';
}
public ShutEndPnl(): void {
this.endGamePnl.active = false;
}
//#endregion
private StartGameClicked(): void {
GameplayController.Instance().ChangeGameState(GameState.StartGame);
SoundManager.Instance().PlayOneShot(SoundManager.Instance().menuTap);
}
private RestartClicked(): void {
director.loadScene(director.getScene().name);
}
}

View File

@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "575edf24-cdba-4302-91b1-8a89441ce7a4",
"files": [],
"subMetas": {},
"userData": {}
}

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
"ver": "1.1.0", "ver": "1.1.0",
"importer": "directory", "importer": "directory",
"imported": true, "imported": true,
"uuid": "907fcdde-1d95-4780-8f0d-1d5756cab63e", "uuid": "e96f2577-0b37-40e8-908f-29359e31dde5",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": { "userData": {

View File

@ -2,7 +2,7 @@
"ver": "1.1.0", "ver": "1.1.0",
"importer": "directory", "importer": "directory",
"imported": true, "imported": true,
"uuid": "808f6a72-4905-4684-b0ef-a138191db715", "uuid": "46ab7167-6eec-4756-9dfb-67301f88f4ad",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": { "userData": {

View File

@ -1,6 +1,6 @@
import { _decorator } from 'cc'; import { _decorator } from 'cc';
import * as CryptoES from 'crypto-es'; import * as CryptoES from 'crypto-es';
import { GameplayController } from './GameplayController'; import { GameManager } from '../Manager/GameManager';
export let CryptoESDefault = CryptoES.default; export let CryptoESDefault = CryptoES.default;
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ -99,7 +99,7 @@ export default class BEConnector {
} }
public async checkGameScoreTicket() { public async checkGameScoreTicket() {
let totalScore: number = GameplayController.Instance().score; let totalScore: number = GameManager.instance.score;
let dataEncrypted: string = this.getDataEncrypted({ score: totalScore, ticket: this.getTicketCanBeMinus() }); let dataEncrypted: string = this.getDataEncrypted({ score: totalScore, ticket: this.getTicketCanBeMinus() });
await fetch(`${this.gameURL}/promotions/check-game-score-ticket/${this.tournamentId}/${this.skinId}?cocos=1`, { await fetch(`${this.gameURL}/promotions/check-game-score-ticket/${this.tournamentId}/${this.skinId}?cocos=1`, {
@ -114,7 +114,7 @@ export default class BEConnector {
} }
public postMessage() { public postMessage() {
let totalScore: number = GameplayController.Instance().score; let totalScore: number = GameManager.instance.score;
// window.parent.postMessage( // window.parent.postMessage(
// JSON.stringify({ // JSON.stringify({
// error: false, // error: false,
@ -126,7 +126,7 @@ export default class BEConnector {
// ); // );
setTimeout(() => { setTimeout(() => {
BEConnector.instance.numberTicket += 5; BEConnector.instance.numberTicket += 5;
GameplayController.Instance().OnRevive(); GameManager.instance.onRevive();
}, 2000); }, 2000);
} }
@ -172,7 +172,7 @@ export default class BEConnector {
public getTicketCanBeMinus() { public getTicketCanBeMinus() {
let mileStone = JSON.parse(this.mileStone); let mileStone = JSON.parse(this.mileStone);
let currentScore = GameplayController.Instance().score; let currentScore = GameManager.instance.score;
let total = this.calculatingTicketToContinue(mileStone, currentScore); let total = this.calculatingTicketToContinue(mileStone, currentScore);
return total; return total;
} }

View File

@ -2,7 +2,7 @@
"ver": "4.0.23", "ver": "4.0.23",
"importer": "typescript", "importer": "typescript",
"imported": true, "imported": true,
"uuid": "28d9c88b-9c32-4adf-96e3-00872db954da", "uuid": "268944fd-86a0-4e77-b478-a690fb01e519",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": {} "userData": {}

View File

@ -2,7 +2,7 @@
"ver": "1.1.0", "ver": "1.1.0",
"importer": "directory", "importer": "directory",
"imported": true, "imported": true,
"uuid": "8008f10e-fa35-4d25-84e2-e3f6ab2b470f", "uuid": "ade0f387-95dc-431a-85db-7cab3149bae2",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": { "userData": {

View File

@ -0,0 +1,3 @@
enum GameEvent {}
export default GameEvent;

View File

@ -2,7 +2,7 @@
"ver": "4.0.23", "ver": "4.0.23",
"importer": "typescript", "importer": "typescript",
"imported": true, "imported": true,
"uuid": "ed2d5377-8be4-48b3-87bd-af395745c81d", "uuid": "a28ecc68-efbe-427e-8f18-5712ec3b9c2e",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": {} "userData": {}

View File

@ -2,7 +2,7 @@
"ver": "1.1.0", "ver": "1.1.0",
"importer": "directory", "importer": "directory",
"imported": true, "imported": true,
"uuid": "892a9e6d-ef47-4bf6-94bb-c2f393500fdf", "uuid": "8a40230e-4ec0-4996-91d6-ea77c9a2f5a5",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": { "userData": {

View File

@ -1,6 +1,5 @@
import { import {
_decorator, _decorator,
Animation,
CCFloat, CCFloat,
Collider2D, Collider2D,
Component, Component,
@ -11,8 +10,6 @@ import {
IPhysics2DContact, IPhysics2DContact,
RigidBody2D, RigidBody2D,
} from 'cc'; } from 'cc';
import { GameplayController } from './GameplayController';
import { SoundManager } from './SoundManager';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ccclass('Ball') @ccclass('Ball')
@ -38,43 +35,7 @@ export class Ball extends Component {
director.on(Director.EVENT_AFTER_PHYSICS, this.setMaxVelocity, this); director.on(Director.EVENT_AFTER_PHYSICS, this.setMaxVelocity, this);
} }
protected onDestroy(): void { private onBeginContact(selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {}
GameplayController.Instance().updateCurrentBallsInGame(-1);
}
private onBeginContact(selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
// Hit boundary
if (otherCollider.tag == 1) {
this.node.destroy();
// GameplayController.Instance().SpawnBallInTime(1);
GameplayController.Instance().LoseStreak();
SoundManager.Instance().PlayOneShot(SoundManager.Instance().hitGround);
return;
}
// Hit goal
if (otherCollider.tag == 2) {
this.node.destroy();
otherCollider.getComponent(Animation)?.play();
GameplayController.Instance().AddScore(1);
// GameplayController.Instance().SpawnBallInTime(1);
SoundManager.Instance().PlayOneShot(SoundManager.Instance().goal);
this.eventGoal.emit('Goal', this.node.getWorldPosition());
return;
}
// Hit obstacle
if (otherCollider.tag == 3) {
this.eventHitObstacle.emit('HitObstacle', otherCollider.node);
return;
}
if (!this.hitted && this.rigidbody.linearVelocity.length() >= 2) {
SoundManager.Instance().PlayOneShot(SoundManager.Instance().hitPlayer);
}
this.hitted = true;
}
private setMaxVelocity() { private setMaxVelocity() {
if (this.rigidbody.linearVelocity.length() > this.maxSpeed) { if (this.rigidbody.linearVelocity.length() > this.maxSpeed) {

View File

@ -2,7 +2,7 @@
"ver": "4.0.23", "ver": "4.0.23",
"importer": "typescript", "importer": "typescript",
"imported": true, "imported": true,
"uuid": "cad12704-b9b0-485d-bd8d-bef0a89f919e", "uuid": "b14f8356-cd12-4334-bf5e-45f3e10f1dc6",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": {} "userData": {}

View File

@ -1,6 +1,6 @@
import { _decorator, Button, CCInteger, Component, EventTarget, Label, Node, EventTouch } from 'cc'; import { _decorator, Button, CCInteger, Component, EventTarget, Label, Node, EventTouch } from 'cc';
import { GameplayController } from './GameplayController'; import BEConnector from '../API/BEConnector';
import BEConnector from './BEConnector'; import { GameManager } from '../Manager/GameManager';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
export enum PanelState { export enum PanelState {
@ -76,7 +76,7 @@ export class EndGameUIController extends Component {
switch (this.currentState) { switch (this.currentState) {
case PanelState.CompareScore: case PanelState.CompareScore:
this.TurnOffAllPanels(this.compareScorePnl); this.TurnOffAllPanels(this.compareScorePnl);
var totalScore = GameplayController.Instance().score + GameplayController.Instance().highestStreak * 2; var totalScore = GameManager.instance.score + GameManager.instance.highestStreak * 2;
this.yourScoreTxt.string = 'Your score: ' + totalScore; this.yourScoreTxt.string = 'Your score: ' + totalScore;
/// Todo: set top score here /// Todo: set top score here
@ -99,7 +99,7 @@ export class EndGameUIController extends Component {
this.countdownToReplayTxt.node.active = false; this.countdownToReplayTxt.node.active = false;
this.TurnOffAllPanels(this.finalResultPnl); this.TurnOffAllPanels(this.finalResultPnl);
BEConnector.instance.postScoreToServer(GameplayController.Instance().score); BEConnector.instance.postScoreToServer(GameManager.instance.score);
break; break;
} }
} }
@ -124,7 +124,7 @@ export class EndGameUIController extends Component {
if (isYesClick) { if (isYesClick) {
var ticket = BEConnector.instance.getTicketCanBeMinus(); var ticket = BEConnector.instance.getTicketCanBeMinus();
if (BEConnector.instance.numberTicket >= ticket) { if (BEConnector.instance.numberTicket >= ticket) {
GameplayController.Instance().OnRevive(); GameManager.instance.onRevive();
BEConnector.instance.ticketMinus('revive'); BEConnector.instance.ticketMinus('revive');
this.isContinuable = false; this.isContinuable = false;
} else BEConnector.instance.postMessage(); } else BEConnector.instance.postMessage();

View File

@ -2,7 +2,7 @@
"ver": "4.0.23", "ver": "4.0.23",
"importer": "typescript", "importer": "typescript",
"imported": true, "imported": true,
"uuid": "27b91595-c9a1-43da-9109-716b0dd7b6ee", "uuid": "99bfd134-ace2-424f-b5da-79474dd94bd9",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": {} "userData": {}

View File

@ -10,10 +10,10 @@ export class Flipper extends Component {
@property({ visible: true, type: CCFloat }) @property({ visible: true, type: CCFloat })
public _motorSpeedDeActive: number; public _motorSpeedDeActive: number;
public ActiveFlipper(): void { public activeFlipper(): void {
this._hingeJoint.motorSpeed = this._motorSpeedActive; this._hingeJoint.motorSpeed = this._motorSpeedActive;
} }
public DeActiveFlipper(): void { public deActiveFlipper(): void {
this._hingeJoint.motorSpeed = this._motorSpeedDeActive; this._hingeJoint.motorSpeed = this._motorSpeedDeActive;
} }
} }

View File

@ -2,7 +2,7 @@
"ver": "4.0.23", "ver": "4.0.23",
"importer": "typescript", "importer": "typescript",
"imported": true, "imported": true,
"uuid": "c3f2b353-5fa6-4517-93b8-9ec8c8ff0006", "uuid": "3bf75aec-53f8-41b1-b490-e0ae7bdf9798",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": {} "userData": {}

View File

@ -2,7 +2,7 @@
"ver": "4.0.23", "ver": "4.0.23",
"importer": "typescript", "importer": "typescript",
"imported": true, "imported": true,
"uuid": "c9d88ffb-aa44-4460-91cf-8993b0e4313e", "uuid": "73cbd9b6-9959-43b8-8ee3-35c54f5fac3f",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": {} "userData": {}

View File

@ -2,7 +2,7 @@
"ver": "1.1.0", "ver": "1.1.0",
"importer": "directory", "importer": "directory",
"imported": true, "imported": true,
"uuid": "7e65366b-dce8-4c7a-9e6f-52fd3e9cad8d", "uuid": "df276c5e-5e31-4499-8818-1d119c265881",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": { "userData": {

View File

@ -0,0 +1,35 @@
import { _decorator, Component, EventTarget, Node } from 'cc';
import GameEvent from '../Enum/GameEvent';
const { ccclass, property } = _decorator;
@ccclass('EventManger')
export class EventManger extends Component {
//singleton
private static _instance: EventManger = null;
public static get instance(): EventManger {
if (!EventManger._instance) {
EventManger._instance = new EventManger('EventManger');
}
return EventManger._instance;
}
private _eventTarget = new EventTarget();
onLoad() {
if (!EventManger._instance) {
EventManger._instance = this;
}
}
public on(eventType: GameEvent, callback?: (...args: any[]) => void, thisArg?: any) {
this._eventTarget.on(eventType, callback, thisArg);
}
public off(eventType: GameEvent, callback?: (...args: any[]) => void, thisArg?: any) {
this._eventTarget.on(eventType, callback, thisArg);
}
public emit(eventType: GameEvent, arg0?: any, arg1?: any, arg2?: any, arg3?: any, arg4?: any) {
this._eventTarget.emit(eventType, arg0, arg1, arg2, arg3, arg4);
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "f2c61cf8-ab8d-47dc-959e-e8da55e7b1e5",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,18 @@
import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('GameManager')
export class GameManager extends Component {
//singleton
private static _instance: GameManager = null;
public static get instance(): GameManager {
return GameManager._instance;
}
public highestStreak: number;
public score = 0;
public onRevive() {
throw new Error('Method not implemented.');
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "85b9a691-b190-409f-9b14-c52e51437105",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,121 @@
import { _decorator, AudioClip, AudioSource, Component, Node } from 'cc';
const { ccclass, property } = _decorator;
class SoundSource {
public source: AudioSource;
private _volume = 1;
public get volume() {
return this._volume;
}
public set volume(value: number) {
this._volume = value;
if (!this.mute) this.source.volume = value;
}
private _mute = false;
public get mute() {
return this._mute;
}
public set mute(value: boolean) {
if (value) {
this.source.volume = 0;
} else {
this.source.volume = this.volume;
}
}
public play() {
this.source.play();
}
public stop() {
this.source.stop();
}
}
@ccclass('SoundManager')
export class SoundManager extends Component {
//singleton
private static _instance: SoundManager;
public static get instance(): SoundManager {
if (SoundManager._instance) {
SoundManager._instance = new SoundManager('SoundManager');
}
return SoundManager.instance;
}
private _audioSourcesSfx: { [key: string]: SoundSource } = {};
private _audioSourceBgm: SoundSource;
private isMute = false;
protected onLoad(): void {
SoundManager._instance = this;
}
public toggleMute(): boolean {
this.isMute = !this.isMute;
this.setMute(this.isMute);
return this.isMute;
}
public setMute(mute: boolean) {
this.isMute = mute;
this._audioSourceBgm.mute = this.isMute;
for (const key in this._audioSourcesSfx) {
this._audioSourcesSfx[key].mute = this.isMute;
}
}
public playBGM(audio: AudioClip, volume = 1, loop = true) {
if (this._audioSourceBgm) {
this._audioSourceBgm = new SoundSource();
this._audioSourceBgm.source = new AudioSource('audioSourceBgm');
this._audioSourceBgm.source.playOnAwake = false;
}
this._audioSourceBgm.stop();
this._audioSourceBgm.volume = volume;
this._audioSourceBgm.source.clip = audio;
this._audioSourceBgm.source.loop = loop;
this._audioSourceBgm.mute = this.isMute;
this._audioSourceBgm.play();
}
public playSfx(audioClip: AudioClip, volume = 1, loop = false) {
let soundSource = this._audioSourcesSfx[audioClip.uuid];
if (soundSource) {
soundSource.volume = volume;
soundSource.source.loop = loop;
soundSource.play();
return;
}
soundSource = new SoundSource();
const audioSource = new AudioSource('audioSourceSfx:' + audioClip.name);
soundSource.source = audioSource;
soundSource.source.playOnAwake = false;
soundSource.source.clip = audioClip;
soundSource.source.loop = loop;
soundSource.source.volume = volume;
soundSource.mute = this.isMute;
this._audioSourcesSfx[audioClip.uuid] = soundSource;
soundSource.play();
}
public stopBgm() {
this._audioSourceBgm.stop();
}
public stopSfx(audioClip: AudioClip) {
this._audioSourcesSfx[audioClip.uuid].stop();
}
public stopAllSfxLoop() {
for (const key in this._audioSourcesSfx) {
this._audioSourcesSfx[key].stop();
}
}
public findAudioSourcesSfx(audioClip: AudioClip): SoundSource {
return this._audioSourcesSfx[audioClip.uuid];
}
}

View File

@ -2,7 +2,7 @@
"ver": "4.0.23", "ver": "4.0.23",
"importer": "typescript", "importer": "typescript",
"imported": true, "imported": true,
"uuid": "f4bdc5e2-afd5-4307-8700-da3026204fe9", "uuid": "995ccd98-cdc8-4a0c-96f0-e10abd60ec3a",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": {} "userData": {}

View File

@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "817bbd10-9209-47cb-8df3-f5e9b0e396b1",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@ -0,0 +1,4 @@
export default interface IPoolable {
unuse(): void;
reuse(): void;
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "6f185b0c-3b7d-4f18-bdf5-ebd82143597f",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,69 @@
import { Component, Node, Prefab, __private, director, instantiate } from 'cc';
export default class ObjectPool<T extends Component> {
private _inactives: Node[] = [];
private _actives: Node[] = [];
private _classConstructor: string;
private _prefab: Prefab;
private _expandable;
public get countInactive() {
return this._inactives.length;
}
public get countActive() {
return this._actives.length;
}
public get countAll() {
return this.countInactive + this.countActive;
}
constructor(classConstructor: string, prefab: Prefab, size: number, expandable = true) {
this._classConstructor = classConstructor;
this._expandable = expandable;
this._prefab = prefab;
for (let i = 0; i < size; ++i) {
let obj = instantiate(this._prefab); // create node instance
obj.active = false;
this._inactives.push(obj); // populate your pool with put method
}
}
public get<T>(parent?: Node): T {
let obj: Node = null;
let p = parent || director.getScene();
if (this._inactives.length > 0) {
// use size method to check if there're nodes available in the pool
obj = this._inactives.pop();
obj.setParent(p);
this._actives.push(obj);
} else if (this._expandable) {
// if not enough node in the pool, we call cc.instantiate to create node
obj = instantiate(this._prefab);
obj.setParent(p);
this._actives.push(obj);
} else {
obj = this._actives[0];
}
const comp = obj.getComponent(this._classConstructor) as any;
comp.reuse?.();
return comp as T;
}
public release(obj: T) {
obj.node.active = false;
const index = this._actives.indexOf(obj.node);
this._actives.splice(index, 1);
this._inactives.push(obj.node);
const comp = obj.getComponent(this._classConstructor) as any;
comp.unuse?.();
}
public clear() {
this._inactives.forEach((obj) => obj.destroy());
this._inactives = [];
this._actives = [];
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "aaeff0da-269a-427a-b752-8851ca101b14",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -1,35 +0,0 @@
import { _decorator, Component, Game, Label, Node } from 'cc';
import BEConnector from '../../../Scripts/BEConnector';
import { GameplayController, GameState } from '../../../Scripts/GameplayController';
const { ccclass, property } = _decorator;
@ccclass('ConfirmPanel')
export class ConfirmPanel extends Component {
@property(Label) ticketWaringText : Label = null;
protected onEnable(): void {
this.ticketWaringText.string = `To continue playing, you will be deducted ${BEConnector.instance.getTicketCanBeMinus()} ticket`;
}
onClickYesButton()
{
if(BEConnector.instance.canRelive()){
BEConnector.instance.checkGameScoreTicket()
.then(()=>{
GameplayController.Instance().OnRevive();
})
.catch(()=>{
GameplayController.Instance().ChangeGameState(GameState.EndGame);
})
}else{
BEConnector.instance.postMessage();
}
}
onClickNoButton(){
this.node.active = false;
}
}

View File

@ -1 +0,0 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"09897cf3-e99a-4576-b79d-4bd1ef15db44","files":[],"subMetas":{},"userData":{}}

View File

@ -1,37 +0,0 @@
import { _decorator, Component, Label, Node } from 'cc';
import BEConnector from '../../../Scripts/BEConnector';
import { GameplayController, GameState } from '../../../Scripts/GameplayController';
const { ccclass, property } = _decorator;
@ccclass('GameOverPanel')
export class GameOverPanel extends Component {
@property(Label) private topScore: Label = null;
@property(Label) private yourScore: Label = null;
protected onEnable(): void {
let currentScore = GameplayController.Instance().score;
this.topScore.string = BEConnector.instance.maxScore.toString();
this.yourScore.string = currentScore.toString();
this.scheduleOnce(this.endGame,60);
}
onClickYesButton(){
let confirmPanel = this.node.getChildByName("ConfirmPanel");
confirmPanel.active = true;
}
onClickNoButton(){
GameplayController.Instance().ChangeGameState(GameState.EndGame);
}
protected onDisable(): void {
this.unschedule(this.endGame);
}
private endGame(){
GameplayController.Instance().ChangeGameState(GameState.EndGame);
}
}

View File

@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "d43dbb30-5ec5-42fe-8230-f9c39b8b852f",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -1,5 +1,3 @@
import { Vec3 } from 'cc';
export default class Utilities { export default class Utilities {
/** /**
* *

Some files were not shown because too many files have changed in this diff Show More