refactor
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { _decorator, instantiate, ProgressBar, Label, Vec3, Tween, tween } from 'cc';
|
||||
import { _decorator, instantiate, ProgressBar, Label, Vec3, Tween, tween, director } from 'cc';
|
||||
import { EntityManager } from '../../Base/EntityManager';
|
||||
import { ApiMsgEnum, EntityTypeEnum, IActor, InputTypeEnum, IVec2, toFixed } from '../../Common';
|
||||
import { EntityStateEnum } from '../../Enum';
|
||||
import { EntityStateEnum, EventEnum, SceneEnum } from '../../Enum';
|
||||
import DataManager from '../../Global/DataManager';
|
||||
import EventManager from '../../Global/EventManager';
|
||||
import NetworkManager from '../../Global/NetworkManager';
|
||||
import { rad2Angle } from '../../Utils';
|
||||
import { WeaponManager } from '../Weapon/WeaponManager';
|
||||
@@ -30,6 +31,8 @@ export class ActorManager extends EntityManager implements IActor {
|
||||
private tw: Tween<any>
|
||||
private targetPos: Vec3
|
||||
|
||||
private isDead = false
|
||||
|
||||
get isSelf() {
|
||||
return DataManager.Instance.myPlayerId === this.id
|
||||
}
|
||||
@@ -60,11 +63,17 @@ export class ActorManager extends EntityManager implements IActor {
|
||||
this.node.active = false
|
||||
}
|
||||
|
||||
tick(dt: number) {
|
||||
async tick(dt: number) {
|
||||
if (!this.isSelf) {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.hp <= 0 && !this.isDead) {
|
||||
EventManager.Instance.emit(EventEnum.GameEnd)
|
||||
this.isDead = true
|
||||
return
|
||||
}
|
||||
|
||||
if (DataManager.Instance.jm.input.length()) {
|
||||
const { x, y } = DataManager.Instance.jm.input
|
||||
NetworkManager.Instance.sendMsg(ApiMsgEnum.MsgClientSync, {
|
||||
@@ -87,6 +96,7 @@ export class ActorManager extends EntityManager implements IActor {
|
||||
}
|
||||
|
||||
renderHP(data: IActor) {
|
||||
this.hp = data.hp
|
||||
this.hpBar.progress = data.hp / this.hpBar.totalLength
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user