新增CameraController,现在项目可以正常运作了。
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { _decorator, EditBox, Button } from 'cc';
|
||||
import { UIBase } from '../../Framework/UI/UIBase';
|
||||
import { _decorator, Button, EditBox } from 'cc';
|
||||
import { NetManager } from '../../Framework/Net/NetManager';
|
||||
import { ReqLogin, ResLogin } from '../../Framework/Net/LoginProtocol';
|
||||
import { UIBase } from '../../Framework/UI/UIBase';
|
||||
import { AppStatusManager } from '../AppStatus/AppStatusManager';
|
||||
import { LoginMessagePair } from '../Msg/Pair/LoginMessagePair';
|
||||
|
||||
const { ccclass } = _decorator;
|
||||
|
||||
@@ -19,34 +19,34 @@ const { ccclass } = _decorator;
|
||||
export class UILogin extends UIBase {
|
||||
/** 账号输入框 */
|
||||
private _inputAccount: EditBox | null = null;
|
||||
|
||||
|
||||
/** 登录按钮 */
|
||||
private _btnLogin: Button | null = null;
|
||||
|
||||
|
||||
/** 是否正在登录中 */
|
||||
private _isLogging: boolean = false;
|
||||
|
||||
|
||||
/**
|
||||
* 获取UI资源路径
|
||||
*/
|
||||
onGetUrl(): string {
|
||||
return 'res://UI/Login/UILogin';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* UI初始化
|
||||
*/
|
||||
async onStart(params?: any): Promise<void> {
|
||||
console.log('[UILogin] 登录界面初始化', params);
|
||||
|
||||
|
||||
// 使用GetChild查找子节点
|
||||
this._inputAccount = this.GetChild('mid/input_account', EditBox);
|
||||
this._btnLogin = this.GetChild('mid/btn_login', Button);
|
||||
|
||||
|
||||
// 使用SetClick绑定点击事件
|
||||
this.SetClick(this._btnLogin, this.onLoginClick, this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 登录按钮点击
|
||||
*/
|
||||
@@ -55,21 +55,21 @@ export class UILogin extends UIBase {
|
||||
console.log('[UILogin] 正在登录中,请稍候...');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 获取账号
|
||||
const account = this._inputAccount?.string?.trim() || '';
|
||||
|
||||
|
||||
if (!account) {
|
||||
console.warn('[UILogin] 请输入账号');
|
||||
// TODO: 显示提示UI
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
console.log(`[UILogin] 开始登录,账号: ${account}`);
|
||||
|
||||
|
||||
// 开始登录
|
||||
this._isLogging = true;
|
||||
|
||||
|
||||
try {
|
||||
await this.login(account);
|
||||
} catch (error) {
|
||||
@@ -79,29 +79,29 @@ export class UILogin extends UIBase {
|
||||
this._isLogging = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 执行登录
|
||||
* @param account 账号
|
||||
*/
|
||||
private async login(account: string): Promise<void> {
|
||||
const netManager = NetManager.getInstance();
|
||||
|
||||
|
||||
// 使用类型化的登录协议
|
||||
const result = await netManager.callApi<ReqLogin, ResLogin>('Login', {
|
||||
account: account
|
||||
});
|
||||
|
||||
const result = await netManager.callMsg(new LoginMessagePair(), {
|
||||
playerId: account
|
||||
},);
|
||||
|
||||
if (result && result.success) {
|
||||
console.log('[UILogin] 登录成功:', result);
|
||||
|
||||
|
||||
// 登录成功,切换到游戏状态
|
||||
const appStatusManager = AppStatusManager.getInstance();
|
||||
appStatusManager.changeState('Game', {
|
||||
player: result.player,
|
||||
isNewPlayer: result.isNewPlayer || false
|
||||
});
|
||||
|
||||
|
||||
// 隐藏登录界面
|
||||
this.hide();
|
||||
} else {
|
||||
@@ -109,7 +109,7 @@ export class UILogin extends UIBase {
|
||||
// TODO: 显示错误提示UI
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* UI清理
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user