feat: add full gacha

feature/ads-smart-display
tiendat3699 2024-06-17 18:07:20 +07:00
parent 095ee151f3
commit 75a60bea9e
19 changed files with 15655 additions and 9316 deletions

View File

@ -1011,7 +1011,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"width": 90,
"height": 80
},
"_anchorPoint": {
@ -1127,7 +1127,7 @@
"__id__": 80
},
"_collectSound": {
"__uuid__": "1ac12acc-dde3-4d31-9106-dfc30c030d40",
"__uuid__": "ca7dc97e-d8a6-43f4-922d-14a2b5422cd6",
"__expectedType__": "cc.AudioClip"
},
"_animation": {

View File

@ -1011,7 +1011,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"width": 90,
"height": 80
},
"_anchorPoint": {
@ -1127,7 +1127,7 @@
"__id__": 80
},
"_collectSound": {
"__uuid__": "1ac12acc-dde3-4d31-9106-dfc30c030d40",
"__uuid__": "ca7dc97e-d8a6-43f4-922d-14a2b5422cd6",
"__expectedType__": "cc.AudioClip"
},
"_animation": {

View File

@ -1011,7 +1011,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"width": 90,
"height": 80
},
"_anchorPoint": {
@ -1127,7 +1127,7 @@
"__id__": 80
},
"_collectSound": {
"__uuid__": "1ac12acc-dde3-4d31-9106-dfc30c030d40",
"__uuid__": "ca7dc97e-d8a6-43f4-922d-14a2b5422cd6",
"__expectedType__": "cc.AudioClip"
},
"_animation": {

View File

@ -1011,7 +1011,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"width": 90,
"height": 80
},
"_anchorPoint": {
@ -1127,7 +1127,7 @@
"__id__": 80
},
"_collectSound": {
"__uuid__": "1ac12acc-dde3-4d31-9106-dfc30c030d40",
"__uuid__": "ca7dc97e-d8a6-43f4-922d-14a2b5422cd6",
"__expectedType__": "cc.AudioClip"
},
"_animation": {

View File

@ -24,18 +24,18 @@
],
"_active": true,
"_components": [
{
"__id__": 10
},
{
"__id__": 12
},
{
"__id__": 14
},
{
"__id__": 16
}
],
"_prefab": {
"__id__": 18
"__id__": 20
},
"_lpos": {
"__type__": "cc.Vec3",
@ -85,14 +85,17 @@
},
{
"__id__": 7
},
{
"__id__": 9
}
],
"_prefab": {
"__id__": 9
"__id__": 11
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 46.12109375,
"x": 46.12109375000001,
"y": 0,
"z": 0
},
@ -133,7 +136,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 40,
"width": 39.11764705882353,
"height": 35
},
"_anchorPoint": {
@ -207,7 +210,7 @@
"_alignFlags": 34,
"_target": null,
"_left": 20.619999999999997,
"_right": -45,
"_right": -44.11764705882353,
"_top": 0,
"_bottom": 0,
"_horizontalCenter": 0,
@ -228,6 +231,24 @@
"__type__": "cc.CompPrefabInfo",
"fileId": "c6jbkI4Y1DIY6xOK2rRAGv"
},
{
"__type__": "2291brx8LpIc5DogteLVdjM",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 10
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "2e0dbL5a1NFq59fBhH5ViM"
},
{
"__type__": "cc.PrefabInfo",
"root": {
@ -251,7 +272,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 11
"__id__": 13
},
"_contentSize": {
"__type__": "cc.Size",
@ -279,7 +300,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 13
"__id__": 15
},
"_customMaterial": null,
"_srcBlendFactor": 2,
@ -350,17 +371,17 @@
},
"_enabled": true,
"__prefab": {
"__id__": 15
"__id__": 17
},
"_label": {
"__id__": 12
"__id__": 14
},
"_sprite": {
"__id__": 5
},
"_moveSpeed": 50,
"_animationCurve": {
"__id__": 16
"__id__": 18
},
"_id": ""
},
@ -371,7 +392,7 @@
{
"__type__": "cc.AnimationCurve",
"_curve": {
"__id__": 17
"__id__": 19
}
},
{

View File

@ -24,18 +24,18 @@
],
"_active": true,
"_components": [
{
"__id__": 40
},
{
"__id__": 42
},
{
"__id__": 44
},
{
"__id__": 46
},
{
"__id__": 48
}
],
"_prefab": {
"__id__": 46
"__id__": 50
},
"_lpos": {
"__type__": "cc.Vec3",
@ -85,23 +85,23 @@
"__id__": 17
},
{
"__id__": 23
"__id__": 25
}
],
"_active": true,
"_components": [
{
"__id__": 29
"__id__": 33
},
{
"__id__": 31
"__id__": 35
},
{
"__id__": 37
"__id__": 41
}
],
"_prefab": {
"__id__": 39
"__id__": 43
},
"_lpos": {
"__type__": "cc.Vec3",
@ -498,10 +498,13 @@
},
{
"__id__": 20
},
{
"__id__": 22
}
],
"_prefab": {
"__id__": 22
"__id__": 24
},
"_lpos": {
"__type__": "cc.Vec3",
@ -585,7 +588,7 @@
"_spriteFrame": null,
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
@ -602,6 +605,24 @@
"__type__": "cc.CompPrefabInfo",
"fileId": "5bp0bh7QtOdYSYqKSecZXS"
},
{
"__type__": "2291brx8LpIc5DogteLVdjM",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 17
},
"_enabled": true,
"__prefab": {
"__id__": 23
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "8ecYdHwx1C0r1QDOjbEz29"
},
{
"__type__": "cc.PrefabInfo",
"root": {
@ -627,14 +648,17 @@
"_active": true,
"_components": [
{
"__id__": 24
"__id__": 26
},
{
"__id__": 26
"__id__": 28
},
{
"__id__": 30
}
],
"_prefab": {
"__id__": 28
"__id__": 32
},
"_lpos": {
"__type__": "cc.Vec3",
@ -671,11 +695,11 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 23
"__id__": 25
},
"_enabled": true,
"__prefab": {
"__id__": 25
"__id__": 27
},
"_contentSize": {
"__type__": "cc.Size",
@ -699,11 +723,11 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 23
"__id__": 25
},
"_enabled": true,
"__prefab": {
"__id__": 27
"__id__": 29
},
"_customMaterial": null,
"_srcBlendFactor": 2,
@ -718,7 +742,7 @@
"_spriteFrame": null,
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
@ -735,6 +759,24 @@
"__type__": "cc.CompPrefabInfo",
"fileId": "35J3m92mFAsLCZJtt+wVE3"
},
{
"__type__": "2291brx8LpIc5DogteLVdjM",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 25
},
"_enabled": true,
"__prefab": {
"__id__": 31
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "6eRV4oDuBB87jqJLNT3pkJ"
},
{
"__type__": "cc.PrefabInfo",
"root": {
@ -758,7 +800,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 30
"__id__": 34
},
"_contentSize": {
"__type__": "cc.Size",
@ -786,7 +828,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 32
"__id__": 36
},
"_customMaterial": null,
"_srcBlendFactor": 2,
@ -810,16 +852,16 @@
"_cacheMode": 0,
"_sockets": [
{
"__id__": 33
"__id__": 37
},
{
"__id__": 34
"__id__": 38
},
{
"__id__": 35
"__id__": 39
},
{
"__id__": 36
"__id__": 40
}
],
"_useTint": false,
@ -859,7 +901,7 @@
"__type__": "sp.Skeleton.SpineSocket",
"path": "root/card2/card2-flip",
"target": {
"__id__": 23
"__id__": 25
}
},
{
@ -872,7 +914,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 38
"__id__": 42
},
"ignoreTimeScale": true,
"_id": ""
@ -904,7 +946,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 41
"__id__": 45
},
"_contentSize": {
"__type__": "cc.Size",
@ -932,10 +974,10 @@
},
"_enabled": true,
"__prefab": {
"__id__": 43
"__id__": 47
},
"skeleton": {
"__id__": 31
"__id__": 35
},
"_flipX": false,
"_flipY": false,
@ -955,10 +997,10 @@
},
"_enabled": true,
"__prefab": {
"__id__": 45
"__id__": 49
},
"animationHandler": {
"__id__": 42
"__id__": 46
},
"spineRoot": {
"__id__": 2
@ -968,7 +1010,7 @@
"__id__": 20
},
{
"__id__": 26
"__id__": 28
}
],
"_id": ""

View File

@ -24,18 +24,18 @@
],
"_active": true,
"_components": [
{
"__id__": 40
},
{
"__id__": 42
},
{
"__id__": 44
},
{
"__id__": 46
}
],
"_prefab": {
"__id__": 46
"__id__": 48
},
"_lpos": {
"__type__": "cc.Vec3",
@ -84,18 +84,18 @@
],
"_active": true,
"_components": [
{
"__id__": 32
},
{
"__id__": 34
},
{
"__id__": 37
"__id__": 36
},
{
"__id__": 39
}
],
"_prefab": {
"__id__": 39
"__id__": 41
},
"_lpos": {
"__type__": "cc.Vec3",
@ -303,11 +303,11 @@
"_active": true,
"_components": [
{
"__id__": 29
"__id__": 31
}
],
"_prefab": {
"__id__": 31
"__id__": 33
},
"_lpos": {
"__type__": "cc.Vec3",
@ -351,20 +351,20 @@
"__id__": 12
},
{
"__id__": 18
"__id__": 20
}
],
"_active": true,
"_components": [
{
"__id__": 24
"__id__": 26
},
{
"__id__": 26
"__id__": 28
}
],
"_prefab": {
"__id__": 28
"__id__": 30
},
"_lpos": {
"__type__": "cc.Vec3",
@ -411,15 +411,18 @@
},
{
"__id__": 15
},
{
"__id__": 17
}
],
"_prefab": {
"__id__": 17
"__id__": 19
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": -50,
"y": -25,
"z": 0
},
"_lrot": {
@ -459,8 +462,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 200,
"height": 200
"width": 150,
"height": 150
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@ -495,10 +498,7 @@
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "e993110b-c53f-4d5c-bf69-b58cf61036b4@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_spriteFrame": null,
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
@ -518,6 +518,24 @@
"__type__": "cc.CompPrefabInfo",
"fileId": "ecbp9qmr5AsK8U3oG22/LR"
},
{
"__type__": "2291brx8LpIc5DogteLVdjM",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 12
},
"_enabled": true,
"__prefab": {
"__id__": 18
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "2fv6Ri0adHYqS4RF9PY2mq"
},
{
"__type__": "cc.PrefabInfo",
"root": {
@ -527,8 +545,6 @@
"__id__": 0
},
"fileId": "01q2I1EmNPXr4APxBvWUXg",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
@ -543,19 +559,19 @@
"_active": true,
"_components": [
{
"__id__": 19
"__id__": 21
},
{
"__id__": 21
"__id__": 23
}
],
"_prefab": {
"__id__": 23
"__id__": 25
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": -193.8,
"y": -143.8,
"z": 0
},
"_lrot": {
@ -587,11 +603,11 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 18
"__id__": 20
},
"_enabled": true,
"__prefab": {
"__id__": 20
"__id__": 22
},
"_contentSize": {
"__type__": "cc.Size",
@ -615,11 +631,11 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 18
"__id__": 20
},
"_enabled": true,
"__prefab": {
"__id__": 22
"__id__": 24
},
"_customMaterial": null,
"_srcBlendFactor": 2,
@ -703,7 +719,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 25
"__id__": 27
},
"_contentSize": {
"__type__": "cc.Size",
@ -731,7 +747,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 27
"__id__": 29
},
"_resizeMode": 0,
"_layoutType": 2,
@ -782,7 +798,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 30
"__id__": 32
},
"_contentSize": {
"__type__": "cc.Size",
@ -823,7 +839,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 33
"__id__": 35
},
"_contentSize": {
"__type__": "cc.Size",
@ -851,7 +867,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 35
"__id__": 37
},
"_customMaterial": null,
"_srcBlendFactor": 2,
@ -875,7 +891,7 @@
"_cacheMode": 0,
"_sockets": [
{
"__id__": 36
"__id__": 38
}
],
"_useTint": false,
@ -907,7 +923,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 38
"__id__": 40
},
"ignoreTimeScale": true,
"_id": ""
@ -939,7 +955,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 41
"__id__": 43
},
"_contentSize": {
"__type__": "cc.Size",
@ -967,10 +983,10 @@
},
"_enabled": true,
"__prefab": {
"__id__": 43
"__id__": 45
},
"skeleton": {
"__id__": 34
"__id__": 36
},
"_flipX": false,
"_flipY": false,
@ -990,10 +1006,10 @@
},
"_enabled": true,
"__prefab": {
"__id__": 45
"__id__": 47
},
"animationHandler": {
"__id__": 42
"__id__": 44
},
"spineRoot": {
"__id__": 2
@ -1005,7 +1021,7 @@
"__id__": 15
},
"rewardLabel": {
"__id__": 21
"__id__": 23
},
"_id": ""
},

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -338,16 +338,7 @@ AudioSource.prototype.getPlaybackRate = function () {
};
AudioSource.prototype.setPlaybackRate = function (value: number) {
if (this._player) {
try {
this._player._player._sourceNode.playbackRate.value = value;
} catch (e) {
console.log(e);
}
this._playbackRate = this._player.playbackRate;
} else {
this._playbackRate = value;
}
};
//#endregion

View File

@ -125,9 +125,9 @@ export default class AudioManager {
}
this._audioSourceBgm.loop = config.loop;
this._audioSourceBgm.volume = config.volume;
this._audioSourceBgm.playbackRate = config.playbackRate;
this._audioSourceBgm.mute = this._isMute;
this._audioSourceBgm.play();
this._audioSourceBgm.playbackRate = config.playbackRate;
}
public static setPlayRateBGM(rate: number) {

View File

@ -7,6 +7,7 @@ import {
easing,
Enum,
game,
Label,
lerp,
Node,
SpriteFrame,
@ -75,6 +76,8 @@ export default class GachaManager extends Singleton<GachaManager>() {
private container: UIOpacity;
@property(FloatingTextFactory)
private floatingScoreFactory: FloatingTextFactory;
@property(Label)
private countDownLabel: Label;
@property(Gacha)
private gachas: Gacha[] = [];
@property(RewardConfig)
@ -84,10 +87,13 @@ export default class GachaManager extends Singleton<GachaManager>() {
private _showing: boolean = false;
private _showTimer: number = 0;
private _idType: GachaType;
private _currentGacha: GachaBase;
protected onLoad(): void {
super.onLoad();
this.container.setNodeActive(false);
this.countDownLabel.setNodeActive(false);
this.gachas.forEach((gacha) => gacha.gacha.setNodeActive(false));
}
public async show(type: GachaType, delay: number = 0) {
@ -117,8 +123,9 @@ export default class GachaManager extends Singleton<GachaManager>() {
}
private showGacha() {
const gacha = this.gachas.find((gacha) => gacha.type == this._idType);
gacha.gacha.show();
this._currentGacha = this.gachas.find((gacha) => gacha.type == this._idType).gacha;
this._currentGacha.setNodeActive(true);
this._currentGacha.show();
}
public async getReward(): Promise<RewardConfig> {
@ -141,14 +148,23 @@ export default class GachaManager extends Singleton<GachaManager>() {
}
public async gachaDone() {
console.log(`Gacha reward: ${RewardType[this._reward.type]} quantity: ${this._reward.quantity}`);
await Utils.delay(1);
this._currentGacha.setNodeActive(false);
this.countDownLabel.setNodeActive(true);
console.log(`Gacha reward: ${RewardType[this._reward.type]} quantity: ${this._reward.quantity}`);
let count = 3;
while (count >= 0) {
this.countDownLabel.setString(count == 0 ? 'Ready' : count);
count--;
await Utils.delay(0.5);
}
game.timeScale = 1;
tween(this.container)
.to(0.1, { opacity: 0 })
.call(() => {
this.container.setNodeActive(false);
this.countDownLabel.setNodeActive(false);
switch (this._reward.type) {
case RewardType.Star:
GameManager.instance.addScore(this._reward.quantity, ScoreType.DestroyObject);

View File

@ -0,0 +1,60 @@
import { _decorator, Component, director, Director, math, Node, Size, Sprite, UITransform } from 'cc';
const { ccclass, property, requireComponent, executeInEditMode } = _decorator;
@ccclass('PreserveAspectRatioSprite')
@requireComponent(Sprite)
@executeInEditMode
export class PreserveAspectRatioSprite extends Component {
private _sprite: Sprite;
private _uiTransform: UITransform;
protected onLoad(): void {}
protected onEnable() {
this._sprite = this.getComponent(Sprite);
this._uiTransform = this.getComponent(UITransform);
this.addEventListeners();
this.resize();
}
protected onDisable() {
this.removeEventListeners();
}
protected addEventListeners() {
director.on(Director.EVENT_AFTER_UPDATE, this.resize, this);
this.node.off(Node.EventType.ANCHOR_CHANGED, this.resize, this);
this.node.off(Node.EventType.SIZE_CHANGED, this.resize, this);
}
protected removeEventListeners() {
director.off(Director.EVENT_AFTER_UPDATE, this.resize, this);
this.node.off(Node.EventType.SIZE_CHANGED, this.resize, this);
this.node.off(Node.EventType.ANCHOR_CHANGED, this.resize, this);
}
protected resize() {
if (!this._sprite.spriteFrame) {
return;
}
const spriteSize = this._sprite.spriteFrame.originalSize;
const rectSize = this._uiTransform.contentSize.clone();
const spriteRatio = spriteSize.x / spriteSize.y;
const rectRatio = rectSize.width / rectSize.height;
if (spriteRatio > rectRatio) {
const oldHeight = rectSize.height;
rectSize.height = rectSize.width * (1 / spriteRatio);
rectSize.y += (oldHeight - rectSize.height) * this._uiTransform.anchorY;
} else {
const oldWidth = rectSize.width;
rectSize.width = rectSize.height * spriteRatio;
rectSize.x += (oldWidth - rectSize.width) * this._uiTransform.anchorX;
}
this._uiTransform.contentSize = rectSize;
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "2291baf1-f0ba-4873-90e8-82d78b55d8cc",
"files": [],
"subMetas": {},
"userData": {}
}