Commit 1c574bd9 authored by Nguyễn Quang Sáng's avatar Nguyễn Quang Sáng

12/10/23 commit

parent 1b412c27
{
"ver": "1.1.3",
"uuid": "f40bca90-2f85-490b-9613-bcf82a5d8ba4",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "e493052e-b9c3-4753-8674-b1cc62c4f606",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 2.037551,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "063ab77e-6b30-472f-a272-120cbdea50bd",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 0.574694,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "fba914dc-ac06-4b40-8e63-c8eb45886975",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 1.358367,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "2c1156f8-3b0c-4423-ac33-85809c809fb3",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 0.574694,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "104a99ce-77cf-4bb3-a9ea-f24a46bfb730",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 0.548571,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "add104f7-f544-4441-93d2-6fcbbb820177",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 0.626939,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "5c67484a-9d75-483b-9f0f-f14251a4f746",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 2.533878,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "ffa29f64-c9e9-4ce7-a0fe-35b5d686cc3a",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 1.436735,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "55041368-92ed-4b1d-a51a-1ef92eae884d",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 2.66449,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "0161dfda-4453-4e19-a72d-424bc8e3620f",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 0.235102,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "68796e51-e944-40b4-9d51-ff47c67641d4",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 1.332245,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "6c32cd91-c4a7-4d9b-8ada-f236adc91bc0",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 1.332245,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "52ee7efb-0e38-47e5-a3d5-751d234d3a2c",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 1.332245,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "24f23cdb-5fc8-46e2-bf2a-37ff41b78e9f",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 1.332245,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "b221be45-8e0c-4142-a50d-71ed9038f22e",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 1.332245,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "bdac315e-8d1b-406b-ac7c-ef42306fc793",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 1.332245,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "909a37a1-5c39-45c0-8b79-2853153e107d",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 1.332245,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "566a47ca-fd19-4d7d-be78-ec0cc83a8660",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 1.332245,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "c78dfab2-1b3a-46f5-8057-a39c553f75f5",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 1.332245,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "21682b16-9924-4e7f-ac81-1be85d924a36",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 0.10449,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "b12c902a-9d7e-4073-8005-6c79d2492e7e",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 8.045714,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "9522f732-829c-456f-a64e-ec79d14ce403",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 2.612245,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "7d5dd4f7-4615-4e32-8c4b-0f931b8b7e95",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 1.724082,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "3b829faf-db4f-4722-acdc-c000be5cd603",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 3.526531,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.3",
"uuid": "5980fabc-2201-4b66-b917-632e80d0b961",
"importer": "audio-clip",
"downloadMode": 0,
"duration": 1.436735,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
import BlockData from "../Data/BlockData"; import BlockData from "../Data/BlockData";
import LocalStorage from "../Data/LocalStorage"; import LocalStorage from "../Data/LocalStorage";
import GameController from "./GameController"; import GameController from "./GameController";
import GameOverScreen from "./GameOverScreen"; import SoundsController from "./SoundsController";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -15,12 +15,15 @@ export default class ButtonsController extends cc.Component { ...@@ -15,12 +15,15 @@ export default class ButtonsController extends cc.Component {
@property(cc.Node) soundBtn: cc.Node = null; @property(cc.Node) soundBtn: cc.Node = null;
@property(cc.Node) popup: cc.Node = null; @property(cc.Node) popup: cc.Node = null;
@property(cc.Node) destroyBlockPopUp: cc.Node = null; @property(cc.Node) destroyBlockPopUp: cc.Node = null;
@property(SoundsController) soundsController: SoundsController = null;
currentSoundSpf: cc.SpriteFrame; currentSoundSpf: cc.SpriteFrame;
protected onLoad(): void { protected onLoad(): void {
if (LocalStorage.getMusic()) { if (LocalStorage.getMusic()) {
this.currentSoundSpf = this.soundOnSpf; this.currentSoundSpf = this.soundOnSpf;
cc.audioEngine.setMusicVolume(1);
cc.audioEngine.setEffectsVolume(1);
} else { } else {
this.currentSoundSpf = this.soundOffSpf; this.currentSoundSpf = this.soundOffSpf;
cc.audioEngine.setMusicVolume(0); cc.audioEngine.setMusicVolume(0);
...@@ -34,10 +37,12 @@ export default class ButtonsController extends cc.Component { ...@@ -34,10 +37,12 @@ export default class ButtonsController extends cc.Component {
this.startScreen.active = false; this.startScreen.active = false;
this.shadow.active = false; this.shadow.active = false;
GameController.instance.node.emit("startGame"); GameController.instance.node.emit("startGame");
this.soundsController.playSound("click_btn");
} }
onClickPause() { onClickPause() {
if (GameOverScreen.instance.gameOver) return; this.soundsController.playSound("tap");
if (GameController.instance.isGameOver) return;
if (!GameController.instance.isGameStart) return; if (!GameController.instance.isGameStart) return;
if (GameController.instance.isGamePaused) { if (GameController.instance.isGamePaused) {
GameController.instance.isGamePaused = false; GameController.instance.isGamePaused = false;
...@@ -51,16 +56,22 @@ export default class ButtonsController extends cc.Component { ...@@ -51,16 +56,22 @@ export default class ButtonsController extends cc.Component {
} }
onClickRestart() { onClickRestart() {
this.soundsController.playSound("tap");
cc.director.loadScene("gameplay"); cc.director.loadScene("gameplay");
} }
onClickSound() { onClickSound() {
this.soundsController.playSound("tap");
if (this.currentSoundSpf === this.soundOnSpf) { if (this.currentSoundSpf === this.soundOnSpf) {
this.currentSoundSpf = this.soundOffSpf; this.currentSoundSpf = this.soundOffSpf;
LocalStorage.setMusic(false); LocalStorage.setMusic(false);
cc.audioEngine.setMusicVolume(0);
cc.audioEngine.setEffectsVolume(0);
} else { } else {
this.currentSoundSpf = this.soundOnSpf; this.currentSoundSpf = this.soundOnSpf;
LocalStorage.setMusic(true); LocalStorage.setMusic(true);
cc.audioEngine.setMusicVolume(1);
cc.audioEngine.setEffectsVolume(1);
} }
this.updateSoundBtnSpf(); this.updateSoundBtnSpf();
} }
...@@ -86,6 +97,7 @@ export default class ButtonsController extends cc.Component { ...@@ -86,6 +97,7 @@ export default class ButtonsController extends cc.Component {
.getChildByName("Label") .getChildByName("Label")
.getComponent(cc.Label).string = LocalStorage.getAllCoin().toString(); .getComponent(cc.Label).string = LocalStorage.getAllCoin().toString();
GameController.instance.isGet512Block = true; GameController.instance.isGet512Block = true;
this.soundsController.playSound("buy_booster");
} }
onClickBuyNextBlock() { onClickBuyNextBlock() {
...@@ -104,9 +116,11 @@ export default class ButtonsController extends cc.Component { ...@@ -104,9 +116,11 @@ export default class ButtonsController extends cc.Component {
.getChildByName("Label") .getChildByName("Label")
.getComponent(cc.Label).string = LocalStorage.getAllCoin().toString(); .getComponent(cc.Label).string = LocalStorage.getAllCoin().toString();
GameController.instance.isPreviewNextBlock = true; GameController.instance.isPreviewNextBlock = true;
this.soundsController.playSound("buy_booster");
} }
onClickDestroyBlock() { onClickDestroyBlock() {
this.soundsController.playSound("tap");
const data = BlockData.instance.blockData; const data = BlockData.instance.blockData;
let hasNonZeroValue = false; let hasNonZeroValue = false;
......
...@@ -4,6 +4,7 @@ import Score from "../Data/Score"; ...@@ -4,6 +4,7 @@ import Score from "../Data/Score";
import Block from "../Objects/Block"; import Block from "../Objects/Block";
import Utils from "../Tools/Utils"; import Utils from "../Tools/Utils";
import GameOverScreen from "./GameOverScreen"; import GameOverScreen from "./GameOverScreen";
import SoundsController from "./SoundsController";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -18,6 +19,7 @@ export default class GameController extends cc.Component { ...@@ -18,6 +19,7 @@ export default class GameController extends cc.Component {
@property(cc.Node) nextBlockSpf: cc.Node = null; @property(cc.Node) nextBlockSpf: cc.Node = null;
@property(cc.Node) shadow: cc.Node = null; @property(cc.Node) shadow: cc.Node = null;
@property(cc.Node) gameOverScreen: cc.Node = null; @property(cc.Node) gameOverScreen: cc.Node = null;
@property(SoundsController) soundsController: SoundsController = null;
static instance: GameController; static instance: GameController;
...@@ -38,7 +40,10 @@ export default class GameController extends cc.Component { ...@@ -38,7 +40,10 @@ export default class GameController extends cc.Component {
isGameStart: boolean = false; isGameStart: boolean = false;
isGet512Block: boolean = false; isGet512Block: boolean = false;
isPreviewNextBlock: boolean = false; isPreviewNextBlock: boolean = false;
isGameOver: boolean = false;
nextBlock: number = 0; nextBlock: number = 0;
numberOfConsecutiveMerges: number = 0;
protected onLoad(): void { protected onLoad(): void {
GameController.instance = this; GameController.instance = this;
...@@ -78,8 +83,11 @@ export default class GameController extends cc.Component { ...@@ -78,8 +83,11 @@ export default class GameController extends cc.Component {
spawnBlock(index: number) { spawnBlock(index: number) {
if (this.blocksData.blockData.length > 0) { if (this.blocksData.blockData.length > 0) {
const isFull = this.blocksData.blockData[0].some((e) => e !== 0); const isFull = this.blocksData.blockData[0].some((e) => e !== 0);
if (isFull) if (isFull) {
this.isGameOver = true;
this.soundsController.playSound("game_over");
return this.gameOverScreen.getComponent(GameOverScreen).isGameOver(); return this.gameOverScreen.getComponent(GameOverScreen).isGameOver();
}
} }
if (this.isPreviewNextBlock) { if (this.isPreviewNextBlock) {
...@@ -159,6 +167,7 @@ export default class GameController extends cc.Component { ...@@ -159,6 +167,7 @@ export default class GameController extends cc.Component {
} }
onDropBlock(col: number) { onDropBlock(col: number) {
this.soundsController.playSound("fall_fast");
for (let row = 5; row >= 0; row--) { for (let row = 5; row >= 0; row--) {
if (this.blocksData.getBlockValue(row, col) == 0) { if (this.blocksData.getBlockValue(row, col) == 0) {
this.cellTarget = this.board.children[row * 5 + col]; this.cellTarget = this.board.children[row * 5 + col];
...@@ -231,6 +240,7 @@ export default class GameController extends cc.Component { ...@@ -231,6 +240,7 @@ export default class GameController extends cc.Component {
} }
if (!canMerge) { if (!canMerge) {
this.numberOfConsecutiveMerges = 0;
this.blocksData.setBlockValue( this.blocksData.setBlockValue(
row, row,
col, col,
...@@ -340,6 +350,10 @@ export default class GameController extends cc.Component { ...@@ -340,6 +350,10 @@ export default class GameController extends cc.Component {
} }
mergeAction(cellToMerge: cc.Node, value: number, index: number) { mergeAction(cellToMerge: cc.Node, value: number, index: number) {
this.soundsController.playSoundMerge(
(this.numberOfConsecutiveMerges += 1 * this.cachedBlocksToMove.length)
);
let hasCheckedEmptyCell = false; let hasCheckedEmptyCell = false;
for (let i = 0; i < this.cachedBlocksToMove.length; i++) { for (let i = 0; i < this.cachedBlocksToMove.length; i++) {
......
import BlockData from "../Data/BlockData";
import LocalStorage from "../Data/LocalStorage"; import LocalStorage from "../Data/LocalStorage";
import Score from "../Data/Score"; import Score from "../Data/Score";
import GameController from "./GameController";
import SoundsController from "./SoundsController";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -11,17 +14,16 @@ export default class GameOverScreen extends cc.Component { ...@@ -11,17 +14,16 @@ export default class GameOverScreen extends cc.Component {
@property(cc.Node) currentScore: cc.Node = null; @property(cc.Node) currentScore: cc.Node = null;
@property(cc.Node) ignoreBtn: cc.Node = null; @property(cc.Node) ignoreBtn: cc.Node = null;
@property(cc.Node) matchResultSrceen: cc.Node = null; @property(cc.Node) matchResultSrceen: cc.Node = null;
@property(cc.Node) notEnough: cc.Node = null;
@property(SoundsController) soundsController: SoundsController = null;
static instance: GameOverScreen; static instance: GameOverScreen;
gameOver: boolean = false;
protected onLoad(): void { protected onLoad(): void {
GameOverScreen.instance = this; GameOverScreen.instance = this;
} }
isGameOver() { isGameOver() {
this.gameOver = true;
this.shadow.active = true; this.shadow.active = true;
this.node.active = true; this.node.active = true;
this.coin.getComponent(cc.Label).string = this.coin.getComponent(cc.Label).string =
...@@ -35,6 +37,7 @@ export default class GameOverScreen extends cc.Component { ...@@ -35,6 +37,7 @@ export default class GameOverScreen extends cc.Component {
} }
onClickIgnoreBtn() { onClickIgnoreBtn() {
this.soundsController.playSound("collectGems");
this.node.active = false; this.node.active = false;
this.matchResultSrceen.active = true; this.matchResultSrceen.active = true;
this.matchResultSrceen this.matchResultSrceen
...@@ -58,7 +61,7 @@ export default class GameOverScreen extends cc.Component { ...@@ -58,7 +61,7 @@ export default class GameOverScreen extends cc.Component {
const score = Score.instance.currentScore; const score = Score.instance.currentScore;
const rewardValues = [10, 20, 30, 40, 50, 60, 70, 80, 100]; const rewardValues = [10, 20, 30, 40, 50, 60, 70, 80, 100];
if (score < 3000) return this.updateReward(0); if (score < 3000) return this.updateReward(5);
for (let i = 0; i < rewardValues.length; i++) { for (let i = 0; i < rewardValues.length; i++) {
if (score <= (i + 1) * 10000) { if (score <= (i + 1) * 10000) {
...@@ -81,4 +84,36 @@ export default class GameOverScreen extends cc.Component { ...@@ -81,4 +84,36 @@ export default class GameOverScreen extends cc.Component {
.getChildByName("Coin") .getChildByName("Coin")
.getComponent(cc.Label).string = LocalStorage.getAllCoin().toString(); .getComponent(cc.Label).string = LocalStorage.getAllCoin().toString();
} }
onClickRevive() {
if (LocalStorage.getAllCoin() < 150)
return this.notEnough.getComponent(cc.Animation).play("PopUp");
this.soundsController.playSound("unlock_newtile_1");
const data = BlockData.instance.blockData;
const childrens = GameController.instance.board.children;
for (let row = 0; row < 3; row++) {
for (let col = 0; col < 5; col++) {
if (data[row][col] !== 0) {
data[row][col] = 0;
}
}
}
for (let i = 0; i < 15; i++) {
const cell = childrens[i];
if (cell.children && cell.children[0]) {
cell.children[0].destroy();
}
}
this.node.active = false;
this.shadow.active = false;
GameController.instance.isGameOver = false;
LocalStorage.setAllCoin(LocalStorage.getAllCoin() - 150);
this.coin.getComponent(cc.Label).string =
LocalStorage.getAllCoin().toString();
GameController.instance.node.emit("startGame");
}
} }
const { ccclass, property } = cc._decorator;
@ccclass
export default class SoundsController extends cc.Component {
@property(Array(cc.AudioClip)) sounds: Array<cc.AudioClip> =
new Array<cc.AudioClip>();
@property(Array(cc.AudioClip)) soundsMerge: Array<cc.AudioClip> =
new Array<cc.AudioClip>();
playSound(name: string) {
for (let i = 0; i < this.sounds.length; i++) {
const sound = this.sounds[i];
if (sound.name == name) {
cc.audioEngine.playEffect(sound, false);
}
}
}
playSoundMerge(time: number) {
cc.audioEngine.playEffect(this.soundsMerge[time], false);
}
}
{
"ver": "1.1.0",
"uuid": "15214547-c260-47af-af16-f4a0879069ae",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
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