新增CameraController,现在项目可以正常运作了。
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { _decorator, Component, Node, EventKeyboard, KeyCode, Input, input, Vec3 } from 'cc';
|
||||
import { NetManager } from '../../Framework/Net/NetManager';
|
||||
import { ReqMove, ResMove } from '../../Shared/protocols/PtlMove';
|
||||
import { PlayerInfo } from '../../Shared/protocols/PtlLogin';
|
||||
import { _decorator, Component, EventKeyboard, Input, input, KeyCode, Vec3 } from 'cc';
|
||||
import { RoleController } from '../../CC/RoleController';
|
||||
import { NetManager } from '../../Framework/Net/NetManager';
|
||||
import { PlayerInfo } from '../../Shared/protocols/MsgResLogin';
|
||||
import { MoveMessagePair } from '../Msg/Pair/MoveMessagePair';
|
||||
|
||||
const { ccclass } = _decorator;
|
||||
|
||||
@@ -134,7 +134,7 @@ export class PlayerController extends Component {
|
||||
private move(dt: number): void {
|
||||
// 计算移动增量
|
||||
const moveOffset = this.moveDirection.clone().multiplyScalar(this.moveSpeed * dt);
|
||||
|
||||
|
||||
// 更新节点位置
|
||||
const currentPos = this.node.position.clone();
|
||||
currentPos.add(moveOffset);
|
||||
@@ -163,7 +163,7 @@ export class PlayerController extends Component {
|
||||
*/
|
||||
private checkSendMoveRequest(currentPos: Vec3): void {
|
||||
const distance = Vec3.distance(currentPos, this.lastSentPosition);
|
||||
|
||||
|
||||
// 如果移动距离超过阈值,发送移动请求
|
||||
if (distance >= this.moveSendThreshold) {
|
||||
this.sendMoveRequest(currentPos.x, currentPos.z);
|
||||
@@ -177,9 +177,9 @@ export class PlayerController extends Component {
|
||||
private async sendMoveRequest(x: number, z: number): Promise<void> {
|
||||
try {
|
||||
const netManager = NetManager.getInstance();
|
||||
const result = await netManager.callApi<ReqMove, ResMove>('Move', {
|
||||
x: x,
|
||||
y: z
|
||||
const result = await netManager.callMsg(new MoveMessagePair(), {
|
||||
x: Math.round(x * 1000),
|
||||
y: Math.round(z * 1000)
|
||||
});
|
||||
|
||||
if (!result) {
|
||||
|
||||
Reference in New Issue
Block a user