refactor: 移除多余的新手引导2、3、4相关代码和资源
1. 删除Guide2、Guide3、Guide4的UIID配置和对应弹窗资源 2. 移除MissionCardComp中关闭guide3、guide4的逻辑代码 3. 移除GuideComp中对应guide2、3、4的UIID判断逻辑 4. 简化云函数代码中冗余的get请求分支 5. 调整按钮抖动动画的时长参数优化视觉效果 6. 新增微信云开发客户端API封装代码
This commit is contained in:
9
assets/Scripts.meta
Normal file
9
assets/Scripts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "3e36fd17-8df9-4f4f-8904-61ad60e7a3e9",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
9
assets/Scripts/wx_clound_client_api.meta
Normal file
9
assets/Scripts/wx_clound_client_api.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "91afed13-a3a6-4666-8f0a-c3259c5f6fa5",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
84
assets/Scripts/wx_clound_client_api/WxCloudApi.ts
Normal file
84
assets/Scripts/wx_clound_client_api/WxCloudApi.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
export type CloudReturnType<T = any> = {
|
||||
code: number,// 200成功
|
||||
msg?:string,
|
||||
data?:T
|
||||
}
|
||||
|
||||
export class WxCloudApi{
|
||||
/**
|
||||
* @en init the cloud
|
||||
* @zh 初始化云客户端(只调用一次即可)
|
||||
* @param {string} env 云环境名称
|
||||
*/
|
||||
public static init(env:string){
|
||||
wx?.cloud.init({
|
||||
env: env
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @en Login to the cloud
|
||||
* @zh 登录云
|
||||
* @return 返回结果
|
||||
* 参考:
|
||||
* result.result = {
|
||||
* code: number, // 200成功,其他都是失败
|
||||
* msg: string, // 如果失败,这里是失败原因等信息
|
||||
* data: { // 成功才有
|
||||
* openid: string, // 用户微信平台openid
|
||||
* regist_time: number, // 时间戳,用户注册时间
|
||||
* game_data: object, // 开发者自己保存的数据
|
||||
* }
|
||||
* }
|
||||
* 如果这个泛型令你报错(一般是因为你删了wx.api.d.ts导致),请使用以下签名:
|
||||
* login():Promise<{result: CloudReturnType<{openid: string, regist_time: number, game_data: object}>}>
|
||||
* 或者你是个“不拘小节”的老哥,可以用以下简洁版签名(参考上方的数据结构例子使用即可)
|
||||
* login():Promise<any>
|
||||
*/
|
||||
public static async login(): Promise<CloudCallFunctionResult<CloudReturnType<{
|
||||
openid:string,
|
||||
regist_time:number,
|
||||
game_data:any
|
||||
}>>>{
|
||||
return await wx?.cloud.callFunction({
|
||||
name: 'cocos_cloud',
|
||||
data: {
|
||||
cmd: "login"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @en Save game data to the cloud
|
||||
* @zh 把客户端数据写入云,此为全覆盖写入,请自行管理完整数据
|
||||
* @return 返回结果
|
||||
* 参考:
|
||||
* result.result = {
|
||||
* code: number, // 200成功,其他都是失败
|
||||
* msg: string, // 如果失败,这里是失败原因等信息
|
||||
* data: {
|
||||
* errMsg: "document.update:ok", // 数据库返回结果
|
||||
* stats: {
|
||||
* updated: number, // 更新了几条数据(正常是1)
|
||||
* }
|
||||
* }
|
||||
* 如果这个泛型令你报错(一般是因为你删了wx.api.d.ts导致),请使用以下签名:
|
||||
* save(gameData: any): Promise<{resoult:CloudReturnType}>
|
||||
* 或者你是个“不拘小节”的老哥,可以用以下简洁版签名(参考上方的数据结构例子使用即可)
|
||||
* login():Promise<any>
|
||||
*/
|
||||
public static async save(gameData: any): Promise<CloudCallFunctionResult<CloudReturnType<{
|
||||
errMsg: string,
|
||||
status:{
|
||||
updated: number
|
||||
}
|
||||
}>>> {
|
||||
return await wx?.cloud.callFunction({
|
||||
name: 'cocos_cloud',
|
||||
data: {
|
||||
cmd: 'save',
|
||||
data: gameData
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
9
assets/Scripts/wx_clound_client_api/WxCloudApi.ts.meta
Normal file
9
assets/Scripts/wx_clound_client_api/WxCloudApi.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "6cae54d1-19a6-458d-ba26-92e6ada39b58",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
29
assets/Scripts/wx_clound_client_api/wx.aip.d.ts
vendored
Normal file
29
assets/Scripts/wx_clound_client_api/wx.aip.d.ts
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
// 注意:此文件是为了引入微信接口
|
||||
// !!如果这个文件,与你的wx.d.ts因为定义重复报错,你可以删除本文件!!
|
||||
|
||||
// @ts-ignore
|
||||
declare class wx {
|
||||
public static cloud: Cloud;
|
||||
}
|
||||
// @ts-ignore
|
||||
declare class Cloud {
|
||||
public init(options: {
|
||||
env?: string | {
|
||||
database?: string
|
||||
storage?: string
|
||||
functions?: string
|
||||
},
|
||||
traceUser?: boolean//default true
|
||||
});
|
||||
public callFunction(obj: {
|
||||
name: string,
|
||||
data?: any,
|
||||
config?: { env: string },
|
||||
}): Promise<CloudCallFunctionResult>;
|
||||
}
|
||||
// @ts-ignore
|
||||
declare type CloudCallFunctionResult<T = any> = {
|
||||
result: T,
|
||||
errMsg: string,
|
||||
requestID: string
|
||||
}
|
||||
9
assets/Scripts/wx_clound_client_api/wx.aip.d.ts.meta
Normal file
9
assets/Scripts/wx_clound_client_api/wx.aip.d.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "c0e94674-fd35-4f37-a57c-694b85dddbd0",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"ver": "1.1.50",
|
||||
"importer": "prefab",
|
||||
"imported": true,
|
||||
"uuid": "26b4ba5a-c5e4-405a-8ce9-27be21f86171",
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"syncNodeName": "guide2"
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"ver": "1.1.50",
|
||||
"importer": "prefab",
|
||||
"imported": true,
|
||||
"uuid": "9864952d-1b4a-4fb8-9e10-05ae52a1befb",
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"syncNodeName": "guide3"
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"ver": "1.1.50",
|
||||
"importer": "prefab",
|
||||
"imported": true,
|
||||
"uuid": "d2dcd02d-b49b-45ea-8e20-1cc474837da9",
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"syncNodeName": "guide4"
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,6 @@ export class SingletonModuleComp extends ecs.Comp {
|
||||
heroGrid: [-1, -1, -1, -1, -1, -1],
|
||||
monGrid: [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
|
||||
};
|
||||
finish_guides: number[] = [0]
|
||||
data: any = {
|
||||
score: 0,
|
||||
mission: 1,
|
||||
@@ -58,11 +57,10 @@ export class SingletonModuleComp extends ecs.Comp {
|
||||
noStop: false,
|
||||
showInfo: true,
|
||||
}
|
||||
|
||||
|
||||
guides: any = [0, 0, 0, 0, 0]
|
||||
current_guide: number = 0
|
||||
|
||||
finish_guides: number[] = [0]
|
||||
|
||||
vmdata: any = {
|
||||
game_over: false,
|
||||
game_pause: false,
|
||||
|
||||
@@ -27,9 +27,6 @@ export enum UIID {
|
||||
/** 技能卡牌系统核心控制器 */
|
||||
SkillBox,
|
||||
Guide1,
|
||||
Guide2,
|
||||
Guide3,
|
||||
Guide4,
|
||||
}
|
||||
|
||||
/** 打开界面方式的配置数据 */
|
||||
@@ -48,7 +45,5 @@ export var UIConfigData: { [key: number]: UIConfig } = {
|
||||
[UIID.HInfo]: { layer: LayerType.UI, prefab: "gui/element/hnode" },
|
||||
[UIID.SkillBox]: { layer: LayerType.UI, prefab: "gui/element/skillbox" },
|
||||
[UIID.Guide1]: { layer: LayerType.PopUp, prefab: "gui/element/guide1" },
|
||||
[UIID.Guide2]: { layer: LayerType.PopUp, prefab: "gui/element/guide2" },
|
||||
[UIID.Guide3]: { layer: LayerType.PopUp, prefab: "gui/element/guide3" },
|
||||
[UIID.Guide4]: { layer: LayerType.PopUp, prefab: "gui/element/guide4" },
|
||||
|
||||
}
|
||||
@@ -46,9 +46,6 @@ export class GuideComp extends Component {
|
||||
// 所以应当通过 oops.gui.remove 彻底从框架的层级管理中移除当前界面。
|
||||
let targetUIID = -1;
|
||||
if (this.guide_id === 1) targetUIID = UIID.Guide1;
|
||||
if (this.guide_id === 2) targetUIID = UIID.Guide2;
|
||||
if (this.guide_id === 3) targetUIID = UIID.Guide3;
|
||||
if (this.guide_id === 4) targetUIID = UIID.Guide4;
|
||||
|
||||
if (targetUIID !== -1) {
|
||||
oops.gui.remove(targetUIID);
|
||||
|
||||
@@ -488,11 +488,6 @@ export class MissionCardComp extends CCComp {
|
||||
private onFightStart() {
|
||||
this.enterBattlePhase();
|
||||
|
||||
// 第一次进入战斗阶段,关闭guide4
|
||||
if (!smc.finish_guides.includes(4)) {
|
||||
smc.finish_guides.push(4);
|
||||
oops.gui.remove(UIID.Guide4);
|
||||
}
|
||||
|
||||
// 首次进入战斗阶段:启动按钮逐个指引(仅提醒 1 次)
|
||||
if (!smc.finish_guides.includes(MissionCardComp.BUTTON_GUIDE_ID)) {
|
||||
@@ -749,12 +744,7 @@ export class MissionCardComp extends CCComp {
|
||||
this.updatePanelButtonsInteractable();
|
||||
}
|
||||
|
||||
// 第一次召唤英雄后,关闭guide3
|
||||
// 注:首个英雄召唤后战斗自动开始(见 MissionComp),不再需要 Guide4 引导点击开始按钮
|
||||
if (!smc.finish_guides.includes(3)) {
|
||||
smc.finish_guides.push(3);
|
||||
oops.gui.remove(UIID.Guide3);
|
||||
}
|
||||
|
||||
|
||||
// 英雄登场后同步英雄信息盒
|
||||
this.refreshHeroBoxSlots();
|
||||
@@ -1019,11 +1009,12 @@ export class MissionCardComp extends CCComp {
|
||||
if (!child || !child.isValid) continue;
|
||||
Tween.stopAllByTarget(child);
|
||||
child.angle = 0;
|
||||
// 单轮抖动约 0.94s(含间歇),节奏放慢避免高频晃动过刺眼
|
||||
let t = tween(child)
|
||||
.to(0.07, { angle: angle })
|
||||
.to(0.14, { angle: -angle })
|
||||
.to(0.07, { angle: 0 })
|
||||
.delay(0.12);
|
||||
.to(0.15, { angle: angle })
|
||||
.to(0.3, { angle: -angle })
|
||||
.to(0.15, { angle: 0 })
|
||||
.delay(0.34);
|
||||
if (repeat) {
|
||||
t = t.repeatForever();
|
||||
}
|
||||
|
||||
@@ -48,13 +48,8 @@ exports.main = async (event, context) => {
|
||||
msg: `Save fail, ${JSON.stringify(saveDataRes)}`
|
||||
};
|
||||
}
|
||||
}else if (event?.cmd === "get") {
|
||||
let user = await getOrCreaterUser(db, wxContext.OPENID);
|
||||
return {
|
||||
code: 200,
|
||||
data: user,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
code: -2,
|
||||
msg: `Unknow cmd: ${event?.cmd}`,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user