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

11/10/23 commit

parent ac24b9d1
{
"ver": "2.3.7",
"uuid": "034c243f-8d75-4d38-b22d-9d91a95ec31f",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 160,
"height": 54,
"platformSettings": {},
"subMetas": {
"priceBar": {
"ver": "1.0.6",
"uuid": "de754ef0-d9c2-48ea-8a58-c800bb21b925",
"importer": "sprite-frame",
"rawTextureUuid": "034c243f-8d75-4d38-b22d-9d91a95ec31f",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 160,
"height": 54,
"rawWidth": 160,
"rawHeight": 54,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 18,
"borderRight": 15,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.7",
"uuid": "756f8b45-1006-4286-a493-b9234ba94918",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 249,
"height": 97,
"platformSettings": {},
"subMetas": {
"restartBtn": {
"ver": "1.0.6",
"uuid": "1a9d0455-9c5d-4689-a0bc-eb4a92c378bb",
"importer": "sprite-frame",
"rawTextureUuid": "756f8b45-1006-4286-a493-b9234ba94918",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 249,
"height": 97,
"rawWidth": 249,
"rawHeight": 97,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 81,
"borderRight": 91,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.7",
"uuid": "3d1860a3-a55d-4230-9498-5477b03e8b55",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 409,
"height": 131,
"platformSettings": {},
"subMetas": {
"reviveBar1": {
"ver": "1.0.6",
"uuid": "aadb8c66-2ab2-4d45-ae77-72dcacb578c7",
"importer": "sprite-frame",
"rawTextureUuid": "3d1860a3-a55d-4230-9498-5477b03e8b55",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 409,
"height": 131,
"rawWidth": 409,
"rawHeight": 131,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 43,
"borderRight": 40,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.7",
"uuid": "e2a3ef02-46b8-44a7-8f80-1037be7c54b5",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 166,
"height": 76,
"platformSettings": {},
"subMetas": {
"reviveBar2": {
"ver": "1.0.6",
"uuid": "fcc1f587-eb5e-4fd0-aea0-196792afaf27",
"importer": "sprite-frame",
"rawTextureUuid": "e2a3ef02-46b8-44a7-8f80-1037be7c54b5",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 166,
"height": 76,
"rawWidth": 166,
"rawHeight": 76,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 28,
"borderRight": 26,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.7",
"uuid": "593f2aea-6f48-4534-a2a5-6f5cfaec84eb",
"uuid": "96b4d338-5f57-4516-918e-9b3de55b3ea5",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
......@@ -14,9 +14,9 @@
"subMetas": {
"ads": {
"ver": "1.0.6",
"uuid": "5b2c4cea-6c15-4f45-9296-76285a5e9ba7",
"uuid": "f88a8d60-654d-4a21-bfbc-790aee7f39a5",
"importer": "sprite-frame",
"rawTextureUuid": "593f2aea-6f48-4534-a2a5-6f5cfaec84eb",
"rawTextureUuid": "96b4d338-5f57-4516-918e-9b3de55b3ea5",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
......@@ -24,10 +24,10 @@
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 61,
"height": 54,
"rawWidth": 61,
"rawHeight": 54,
"width": 71,
"height": 81,
"rawWidth": 71,
"rawHeight": 81,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
{
"ver": "2.3.7",
"uuid": "59af5a30-ac4e-4321-a8d1-08243202a656",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 411,
"height": 206,
"platformSettings": {},
"subMetas": {
"gameover": {
"ver": "1.0.6",
"uuid": "712fba40-fad1-4809-afa6-0bcb2691866f",
"importer": "sprite-frame",
"rawTextureUuid": "59af5a30-ac4e-4321-a8d1-08243202a656",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 411,
"height": 206,
"rawWidth": 411,
"rawHeight": 206,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
This diff is collapsed.
import BlockData from "../Data/BlockData";
import LocalStorage from "../Data/LocalStorage";
import GameController from "./GameController";
import GameOverScreen from "./GameOverScreen";
const { ccclass, property } = cc._decorator;
......@@ -36,6 +37,7 @@ export default class ButtonsController extends cc.Component {
}
onClickPause() {
if (GameOverScreen.instance.gameOver) return;
if (!GameController.instance.isGameStart) return;
if (GameController.instance.isGamePaused) {
GameController.instance.isGamePaused = false;
......@@ -122,11 +124,11 @@ export default class ButtonsController extends cc.Component {
if (!hasNonZeroValue) return;
GameController.instance.isGamePaused = true;
this.regEvents();
this.regEvent();
this.destroyBlockPopUp.getComponent(cc.Animation).play("PopDown");
}
regEvents() {
regEvent() {
let childrens = GameController.instance.board.children;
childrens.forEach((child) => {
if (child.children.length > 0) {
......@@ -135,6 +137,15 @@ export default class ButtonsController extends cc.Component {
});
}
removeEvent() {
let childrens = GameController.instance.board.children;
childrens.forEach((child) => {
if (child.children.length > 0) {
child.off(cc.Node.EventType.TOUCH_START, this.onTouchDown, this);
}
});
}
onTouchDown(event: cc.Event.EventTouch) {
const data = BlockData.instance.blockData;
const childrens = GameController.instance.board.children;
......@@ -156,7 +167,8 @@ export default class ButtonsController extends cc.Component {
}
GameController.instance.checkEmptyCell();
this.destroyBlockPopUp.getComponent(cc.Animation).play("PullUp");
GameController.instance.isGamePaused = false;
this.removeEvent();
this.destroyBlockPopUp.getComponent(cc.Animation).play("PullUp");
}
}
......@@ -3,6 +3,7 @@ import LocalStorage from "../Data/LocalStorage";
import Score from "../Data/Score";
import Block from "../Objects/Block";
import Utils from "../Tools/Utils";
import GameOverScreen from "./GameOverScreen";
const { ccclass, property } = cc._decorator;
......@@ -15,6 +16,8 @@ export default class GameController extends cc.Component {
@property(Score) scoreLbl: Score = null;
@property(cc.Label) coinLbl: cc.Label = null;
@property(cc.Node) nextBlockSpf: cc.Node = null;
@property(cc.Node) shadow: cc.Node = null;
@property(cc.Node) gameOverScreen: cc.Node = null;
static instance: GameController;
......@@ -75,7 +78,8 @@ export default class GameController extends cc.Component {
spawnBlock(index: number) {
if (this.blocksData.blockData.length > 0) {
const isFull = this.blocksData.blockData[0].some((e) => e !== 0);
if (isFull) return;
if (isFull)
return this.gameOverScreen.getComponent(GameOverScreen).isGameOver();
}
if (this.isPreviewNextBlock) {
......@@ -242,7 +246,6 @@ export default class GameController extends cc.Component {
this.currentBlock.getComponent(Block).isPlace = true;
this.touched = false;
this.currentBlock = null;
if (this.isPreviewNextBlock) {
this.spawnBlock(this.nextBlock);
......
import LocalStorage from "../Data/LocalStorage";
import Score from "../Data/Score";
const { ccclass, property } = cc._decorator;
@ccclass
export default class GameOverScreen extends cc.Component {
@property(cc.Node) shadow: cc.Node = null;
@property(cc.Node) coin: cc.Node = null;
@property(cc.Node) highScore: cc.Node = null;
@property(cc.Node) currentScore: cc.Node = null;
@property(cc.Node) ignoreBtn: cc.Node = null;
@property(cc.Node) matchResultSrceen: cc.Node = null;
static instance: GameOverScreen;
gameOver: boolean = false;
protected onLoad(): void {
GameOverScreen.instance = this;
}
isGameOver() {
this.gameOver = true;
this.shadow.active = true;
this.node.active = true;
this.coin.getComponent(cc.Label).string =
LocalStorage.getAllCoin().toString();
this.highScore.getComponent(cc.Label).string =
LocalStorage.getHighestScore().toString();
this.currentScore.getComponent(cc.Label).string =
Score.instance.currentScore.toString();
}
onClickIgnoreBtn() {
this.node.active = false;
this.matchResultSrceen.active = true;
this.matchResultSrceen
.getChildByName("CoinBar")
.getChildByName("Coin")
.getComponent(cc.Label).string = LocalStorage.getAllCoin().toString();
this.matchResultSrceen
.getChildByName("ScoreBox")
.getChildByName("HighScoreBar")
.getChildByName("Label")
.getComponent(cc.Label).string =
LocalStorage.getHighestScore().toString();
this.matchResultSrceen
.getChildByName("ScoreBox")
.getChildByName("CurrentScoreBar")
.getChildByName("Label")
.getComponent(cc.Label).string = Score.instance.currentScore.toString();
const score = Score.instance.currentScore;
const rewardValues = [10, 20, 30, 40, 50, 60, 70, 80, 100];
if (score < 3000) return this.updateReward(0);
for (let i = 0; i < rewardValues.length; i++) {
if (score <= (i + 1) * 10000) {
this.updateReward(rewardValues[i]);
break;
}
}
}
updateReward(amount: number) {
const reward = this.matchResultSrceen
.getChildByName("RewardBar")
.getChildByName("Label");
reward.getComponent(cc.Label).string = "+" + amount;
LocalStorage.setAllCoin(LocalStorage.getAllCoin() + amount);
this.matchResultSrceen
.getChildByName("CoinBar")
.getChildByName("Coin")
.getComponent(cc.Label).string = LocalStorage.getAllCoin().toString();
}
}
{
"ver": "1.1.0",
"uuid": "e6b5fcd0-45c6-44a6-8175-f163cd4875d2",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -6,10 +6,14 @@ const { ccclass, property } = cc._decorator;
export default class Score extends cc.Component {
@property(cc.Node) highScoreLbl: cc.Node = null;
static instance: Score;
currentScore: number = 0;
highestScore: number = LocalStorage.getHighestScore();
protected onLoad(): void {
Score.instance = this;
this.highScoreLbl.getComponent(cc.Label).string =
this.highestScore.toString();
}
......@@ -17,7 +21,7 @@ export default class Score extends cc.Component {
setScore(score: number) {
this.currentScore += score;
this.node.getComponent(cc.Label).string = this.currentScore.toString();
if (this.currentScore > this.highestScore) {
LocalStorage.setHighestScore(this.currentScore);
this.highScoreLbl.getComponent(cc.Label).string =
......
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