Merge pull request 'Close #9: add chip template' (#11) from feature/add-chip-template into master

Reviewed-on: dev-tech/ts-table-game-template#11
Reviewed-by: Le Hoang Nam <nam.le@noreply.localhost>
This commit is contained in:
Le Hoang Nam 2025-06-11 14:36:14 +08:00
commit 2731ced421
15 changed files with 668 additions and 0 deletions

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

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "c3c21a4a-e1a3-407d-a865-de0a631f9c0f",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "dc4c782c-195a-420e-99f4-fb7552dbb61d",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,35 @@
export class ChipColorConfig
{
private static mapHexColorByValue: Map<Number, string> = new Map<Number, string>([
[1, "#741F20"],
[2, "#742356"],
[3, "#1B5B15"],
[4, "#1B5B15"],
[5, "#9D4065"],
[6, "#9D4065"],
[7, "#9D4065"],
[8, "#9D4065"],
[9, "#9D4065"],
[10, "#201F5E"],
[11, "#201F5E"],
[12, "#201F5E"],
[13, "#201F5E"],
[14, "#201F5E"],
[15, "#201F5E"],
[16, "#201F5E"],
]);
public static GetColor(chipValue: Number): cc.Color
{
var colorHex = this.mapHexColorByValue.get(chipValue);
if (colorHex == null)
{
return cc.Color.WHITE;
} else
{
var color = new cc.Color().fromHEX(colorHex);;
return color;
}
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "f3e6582e-d503-481d-bbbd-b4be508e6dc6",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "c22fe85b-e5b1-4a52-919f-0e777095af56",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,436 @@
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "chip",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 5
},
{
"__id__": 8
}
],
"_active": true,
"_components": [
{
"__id__": 11
}
],
"_prefab": {
"__id__": 12
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 138,
"height": 138
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-60.678,
0,
0,
0,
0,
0,
1,
0.65,
0.65,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "below-layer",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
}
],
"_prefab": {
"__id__": 4
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 116,
"g": 31,
"b": 32,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 140,
"height": 140
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0.636,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "bff54f22-0f2d-4eb3-a256-0a5ca31f36f5"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "43ANAqfhhCD4xTCOMvW5nT",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "above-layer",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 6
}
],
"_prefab": {
"__id__": 7
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 140,
"height": 140
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0.636,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "03a08d17-a871-4148-88c4-49181c0f25e2"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "2dmBPBa/ZJPakJqfb7CrHt",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "label-value",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 9
}
],
"_prefab": {
"__id__": 10
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 80,
"height": 78.12
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
1,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "1",
"_N$string": "1",
"_fontSize": 62,
"_lineHeight": 62,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": false,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 2,
"_N$cacheMode": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "06lDa363xGZKXU/10WRDWE",
"sync": false
},
{
"__type__": "2b048YbtMZEWrnIdtkXQ/EK",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"labelChipValue": {
"__id__": 9
},
"nodeChipColor": {
"__id__": 2
},
"value": 1,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "",
"sync": false
}
]

View File

@ -0,0 +1,9 @@
{
"ver": "1.3.2",
"uuid": "ad6757ac-55f7-43b6-99bf-09806442345d",
"importer": "prefab",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "e4f1840d-5a30-41d5-8789-694bf3dd26d7",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,27 @@
import { ChipColorConfig } from "../config/chip-color-config";
const { ccclass, property } = cc._decorator;
@ccclass
export class Chip extends cc.Component
{
@property(cc.Label)
private labelChipValue: cc.Label = null;
@property(cc.Node)
private nodeChipColor: cc.Node = null;
@property(cc.Integer)
private value: number = 1;
public setChipValue(value: number): void
{
this.value = value;
this.labelChipValue.string = value.toString();
this.nodeChipColor.color = ChipColorConfig.GetColor(value);
}
public getChipValue(): number
{
return this.value;
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "2b04861b-b4c6-445a-b9c8-76d91743f10a",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "525d3784-086b-4a1b-bf8d-ca4eb414a231",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -0,0 +1,38 @@
{
"ver": "2.3.7",
"uuid": "e47954fd-d224-4959-98be-76c5d94d6ca7",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 148,
"height": 148,
"platformSettings": {},
"subMetas": {
"below-chip": {
"ver": "1.0.6",
"uuid": "bff54f22-0f2d-4eb3-a256-0a5ca31f36f5",
"importer": "sprite-frame",
"rawTextureUuid": "e47954fd-d224-4959-98be-76c5d94d6ca7",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 148,
"height": 148,
"rawWidth": 148,
"rawHeight": 148,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

@ -0,0 +1,38 @@
{
"ver": "2.3.7",
"uuid": "c0c639cd-5cca-4994-a585-9b2895aefed0",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 148,
"height": 148,
"platformSettings": {},
"subMetas": {
"top-chip": {
"ver": "1.0.6",
"uuid": "03a08d17-a871-4148-88c4-49181c0f25e2",
"importer": "sprite-frame",
"rawTextureUuid": "c0c639cd-5cca-4994-a585-9b2895aefed0",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 148,
"height": 148,
"rawWidth": 148,
"rawHeight": 148,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}