update
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "5802fd2f-7823-4294-91c8-d71adca41319",
|
||||
"uuid": "b207a15b-0f84-4e83-93de-cb6186e22772",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
@@ -1,14 +1,16 @@
|
||||
import { _decorator, instantiate, ProgressBar, Label } from 'cc';
|
||||
import { EntityManager } from '../../Base/EntityManager';
|
||||
import { EntityTypeEnum, EntityStateEnum, InputType } from '../../Enum';
|
||||
import DataManager, { IPlayer, IVec2 } from '../../Global/DataManager';
|
||||
import { ApiMsgEnum, EntityTypeEnum, IActor, InputTypeEnum, IVec2 } from '../../Common';
|
||||
import { EntityStateEnum } from '../../Enum';
|
||||
import DataManager from '../../Global/DataManager';
|
||||
import NetworkManager from '../../Global/NetworkManager';
|
||||
import { rad2Angle } from '../../Utils';
|
||||
import { WeaponManager } from '../Weapon/WeaponManager';
|
||||
import { PlayerStateMachine } from './PlayerStateMachine';
|
||||
import { PlayerStateMachine } from './ActorStateMachine';
|
||||
const { ccclass } = _decorator;
|
||||
|
||||
@ccclass('PlayerManager')
|
||||
export class PlayerManager extends EntityManager {
|
||||
@ccclass('ActorManager')
|
||||
export class ActorManager extends EntityManager implements IActor {
|
||||
//静态数据
|
||||
id: number
|
||||
nickname: string
|
||||
@@ -29,7 +31,7 @@ export class PlayerManager extends EntityManager {
|
||||
return DataManager.Instance.myPlayerId === this.id
|
||||
}
|
||||
|
||||
init(data: IPlayer) {
|
||||
init(data: IActor) {
|
||||
const { id, nickname, type, weaponType, bulletType } = data
|
||||
this.id = id
|
||||
this.nickname = nickname
|
||||
@@ -58,8 +60,8 @@ export class PlayerManager extends EntityManager {
|
||||
}
|
||||
|
||||
const { x, y } = DataManager.Instance.jm.input
|
||||
DataManager.Instance.applyInput({
|
||||
type: InputType.PlayerMove,
|
||||
NetworkManager.Instance.sendMsg(ApiMsgEnum.MsgClientSync, {
|
||||
type: InputTypeEnum.ActorMove,
|
||||
id: this.id,
|
||||
direction: {
|
||||
x,
|
||||
@@ -69,21 +71,21 @@ export class PlayerManager extends EntityManager {
|
||||
})
|
||||
}
|
||||
|
||||
render(data: IPlayer) {
|
||||
render(data: IActor) {
|
||||
this.renderHP(data)
|
||||
this.renderPosition(data)
|
||||
this.renderDirection(data)
|
||||
}
|
||||
|
||||
renderHP(data: IPlayer) {
|
||||
renderHP(data: IActor) {
|
||||
this.hpBar.progress = data.hp / this.hpBar.totalLength
|
||||
}
|
||||
|
||||
renderPosition(data: IPlayer) {
|
||||
renderPosition(data: IActor) {
|
||||
this.node.setPosition(data.position.x, data.position.y)
|
||||
}
|
||||
|
||||
renderDirection(data: IPlayer) {
|
||||
renderDirection(data: IActor) {
|
||||
if (data.direction.x === 0 && data.direction.y === 0) {
|
||||
this.state = EntityStateEnum.Idle
|
||||
return
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "aaa694fa-4476-44b2-9213-4b4978a57d66",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -1,7 +1,8 @@
|
||||
import { _decorator, Animation, AnimationClip } from 'cc'
|
||||
import State from '../../Base/State'
|
||||
import StateMachine, { getInitParamsTrigger } from '../../Base/StateMachine'
|
||||
import { EntityTypeEnum, EntityStateEnum, ParamsNameEnum } from '../../Enum'
|
||||
import { EntityTypeEnum } from '../../Common'
|
||||
import { EntityStateEnum, ParamsNameEnum } from '../../Enum'
|
||||
const { ccclass } = _decorator
|
||||
|
||||
@ccclass('PlayerStateMachine')
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "67239e69-9cbb-42c8-ae8f-27f8bae24103",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -1,7 +1,8 @@
|
||||
import { _decorator } from 'cc'
|
||||
import { EntityManager } from '../../Base/EntityManager'
|
||||
import { EntityTypeEnum, EntityStateEnum, EventEnum } from '../../Enum'
|
||||
import DataManager, { IBullet, IVec2 } from '../../Global/DataManager'
|
||||
import { EntityTypeEnum, IBullet, IVec2 } from '../../Common'
|
||||
import { EntityStateEnum, EventEnum } from '../../Enum'
|
||||
import DataManager from '../../Global/DataManager'
|
||||
import EventManager from '../../Global/EventManager'
|
||||
import ObjectPoolManager from '../../Global/ObjectPoolManager'
|
||||
import { rad2Angle } from '../../Utils'
|
||||
@@ -10,7 +11,7 @@ import { BulletStateMachine } from './BulletStateMachine'
|
||||
const { ccclass } = _decorator
|
||||
|
||||
@ccclass('BulletManager')
|
||||
export class BulletManager extends EntityManager {
|
||||
export class BulletManager extends EntityManager implements IBullet {
|
||||
//静态数据
|
||||
id: number
|
||||
owner: number
|
||||
|
@@ -1,7 +1,8 @@
|
||||
import { _decorator, Animation } from 'cc'
|
||||
import State from '../../Base/State'
|
||||
import StateMachine, { getInitParamsTrigger } from '../../Base/StateMachine'
|
||||
import { EntityTypeEnum, EntityStateEnum, ParamsNameEnum } from '../../Enum'
|
||||
import { EntityTypeEnum } from '../../Common'
|
||||
import { EntityStateEnum, ParamsNameEnum } from '../../Enum'
|
||||
const { ccclass } = _decorator
|
||||
|
||||
@ccclass('BulletStateMachine')
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { _decorator } from 'cc'
|
||||
import { EntityManager } from '../../Base/EntityManager'
|
||||
import { EntityTypeEnum, EntityStateEnum } from '../../Enum'
|
||||
import { IVec2 } from '../../Global/DataManager'
|
||||
import { EntityTypeEnum, IVec2 } from '../../Common'
|
||||
import { EntityStateEnum } from '../../Enum'
|
||||
import { ExplosionStateMachine } from './ExplosionStateMachine'
|
||||
const { ccclass, property } = _decorator
|
||||
|
||||
|
@@ -1,7 +1,8 @@
|
||||
import { _decorator, Animation } from 'cc'
|
||||
import State from '../../Base/State'
|
||||
import StateMachine, { getInitParamsTrigger } from '../../Base/StateMachine'
|
||||
import { EntityTypeEnum, EntityStateEnum, ParamsNameEnum } from '../../Enum'
|
||||
import { EntityTypeEnum } from '../../Common'
|
||||
import { EntityStateEnum, ParamsNameEnum } from '../../Enum'
|
||||
import ObjectPoolManager from '../../Global/ObjectPoolManager'
|
||||
const { ccclass, property } = _decorator
|
||||
|
||||
|
@@ -1,8 +1,10 @@
|
||||
import { _decorator, Node, Vec2, UITransform } from 'cc'
|
||||
import { EntityManager } from '../../Base/EntityManager'
|
||||
import { EntityTypeEnum, EntityStateEnum, EventEnum, InputType } from '../../Enum'
|
||||
import DataManager, { IPlayer } from '../../Global/DataManager'
|
||||
import { ApiMsgEnum, EntityTypeEnum, InputTypeEnum } from '../../Common'
|
||||
import { EntityStateEnum, EventEnum } from '../../Enum'
|
||||
import DataManager from '../../Global/DataManager'
|
||||
import EventManager from '../../Global/EventManager'
|
||||
import NetworkManager from '../../Global/NetworkManager'
|
||||
import { WeaponStateMachine } from './WeaponStateMachine'
|
||||
const { ccclass } = _decorator
|
||||
|
||||
@@ -19,7 +21,7 @@ export class WeaponManager extends EntityManager {
|
||||
return DataManager.Instance.myPlayerId === this.owner
|
||||
}
|
||||
|
||||
init({ id, weaponType }: IPlayer) {
|
||||
init({ id, weaponType }: { id: number, weaponType: EntityTypeEnum }) {
|
||||
this.owner = id
|
||||
this.type = weaponType
|
||||
|
||||
@@ -58,8 +60,8 @@ export class WeaponManager extends EntityManager {
|
||||
const anchorWorldPos = this.anchor.getWorldPosition()
|
||||
const directionVec2 = new Vec2(pointWorldPos.x - anchorWorldPos.x, pointWorldPos.y - anchorWorldPos.y).normalize()
|
||||
|
||||
DataManager.Instance.applyInput({
|
||||
type: InputType.WeaponShoot,
|
||||
NetworkManager.Instance.sendMsg(ApiMsgEnum.MsgClientSync, {
|
||||
type: InputTypeEnum.WeaponShoot,
|
||||
owner: this.owner,
|
||||
position: {
|
||||
x: pointStagePos.x,
|
||||
|
@@ -1,7 +1,8 @@
|
||||
import { _decorator, Animation, AnimationClip } from 'cc'
|
||||
import State from '../../Base/State'
|
||||
import StateMachine, { getInitParamsTrigger } from '../../Base/StateMachine'
|
||||
import { EntityStateEnum, EntityTypeEnum, ParamsNameEnum } from '../../Enum'
|
||||
import { EntityTypeEnum } from '../../Common'
|
||||
import { EntityStateEnum, ParamsNameEnum } from '../../Enum'
|
||||
import { WeaponManager } from './WeaponManager'
|
||||
const { ccclass } = _decorator
|
||||
|
||||
|
Reference in New Issue
Block a user