update
This commit is contained in:
@@ -7,7 +7,8 @@ import { PrefabPathEnum, TexturePathEnum } from '../Enum';
|
||||
import NetworkManager from '../Global/NetworkManager';
|
||||
import ObjectPoolManager from '../Global/ObjectPoolManager';
|
||||
import { BulletManager } from '../Entity/Bullet/BulletManager';
|
||||
import { EntityTypeEnum, InputTypeEnum } from '../Common';
|
||||
import { ApiMsgEnum, EntityTypeEnum, IMsgServerSync, InputTypeEnum } from '../Common';
|
||||
import { toFixed } from '../Utils';
|
||||
|
||||
const { ccclass } = _decorator;
|
||||
|
||||
@@ -26,6 +27,7 @@ export class BattleManager extends Component {
|
||||
await this.loadRes()
|
||||
this.initScene()
|
||||
await this.connectServer()
|
||||
NetworkManager.Instance.listenMsg(ApiMsgEnum.MsgServerSync, this.handleSync);
|
||||
this.isInited = true
|
||||
}
|
||||
|
||||
@@ -84,6 +86,12 @@ export class BattleManager extends Component {
|
||||
map.setParent(this.stage)
|
||||
}
|
||||
|
||||
handleSync({ inputs }: IMsgServerSync) {
|
||||
for (const input of inputs) {
|
||||
DataManager.Instance.applyInput(input)
|
||||
}
|
||||
}
|
||||
|
||||
update(dt: number) {
|
||||
if (!this.isInited) {
|
||||
return
|
||||
@@ -108,9 +116,11 @@ export class BattleManager extends Component {
|
||||
}
|
||||
|
||||
tickGlobal(dt: number) {
|
||||
DataManager.Instance.applyInput({
|
||||
type: InputTypeEnum.TimePast,
|
||||
dt
|
||||
NetworkManager.Instance.sendMsg(ApiMsgEnum.MsgClientSync, {
|
||||
input: {
|
||||
type: InputTypeEnum.TimePast,
|
||||
dt: toFixed(dt),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user