binary encode
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { _decorator, instantiate, ProgressBar, Label } from 'cc';
|
||||
import { EntityManager } from '../../Base/EntityManager';
|
||||
import { ApiMsgEnum, EntityTypeEnum, IActor, InputTypeEnum, IVec2 } from '../../Common';
|
||||
import { ApiMsgEnum, EntityTypeEnum, IActor, InputTypeEnum, IVec2, toFixed } from '../../Common';
|
||||
import { EntityStateEnum } from '../../Enum';
|
||||
import DataManager from '../../Global/DataManager';
|
||||
import NetworkManager from '../../Global/NetworkManager';
|
||||
import { rad2Angle, toFixed } from '../../Utils';
|
||||
import { rad2Angle } from '../../Utils';
|
||||
import { WeaponManager } from '../Weapon/WeaponManager';
|
||||
import { PlayerStateMachine } from './ActorStateMachine';
|
||||
const { ccclass } = _decorator;
|
||||
@@ -59,9 +59,9 @@ export class ActorManager extends EntityManager implements IActor {
|
||||
return
|
||||
}
|
||||
|
||||
const { x, y } = DataManager.Instance.jm.input
|
||||
NetworkManager.Instance.sendMsg(ApiMsgEnum.MsgClientSync, {
|
||||
input: {
|
||||
if (DataManager.Instance.jm.input.length()) {
|
||||
const { x, y } = DataManager.Instance.jm.input
|
||||
NetworkManager.Instance.sendMsg(ApiMsgEnum.MsgClientSync, {
|
||||
type: InputTypeEnum.ActorMove,
|
||||
id: this.id,
|
||||
direction: {
|
||||
@@ -69,8 +69,9 @@ export class ActorManager extends EntityManager implements IActor {
|
||||
y: toFixed(y),
|
||||
},
|
||||
dt: toFixed(dt)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
render(data: IActor) {
|
||||
|
@@ -1,11 +1,10 @@
|
||||
import { _decorator, Node, Vec2, UITransform } from 'cc'
|
||||
import { EntityManager } from '../../Base/EntityManager'
|
||||
import { ApiMsgEnum, EntityTypeEnum, InputTypeEnum } from '../../Common'
|
||||
import { ApiMsgEnum, EntityTypeEnum, InputTypeEnum, toFixed } from '../../Common'
|
||||
import { EntityStateEnum, EventEnum } from '../../Enum'
|
||||
import DataManager from '../../Global/DataManager'
|
||||
import EventManager from '../../Global/EventManager'
|
||||
import NetworkManager from '../../Global/NetworkManager'
|
||||
import { toFixed } from '../../Utils'
|
||||
import { WeaponStateMachine } from './WeaponStateMachine'
|
||||
const { ccclass } = _decorator
|
||||
|
||||
@@ -62,18 +61,16 @@ export class WeaponManager extends EntityManager {
|
||||
const directionVec2 = new Vec2(pointWorldPos.x - anchorWorldPos.x, pointWorldPos.y - anchorWorldPos.y).normalize()
|
||||
|
||||
NetworkManager.Instance.sendMsg(ApiMsgEnum.MsgClientSync, {
|
||||
input: {
|
||||
type: InputTypeEnum.WeaponShoot,
|
||||
owner: this.owner,
|
||||
position: {
|
||||
x: toFixed(pointStagePos.x),
|
||||
y: toFixed(pointStagePos.y),
|
||||
},
|
||||
direction: {
|
||||
x: toFixed(directionVec2.x),
|
||||
y: toFixed(directionVec2.y),
|
||||
},
|
||||
}
|
||||
type: InputTypeEnum.WeaponShoot,
|
||||
owner: this.owner,
|
||||
position: {
|
||||
x: toFixed(pointStagePos.x),
|
||||
y: toFixed(pointStagePos.y),
|
||||
},
|
||||
direction: {
|
||||
x: toFixed(directionVec2.x),
|
||||
y: toFixed(directionVec2.y),
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user