add balance template

This commit is contained in:
Tu Bui 2025-06-11 16:32:14 +07:00
parent de54306c46
commit 110cd52f2a
22 changed files with 1962 additions and 0 deletions

13
assets/core/balance.meta Normal file
View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "9b399c8f-b109-413b-bddf-d990428db0b0",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "deaecb7c-66d4-4e00-8265-9bcebb1755ba",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,9 @@
{
"ver": "1.3.2",
"uuid": "894c2c5e-5952-40a4-8db1-3836f2038903",
"importer": "prefab",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "ea973ab2-c31f-4ec4-8efa-4e02d6eaaa9d",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "e82d09af-22de-4ffa-a7e6-03fd32b65473",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,48 @@
import { WinPoint } from "./win-point";
const { ccclass, property } = cc._decorator;
@ccclass
export class BalanceComponent extends cc.Component
{
@property(WinPoint)
private winPoint: WinPoint = null;
@property(cc.Label)
private labelUserName: cc.Label = null;
@property(cc.Label)
private labelBalanceValue: cc.Label = null;
private balanceValue: number = -1;
public updateBalance(value: number): void
{
if (this.validateWinMoney(value))
{
this.showWinPoint(value);
} else
{
this.updateLabelValue(value);
}
}
public updateUserName(value: number): void
{
this.labelBalanceValue.string = value.toString();
}
private showWinPoint(value: number): void
{
this.winPoint.show(value - this.balanceValue, () => { this.updateLabelValue(value) });
}
private validateWinMoney(value: number): boolean
{
return this.balanceValue != -1 && value > this.balanceValue
}
private updateLabelValue(value: number): void
{
this.balanceValue = value;
this.labelBalanceValue.string = value.toFixed(2).toString();
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "a3fb5522-eef3-4b4e-a667-a441b572289c",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,25 @@
import gsap from "gsap";
const { ccclass, property } = cc._decorator;
@ccclass
export class WinPoint extends cc.Component
{
@property(cc.Label)
private labelWinPoint: cc.Label = null;
protected onLoad(): void
{
this.node.active = false;
}
public show(value: number, callback: Function): void
{
this.node.active = true;
this.labelWinPoint.string = "+" + value.toFixed(2);
gsap.delayedCall(1, () =>
{
this.node.active = false;
});
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "8a1d67c2-c378-40af-9689-15f01fd6ef8a",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "60a91349-ae6f-49ba-8d8c-c5a0aa1d5c95",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,29 @@
import getDecorators from "inversify-inject-decorators";
import { BalanceModel, container, GAME_VIEW, MODEL } from "../../../plugins/core";
import { BalanceComponent } from "../component/balance-component";
const { ccclass, property } = cc._decorator;
const { lazyInject } = getDecorators(container);
@ccclass
export default class UpdateBalanceValueOnDataChange extends cc.Component implements Core.View.ComponentView
{
@lazyInject(GAME_VIEW.Balance)
private gameViewBalance: Core.View.GameView;
@lazyInject(MODEL.RemainBalance)
private balanceModel: BalanceModel;
@property(BalanceComponent)
private balanceComponent: BalanceComponent = null;
protected onLoad(): void
{
this.gameViewBalance.addComponent(this);
this.render();
}
public render()
{
this.balanceComponent.updateBalance(this.balanceModel.totalCredit);
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "794b3b20-bd72-4392-8776-058becd2ebf3",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "38c58cf1-2373-44ff-8c45-afdbc07db7b1",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -0,0 +1,38 @@
{
"ver": "2.3.7",
"uuid": "573de954-070d-4e16-b261-41ed51af2f8a",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 245,
"height": 71,
"platformSettings": {},
"subMetas": {
"bg-balance": {
"ver": "1.0.6",
"uuid": "fed051b1-f0f0-4fcd-b612-255d30af003e",
"importer": "sprite-frame",
"rawTextureUuid": "573de954-070d-4e16-b261-41ed51af2f8a",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 2,
"trimY": 0,
"width": 241,
"height": 71,
"rawWidth": 245,
"rawHeight": 71,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,38 @@
{
"ver": "2.3.7",
"uuid": "fc57a3c2-4c2c-48de-b1b5-402cb8a7cbe4",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 26,
"height": 26,
"platformSettings": {},
"subMetas": {
"coin-balance": {
"ver": "1.0.6",
"uuid": "c6b4abde-4bb9-419b-bb70-d6c30ba92540",
"importer": "sprite-frame",
"rawTextureUuid": "fc57a3c2-4c2c-48de-b1b5-402cb8a7cbe4",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 26,
"height": 26,
"rawWidth": 26,
"rawHeight": 26,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,38 @@
{
"ver": "2.3.7",
"uuid": "6e61c7d9-06d0-4f06-be46-61b8d26af192",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 200,
"height": 200,
"platformSettings": {},
"subMetas": {
"player-profile": {
"ver": "1.0.6",
"uuid": "4a5cac60-ce45-4446-bb88-0b3110f42dea",
"importer": "sprite-frame",
"rawTextureUuid": "6e61c7d9-06d0-4f06-be46-61b8d26af192",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 200,
"height": 200,
"rawWidth": 200,
"rawHeight": 200,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,38 @@
{
"ver": "2.3.7",
"uuid": "a2932a65-a282-4349-ab35-628603779fb5",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 88,
"height": 91,
"platformSettings": {},
"subMetas": {
"profile-border": {
"ver": "1.0.6",
"uuid": "766af824-10f1-4fc3-bd30-d647fb4a44f1",
"importer": "sprite-frame",
"rawTextureUuid": "a2932a65-a282-4349-ab35-628603779fb5",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 88,
"height": 91,
"rawWidth": 88,
"rawHeight": 91,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}