feat: add gacha booster

feature/ads-smart-display
tiendat3699 2024-06-11 11:35:13 +07:00
parent e095cfdfd2
commit 77e1e74333
41 changed files with 14466 additions and 5993 deletions

View File

@ -21,5 +21,5 @@
"library/": true,
"**/*.anim": true
},
"cSpell.ignoreWords": ["Poolable", "ccclass", "endregion", "lerp"]
"cSpell.ignoreWords": ["Gacha", "Poolable", "ccclass", "endregion", "lerp"]
}

View File

@ -23,7 +23,11 @@
],
"_exoticAnimation": null,
"_events": [],
"_embeddedPlayers": []
"_embeddedPlayers": [],
"_additiveSettings": {
"__id__": 23
},
"_auxiliaryCurveEntries": []
},
{
"__type__": "cc.animation.VectorTrack",
@ -105,7 +109,7 @@
"__type__": "cc.RealKeyframeValue",
"interpolationMode": 2,
"tangentWeightMode": 0,
"value": 0,
"value": -40,
"rightTangent": 0,
"rightTangentWeight": 1,
"leftTangent": 0,
@ -299,5 +303,10 @@
"_values": [],
"preExtrapolation": 1,
"postExtrapolation": 1
},
{
"__type__": "cc.AnimationClipAdditiveSettings",
"enabled": false,
"refClip": null
}
]

View File

@ -153,7 +153,7 @@
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"y": 40,
"z": 10
},
"_lrot": {
@ -1017,7 +1017,7 @@
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
"y": 0
},
"_id": ""
},
@ -1127,7 +1127,7 @@
"__id__": 80
},
"_collectSound": {
"__uuid__": "1ac12acc-dde3-4d31-9106-dfc30c030d40",
"__uuid__": "05a2671e-35bb-4be0-9244-43d541b9a26a",
"__expectedType__": "cc.AudioClip"
},
"_animation": {

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "fd465778-69b4-4cf8-9be2-48528a561b58",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "SecretBooster_flip_card"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "3aaaa833-5e70-4ec2-9480-47180250bb9d",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "SecretBooster_free_reward"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "a0154013-d559-4ebd-9c19-e549f8759829",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "SecretBooster_lucky_chain"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "c4569dbe-f865-41fd-9cb9-d2be403e5c52",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "SecretBooster_lucky_wheel"
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "90d80be9-d824-4dd9-bfd1-2035981a793b",
"files": [],
"subMetas": {},
"userData": {}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "95970f5f-8dce-493c-8996-6e3965a2fd9f",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "Flip_Card"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "5daa0690-4b3e-4026-b745-0b0420095ef2",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "Lucky_Chain"
}
}

View File

@ -0,0 +1,826 @@
[
{
"__type__": "cc.Prefab",
"_name": "Lucky_Chest",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false
},
{
"__type__": "cc.Node",
"_name": "Lucky_Chest",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [
{
"__id__": 2
}
],
"_active": true,
"_components": [
{
"__id__": 31
},
{
"__id__": 33
},
{
"__id__": 35
}
],
"_prefab": {
"__id__": 37
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "spine",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 3
},
{
"__id__": 10
}
],
"_active": true,
"_components": [
{
"__id__": 24
},
{
"__id__": 26
},
{
"__id__": 28
}
],
"_prefab": {
"__id__": 30
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "Button",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 4
},
{
"__id__": 6
}
],
"_prefab": {
"__id__": 9
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -30,
"y": 140,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 3
},
"_enabled": true,
"__prefab": {
"__id__": 5
},
"_contentSize": {
"__type__": "cc.Size",
"width": 600,
"height": 600
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "17q54A7hRAu7w+5ib7EKGa"
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 3
},
"_enabled": true,
"__prefab": {
"__id__": 7
},
"clickEvents": [
{
"__id__": 8
}
],
"_interactable": true,
"_transition": 0,
"_normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_hoverColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_pressedColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_normalSprite": null,
"_hoverSprite": null,
"_pressedSprite": null,
"_disabledSprite": null,
"_duration": 0.1,
"_zoomScale": 1.2,
"_target": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "0bNQnwKhtHNrIlRZw8VaXB"
},
{
"__type__": "cc.ClickEvent",
"target": {
"__id__": 1
},
"component": "",
"_componentId": "ad470Ao3iRJlqlmRKGumrMu",
"handler": "open",
"customEventData": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "a7FWR8Hx1IfILVF+Kna5vR",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_name": "Reward",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 2
},
"_children": [
{
"__id__": 11
}
],
"_active": true,
"_components": [
{
"__id__": 19
},
{
"__id__": 21
}
],
"_prefab": {
"__id__": 23
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "Label",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 10
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 12
},
{
"__id__": 14
},
{
"__id__": 16
}
],
"_prefab": {
"__id__": 18
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -231.45703125,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 11
},
"_enabled": true,
"__prefab": {
"__id__": 13
},
"_contentSize": {
"__type__": "cc.Size",
"width": 148.23046875,
"height": 138
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "33YwxJiIZFx52T+GuIPANS"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 11
},
"_enabled": true,
"__prefab": {
"__id__": 15
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_string": "100",
"_horizontalAlign": 2,
"_verticalAlign": 1,
"_actualFontSize": 100,
"_fontSize": 100,
"_fontFamily": "Arial",
"_lineHeight": 100,
"_overflow": 0,
"_enableWrapText": true,
"_font": {
"__uuid__": "4eb60b5b-72b8-497c-b499-d7921c9b84db",
"__expectedType__": "cc.TTFFont"
},
"_isSystemFontUsed": false,
"_spacingX": 0,
"_isItalic": false,
"_isBold": false,
"_isUnderline": false,
"_underlineHeight": 2,
"_cacheMode": 0,
"_enableOutline": true,
"_outlineColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_outlineWidth": 6,
"_enableShadow": false,
"_shadowColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_shadowOffset": {
"__type__": "cc.Vec2",
"x": 2,
"y": 2
},
"_shadowBlur": 2,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "abqDTVc0pLFJAI+MKxq3eQ"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 11
},
"_enabled": true,
"__prefab": {
"__id__": 17
},
"_alignFlags": 10,
"_target": null,
"_left": -161.572265625,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_horizontalCenter": 0,
"_verticalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_alignMode": 2,
"_lockFlags": 0,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "a0YsiditVM1JgTlUtoFyOX"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "c6lHFE6oBJM6bTulGiWcBC",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 10
},
"_enabled": true,
"__prefab": {
"__id__": 20
},
"_contentSize": {
"__type__": "cc.Size",
"width": 288,
"height": 281
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "00TALsq4ZHl6Ld0LVWiUr7"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 10
},
"_enabled": true,
"__prefab": {
"__id__": 22
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": null,
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "6dTw63zDlHr4d6fvs5Jqp2"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "eecto8uchI0JBttEQ77b3N",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 25
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1280,
"height": 1280
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.46616406440734864,
"y": 0.4069765567779541
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "0cfBKLa1pChZne6FjL9cYq"
},
{
"__type__": "sp.Skeleton",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 27
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_skeletonData": {
"__uuid__": "75cc4005-0956-4ded-8966-c8e347fc48d5",
"__expectedType__": "sp.SkeletonData"
},
"defaultSkin": "default",
"defaultAnimation": "",
"_premultipliedAlpha": true,
"_timeScale": 1,
"_preCacheMode": 0,
"_cacheMode": 0,
"_sockets": [],
"_useTint": false,
"_debugMesh": false,
"_debugBones": false,
"_debugSlots": false,
"_enableBatch": false,
"loop": false,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "21L7AIRjlL4LYtwXg0hbBU"
},
{
"__type__": "88095558MdN+qsTqyxCx1uE",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 29
},
"ignoreTimeScale": true,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "d5wG1k12tPSLtnW0+IQXsf"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "d8x2Oiw+pDOaWKifX4nb+x",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 32
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"height": 100
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "88ziLh6chEWpDcSRlXBn+Z"
},
{
"__type__": "b2937Y+5yVLE4z8uGa84ZqS",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 34
},
"skeleton": {
"__id__": 26
},
"_flipX": false,
"_flipY": false,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "c1MbWXU5hLnKm6/fqQUv00"
},
{
"__type__": "ad470Ao3iRJlqlmRKGumrMu",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 36
},
"animationHandler": {
"__id__": 33
},
"spineRoot": {
"__id__": 2
},
"rewardSprite": {
"__id__": 21
},
"rewardLabel": {
"__id__": 14
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "cfV16eXGdO6agmNgVxnedh"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "d8nEtFnupHxp1DyuqkemXx",
"instance": null,
"targetOverrides": null
}
]

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "f1071cf2-53d2-46b0-8fa4-c95b17f8e622",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "Lucky_Chest"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "624d1fb0-782f-48f7-8864-9e1db2dc8483",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "Lucky_Wheel"
}
}

View File

@ -92,7 +92,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 30.310546875,
"x": 46.12109375,
"y": 0,
"z": 0
},
@ -207,7 +207,7 @@
"_alignFlags": 34,
"_target": null,
"_left": 20.619999999999997,
"_right": -40,
"_right": -45,
"_top": 0,
"_bottom": 0,
"_horizontalCenter": 0,
@ -255,7 +255,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 60.62109375,
"width": 82.2421875,
"height": 54.4
},
"_anchorPoint": {
@ -291,7 +291,7 @@
"b": 0,
"a": 255
},
"_string": "+10",
"_string": "+100",
"_horizontalAlign": 1,
"_verticalAlign": 1,
"_actualFontSize": 40,

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -36,7 +36,7 @@ export class BoosterBase extends Component implements IPoolable {
ObjectPool.release(this.node);
}
protected boosterActive?(): void;
protected boosterActive() {}
async onGet() {
this._animation.play();

View File

@ -0,0 +1,18 @@
import { _decorator, Component, Node } from 'cc';
import BoosterType from '../Enum/BoosterType';
import GachaManager, { GachaType } from '../Manager/GachaManager';
import { GameManager } from '../Manager/GameManager';
import { BoosterBase } from './BoosterBase';
const { ccclass, property } = _decorator;
@ccclass('SecretBoxBooster')
export default class SecretBoxBooster extends BoosterBase {
@property({ type: GachaType })
private gachaType: GachaType;
protected boosterActive() {
GameManager.instance.ActiveBooster(BoosterType.Gacha, this.time, this.displayName);
GachaManager.instance.show(this.gachaType, 1.5);
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "016c5a9d-bb6a-44d9-acef-c99f56add5a3",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -1,5 +1,6 @@
enum BoosterType {
CumulativeBar,
Gacha,
}
export default BoosterType;

View File

@ -1,5 +1,6 @@
import { _decorator, CCFloat, Component, geometry, Label, Sprite, SpriteFrame, tween, Vec3 } from 'cc';
import { _decorator, CCFloat, Component, geometry, Label, Sprite, SpriteFrame, tween, Vec3, Widget } from 'cc';
import ObjectPool from '../Pool/ObjectPool';
import Utils from '../Utilities';
const { ccclass, property } = _decorator;
@ccclass('FloatingText')
@ -16,7 +17,7 @@ export class FloatingText extends Component {
private readonly _scaleDownDuration = 0.2;
private _moveDuration = 0;
public show(text: string, position: Vec3, scale = 1, duration = 1, image: SpriteFrame = null) {
public async show(text: string, position: Vec3, scale = 1, duration = 1, image: SpriteFrame = null) {
if (duration < this._scaleUpDuration + this._scaleDownDuration) {
console.warn(
`show duration time of floating text must be greater than ${this._scaleUpDuration + this._scaleDownDuration}`,
@ -54,5 +55,7 @@ export class FloatingText extends Component {
ObjectPool.release(this.node);
})
.start();
await Utils.delay(0.05);
this._sprite.getComponent(Widget).updateAlignment();
}
}

View File

@ -18,7 +18,6 @@ enum GameEvent {
ControlTouchEnd,
WarningTime,
TicketUpdate,
GachaReward,
}
export interface GameEventCallbackMap {
@ -49,7 +48,6 @@ export interface GameEventArgMap {
[GameEvent.ControlTouchEnd]: ControllerSide;
[GameEvent.WarningTime]: boolean;
[GameEvent.TicketUpdate]: number;
[GameEvent.GachaReward]: [RewardType, number];
}
export default GameEvent;

View File

@ -85,6 +85,7 @@ declare global {
}
interface Array<T> {
getRandomIndex(): number;
getRandom(): T;
getRandom(weights: number[]): T;
}
@ -268,6 +269,10 @@ String.prototype.isNullOrWhiteSpace = function () {
//#region ARRAY
Array.prototype.getRandomIndex = function () {
return randomRangeInt(0, this.length);
};
Array.prototype.getRandom = function (weights?: number[]) {
if (weights) {
let weightsClone = [...weights];

View File

@ -55,6 +55,11 @@ export default class FlipCard extends GachaBase {
if (reward) {
this.cards[+value - 1].spriteFrame = reward.icon;
await this.animationHandler.setAnimationAsync(`card${value}-active`, { trackIndex: +value });
GachaManager.instance.showFloatingText(
reward.quantity.toString(),
this.cards[+value - 1].node.worldPosition,
reward.icon,
);
GachaManager.instance.gachaDone();
}

View File

@ -1,7 +1,7 @@
import { _decorator, clamp01, Component, easing, game, Label, Node, Sprite, Vec3 } from 'cc';
import GachaBase from '../Base/GachaBase';
import SpineAnimationHandler from '../Base/SpineAnimationHandler';
import GachaManager from '../Manager/GachaManager';
import GachaManager, { RewardConfig } from '../Manager/GachaManager';
import Utils from '../Utilities';
const { ccclass, property } = _decorator;
@ -20,6 +20,7 @@ export default class FreeReward extends GachaBase {
private _opened: boolean = false;
private _startShowReward: boolean = false;
private _timer: number = 0;
private _reward: RewardConfig;
protected onEnable(): void {
this.spineRoot.setActive(false);
@ -38,6 +39,11 @@ export default class FreeReward extends GachaBase {
this._timer += game.deltaTime;
if (k === 1) {
this._startShowReward = false;
GachaManager.instance.showFloatingText(
this._reward.quantity.toString(),
this.rewardSprite.node.worldPosition,
this._reward.icon,
);
GachaManager.instance.gachaDone();
}
}
@ -53,11 +59,11 @@ export default class FreeReward extends GachaBase {
if (this._opened) return;
this._timer = 0;
this._opened = true;
const reward = await GachaManager.instance.getReward();
if (reward) {
this._reward = await GachaManager.instance.getReward();
if (this._reward) {
this.animationHandler.setAnimation('open');
this.rewardSprite.spriteFrame = reward.icon;
this.rewardLabel.string = reward.quantity.toString();
this.rewardSprite.spriteFrame = this._reward.icon;
this.rewardLabel.string = this._reward.quantity.toString();
await Utils.delay(1);
this.rewardSprite.setNodeActive(true);
this._startShowReward = true;

View File

@ -1,19 +1,19 @@
import { _decorator, Component, Node, sp, Sprite } from 'cc';
import { _decorator, Component, Node, sp, Sprite, SpriteFrame } from 'cc';
import GachaBase from '../Base/GachaBase';
import SpineAnimationHandler, { SocketPath, SpineAnimation, SpineSkin } from '../Base/SpineAnimationHandler';
import GachaManager from '../Manager/GachaManager';
import GachaManager, { RewardConfig } from '../Manager/GachaManager';
import Utils from '../Utilities';
const { ccclass, property } = _decorator;
class ActiveCard {
class RewardCard {
public socket: sp.SpineSocket;
public node: Node;
public idReward: string;
public reward: RewardConfig;
constructor(node: Node, idReward: string) {
constructor(node: Node, reward: RewardConfig) {
this.node = node;
this.idReward = idReward;
this.reward = reward;
}
public setActive(value: boolean) {
@ -32,9 +32,9 @@ export default class LuckyChain extends GachaBase {
@property({ type: SocketPath })
private cardSlotPath: SocketPath[] = [];
private _activeCards: ActiveCard[] = [];
private _allCards: ActiveCard[] = [];
private _rewardId: string;
private _activeCards: RewardCard[] = [];
private _allCards: RewardCard[] = [];
private _reward: RewardCard;
onFocusInEditor(): void {
this.animationHandler.setPropertySocketPath(this, 'cardSlotPath');
@ -56,7 +56,7 @@ export default class LuckyChain extends GachaBase {
switch (e.data.name) {
case 'card-claimed':
const cardRemove = this._activeCards.shift();
this._rewardId = cardRemove.idReward;
this._reward = cardRemove;
this.animationHandler.removeSocket(cardRemove.socket);
cardRemove.setActive(false);
cardRemove.socket = null;
@ -80,10 +80,10 @@ export default class LuckyChain extends GachaBase {
private setReward() {
this._allCards = this.cards.map((card) => {
const rw = GachaManager.instance.getRandomReward();
const rw = GachaManager.instance.getRandomReward([60, 35, 5]);
card.getComponent(Sprite).spriteFrame = rw.icon;
card.setActive(false);
return new ActiveCard(card, rw.id);
return new RewardCard(card, rw);
});
}
@ -91,8 +91,12 @@ export default class LuckyChain extends GachaBase {
this.spriteRoot.setActive(true);
await this.animationHandler.setAnimationAsync('appear');
await this.animationHandler.addAnimationAsync('active');
GachaManager.instance.setReward(this._rewardId);
GachaManager.instance.showFloatingText(
this._reward.reward.quantity.toString(),
this.node.worldPosition,
this._reward.reward.icon,
);
GachaManager.instance.setReward(this._reward.reward.id);
await Utils.delay(1.5);
//update socket path

View File

@ -1,10 +1,36 @@
import { _decorator, CCInteger, CCString, Component, game, Node, randomRangeInt, RealCurve, sp, Sprite } from 'cc';
import {
_decorator,
CCInteger,
CCString,
Component,
game,
Node,
random,
randomRangeInt,
RealCurve,
sp,
Sprite,
} from 'cc';
import GachaBase from '../Base/GachaBase';
import SpineAnimationHandler from '../Base/SpineAnimationHandler';
import GachaManager from '../Manager/GachaManager';
import GachaManager, { RewardConfig } from '../Manager/GachaManager';
const { ccclass, property } = _decorator;
class RewardCard {
public node: Node;
public reward: RewardConfig;
constructor(node: Node, reward: RewardConfig) {
this.node = node;
this.reward = reward;
}
public setActive(value: boolean) {
this.node.setActive(value);
}
}
@ccclass('LuckyWheel')
export default class LuckyWheel extends GachaBase {
@property(SpineAnimationHandler)
@ -26,12 +52,15 @@ export default class LuckyWheel extends GachaBase {
private _timer: number = 0;
private _timeSpin: number = 0;
private _maxAngle: number = 0;
private _allCards: RewardCard[];
private _random: number;
protected onLoad(): void {
this._wheel = this.animationHandler.findBone(this.wheelBoneName);
}
protected onEnable(): void {
this.setReward();
this.spineRoot.setActive(false);
this._wheel.rotation = 0;
this._wheel.update();
@ -45,11 +74,24 @@ export default class LuckyWheel extends GachaBase {
this._wheel.update();
if (this._timer >= this._timeSpin) {
this._spinning = false;
GachaManager.instance.gachaDone();
GachaManager.instance.showFloatingText(
this._allCards[this._random].reward.quantity.toString(),
this.node.worldPosition,
this._allCards[this._random].reward.icon,
);
GachaManager.instance.setReward(this._allCards[this._random].reward.id);
}
}
}
private setReward() {
this._allCards = this.sprites.map((card) => {
const rw = GachaManager.instance.getRandomReward([60, 35, 5]);
card.spriteFrame = rw.icon;
return new RewardCard(card.node, rw);
});
}
public async show(): Promise<void> {
for (let i = 0; i < GachaManager.instance.rewards.length; i++) {
this.sprites[i].spriteFrame = GachaManager.instance.rewards[i].icon;
@ -63,11 +105,10 @@ export default class LuckyWheel extends GachaBase {
public async spin() {
if (this._spinning) return;
this._spinning = true;
const reward = await GachaManager.instance.getReward();
const item = GachaManager.instance.getRewardIndex(reward);
if (reward) {
this._random = this._allCards.getRandomIndex();
if (this._random) {
this.animationHandler.clearTrack(0);
this._targetAngle = -36 * item;
this._targetAngle = -36 * this._random;
this._timer = 0;
this._timeSpin = randomRangeInt(10, 15);
this._maxAngle = 360 * this._timeSpin;
@ -76,6 +117,6 @@ export default class LuckyWheel extends GachaBase {
}
this._spinning = true;
GachaManager.instance.gachaDone();
GachaManager.instance.setReward(this._allCards[this._random].reward.id);
}
}

View File

@ -12,12 +12,16 @@ import {
SpriteFrame,
tween,
UIOpacity,
Vec3,
} from 'cc';
import GachaBase from '../Base/GachaBase';
import ScoreType from '../Enum/ScoreType';
import GameEvent from '../Events/GameEvent';
import FloatingTextFactory from '../Factory/FloatingTextFactory';
import Singleton from '../Singleton';
import Utils from '../Utilities';
import { EventManger } from './EventManger';
import { GameManager } from './GameManager';
const { ccclass, property } = _decorator;
@ -30,12 +34,9 @@ export enum GachaType {
Enum(GachaType);
export enum RewardType {
Oxi,
Gas,
Star,
Shield,
ScoreX2,
Magnet,
Time,
Cheese,
}
Enum(RewardType);
@ -50,11 +51,11 @@ class Gacha {
}
@ccclass('RewardConfig')
class RewardConfig {
export class RewardConfig {
@property(CCString)
public id: string = '';
@property({ type: RewardType })
public type: RewardType = RewardType.Oxi;
public type: RewardType = RewardType.Star;
@property(SpriteFrame)
public icon: SpriteFrame;
@property(CCInteger)
@ -67,6 +68,8 @@ export default class GachaManager extends Singleton<GachaManager>() {
public gachaId: string;
@property(UIOpacity)
private container: UIOpacity;
@property(FloatingTextFactory)
private floatingScoreFactory: FloatingTextFactory;
@property(Gacha)
private gachas: Gacha[] = [];
@property(RewardConfig)
@ -75,19 +78,20 @@ export default class GachaManager extends Singleton<GachaManager>() {
private _reward: RewardConfig;
private _showing: boolean = false;
private _showTimer: number = 0;
private _idType: string;
private _idType: GachaType;
protected onLoad(): void {
super.onLoad();
this.container.setNodeActive(false);
}
public show(idType: string) {
public async show(type: GachaType, delay: number = 0) {
game.timeScale = 0;
await Utils.delay(delay);
this.container.setNodeActive(true);
this._showTimer = 0;
this._showing = true;
this._idType = idType;
this._idType = type;
}
protected update(dt: number): void {
@ -102,8 +106,13 @@ export default class GachaManager extends Singleton<GachaManager>() {
}
}
public showFloatingText(text: string, position: Vec3, icon: SpriteFrame) {
const floatingText = this.floatingScoreFactory.create(this.node);
floatingText.show(`+${text}`, position, 3, 1, icon);
}
private showGacha() {
const gacha = this.gachas.find((gacha) => gacha.id == this._idType);
const gacha = this.gachas.find((gacha) => gacha.type == this._idType);
gacha.gacha.show();
}
@ -118,17 +127,26 @@ export default class GachaManager extends Singleton<GachaManager>() {
public async gachaDone() {
console.log(`Gacha reward: ${RewardType[this._reward.type]} quantity: ${this._reward.quantity}`);
EventManger.instance.emit(GameEvent.GachaReward, [this._reward.type, this._reward.quantity]);
await Utils.delay(1);
game.timeScale = 1;
tween(this.container)
.to(0.1, { opacity: 0 })
.call(() => this.container.setNodeActive(false))
.call(() => {
this.container.setNodeActive(false);
switch (this._reward.type) {
case RewardType.Star:
GameManager.instance.addScore(this._reward.quantity, ScoreType.DestroyObject);
break;
case RewardType.Time:
GameManager.instance.addTime(this._reward.quantity, Vec3.ZERO);
break;
}
})
.start();
}
public getRandomReward() {
return this.rewards.getRandom();
public getRandomReward(weights?: number[]) {
return this.rewards.getRandom(weights);
}
public setReward(id: string) {

View File

@ -9,6 +9,7 @@ import {
Quat,
randomRangeInt,
SpriteFrame,
tween,
Vec2,
Vec3,
} from 'cc';
@ -70,8 +71,6 @@ export class GameManager extends Singleton<GameManager>() {
@property({ type: SpriteFrame, visible: true })
private _clockIcon: SpriteFrame;
@property({ type: AudioClip, visible: true })
private _boosterActiveSound: AudioClip;
@property({ type: AudioClip, visible: true })
private _startSound: AudioClip;
@property({ type: AudioClip, visible: true })
@ -169,17 +168,19 @@ export class GameManager extends Singleton<GameManager>() {
public addScore(
score: number,
type: ScoreType,
position: Vec3,
position?: Vec3,
opts?: { scaleMin?: number; scaleMax?: number; duration?: number },
) {
this._score += score;
const floatingScore = this._floatingScoreFactory.create(this._topContainer);
floatingScore.show(
`+${score}`,
position,
score >= 100 ? opts?.scaleMax || 1 : opts?.scaleMin || 1,
opts?.duration || 1,
);
if (position) {
floatingScore.show(
`+${score}`,
position,
score >= 100 ? opts?.scaleMax || 1 : opts?.scaleMin || 1,
opts?.duration || 1,
);
}
EventManger.instance.emit(GameEvent.Score, [this._score, score, type, position]);
}
@ -283,18 +284,20 @@ export class GameManager extends Singleton<GameManager>() {
await Utils.delay(0.3);
}
if (bonusTime) {
this.addTime(bonusTime);
const floatingScore = this._floatingScoreFactory.create(this._topContainer);
floatingScore.show(`+${bonusTime}`, position, 1.5, 1, this._clockIcon);
this.addTime(bonusTime, position);
}
}
public addTime(time: number) {
public addTime(time: number, position?: Vec3) {
this._timer.time += time;
if (this._warningTime && this._timer.time > 10) {
this._warningTime = false;
EventManger.instance.emit(GameEvent.WarningTime, false);
}
if (position) {
const floatingScore = this._floatingScoreFactory.create(this._topContainer);
floatingScore.show(`+${time}`, position, 1.5, 1, this._clockIcon);
}
EventManger.instance.emit(GameEvent.TimeUpdate, this._timer.timeRound);
}
@ -358,7 +361,6 @@ export class GameManager extends Singleton<GameManager>() {
}
this._boostersActive.push(new Booster(type, time));
EventManger.instance.emit(GameEvent.BoosterActive, [type, displayName]);
AudioManager.playSfx(this._boosterActiveSound);
AudioManager.setPlayRateBGM(1.25);
}
}

View File

@ -1,4 +1,18 @@
import { _decorator, CCString, Color, Component, Label, Node, Sprite, SpriteFrame, Tween, tween, Vec3 } from 'cc';
import {
_decorator,
CCString,
Color,
Component,
game,
Label,
Node,
Sprite,
SpriteFrame,
Tween,
tween,
TweenSystem,
Vec3,
} from 'cc';
import Singleton from '../Singleton';
const { ccclass, property } = _decorator;
@ -19,12 +33,21 @@ export class StickerManager extends Singleton<StickerManager>() {
@property({ type: Sticker, visible: true })
private _stickers: Sticker[] = [];
private _showing: boolean = false;
protected start(): void {
this._popup.setScale(Vec3.ZERO);
this._label.string = '';
}
protected update(dt: number): void {
if (this._showing && game.timeScale == 0) {
TweenSystem.instance.ActionManager.update(game.deltaTime);
}
}
public Show(stickerName: string, position: Vec3 = Vec3.ZERO) {
this._showing = true;
let sticker = this._stickers.find((s) => s.Name == stickerName);
this._popup.setPosition(position);
this._popup.getComponent(Sprite).spriteFrame = sticker.SpriteFrame;
@ -33,10 +56,12 @@ export class StickerManager extends Singleton<StickerManager>() {
.to(0.3, { scale: Vec3.ONE }, { easing: 'backOut' })
.delay(0.5)
.to(0.2, { scale: Vec3.ZERO }, { easing: 'backIn' })
.call(() => (this._showing = false))
.start();
}
public showLabel(string: string, opts?: { color?: Color; outLineColor?: Color; position?: Vec3 }) {
this._showing = true;
this._label.string = string;
this._label.color = opts?.color || new Color('#FFFF00');
this._label.node.setPosition(opts?.position || Vec3.ZERO);
@ -57,6 +82,7 @@ export class StickerManager extends Singleton<StickerManager>() {
easing: 'backIn',
},
)
.call(() => (this._showing = false))
.start();
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "9d09f58c-4e94-4644-bb29-5926a43a1b18",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -131,7 +131,7 @@ export class GameOverPanel extends Component {
score += x;
duration = this._starSpeedCurve.evaluate(i / items - 1);
score = score > totalScore ? totalScore : score;
const obj = this._floatingStarFactory.create(this.node);
const obj = this._floatingStarFactory.create(this._scoreUI);
obj.node.setWorldPosition(this._scoreUI.worldPosition);
tween(obj.node)
.to(

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@ -0,0 +1,134 @@
{
"ver": "1.0.26",
"importer": "image",
"imported": true,
"uuid": "9ee71731-507c-4afa-acbe-f2f16dc3cd50",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "9ee71731-507c-4afa-acbe-f2f16dc3cd50@6c48a",
"displayName": "Asset Booster Random Gacha",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "9ee71731-507c-4afa-acbe-f2f16dc3cd50",
"isUuid": true,
"visible": false,
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "9ee71731-507c-4afa-acbe-f2f16dc3cd50@f9941",
"displayName": "Asset Booster Random Gacha",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 176,
"height": 155,
"rawWidth": 176,
"rawHeight": 155,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-88,
-77.5,
0,
88,
-77.5,
0,
-88,
77.5,
0,
88,
77.5,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
155,
176,
155,
0,
0,
176,
0
],
"nuv": [
0,
0,
1,
0,
0,
1,
1,
1
],
"minPos": [
-88,
-77.5,
0
],
"maxPos": [
88,
77.5,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "9ee71731-507c-4afa-acbe-f2f16dc3cd50@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "9ee71731-507c-4afa-acbe-f2f16dc3cd50@f9941"
}
}