update
This commit is contained in:
		| @@ -1,5 +1 @@ | |||||||
| # 实时对战 | # Cocos Creator、Node.js、实时对战、IO、帧同步 | ||||||
| # IO |  | ||||||
| # 帧同步 |  | ||||||
| # Cocos Creator |  | ||||||
| # Node.js |  | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ | |||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|     "__type__": "cc.Scene", |     "__type__": "cc.Scene", | ||||||
|     "_name": "Batle", |     "_name": "Battle", | ||||||
|     "_objFlags": 0, |     "_objFlags": 0, | ||||||
|     "_parent": null, |     "_parent": null, | ||||||
|     "_children": [ |     "_children": [ | ||||||
							
								
								
									
										2157
									
								
								apps/client/assets/Scenes/Hall.scene
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2157
									
								
								apps/client/assets/Scenes/Hall.scene
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										11
									
								
								apps/client/assets/Scenes/Hall.scene.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								apps/client/assets/Scenes/Hall.scene.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | { | ||||||
|  |   "ver": "1.1.39", | ||||||
|  |   "importer": "scene", | ||||||
|  |   "imported": true, | ||||||
|  |   "uuid": "43b185e1-294e-4f6e-a660-e27f4cc5e45c", | ||||||
|  |   "files": [ | ||||||
|  |     ".json" | ||||||
|  |   ], | ||||||
|  |   "subMetas": {}, | ||||||
|  |   "userData": {} | ||||||
|  | } | ||||||
							
								
								
									
										1254
									
								
								apps/client/assets/Scenes/Login.scene
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1254
									
								
								apps/client/assets/Scenes/Login.scene
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										11
									
								
								apps/client/assets/Scenes/Login.scene.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								apps/client/assets/Scenes/Login.scene.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | { | ||||||
|  |   "ver": "1.1.39", | ||||||
|  |   "importer": "scene", | ||||||
|  |   "imported": true, | ||||||
|  |   "uuid": "6088b18f-3a16-4317-92e4-e7c904905e21", | ||||||
|  |   "files": [ | ||||||
|  |     ".json" | ||||||
|  |   ], | ||||||
|  |   "subMetas": {}, | ||||||
|  |   "userData": {} | ||||||
|  | } | ||||||
							
								
								
									
										1842
									
								
								apps/client/assets/Scenes/Room.scene
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1842
									
								
								apps/client/assets/Scenes/Room.scene
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										11
									
								
								apps/client/assets/Scenes/Room.scene.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								apps/client/assets/Scenes/Room.scene.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | { | ||||||
|  |   "ver": "1.1.39", | ||||||
|  |   "importer": "scene", | ||||||
|  |   "imported": true, | ||||||
|  |   "uuid": "af1ea920-28ec-466e-9318-0fc537171240", | ||||||
|  |   "files": [ | ||||||
|  |     ".json" | ||||||
|  |   ], | ||||||
|  |   "subMetas": {}, | ||||||
|  |   "userData": {} | ||||||
|  | } | ||||||
| @@ -1,5 +1,5 @@ | |||||||
| import { _decorator, Component, Node, Layers, UITransform, Sprite, KeyCode, Vec2, RigidBody2D, BoxCollider2D, Size, ERigidBody2DType } from 'cc'; | import { _decorator, Component } from 'cc'; | ||||||
| import { EntityEnum, EntityStateEnum } from '../Enum'; | import { EntityStateEnum } from '../Enum'; | ||||||
| import StateMachine from './StateMachine'; | import StateMachine from './StateMachine'; | ||||||
| const { ccclass, property } = _decorator; | const { ccclass, property } = _decorator; | ||||||
| 
 | 
 | ||||||
| @@ -1,7 +1,3 @@ | |||||||
| /*** |  | ||||||
|  * 泛型单例模式接口 |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| export default class Singleton { | export default class Singleton { | ||||||
|   private static _instance: any = null |   private static _instance: any = null | ||||||
| 
 | 
 | ||||||
| @@ -1,5 +1,5 @@ | |||||||
| import { _decorator, Animation, Component, SpriteFrame } from 'cc' | import { _decorator, Animation, Component } from 'cc' | ||||||
| import { FsmParamTypeEnum } from '../Enum' | import { EntityTypeEnum, FsmParamTypeEnum } from '../Enum' | ||||||
| const { ccclass } = _decorator | const { ccclass } = _decorator | ||||||
| import State from './State' | import State from './State' | ||||||
| import SubStateMachine from './SubStateMachine' | import SubStateMachine from './SubStateMachine' | ||||||
| @@ -44,6 +44,7 @@ export default abstract class StateMachine extends Component { | |||||||
|   params: Map<string, IParamsValue> = new Map() |   params: Map<string, IParamsValue> = new Map() | ||||||
|   stateMachines: Map<string, SubStateMachine | State> = new Map() |   stateMachines: Map<string, SubStateMachine | State> = new Map() | ||||||
|   animationComponent: Animation |   animationComponent: Animation | ||||||
|  |   type: EntityTypeEnum | ||||||
| 
 | 
 | ||||||
|   getParams(paramName: string) { |   getParams(paramName: string) { | ||||||
|     if (this.params.has(paramName)) { |     if (this.params.has(paramName)) { | ||||||
| @@ -1,20 +1,20 @@ | |||||||
| import { _decorator, Animation, AnimationClip, Node, Sprite, Vec3, Vec2, RigidBody2D, instantiate } from 'cc' | import { _decorator } from 'cc' | ||||||
| import { EntityManager } from '../../Base/EntityManager' | import { EntityManager } from '../../Base/EntityManager' | ||||||
| import { EntityTypeEnum, EntityStateEnum, EventEnum, PrefabPathEnum } from '../../Enum' | import { EntityTypeEnum, EntityStateEnum, EventEnum } from '../../Enum' | ||||||
| import DataManager, { IBullet, IVec2 } from '../../Global/DataManager' | import DataManager, { IBullet, IVec2 } from '../../Global/DataManager' | ||||||
| import EventManager from '../../Global/EventManager' | import EventManager from '../../Global/EventManager' | ||||||
| import ObjectPoolManager from '../../Global/ObjectPoolManager' | import ObjectPoolManager from '../../Global/ObjectPoolManager' | ||||||
| import { rad2Angle } from '../../Utils' | import { rad2Angle } from '../../Utils' | ||||||
| import { ExplosionManager } from '../Explosion/ExplosionManager' | import { ExplosionManager } from '../Explosion/ExplosionManager' | ||||||
| import { BulletStateMachine } from './BulletStateMachine' | import { BulletStateMachine } from './BulletStateMachine' | ||||||
| const { ccclass, property } = _decorator | const { ccclass } = _decorator | ||||||
| 
 | 
 | ||||||
| @ccclass('BulletManager') | @ccclass('BulletManager') | ||||||
| export class BulletManager extends EntityManager { | export class BulletManager extends EntityManager { | ||||||
|   //静态数据
 |   //静态数据
 | ||||||
|   id = 1 |   id: number | ||||||
|   owner = 1 |   owner: number | ||||||
|   type = EntityTypeEnum.Bullet1 |   type: EntityTypeEnum | ||||||
| 
 | 
 | ||||||
|   //动态数据
 |   //动态数据
 | ||||||
|   position: IVec2 |   position: IVec2 | ||||||
| @@ -32,11 +32,7 @@ export class BulletManager extends EntityManager { | |||||||
|     this.state = EntityStateEnum.Idle |     this.state = EntityStateEnum.Idle | ||||||
|     this.node.active = false |     this.node.active = false | ||||||
| 
 | 
 | ||||||
|     EventManager.Instance.on(EventEnum.Explosion, this.handleExplosion, this) |     EventManager.Instance.on(EventEnum.ExplosionBorn, this.handleExplosion, this) | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   onDisable() { |  | ||||||
|     EventManager.Instance.off(EventEnum.Explosion, this.handleExplosion, this) |  | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   handleExplosion(id: number, { x, y }: IVec2) { |   handleExplosion(id: number, { x, y }: IVec2) { | ||||||
| @@ -44,13 +40,16 @@ export class BulletManager extends EntityManager { | |||||||
|       return |       return | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const explosion = ObjectPoolManager.Instance.getPoolObject(EntityTypeEnum.Explosion) |     const explosion = ObjectPoolManager.Instance.get(EntityTypeEnum.Explosion) | ||||||
|     const explosionManager = explosion.getComponent(ExplosionManager) || explosion.addComponent(ExplosionManager) |     const explosionManager = explosion.getComponent(ExplosionManager) || explosion.addComponent(ExplosionManager) | ||||||
|     explosionManager.init(EntityTypeEnum.Explosion, { |     explosionManager.init(EntityTypeEnum.Explosion, { | ||||||
|       x, y, |       x, y, | ||||||
|     }) |     }) | ||||||
| 
 | 
 | ||||||
|     ObjectPoolManager.Instance.returnPoolObject(this.node) |     EventManager.Instance.off(EventEnum.ExplosionBorn, this.handleExplosion, this) | ||||||
|  |     ObjectPoolManager.Instance.ret(this.node) | ||||||
|  |     DataManager.Instance.bulletMap.delete(this.id) | ||||||
|  |     this.angle = undefined | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   render(data: IBullet) { |   render(data: IBullet) { | ||||||
| @@ -1,12 +1,11 @@ | |||||||
| import { _decorator, Animation, AnimationClip } from 'cc' | import { _decorator, Animation } from 'cc' | ||||||
| import State from '../../Base/State' | import State from '../../Base/State' | ||||||
| import StateMachine, { getInitParamsNumber, getInitParamsTrigger } from '../../Base/StateMachine' | import StateMachine, { getInitParamsTrigger } from '../../Base/StateMachine' | ||||||
| import { EntityTypeEnum, TexturePathEnum, EntityStateEnum, ParamsNameEnum } from '../../Enum' | import { EntityTypeEnum, EntityStateEnum, ParamsNameEnum } from '../../Enum' | ||||||
| const { ccclass, property } = _decorator | const { ccclass } = _decorator | ||||||
| 
 | 
 | ||||||
| @ccclass('BulletStateMachine') | @ccclass('BulletStateMachine') | ||||||
| export class BulletStateMachine extends StateMachine { | export class BulletStateMachine extends StateMachine { | ||||||
|   type: EntityTypeEnum |  | ||||||
|   init(type: EntityTypeEnum) { |   init(type: EntityTypeEnum) { | ||||||
|     this.type = type |     this.type = type | ||||||
|     this.animationComponent = this.node.addComponent(Animation) |     this.animationComponent = this.node.addComponent(Animation) | ||||||
| @@ -1,7 +1,7 @@ | |||||||
| import { _decorator, Animation, AnimationClip, Node, Sprite, Vec3, Vec2, RigidBody2D } from 'cc' | import { _decorator } from 'cc' | ||||||
| import { EntityManager } from '../../Base/EntityManager' | import { EntityManager } from '../../Base/EntityManager' | ||||||
| import { EntityTypeEnum, EntityStateEnum, EventEnum } from '../../Enum' | import { EntityTypeEnum, EntityStateEnum } from '../../Enum' | ||||||
| import { IBullet, IVec2 } from '../../Global/DataManager' | import { IVec2 } from '../../Global/DataManager' | ||||||
| import { ExplosionStateMachine } from './ExplosionStateMachine' | import { ExplosionStateMachine } from './ExplosionStateMachine' | ||||||
| const { ccclass, property } = _decorator | const { ccclass, property } = _decorator | ||||||
| 
 | 
 | ||||||
| @@ -1,13 +1,12 @@ | |||||||
| import { _decorator, Animation, AnimationClip } from 'cc' | import { _decorator, Animation } from 'cc' | ||||||
| import State from '../../Base/State' | import State from '../../Base/State' | ||||||
| import StateMachine, { getInitParamsNumber, getInitParamsTrigger } from '../../Base/StateMachine' | import StateMachine, { getInitParamsTrigger } from '../../Base/StateMachine' | ||||||
| import { EntityTypeEnum, TexturePathEnum, EntityStateEnum, ParamsNameEnum } from '../../Enum' | import { EntityTypeEnum, EntityStateEnum, ParamsNameEnum } from '../../Enum' | ||||||
| import ObjectPoolManager from '../../Global/ObjectPoolManager' | import ObjectPoolManager from '../../Global/ObjectPoolManager' | ||||||
| const { ccclass, property } = _decorator | const { ccclass, property } = _decorator | ||||||
| 
 | 
 | ||||||
| @ccclass('ExplosionStateMachine') | @ccclass('ExplosionStateMachine') | ||||||
| export class ExplosionStateMachine extends StateMachine { | export class ExplosionStateMachine extends StateMachine { | ||||||
|   type: EntityTypeEnum |  | ||||||
|   init(type: EntityTypeEnum) { |   init(type: EntityTypeEnum) { | ||||||
|     this.type = type |     this.type = type | ||||||
|     this.animationComponent = this.node.addComponent(Animation) |     this.animationComponent = this.node.addComponent(Animation) | ||||||
| @@ -30,7 +29,7 @@ export class ExplosionStateMachine extends StateMachine { | |||||||
|       const whiteList = [EntityStateEnum.Idle] |       const whiteList = [EntityStateEnum.Idle] | ||||||
|       const name = this.animationComponent.defaultClip.name |       const name = this.animationComponent.defaultClip.name | ||||||
|       if (whiteList.some(v => name.includes(v))) { |       if (whiteList.some(v => name.includes(v))) { | ||||||
|         ObjectPoolManager.Instance.returnPoolObject(this.node) |         ObjectPoolManager.Instance.ret(this.node) | ||||||
|       } |       } | ||||||
|     }) |     }) | ||||||
|   } |   } | ||||||
| @@ -1,22 +1,20 @@ | |||||||
| import { _decorator, Vec2, RigidBody2D, BoxCollider2D, Size, ERigidBody2DType, Prefab, instantiate, Input, ProgressBar, Label } from 'cc'; | import { _decorator, instantiate, ProgressBar, Label } from 'cc'; | ||||||
| import { EntityManager } from '../../Base/EntityManager'; | import { EntityManager } from '../../Base/EntityManager'; | ||||||
| import { EntityTypeEnum, EntityStateEnum, EventEnum, InputType, PrefabPathEnum } from '../../Enum'; | import { EntityTypeEnum, EntityStateEnum, InputType } from '../../Enum'; | ||||||
| import DataManager, { IPlayer, IVec2 } from '../../Global/DataManager'; | import DataManager, { IPlayer, IVec2 } from '../../Global/DataManager'; | ||||||
| import EventManager from '../../Global/EventManager'; |  | ||||||
| import { ResourceManager } from '../../Global/ResourceManager'; |  | ||||||
| import { rad2Angle } from '../../Utils'; | import { rad2Angle } from '../../Utils'; | ||||||
| import { WeaponManager } from '../Weapon/WeaponManager'; | import { WeaponManager } from '../Weapon/WeaponManager'; | ||||||
| import { PlayerStateMachine } from './PlayerStateMachine'; | import { PlayerStateMachine } from './PlayerStateMachine'; | ||||||
| const { ccclass, property } = _decorator; | const { ccclass } = _decorator; | ||||||
| 
 | 
 | ||||||
| @ccclass('PlayerManager') | @ccclass('PlayerManager') | ||||||
| export class PlayerManager extends EntityManager { | export class PlayerManager extends EntityManager { | ||||||
|     //静态数据
 |     //静态数据
 | ||||||
|     id = 1 |     id: number | ||||||
|     nickname = '' |     nickname: string | ||||||
|     type = EntityTypeEnum.Player1 |     type: EntityTypeEnum | ||||||
|     weaponType = EntityTypeEnum.Weapon1 |     weaponType: EntityTypeEnum | ||||||
|     bulletType = EntityTypeEnum.Bullet1 |     bulletType: EntityTypeEnum | ||||||
| 
 | 
 | ||||||
|     //动态数据
 |     //动态数据
 | ||||||
|     hp: number |     hp: number | ||||||
| @@ -24,7 +22,7 @@ export class PlayerManager extends EntityManager { | |||||||
|     direction: IVec2 |     direction: IVec2 | ||||||
| 
 | 
 | ||||||
|     private hpBar: ProgressBar |     private hpBar: ProgressBar | ||||||
|     private nicknameLabel: Label |     private label: Label | ||||||
|     private weapon: WeaponManager |     private weapon: WeaponManager | ||||||
| 
 | 
 | ||||||
|     get isSelf() { |     get isSelf() { | ||||||
| @@ -40,11 +38,12 @@ export class PlayerManager extends EntityManager { | |||||||
|         this.bulletType = bulletType |         this.bulletType = bulletType | ||||||
| 
 | 
 | ||||||
|         this.hpBar = this.node.getComponentInChildren(ProgressBar) |         this.hpBar = this.node.getComponentInChildren(ProgressBar) | ||||||
|         this.nicknameLabel = this.node.getComponentInChildren(Label) |         this.label = this.node.getComponentInChildren(Label) | ||||||
|         this.nicknameLabel.string = data.nickname |         this.label.string = nickname | ||||||
| 
 | 
 | ||||||
|         this.fsm = this.addComponent(PlayerStateMachine) |         this.fsm = this.addComponent(PlayerStateMachine) | ||||||
|         this.fsm.init(type) |         this.fsm.init(type) | ||||||
|  |         this.state = EntityStateEnum.Idle | ||||||
| 
 | 
 | ||||||
|         const weaponPrefab = DataManager.Instance.prefabMap.get(this.weaponType) |         const weaponPrefab = DataManager.Instance.prefabMap.get(this.weaponType) | ||||||
|         const weapon = instantiate(weaponPrefab) |         const weapon = instantiate(weaponPrefab) | ||||||
| @@ -58,10 +57,6 @@ export class PlayerManager extends EntityManager { | |||||||
|             return |             return | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // if (!DataManager.Instance.jm.input.length()) {
 |  | ||||||
|         //     return
 |  | ||||||
|         // }
 |  | ||||||
| 
 |  | ||||||
|         const { x, y } = DataManager.Instance.jm.input |         const { x, y } = DataManager.Instance.jm.input | ||||||
|         DataManager.Instance.applyInput({ |         DataManager.Instance.applyInput({ | ||||||
|             type: InputType.PlayerMove, |             type: InputType.PlayerMove, | ||||||
| @@ -97,7 +92,7 @@ export class PlayerManager extends EntityManager { | |||||||
|         const { x, y } = data.direction |         const { x, y } = data.direction | ||||||
|         if (x !== 0) { |         if (x !== 0) { | ||||||
|             this.node.setScale(x > 0 ? 1 : -1, 1) |             this.node.setScale(x > 0 ? 1 : -1, 1) | ||||||
|             this.nicknameLabel.node.setScale(x > 0 ? 1 : -1, 1) |             this.label.node.setScale(x > 0 ? 1 : -1, 1) | ||||||
|         } |         } | ||||||
|         const side = Math.sqrt(x * x + y * y) |         const side = Math.sqrt(x * x + y * y) | ||||||
|         const angle = rad2Angle(Math.asin(y / side)) |         const angle = rad2Angle(Math.asin(y / side)) | ||||||
| @@ -1,13 +1,11 @@ | |||||||
| import { _decorator, Animation, AnimationClip } from 'cc' | import { _decorator, Animation, AnimationClip } from 'cc' | ||||||
| import State from '../../Base/State' | import State from '../../Base/State' | ||||||
| import StateMachine, { getInitParamsNumber, getInitParamsTrigger } from '../../Base/StateMachine' | import StateMachine, { getInitParamsTrigger } from '../../Base/StateMachine' | ||||||
| import { EntityTypeEnum, EntityStateEnum, ParamsNameEnum } from '../../Enum' | import { EntityTypeEnum, EntityStateEnum, ParamsNameEnum } from '../../Enum' | ||||||
| const { ccclass, property } = _decorator | const { ccclass } = _decorator | ||||||
| 
 | 
 | ||||||
| @ccclass('PlayerStateMachine') | @ccclass('PlayerStateMachine') | ||||||
| export class PlayerStateMachine extends StateMachine { | export class PlayerStateMachine extends StateMachine { | ||||||
|   type: EntityTypeEnum |  | ||||||
| 
 |  | ||||||
|   init(type: EntityTypeEnum) { |   init(type: EntityTypeEnum) { | ||||||
|     this.type = type |     this.type = type | ||||||
|     this.animationComponent = this.node.addComponent(Animation) |     this.animationComponent = this.node.addComponent(Animation) | ||||||
| @@ -1,15 +1,15 @@ | |||||||
| import { _decorator, Animation, AnimationClip, Node, Sprite, Vec3, Vec2, UITransform } from 'cc' | import { _decorator, Node, Vec2, UITransform } from 'cc' | ||||||
| import { EntityManager } from '../../Base/EntityManager' | import { EntityManager } from '../../Base/EntityManager' | ||||||
| import { EntityTypeEnum, EntityStateEnum, EventEnum, InputType } from '../../Enum' | import { EntityTypeEnum, EntityStateEnum, EventEnum, InputType } from '../../Enum' | ||||||
| import DataManager, { IPlayer } from '../../Global/DataManager' | import DataManager, { IPlayer } from '../../Global/DataManager' | ||||||
| import EventManager from '../../Global/EventManager' | import EventManager from '../../Global/EventManager' | ||||||
| import { WeaponStateMachine } from './WeaponStateMachine' | import { WeaponStateMachine } from './WeaponStateMachine' | ||||||
| const { ccclass, property } = _decorator | const { ccclass } = _decorator | ||||||
| 
 | 
 | ||||||
| @ccclass('WeaponManager') | @ccclass('WeaponManager') | ||||||
| export class WeaponManager extends EntityManager { | export class WeaponManager extends EntityManager { | ||||||
|   owner = 1 |   owner: number | ||||||
|   type = EntityTypeEnum.Weapon1 |   type: EntityTypeEnum | ||||||
| 
 | 
 | ||||||
|   private body: Node |   private body: Node | ||||||
|   private anchor: Node |   private anchor: Node | ||||||
| @@ -21,7 +21,6 @@ export class WeaponManager extends EntityManager { | |||||||
| 
 | 
 | ||||||
|   init({ id, weaponType }: IPlayer) { |   init({ id, weaponType }: IPlayer) { | ||||||
|     this.owner = id |     this.owner = id | ||||||
| 
 |  | ||||||
|     this.type = weaponType |     this.type = weaponType | ||||||
| 
 | 
 | ||||||
|     this.node.setSiblingIndex(0) |     this.node.setSiblingIndex(0) | ||||||
| @@ -33,27 +32,29 @@ export class WeaponManager extends EntityManager { | |||||||
|     this.fsm.init(weaponType) |     this.fsm.init(weaponType) | ||||||
|     this.state = EntityStateEnum.Idle |     this.state = EntityStateEnum.Idle | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     EventManager.Instance.on(EventEnum.WeaponShoot, this.handleWeaponShoot, this) |     EventManager.Instance.on(EventEnum.WeaponShoot, this.handleWeaponShoot, this) | ||||||
|     this.isSelf && EventManager.Instance.on(EventEnum.ShootBtnClick, this.handleShootBtnClick, this) |     EventManager.Instance.on(EventEnum.BulletBorn, this.handleBulletBorn, this) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   onDestroy() { |   onDestroy() { | ||||||
|     this.isSelf && EventManager.Instance.off(EventEnum.ShootBtnClick, this.handleShootBtnClick, this) |  | ||||||
|     EventManager.Instance.off(EventEnum.WeaponShoot, this.handleWeaponShoot, this) |     EventManager.Instance.off(EventEnum.WeaponShoot, this.handleWeaponShoot, this) | ||||||
|  |     EventManager.Instance.off(EventEnum.BulletBorn, this.handleBulletBorn, this) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   handleWeaponShoot(id: number) { |   handleBulletBorn(owner: number) { | ||||||
|     if (this.owner !== id) { |     if (this.owner !== owner) { | ||||||
|       return |       return | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     this.state = EntityStateEnum.Attack |     this.state = EntityStateEnum.Attack | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   handleShootBtnClick() { |   handleWeaponShoot() { | ||||||
|  |     if (!this.isSelf) { | ||||||
|  |       return | ||||||
|  |     } | ||||||
|     const pointWorldPos = this.point.getWorldPosition() |     const pointWorldPos = this.point.getWorldPosition() | ||||||
|     const pointStagePos = DataManager.Instance.gm.stage.getComponent(UITransform).convertToNodeSpaceAR(pointWorldPos); |     const pointStagePos = DataManager.Instance.stage.getComponent(UITransform).convertToNodeSpaceAR(pointWorldPos); | ||||||
|     const anchorWorldPos = this.anchor.getWorldPosition() |     const anchorWorldPos = this.anchor.getWorldPosition() | ||||||
|     const directionVec2 = new Vec2(pointWorldPos.x - anchorWorldPos.x, pointWorldPos.y - anchorWorldPos.y).normalize() |     const directionVec2 = new Vec2(pointWorldPos.x - anchorWorldPos.x, pointWorldPos.y - anchorWorldPos.y).normalize() | ||||||
| 
 | 
 | ||||||
| @@ -1,14 +1,12 @@ | |||||||
| import { _decorator, Animation, AnimationClip } from 'cc' | import { _decorator, Animation, AnimationClip } from 'cc' | ||||||
| import State from '../../Base/State' | import State from '../../Base/State' | ||||||
| import StateMachine, { getInitParamsNumber, getInitParamsTrigger } from '../../Base/StateMachine' | import StateMachine, { getInitParamsTrigger } from '../../Base/StateMachine' | ||||||
| import { EntityStateEnum, EntityTypeEnum, ParamsNameEnum } from '../../Enum' | import { EntityStateEnum, EntityTypeEnum, ParamsNameEnum } from '../../Enum' | ||||||
| import { WeaponManager } from './WeaponManager' | import { WeaponManager } from './WeaponManager' | ||||||
| const { ccclass, property } = _decorator | const { ccclass } = _decorator | ||||||
| 
 | 
 | ||||||
| @ccclass('WeaponStateMachine') | @ccclass('WeaponStateMachine') | ||||||
| export class WeaponStateMachine extends StateMachine { | export class WeaponStateMachine extends StateMachine { | ||||||
|   type: EntityTypeEnum |  | ||||||
| 
 |  | ||||||
|   init(type: EntityTypeEnum) { |   init(type: EntityTypeEnum) { | ||||||
|     this.type = type |     this.type = type | ||||||
|     this.animationComponent = this.node.addComponent(Animation) |     this.animationComponent = this.node.addComponent(Animation) | ||||||
| @@ -30,9 +28,7 @@ export class WeaponStateMachine extends StateMachine { | |||||||
| 
 | 
 | ||||||
|   initAnimationEvent() { |   initAnimationEvent() { | ||||||
|     this.animationComponent.on(Animation.EventType.FINISHED, () => { |     this.animationComponent.on(Animation.EventType.FINISHED, () => { | ||||||
|       const whiteList = [EntityStateEnum.Attack] |       if (this.animationComponent.defaultClip.name.includes(EntityStateEnum.Attack)) { | ||||||
|       const name = this.animationComponent.defaultClip.name |  | ||||||
|       if (whiteList.some(v => name.includes(v))) { |  | ||||||
|         this.node.parent.getComponent(WeaponManager).state = EntityStateEnum.Idle |         this.node.parent.getComponent(WeaponManager).state = EntityStateEnum.Idle | ||||||
|       } |       } | ||||||
|     }) |     }) | ||||||
| @@ -16,9 +16,11 @@ export enum ParamsNameEnum { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export enum EventEnum { | export enum EventEnum { | ||||||
|   ShootBtnClick = 'ShootBtnClick', |  | ||||||
|   WeaponShoot = 'WeaponShoot', |   WeaponShoot = 'WeaponShoot', | ||||||
|   Explosion = 'Explosion' |   BulletBorn = 'BulletBorn', | ||||||
|  |   ExplosionBorn = 'ExplosionBorn', | ||||||
|  |   RoomJoin = 'RoomJoin', | ||||||
|  |   GameStart = 'GameStart', | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export enum EntityTypeEnum { | export enum EntityTypeEnum { | ||||||
| @@ -66,3 +68,10 @@ export enum InputType { | |||||||
|   WeaponShoot = 'WeaponShoot', |   WeaponShoot = 'WeaponShoot', | ||||||
|   TimePast = 'TimePast', |   TimePast = 'TimePast', | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | export enum SceneEnum { | ||||||
|  |   Login = 'Login', | ||||||
|  |   Hall = 'Hall', | ||||||
|  |   Room = 'Room', | ||||||
|  |   Battle = 'Battle', | ||||||
|  | } | ||||||
| @@ -1,13 +1,11 @@ | |||||||
| import { Input, Prefab, SpriteFrame } from 'cc' | import { Node, Prefab, SpriteFrame } from 'cc' | ||||||
| import Singleton from '../Base/Singleton' | import Singleton from '../Base/Singleton' | ||||||
| import { BulletManager } from '../Entity/Bullet/BulletManager' | import { BulletManager } from '../Entity/Bullet/BulletManager' | ||||||
| import { PlayerManager } from '../Entity/Player/PlayerManager' | import { PlayerManager } from '../Entity/Player/PlayerManager' | ||||||
| import { WeaponManager } from '../Entity/Weapon/WeaponManager' | import { EntityTypeEnum, EventEnum, InputType } from '../Enum' | ||||||
| import { EntityStateEnum, EntityTypeEnum, EventEnum, InputType } from '../Enum' |  | ||||||
| import { BattleManager } from '../Scene/BattleManager' |  | ||||||
| import { JoyStickManager } from '../UI/JoyStickManager' | import { JoyStickManager } from '../UI/JoyStickManager' | ||||||
| import EventManager from './EventManager' | import EventManager from './EventManager' | ||||||
| import ObjectPoolManager from './ObjectPoolManager' | import { IData } from './NetworkManager' | ||||||
| 
 | 
 | ||||||
| export type IPlayer = Pick<PlayerManager, 'id' | 'nickname' | 'hp' | 'position' | 'direction' | 'type' | 'weaponType' | 'bulletType'> | export type IPlayer = Pick<PlayerManager, 'id' | 'nickname' | 'hp' | 'position' | 'direction' | 'type' | 'weaponType' | 'bulletType'> | ||||||
| export type IBullet = Pick<BulletManager, 'id' | 'owner' | 'position' | 'direction' | 'type'> | export type IBullet = Pick<BulletManager, 'id' | 'owner' | 'position' | 'direction' | 'type'> | ||||||
| @@ -35,8 +33,7 @@ interface IPlayerMove { | |||||||
|   type: InputType.PlayerMove |   type: InputType.PlayerMove | ||||||
|   id: number; |   id: number; | ||||||
|   direction: IVec2; |   direction: IVec2; | ||||||
|   dt: number |   dt: number; | ||||||
| 
 |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| interface IWeaponShoot { | interface IWeaponShoot { | ||||||
| @@ -56,9 +53,8 @@ export default class DataManager extends Singleton { | |||||||
|     return super.GetInstance<DataManager>() |     return super.GetInstance<DataManager>() | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   gm: BattleManager |   stage: Node | ||||||
|   jm: JoyStickManager |   jm: JoyStickManager | ||||||
|   myPlayerId = 1 |  | ||||||
| 
 | 
 | ||||||
|   prefabMap: Map<string, Prefab> = new Map() |   prefabMap: Map<string, Prefab> = new Map() | ||||||
|   textureMap: Map<string, SpriteFrame[]> = new Map() |   textureMap: Map<string, SpriteFrame[]> = new Map() | ||||||
| @@ -66,6 +62,13 @@ export default class DataManager extends Singleton { | |||||||
|   playerMap: Map<number, PlayerManager> = new Map() |   playerMap: Map<number, PlayerManager> = new Map() | ||||||
|   bulletMap: Map<number, BulletManager> = new Map() |   bulletMap: Map<number, BulletManager> = new Map() | ||||||
| 
 | 
 | ||||||
|  |   myPlayerId = 1 | ||||||
|  |   roomInfo: IData | ||||||
|  |   mapSize = { | ||||||
|  |     x: 960, | ||||||
|  |     y: 640, | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   state: IState = { |   state: IState = { | ||||||
|     players: [{ |     players: [{ | ||||||
|       id: 2, |       id: 2, | ||||||
| @@ -113,9 +116,7 @@ export default class DataManager extends Singleton { | |||||||
| 
 | 
 | ||||||
|         player.position.x += x * PLAYER_SPEED * dt |         player.position.x += x * PLAYER_SPEED * dt | ||||||
|         player.position.y += y * PLAYER_SPEED * dt |         player.position.y += y * PLAYER_SPEED * dt | ||||||
| 
 |  | ||||||
|         player.direction = { x, y } |         player.direction = { x, y } | ||||||
| 
 |  | ||||||
|         break |         break | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
| @@ -130,7 +131,7 @@ export default class DataManager extends Singleton { | |||||||
|         } |         } | ||||||
|         this.state.bullets.push(bullet) |         this.state.bullets.push(bullet) | ||||||
| 
 | 
 | ||||||
|         EventManager.Instance.emit(EventEnum.WeaponShoot, owner) |         EventManager.Instance.emit(EventEnum.BulletBorn, owner) | ||||||
|         break |         break | ||||||
|       } |       } | ||||||
|       case InputType.TimePast: { |       case InputType.TimePast: { | ||||||
| @@ -142,7 +143,7 @@ export default class DataManager extends Singleton { | |||||||
|           for (let j = players.length - 1; j >= 0; j--) { |           for (let j = players.length - 1; j >= 0; j--) { | ||||||
|             const player = players[j]; |             const player = players[j]; | ||||||
|             if (((player.position.x - bullet.position.x) ** 2 + (player.position.y - bullet.position.y) ** 2) < (PLAYER_RADIUS + BULLET_RADIUS) ** 2) { |             if (((player.position.x - bullet.position.x) ** 2 + (player.position.y - bullet.position.y) ** 2) < (PLAYER_RADIUS + BULLET_RADIUS) ** 2) { | ||||||
|               EventManager.Instance.emit(EventEnum.Explosion, bullet.id, { |               EventManager.Instance.emit(EventEnum.ExplosionBorn, bullet.id, { | ||||||
|                 x: (player.position.x + bullet.position.x) / 2, |                 x: (player.position.x + bullet.position.x) / 2, | ||||||
|                 y: (player.position.y + bullet.position.y) / 2, |                 y: (player.position.y + bullet.position.y) / 2, | ||||||
|               }) |               }) | ||||||
| @@ -152,6 +153,14 @@ export default class DataManager extends Singleton { | |||||||
|               break |               break | ||||||
|             } |             } | ||||||
|           } |           } | ||||||
|  |           if (Math.abs(bullet.position.x) > this.mapSize.x / 2 || Math.abs(bullet.position.y) > this.mapSize.y / 2) { | ||||||
|  |             EventManager.Instance.emit(EventEnum.ExplosionBorn, bullet.id, { | ||||||
|  |               x: bullet.position.x, | ||||||
|  |               y: bullet.position.y, | ||||||
|  |             }) | ||||||
|  |             bullets.splice(i, 1) | ||||||
|  |           } | ||||||
|  | 
 | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         for (const bullet of this.state.bullets) { |         for (const bullet of this.state.bullets) { | ||||||
							
								
								
									
										42
									
								
								apps/client/assets/Scripts/Global/EventManager.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								apps/client/assets/Scripts/Global/EventManager.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | |||||||
|  | import Singleton from '../Base/Singleton' | ||||||
|  | import { EventEnum } from '../Enum'; | ||||||
|  |  | ||||||
|  | interface IItem { | ||||||
|  |   func: Function; | ||||||
|  |   ctx: unknown; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | export default class EventManager extends Singleton { | ||||||
|  |   static get Instance() { | ||||||
|  |     return super.GetInstance<EventManager>(); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   private map: Map<EventEnum, Array<IItem>> = new Map(); | ||||||
|  |  | ||||||
|  |   on(event: EventEnum, func: Function, ctx?: unknown) { | ||||||
|  |     if (this.map.has(event)) { | ||||||
|  |       this.map.get(event).push({ func, ctx }); | ||||||
|  |     } else { | ||||||
|  |       this.map.set(event, [{ func, ctx }]); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   off(event: EventEnum, func: Function, ctx?: unknown) { | ||||||
|  |     if (this.map.has(event)) { | ||||||
|  |       const index = this.map.get(event).findIndex(i => func === i.func && i.ctx === ctx); | ||||||
|  |       index > -1 && this.map.get(event).splice(index, 1); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   emit(event: EventEnum, ...params: unknown[]) { | ||||||
|  |     if (this.map.has(event)) { | ||||||
|  |       this.map.get(event).forEach(({ func, ctx }) => { | ||||||
|  |         ctx ? func.apply(ctx, params) : func(...params); | ||||||
|  |       }); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   clear() { | ||||||
|  |     this.map.clear(); | ||||||
|  |   } | ||||||
|  | } | ||||||
							
								
								
									
										117
									
								
								apps/client/assets/Scripts/Global/NetworkManager.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										117
									
								
								apps/client/assets/Scripts/Global/NetworkManager.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,117 @@ | |||||||
|  | import Singleton from '../Base/Singleton' | ||||||
|  |  | ||||||
|  | const TIMEOUT = 5000 | ||||||
|  |  | ||||||
|  | export type IData = Record<string, any> | ||||||
|  |  | ||||||
|  | export interface ICallApiRet { | ||||||
|  |   success: boolean; | ||||||
|  |   error?: Error; | ||||||
|  |   res?: IData | ||||||
|  | } | ||||||
|  |  | ||||||
|  | export enum ApiMsgEnum { | ||||||
|  |   ApiPlayerList = 'ApiPlayerList', | ||||||
|  |   ApiPlayerJoin = 'ApiPlayerJoin', | ||||||
|  |   ApiRoomList = 'ApiRoomList', | ||||||
|  |   ApiRoomCreate = 'ApiRoomCreate', | ||||||
|  |   ApiRoomJoin = 'ApiRoomJoin', | ||||||
|  |   ApiRoomLeave = 'ApiRoomLeave', | ||||||
|  |   MsgPlayerList = 'MsgPlayerList', | ||||||
|  |   MsgRoomList = 'MsgRoomList', | ||||||
|  |   MsgRoom = 'MsgRoom', | ||||||
|  | } | ||||||
|  |  | ||||||
|  | export default class NetworkManager extends Singleton { | ||||||
|  |   static get Instance() { | ||||||
|  |     return super.GetInstance<NetworkManager>() | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   ws: WebSocket | ||||||
|  |   port = 8888 | ||||||
|  |   cbs: Map<string, Function[]> = new Map() | ||||||
|  |   isConnected = false | ||||||
|  |  | ||||||
|  |   connect() { | ||||||
|  |     return new Promise((resolve, reject) => { | ||||||
|  |       this.ws = new WebSocket(`ws://localhost:${this.port}`) | ||||||
|  |       this.ws.onopen = () => { | ||||||
|  |         console.log("ws onopen") | ||||||
|  |         this.isConnected = true | ||||||
|  |         resolve(true) | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |       this.ws.onerror = () => { | ||||||
|  |         this.isConnected = false | ||||||
|  |         reject("ws onerror") | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |       this.ws.onclose = () => { | ||||||
|  |         this.isConnected = false | ||||||
|  |         reject("ws onclose") | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |       this.ws.onmessage = (e) => { | ||||||
|  |         try { | ||||||
|  |           const json = JSON.parse(e.data) | ||||||
|  |           const { name, data } = json | ||||||
|  |           try { | ||||||
|  |             if (this.cbs.has(name) && this.cbs.get(name).length) { | ||||||
|  |               console.log(json); | ||||||
|  |               this.cbs.get(name).forEach(cb => cb(data)) | ||||||
|  |             } | ||||||
|  |           } catch (error) { | ||||||
|  |             console.log("this.cbs.get(name).forEach(cb => cb(restData))", error) | ||||||
|  |           } | ||||||
|  |  | ||||||
|  |         } catch (error) { | ||||||
|  |           console.log('解析失败,不是合法的JSON格式', error) | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |     }) | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   sendMsg(name: string, data: IData) { | ||||||
|  |     this.ws.send(JSON.stringify({ name, data })) | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   listenMsg(name: string, cb: Function) { | ||||||
|  |     if (this.cbs.has(name)) { | ||||||
|  |       this.cbs.get(name).push(cb) | ||||||
|  |     } else { | ||||||
|  |       this.cbs.set(name, [cb]) | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   unlistenMsg(name: string, cb: Function) { | ||||||
|  |     if (this.cbs.has(name)) { | ||||||
|  |       const index = this.cbs.get(name).indexOf(cb) | ||||||
|  |       index > -1 && this.cbs.get(name).splice(index, 1) | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   callApi(name: string, data: IData) { | ||||||
|  |     return new Promise<ICallApiRet>((resolve) => { | ||||||
|  |       try { | ||||||
|  |         // 超时处理 | ||||||
|  |         const timer = setTimeout(() => { | ||||||
|  |           resolve({ success: false, error: new Error('timeout') }) | ||||||
|  |           this.unlistenMsg(name, cb) | ||||||
|  |         }, TIMEOUT) | ||||||
|  |  | ||||||
|  |         // 回调处理 | ||||||
|  |         const cb = (res: ICallApiRet) => { | ||||||
|  |           resolve(res) | ||||||
|  |           clearTimeout(timer) | ||||||
|  |           this.unlistenMsg(name, cb) | ||||||
|  |         } | ||||||
|  |         this.listenMsg(name, cb) | ||||||
|  |  | ||||||
|  |         this.ws.send(JSON.stringify({ name, data })) | ||||||
|  |       } catch (error) { | ||||||
|  |         console.log(error) | ||||||
|  |         resolve({ success: false, error: error as Error }) | ||||||
|  |       } | ||||||
|  |     }) | ||||||
|  |   } | ||||||
|  | } | ||||||
							
								
								
									
										50
									
								
								apps/client/assets/Scripts/Global/ObjectPoolManager.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								apps/client/assets/Scripts/Global/ObjectPoolManager.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | |||||||
|  | import Singleton from '../Base/Singleton' | ||||||
|  | import { instantiate, Node } from 'cc' | ||||||
|  | import { EntityTypeEnum } from '../Enum' | ||||||
|  | import DataManager from './DataManager' | ||||||
|  |  | ||||||
|  | export default class ObjectPoolManager extends Singleton { | ||||||
|  |   static get Instance() { | ||||||
|  |     return super.GetInstance<ObjectPoolManager>() | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   private objectPool: Node = null | ||||||
|  |   private map: Map<EntityTypeEnum, Node[]> = new Map() | ||||||
|  |  | ||||||
|  |   private getContainerName(objectName: EntityTypeEnum) { | ||||||
|  |     return objectName + 'Pool' | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   get(objectName: EntityTypeEnum) { | ||||||
|  |     if (this.objectPool === null) { | ||||||
|  |       this.objectPool = new Node("ObjectPool") | ||||||
|  |       this.objectPool.setParent(DataManager.Instance.stage) | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     if (!this.map.has(objectName)) { | ||||||
|  |       this.map.set(objectName, []) | ||||||
|  |       const container = new Node(this.getContainerName(objectName)) | ||||||
|  |       container.setParent(this.objectPool) | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     let node: Node | ||||||
|  |     const nodes = this.map.get(objectName) | ||||||
|  |  | ||||||
|  |     if (!nodes.length) { | ||||||
|  |       const prefab = DataManager.Instance.prefabMap.get(objectName) | ||||||
|  |       node = instantiate(prefab) | ||||||
|  |       node.name = objectName | ||||||
|  |       node.setParent(this.objectPool.getChildByName(this.getContainerName(objectName))) | ||||||
|  |     } else { | ||||||
|  |       node = nodes.pop() | ||||||
|  |     } | ||||||
|  |     node.active = true | ||||||
|  |     return node | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   ret(object: Node) { | ||||||
|  |     object.active = false | ||||||
|  |     const objectName = object.name as EntityTypeEnum | ||||||
|  |     this.map.get(objectName).push(object) | ||||||
|  |   } | ||||||
|  | } | ||||||
| @@ -1,4 +1,4 @@ | |||||||
| import { _decorator, resources, SpriteFrame, Asset } from 'cc' | import { _decorator, resources, Asset } from 'cc' | ||||||
| import Singleton from '../Base/Singleton' | import Singleton from '../Base/Singleton' | ||||||
| 
 | 
 | ||||||
| export class ResourceManager extends Singleton { | export class ResourceManager extends Singleton { | ||||||
| @@ -1,4 +1,4 @@ | |||||||
| import { _decorator, Component, Node, resources, Prefab, instantiate, Vec2, SpriteFrame } from 'cc'; | import { _decorator, Component, Node, Prefab, instantiate, SpriteFrame } from 'cc'; | ||||||
| import { PlayerManager } from '../Entity/Player/PlayerManager'; | import { PlayerManager } from '../Entity/Player/PlayerManager'; | ||||||
| import DataManager from '../Global/DataManager'; | import DataManager from '../Global/DataManager'; | ||||||
| import { JoyStickManager } from '../UI/JoyStickManager'; | import { JoyStickManager } from '../UI/JoyStickManager'; | ||||||
| @@ -8,26 +8,23 @@ import NetworkManager from '../Global/NetworkManager'; | |||||||
| import ObjectPoolManager from '../Global/ObjectPoolManager'; | import ObjectPoolManager from '../Global/ObjectPoolManager'; | ||||||
| import { BulletManager } from '../Entity/Bullet/BulletManager'; | import { BulletManager } from '../Entity/Bullet/BulletManager'; | ||||||
| 
 | 
 | ||||||
| const { ccclass, property, requireComponent } = _decorator; | const { ccclass } = _decorator; | ||||||
| 
 | 
 | ||||||
| @ccclass('BattleManager') | @ccclass('BattleManager') | ||||||
| export class BattleManager extends Component { | export class BattleManager extends Component { | ||||||
|     stage: Node |     stage: Node | ||||||
|     ui: Node |     ui: Node | ||||||
| 
 |  | ||||||
|     isInited = false |     isInited = false | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|     onLoad() { |     onLoad() { | ||||||
|         DataManager.Instance.gm = this |         this.stage = DataManager.Instance.stage = this.node.getChildByName("Stage") | ||||||
|         this.stage = this.node.getChildByName("Stage") |  | ||||||
|         this.ui = this.node.getChildByName("UI") |         this.ui = this.node.getChildByName("UI") | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async start() { |     async start() { | ||||||
|         this.clearGame() |         this.clearGame() | ||||||
|         await this.loadRes() |         await this.loadRes() | ||||||
|         await this.initScene() |         this.initScene() | ||||||
|  |         await this.connectServer() | ||||||
|         this.isInited = true |         this.isInited = true | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @@ -36,19 +33,6 @@ export class BattleManager extends Component { | |||||||
|         this.ui.destroyAllChildren() |         this.ui.destroyAllChildren() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async initScene() { |  | ||||||
|         // await NetworkManager.Instance.connect()
 |  | ||||||
|         // NetworkManager.Instance.sendMsg("我是客户端!!")
 |  | ||||||
|         // const data = await NetworkManager.Instance.callApi("/join")
 |  | ||||||
|         // console.log("data", data);
 |  | ||||||
|         await Promise.all([ |  | ||||||
|             this.initJoyStick(), |  | ||||||
|             this.initFire(), |  | ||||||
|             this.initMap(), |  | ||||||
|         ]) |  | ||||||
| 
 |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     async loadRes() { |     async loadRes() { | ||||||
|         const list = [] |         const list = [] | ||||||
|         for (const type in PrefabPathEnum) { |         for (const type in PrefabPathEnum) { | ||||||
| @@ -66,24 +50,36 @@ export class BattleManager extends Component { | |||||||
|         await Promise.all(list) |         await Promise.all(list) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     async initScene() { | ||||||
|  |         this.initJoyStick() | ||||||
|  |         this.initShoot() | ||||||
|  |         this.initMap() | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     async initJoyStick() { |     async connectServer() { | ||||||
|         const joySitckPrefab = await ResourceManager.Instance.loadRes(PrefabPathEnum[EntityTypeEnum.JoyStick], Prefab) |         if (!await NetworkManager.Instance.connect().catch(() => false)) { | ||||||
|         const joySitck = instantiate(joySitckPrefab) |             await new Promise((resolve) => setTimeout(resolve, 1000)) | ||||||
|  |             await this.connectServer() | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     initJoyStick() { | ||||||
|  |         const prefab = DataManager.Instance.prefabMap.get(EntityTypeEnum.JoyStick) | ||||||
|  |         const joySitck = instantiate(prefab) | ||||||
|         joySitck.setParent(this.ui) |         joySitck.setParent(this.ui) | ||||||
|         const jm = DataManager.Instance.jm = joySitck.getComponent(JoyStickManager) |         const jm = DataManager.Instance.jm = joySitck.getComponent(JoyStickManager) | ||||||
|         await jm.init() |         jm.init() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async initFire() { |     initShoot() { | ||||||
|         const firePrefab = await ResourceManager.Instance.loadRes(PrefabPathEnum[EntityTypeEnum.Shoot], Prefab) |         const prefab = DataManager.Instance.prefabMap.get(EntityTypeEnum.Shoot) | ||||||
|         const fire = instantiate(firePrefab) |         const shoot = instantiate(prefab) | ||||||
|         fire.setParent(this.ui) |         shoot.setParent(this.ui) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async initMap() { |     initMap() { | ||||||
|         const mapPrefab = await ResourceManager.Instance.loadRes(PrefabPathEnum[EntityTypeEnum.Map1], Prefab) |         const prefab = DataManager.Instance.prefabMap.get(EntityTypeEnum.Map1) | ||||||
|         const map = instantiate(mapPrefab) |         const map = instantiate(prefab) | ||||||
|         map.setParent(this.stage) |         map.setParent(this.stage) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @@ -97,17 +93,11 @@ export class BattleManager extends Component { | |||||||
| 
 | 
 | ||||||
|     tick(dt: number) { |     tick(dt: number) { | ||||||
|         this.tickPlayer(dt) |         this.tickPlayer(dt) | ||||||
| 
 |         this.tickGlobal(dt) | ||||||
|         DataManager.Instance.applyInput({ |  | ||||||
|             type: InputType.TimePast, |  | ||||||
|             dt |  | ||||||
|         }) |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     tickPlayer(dt: number) { |     tickPlayer(dt: number) { | ||||||
|         const players = DataManager.Instance.state.players |         for (const p of DataManager.Instance.state.players) { | ||||||
| 
 |  | ||||||
|         for (const p of players) { |  | ||||||
|             const playerManager = DataManager.Instance.playerMap.get(p.id) |             const playerManager = DataManager.Instance.playerMap.get(p.id) | ||||||
|             if (!playerManager) { |             if (!playerManager) { | ||||||
|                 return |                 return | ||||||
| @@ -116,14 +106,20 @@ export class BattleManager extends Component { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     tickGlobal(dt: number) { | ||||||
|  |         DataManager.Instance.applyInput({ | ||||||
|  |             type: InputType.TimePast, | ||||||
|  |             dt | ||||||
|  |         }) | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     render() { |     render() { | ||||||
|         this.renderPlayer() |         this.renderPlayer() | ||||||
|         this.renderBullet() |         this.renderBullet() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     renderPlayer() { |     renderPlayer() { | ||||||
|         const players = DataManager.Instance.state.players |         for (const p of DataManager.Instance.state.players) { | ||||||
|         for (const p of players) { |  | ||||||
|             let playerManager = DataManager.Instance.playerMap.get(p.id) |             let playerManager = DataManager.Instance.playerMap.get(p.id) | ||||||
|             if (!playerManager) { |             if (!playerManager) { | ||||||
|                 const playerPrefab = DataManager.Instance.prefabMap.get(p.type) |                 const playerPrefab = DataManager.Instance.prefabMap.get(p.type) | ||||||
| @@ -139,11 +135,10 @@ export class BattleManager extends Component { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     renderBullet() { |     renderBullet() { | ||||||
|         const bullets = DataManager.Instance.state.bullets |         for (const b of DataManager.Instance.state.bullets) { | ||||||
|         for (const b of bullets) { |  | ||||||
|             let bulletManager = DataManager.Instance.bulletMap.get(b.id) |             let bulletManager = DataManager.Instance.bulletMap.get(b.id) | ||||||
|             if (!bulletManager) { |             if (!bulletManager) { | ||||||
|                 const bullet = ObjectPoolManager.Instance.getPoolObject(b.type) |                 const bullet = ObjectPoolManager.Instance.get(b.type) | ||||||
|                 bulletManager = bullet.getComponent(BulletManager) || bullet.addComponent(BulletManager) |                 bulletManager = bullet.getComponent(BulletManager) || bullet.addComponent(BulletManager) | ||||||
|                 DataManager.Instance.bulletMap.set(b.id, bulletManager) |                 DataManager.Instance.bulletMap.set(b.id, bulletManager) | ||||||
|                 bulletManager.init(b) |                 bulletManager.init(b) | ||||||
							
								
								
									
										122
									
								
								apps/client/assets/Scripts/Scene/HallManager.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										122
									
								
								apps/client/assets/Scripts/Scene/HallManager.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,122 @@ | |||||||
|  | import { _decorator, Component, Node, Prefab, director, instantiate } from 'cc'; | ||||||
|  | import { EventEnum, SceneEnum } from '../Enum'; | ||||||
|  | import DataManager from '../Global/DataManager'; | ||||||
|  | import EventManager from '../Global/EventManager'; | ||||||
|  | import NetworkManager, { ApiMsgEnum, IData } from '../Global/NetworkManager'; | ||||||
|  | import { PlayerItemManager } from '../UI/PlayerItemManager'; | ||||||
|  | import { RoomItemManager } from '../UI/RoomItemManager'; | ||||||
|  | const { ccclass, property } = _decorator; | ||||||
|  |  | ||||||
|  | @ccclass('HallManager') | ||||||
|  | export class HallManager extends Component { | ||||||
|  |     @property(Node) | ||||||
|  |     playerContainer: Node = null; | ||||||
|  |  | ||||||
|  |     @property(Prefab) | ||||||
|  |     playerItem: Prefab = null; | ||||||
|  |  | ||||||
|  |     @property(Node) | ||||||
|  |     roomContainer: Node = null; | ||||||
|  |  | ||||||
|  |     @property(Prefab) | ||||||
|  |     roomItem: Prefab = null; | ||||||
|  |  | ||||||
|  |     onLoad() { | ||||||
|  |         director.preloadScene(SceneEnum.Room); | ||||||
|  |         EventManager.Instance.on(EventEnum.RoomJoin, this.joinRoom, this) | ||||||
|  |         NetworkManager.Instance.listenMsg(ApiMsgEnum.MsgPlayerList, this.renderPlayer); | ||||||
|  |         NetworkManager.Instance.listenMsg(ApiMsgEnum.MsgRoomList, this.renderRooms); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     onDestroy() { | ||||||
|  |         EventManager.Instance.off(EventEnum.RoomJoin, this.joinRoom, this) | ||||||
|  |         NetworkManager.Instance.unlistenMsg(ApiMsgEnum.MsgPlayerList, this.renderPlayer); | ||||||
|  |         NetworkManager.Instance.unlistenMsg(ApiMsgEnum.MsgRoomList, this.renderRooms); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     start() { | ||||||
|  |         this.getPlayers() | ||||||
|  |         this.getRooms() | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     async getPlayers() { | ||||||
|  |         const { success, res, error } = await NetworkManager.Instance.callApi(ApiMsgEnum.ApiPlayerList, {}); | ||||||
|  |         if (!success) { | ||||||
|  |             console.log(error) | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         this.renderPlayer(res) | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     renderPlayer = ({ list }: IData) => { | ||||||
|  |         for (const item of this.playerContainer.children) { | ||||||
|  |             item.active = false | ||||||
|  |         } | ||||||
|  |         while (this.playerContainer.children.length < list.length) { | ||||||
|  |             const playerItem = instantiate(this.playerItem); | ||||||
|  |             playerItem.active = false | ||||||
|  |             playerItem.setParent(this.playerContainer) | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         for (let i = 0; i < list.length; i++) { | ||||||
|  |             const data = list[i]; | ||||||
|  |             const node = this.playerContainer.children[i] | ||||||
|  |             const playerItemManager = node.getComponent(PlayerItemManager) | ||||||
|  |             playerItemManager.init(data) | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     async getRooms() { | ||||||
|  |         const { success, res, error } = await NetworkManager.Instance.callApi(ApiMsgEnum.ApiRoomList, {}); | ||||||
|  |         if (!success) { | ||||||
|  |             console.log(error) | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         this.renderRooms(res) | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     renderRooms = ({ list }: IData) => { | ||||||
|  |         for (const item of this.roomContainer.children) { | ||||||
|  |             item.active = false | ||||||
|  |         } | ||||||
|  |         while (this.roomContainer.children.length < list.length) { | ||||||
|  |             const roomItem = instantiate(this.roomItem); | ||||||
|  |             roomItem.active = false | ||||||
|  |             roomItem.setParent(this.roomContainer) | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         for (let i = 0; i < list.length; i++) { | ||||||
|  |             const data = list[i]; | ||||||
|  |             const node = this.roomContainer.children[i] | ||||||
|  |             const roomItemManager = node.getComponent(RoomItemManager) | ||||||
|  |             roomItemManager.init(data) | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     async createRoom() { | ||||||
|  |         const { success, res, error } = await NetworkManager.Instance.callApi(ApiMsgEnum.ApiRoomCreate, {}); | ||||||
|  |         if (!success) { | ||||||
|  |             console.log(error) | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         DataManager.Instance.roomInfo = { ...res } | ||||||
|  |  | ||||||
|  |         director.loadScene(SceneEnum.Room); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     async joinRoom(rid: number) { | ||||||
|  |         const { success, res, error } = await NetworkManager.Instance.callApi(ApiMsgEnum.ApiRoomJoin, { rid }); | ||||||
|  |         if (!success) { | ||||||
|  |             console.log(error) | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         DataManager.Instance.roomInfo = { ...res } | ||||||
|  |  | ||||||
|  |         director.loadScene(SceneEnum.Room); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
							
								
								
									
										9
									
								
								apps/client/assets/Scripts/Scene/HallManager.ts.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								apps/client/assets/Scripts/Scene/HallManager.ts.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | |||||||
|  | { | ||||||
|  |   "ver": "4.0.23", | ||||||
|  |   "importer": "typescript", | ||||||
|  |   "imported": true, | ||||||
|  |   "uuid": "a14b4d33-c5f8-455c-a935-dbfd7f3ab62b", | ||||||
|  |   "files": [], | ||||||
|  |   "subMetas": {}, | ||||||
|  |   "userData": {} | ||||||
|  | } | ||||||
							
								
								
									
										45
									
								
								apps/client/assets/Scripts/Scene/LoginManager.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								apps/client/assets/Scripts/Scene/LoginManager.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,45 @@ | |||||||
|  | import { _decorator, Component, Node, EditBox, Button, director } from 'cc'; | ||||||
|  | import { SceneEnum } from '../Enum'; | ||||||
|  | import DataManager from '../Global/DataManager'; | ||||||
|  | import NetworkManager, { ApiMsgEnum } from '../Global/NetworkManager'; | ||||||
|  | const { ccclass, property } = _decorator; | ||||||
|  |  | ||||||
|  | @ccclass('LoginManager') | ||||||
|  | export class LoginManager extends Component { | ||||||
|  |     input: EditBox | ||||||
|  |  | ||||||
|  |     onLoad() { | ||||||
|  |         this.input = this.node.getChildByName('Input').getComponent(EditBox) | ||||||
|  |         director.preloadScene(SceneEnum.Hall); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     async start() { | ||||||
|  |         await NetworkManager.Instance.connect(); | ||||||
|  |         console.log("服务连接成功!"); | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     async handleClick() { | ||||||
|  |         if (!NetworkManager.Instance.isConnected) { | ||||||
|  |             console.log("未连接!"); | ||||||
|  |             await NetworkManager.Instance.connect(); | ||||||
|  |         } | ||||||
|  |         const nickname = this.input.string; | ||||||
|  |         if (!nickname) { | ||||||
|  |             console.log("请输入昵称!") | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         let { success, res, error } = await NetworkManager.Instance.callApi(ApiMsgEnum.ApiPlayerJoin, { | ||||||
|  |             nickname, | ||||||
|  |         }); | ||||||
|  |  | ||||||
|  |         if (!success) { | ||||||
|  |             console.log(error); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         DataManager.Instance.myPlayerId = res.id; | ||||||
|  |         director.loadScene(SceneEnum.Hall); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
							
								
								
									
										9
									
								
								apps/client/assets/Scripts/Scene/LoginManager.ts.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								apps/client/assets/Scripts/Scene/LoginManager.ts.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | |||||||
|  | { | ||||||
|  |   "ver": "4.0.23", | ||||||
|  |   "importer": "typescript", | ||||||
|  |   "imported": true, | ||||||
|  |   "uuid": "3be66806-c736-419c-b6cc-0dab1e13cbda", | ||||||
|  |   "files": [], | ||||||
|  |   "subMetas": {}, | ||||||
|  |   "userData": {} | ||||||
|  | } | ||||||
							
								
								
									
										64
									
								
								apps/client/assets/Scripts/Scene/RoomManager.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								apps/client/assets/Scripts/Scene/RoomManager.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,64 @@ | |||||||
|  | import { _decorator, Component, Node, Prefab, director, instantiate } from 'cc'; | ||||||
|  | import { EventEnum, SceneEnum } from '../Enum'; | ||||||
|  | import DataManager from '../Global/DataManager'; | ||||||
|  | import EventManager from '../Global/EventManager'; | ||||||
|  | import NetworkManager, { ApiMsgEnum, IData } from '../Global/NetworkManager'; | ||||||
|  | import { PlayerItemManager } from '../UI/PlayerItemManager'; | ||||||
|  | const { ccclass, property } = _decorator; | ||||||
|  |  | ||||||
|  | @ccclass('RoomManager') | ||||||
|  | export class RoomManager extends Component { | ||||||
|  |     @property(Node) | ||||||
|  |     playerContainer: Node = null; | ||||||
|  |  | ||||||
|  |     @property(Prefab) | ||||||
|  |     playerItem: Prefab = null; | ||||||
|  |  | ||||||
|  |     onLoad() { | ||||||
|  |         director.preloadScene(SceneEnum.Battle); | ||||||
|  |         NetworkManager.Instance.listenMsg(ApiMsgEnum.MsgRoom, this.renderPlayer); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     onDestroy() { | ||||||
|  |         NetworkManager.Instance.unlistenMsg(ApiMsgEnum.MsgRoom, this.renderPlayer); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     async start() { | ||||||
|  |         this.renderPlayer(DataManager.Instance.roomInfo) | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     renderPlayer = ({ players: list }: any) => { | ||||||
|  |         for (const item of this.playerContainer.children) { | ||||||
|  |             item.active = false | ||||||
|  |         } | ||||||
|  |         while (this.playerContainer.children.length < list.length) { | ||||||
|  |             const playerItem = instantiate(this.playerItem); | ||||||
|  |             playerItem.active = false | ||||||
|  |             playerItem.setParent(this.playerContainer) | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         for (let i = 0; i < list.length; i++) { | ||||||
|  |             const data = list[i]; | ||||||
|  |             const node = this.playerContainer.children[i] | ||||||
|  |             const playerItemManager = node.getComponent(PlayerItemManager) | ||||||
|  |             playerItemManager.init(data) | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     async handleLeave() { | ||||||
|  |         const { success, res, error } = await NetworkManager.Instance.callApi(ApiMsgEnum.ApiRoomLeave, {}); | ||||||
|  |         if (!success) { | ||||||
|  |             console.log(error) | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         DataManager.Instance.roomInfo = null | ||||||
|  |         director.loadScene(SceneEnum.Hall); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     handleGameStart() { | ||||||
|  |         console.log("handleGameStart"); | ||||||
|  |  | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
							
								
								
									
										9
									
								
								apps/client/assets/Scripts/Scene/RoomManager.ts.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								apps/client/assets/Scripts/Scene/RoomManager.ts.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | |||||||
|  | { | ||||||
|  |   "ver": "4.0.23", | ||||||
|  |   "importer": "typescript", | ||||||
|  |   "imported": true, | ||||||
|  |   "uuid": "8ee1bd73-5b3b-48ad-a0a0-5a1d6a08da7d", | ||||||
|  |   "files": [], | ||||||
|  |   "subMetas": {}, | ||||||
|  |   "userData": {} | ||||||
|  | } | ||||||
| @@ -3,7 +3,7 @@ const { ccclass, property } = _decorator; | |||||||
| 
 | 
 | ||||||
| @ccclass('JoyStickManager') | @ccclass('JoyStickManager') | ||||||
| export class JoyStickManager extends Component { | export class JoyStickManager extends Component { | ||||||
|     input: Vec2 = new Vec2(0, 0) |     input: Vec2 = Vec2.ZERO | ||||||
| 
 | 
 | ||||||
|     private body: Node |     private body: Node | ||||||
|     private stick: Node |     private stick: Node | ||||||
| @@ -11,7 +11,7 @@ export class JoyStickManager extends Component { | |||||||
|     private defaultPos: Vec2 |     private defaultPos: Vec2 | ||||||
|     private radius: number = 0 |     private radius: number = 0 | ||||||
| 
 | 
 | ||||||
|     async init() { |     init() { | ||||||
|         this.body = this.node.getChildByName("Body") |         this.body = this.node.getChildByName("Body") | ||||||
|         this.stick = this.body.getChildByName("Stick") |         this.stick = this.body.getChildByName("Stick") | ||||||
|         const { x, y } = this.body.position |         const { x, y } = this.body.position | ||||||
| @@ -38,7 +38,6 @@ export class JoyStickManager extends Component { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         const stickPos = new Vec2(touchPos.x - this.touchStartPos.x, touchPos.y - this.touchStartPos.y) |         const stickPos = new Vec2(touchPos.x - this.touchStartPos.x, touchPos.y - this.touchStartPos.y) | ||||||
|         // const stickPos = new Vec2(0, touchPos.y - this.touchStartPos.y)
 |  | ||||||
|         const len = stickPos.length() |         const len = stickPos.length() | ||||||
|         if (len > this.radius) { |         if (len > this.radius) { | ||||||
|             stickPos.multiplyScalar(this.radius / len) |             stickPos.multiplyScalar(this.radius / len) | ||||||
| @@ -52,7 +51,7 @@ export class JoyStickManager extends Component { | |||||||
|         this.body.setPosition(this.defaultPos.x, this.defaultPos.y) |         this.body.setPosition(this.defaultPos.x, this.defaultPos.y) | ||||||
|         this.stick.setPosition(0, 0) |         this.stick.setPosition(0, 0) | ||||||
|         this.touchStartPos = undefined |         this.touchStartPos = undefined | ||||||
|         this.input = new Vec2(0, 0) |         this.input = Vec2.ZERO | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
							
								
								
									
										22
									
								
								apps/client/assets/Scripts/UI/PlayerItemManager.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								apps/client/assets/Scripts/UI/PlayerItemManager.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | |||||||
|  | import { _decorator, Component, Node, Label } from 'cc'; | ||||||
|  | import { EventEnum } from '../Enum'; | ||||||
|  | import DataManager from '../Global/DataManager'; | ||||||
|  | import EventManager from '../Global/EventManager'; | ||||||
|  | const { ccclass, property } = _decorator; | ||||||
|  |  | ||||||
|  | @ccclass('PlayerItemManager') | ||||||
|  | export class PlayerItemManager extends Component { | ||||||
|  |   init({ id, nickname, rid }: { id: number, nickname: string, rid: number }) { | ||||||
|  |     const label = this.getComponent(Label) | ||||||
|  |     let str = nickname | ||||||
|  |     if (DataManager.Instance.myPlayerId === id) { | ||||||
|  |       str += `(我)` | ||||||
|  |     } | ||||||
|  |     if (rid !== -1) { | ||||||
|  |       str += `(房间${rid})` | ||||||
|  |     } | ||||||
|  |     label.string = str | ||||||
|  |     this.node.active = true | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
							
								
								
									
										9
									
								
								apps/client/assets/Scripts/UI/PlayerItemManager.ts.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								apps/client/assets/Scripts/UI/PlayerItemManager.ts.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | |||||||
|  | { | ||||||
|  |   "ver": "4.0.23", | ||||||
|  |   "importer": "typescript", | ||||||
|  |   "imported": true, | ||||||
|  |   "uuid": "0b36580d-5fc7-40c1-9ac0-0fb78a685fd1", | ||||||
|  |   "files": [], | ||||||
|  |   "subMetas": {}, | ||||||
|  |   "userData": {} | ||||||
|  | } | ||||||
							
								
								
									
										20
									
								
								apps/client/assets/Scripts/UI/RoomItemManager.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								apps/client/assets/Scripts/UI/RoomItemManager.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | |||||||
|  | import { _decorator, Component, Node, Label } from 'cc'; | ||||||
|  | import { EventEnum } from '../Enum'; | ||||||
|  | import EventManager from '../Global/EventManager'; | ||||||
|  | const { ccclass, property } = _decorator; | ||||||
|  |  | ||||||
|  | @ccclass('RoomItemManager') | ||||||
|  | export class RoomItemManager extends Component { | ||||||
|  |   id: number | ||||||
|  |   init({ id, players }: { id: number, players: Array<{ id: number, nickname: string }> }) { | ||||||
|  |     this.id = id | ||||||
|  |     const label = this.getComponent(Label) | ||||||
|  |     label.string = `房间id:${id},当前人数:${players.length}` | ||||||
|  |     this.node.active = true | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   handleClick() { | ||||||
|  |     EventManager.Instance.emit(EventEnum.RoomJoin, this.id) | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
							
								
								
									
										9
									
								
								apps/client/assets/Scripts/UI/RoomItemManager.ts.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								apps/client/assets/Scripts/UI/RoomItemManager.ts.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | |||||||
|  | { | ||||||
|  |   "ver": "4.0.23", | ||||||
|  |   "importer": "typescript", | ||||||
|  |   "imported": true, | ||||||
|  |   "uuid": "26da1a71-eb0d-463d-b2d6-fbc64bf0ab89", | ||||||
|  |   "files": [], | ||||||
|  |   "subMetas": {}, | ||||||
|  |   "userData": {} | ||||||
|  | } | ||||||
| @@ -5,8 +5,8 @@ const { ccclass, property } = _decorator; | |||||||
| 
 | 
 | ||||||
| @ccclass('ShootManager') | @ccclass('ShootManager') | ||||||
| export class ShootManager extends Component { | export class ShootManager extends Component { | ||||||
|     fire() { |     shoot() { | ||||||
|         EventManager.Instance.emit(EventEnum.ShootBtnClick) |         EventManager.Instance.emit(EventEnum.WeaponShoot) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| @@ -1,4 +1,4 @@ | |||||||
| import { Layers, SpriteFrame, Node, UITransform } from "cc" | import { SpriteFrame } from "cc" | ||||||
| 
 | 
 | ||||||
| const INDEX_REG = /\((\d+)\)/ | const INDEX_REG = /\((\d+)\)/ | ||||||
| 
 | 
 | ||||||
| @@ -7,14 +7,5 @@ const getNumberWithinString = (str: string) => parseInt(str.match(INDEX_REG)?.[1 | |||||||
| export const sortSpriteFrame = (spriteFrame: Array<SpriteFrame>) => | export const sortSpriteFrame = (spriteFrame: Array<SpriteFrame>) => | ||||||
|   spriteFrame.sort((a, b) => getNumberWithinString(a.name) - getNumberWithinString(b.name)) |   spriteFrame.sort((a, b) => getNumberWithinString(a.name) - getNumberWithinString(b.name)) | ||||||
| 
 | 
 | ||||||
| const getUIMaskNumber = () => 1 << Layers.nameToLayer('UI_2D') |  | ||||||
| 
 |  | ||||||
| export const createUINode = (name: string = '') => { |  | ||||||
|   const node = new Node(name) |  | ||||||
|   node.layer = getUIMaskNumber() |  | ||||||
|   const transform = node.addComponent(UITransform) |  | ||||||
|   return node |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export const rad2Angle = (rad: number) => rad / Math.PI * 180 | export const rad2Angle = (rad: number) => rad / Math.PI * 180 | ||||||
| 
 | 
 | ||||||
| @@ -2,7 +2,7 @@ | |||||||
|   "ver": "1.1.0", |   "ver": "1.1.0", | ||||||
|   "importer": "directory", |   "importer": "directory", | ||||||
|   "imported": true, |   "imported": true, | ||||||
|   "uuid": "2d541e68-a3ab-45a5-a30d-ffc21e6aa37f", |   "uuid": "9348a0ae-1f83-44fe-ae79-892e1db86d1a", | ||||||
|   "files": [], |   "files": [], | ||||||
|   "subMetas": {}, |   "subMetas": {}, | ||||||
|   "userData": { |   "userData": { | ||||||
							
								
								
									
										200
									
								
								apps/client/assets/resources/prefab/Hall/PlayerItem.prefab
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										200
									
								
								apps/client/assets/resources/prefab/Hall/PlayerItem.prefab
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,200 @@ | |||||||
|  | [ | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.Prefab", | ||||||
|  |     "_name": "PlayerItem", | ||||||
|  |     "_objFlags": 0, | ||||||
|  |     "_native": "", | ||||||
|  |     "data": { | ||||||
|  |       "__id__": 1 | ||||||
|  |     }, | ||||||
|  |     "optimizationPolicy": 0, | ||||||
|  |     "persistent": false, | ||||||
|  |     "asyncLoadAssets": false | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.Node", | ||||||
|  |     "_name": "PlayerItem", | ||||||
|  |     "_objFlags": 0, | ||||||
|  |     "__editorExtras__": {}, | ||||||
|  |     "_parent": null, | ||||||
|  |     "_children": [], | ||||||
|  |     "_active": true, | ||||||
|  |     "_components": [ | ||||||
|  |       { | ||||||
|  |         "__id__": 2 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "__id__": 4 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "__id__": 6 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "__id__": 8 | ||||||
|  |       } | ||||||
|  |     ], | ||||||
|  |     "_prefab": { | ||||||
|  |       "__id__": 10 | ||||||
|  |     }, | ||||||
|  |     "_lpos": { | ||||||
|  |       "__type__": "cc.Vec3", | ||||||
|  |       "x": -460, | ||||||
|  |       "y": -20, | ||||||
|  |       "z": 0 | ||||||
|  |     }, | ||||||
|  |     "_lrot": { | ||||||
|  |       "__type__": "cc.Quat", | ||||||
|  |       "x": 0, | ||||||
|  |       "y": 0, | ||||||
|  |       "z": 0, | ||||||
|  |       "w": 1 | ||||||
|  |     }, | ||||||
|  |     "_lscale": { | ||||||
|  |       "__type__": "cc.Vec3", | ||||||
|  |       "x": 1, | ||||||
|  |       "y": 1, | ||||||
|  |       "z": 1 | ||||||
|  |     }, | ||||||
|  |     "_layer": 33554432, | ||||||
|  |     "_euler": { | ||||||
|  |       "__type__": "cc.Vec3", | ||||||
|  |       "x": 0, | ||||||
|  |       "y": 0, | ||||||
|  |       "z": 0 | ||||||
|  |     }, | ||||||
|  |     "_id": "" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.UITransform", | ||||||
|  |     "_name": "", | ||||||
|  |     "_objFlags": 0, | ||||||
|  |     "node": { | ||||||
|  |       "__id__": 1 | ||||||
|  |     }, | ||||||
|  |     "_enabled": true, | ||||||
|  |     "__prefab": { | ||||||
|  |       "__id__": 3 | ||||||
|  |     }, | ||||||
|  |     "_contentSize": { | ||||||
|  |       "__type__": "cc.Size", | ||||||
|  |       "width": 240, | ||||||
|  |       "height": 50.4 | ||||||
|  |     }, | ||||||
|  |     "_anchorPoint": { | ||||||
|  |       "__type__": "cc.Vec2", | ||||||
|  |       "x": 0, | ||||||
|  |       "y": 1 | ||||||
|  |     }, | ||||||
|  |     "_id": "" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.CompPrefabInfo", | ||||||
|  |     "fileId": "69g2Ps4UpEQIdkibaU0mB+" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.Label", | ||||||
|  |     "_name": "", | ||||||
|  |     "_objFlags": 0, | ||||||
|  |     "node": { | ||||||
|  |       "__id__": 1 | ||||||
|  |     }, | ||||||
|  |     "_enabled": true, | ||||||
|  |     "__prefab": { | ||||||
|  |       "__id__": 5 | ||||||
|  |     }, | ||||||
|  |     "_customMaterial": null, | ||||||
|  |     "_srcBlendFactor": 2, | ||||||
|  |     "_dstBlendFactor": 4, | ||||||
|  |     "_color": { | ||||||
|  |       "__type__": "cc.Color", | ||||||
|  |       "r": 255, | ||||||
|  |       "g": 255, | ||||||
|  |       "b": 255, | ||||||
|  |       "a": 255 | ||||||
|  |     }, | ||||||
|  |     "_string": "这是一个昵称", | ||||||
|  |     "_horizontalAlign": 0, | ||||||
|  |     "_verticalAlign": 0, | ||||||
|  |     "_actualFontSize": 40, | ||||||
|  |     "_fontSize": 40, | ||||||
|  |     "_fontFamily": "Arial", | ||||||
|  |     "_lineHeight": 40, | ||||||
|  |     "_overflow": 0, | ||||||
|  |     "_enableWrapText": true, | ||||||
|  |     "_font": null, | ||||||
|  |     "_isSystemFontUsed": true, | ||||||
|  |     "_spacingX": 0, | ||||||
|  |     "_isItalic": false, | ||||||
|  |     "_isBold": false, | ||||||
|  |     "_isUnderline": false, | ||||||
|  |     "_underlineHeight": 2, | ||||||
|  |     "_cacheMode": 0, | ||||||
|  |     "_id": "" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.CompPrefabInfo", | ||||||
|  |     "fileId": "1fVVQb7LdIUZ7E43CVIsuV" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.Widget", | ||||||
|  |     "_name": "", | ||||||
|  |     "_objFlags": 0, | ||||||
|  |     "node": { | ||||||
|  |       "__id__": 1 | ||||||
|  |     }, | ||||||
|  |     "_enabled": true, | ||||||
|  |     "__prefab": { | ||||||
|  |       "__id__": 7 | ||||||
|  |     }, | ||||||
|  |     "_alignFlags": 8, | ||||||
|  |     "_target": null, | ||||||
|  |     "_left": 20, | ||||||
|  |     "_right": 0, | ||||||
|  |     "_top": 0, | ||||||
|  |     "_bottom": 0, | ||||||
|  |     "_horizontalCenter": 0, | ||||||
|  |     "_verticalCenter": 0, | ||||||
|  |     "_isAbsLeft": true, | ||||||
|  |     "_isAbsRight": true, | ||||||
|  |     "_isAbsTop": true, | ||||||
|  |     "_isAbsBottom": true, | ||||||
|  |     "_isAbsHorizontalCenter": true, | ||||||
|  |     "_isAbsVerticalCenter": true, | ||||||
|  |     "_originalWidth": 0, | ||||||
|  |     "_originalHeight": 0, | ||||||
|  |     "_alignMode": 2, | ||||||
|  |     "_lockFlags": 0, | ||||||
|  |     "_id": "" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.CompPrefabInfo", | ||||||
|  |     "fileId": "1dyUPgippJNLS6AWV5oz7O" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "0b365gNX8dAwZrAD7eKaF/R", | ||||||
|  |     "_name": "", | ||||||
|  |     "_objFlags": 0, | ||||||
|  |     "node": { | ||||||
|  |       "__id__": 1 | ||||||
|  |     }, | ||||||
|  |     "_enabled": true, | ||||||
|  |     "__prefab": { | ||||||
|  |       "__id__": 9 | ||||||
|  |     }, | ||||||
|  |     "_id": "" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.CompPrefabInfo", | ||||||
|  |     "fileId": "35yNVdeqZKy6dIzoq3eYwD" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.PrefabInfo", | ||||||
|  |     "root": { | ||||||
|  |       "__id__": 1 | ||||||
|  |     }, | ||||||
|  |     "asset": { | ||||||
|  |       "__id__": 0 | ||||||
|  |     }, | ||||||
|  |     "fileId": "fcj/6WYKJAnbG8wIajLBQ9" | ||||||
|  |   } | ||||||
|  | ] | ||||||
| @@ -0,0 +1,13 @@ | |||||||
|  | { | ||||||
|  |   "ver": "1.1.39", | ||||||
|  |   "importer": "prefab", | ||||||
|  |   "imported": true, | ||||||
|  |   "uuid": "7b0c739f-cf46-48f7-8c15-c97ab34268fe", | ||||||
|  |   "files": [ | ||||||
|  |     ".json" | ||||||
|  |   ], | ||||||
|  |   "subMetas": {}, | ||||||
|  |   "userData": { | ||||||
|  |     "syncNodeName": "PlayerItem" | ||||||
|  |   } | ||||||
|  | } | ||||||
							
								
								
									
										272
									
								
								apps/client/assets/resources/prefab/Hall/RoomItem.prefab
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										272
									
								
								apps/client/assets/resources/prefab/Hall/RoomItem.prefab
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,272 @@ | |||||||
|  | [ | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.Prefab", | ||||||
|  |     "_name": "RoomItem", | ||||||
|  |     "_objFlags": 0, | ||||||
|  |     "_native": "", | ||||||
|  |     "data": { | ||||||
|  |       "__id__": 1 | ||||||
|  |     }, | ||||||
|  |     "optimizationPolicy": 0, | ||||||
|  |     "persistent": false, | ||||||
|  |     "asyncLoadAssets": false | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.Node", | ||||||
|  |     "_name": "RoomItem", | ||||||
|  |     "_objFlags": 0, | ||||||
|  |     "__editorExtras__": {}, | ||||||
|  |     "_parent": null, | ||||||
|  |     "_children": [], | ||||||
|  |     "_active": true, | ||||||
|  |     "_components": [ | ||||||
|  |       { | ||||||
|  |         "__id__": 2 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "__id__": 4 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "__id__": 6 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "__id__": 8 | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         "__id__": 10 | ||||||
|  |       } | ||||||
|  |     ], | ||||||
|  |     "_prefab": { | ||||||
|  |       "__id__": 13 | ||||||
|  |     }, | ||||||
|  |     "_lpos": { | ||||||
|  |       "__type__": "cc.Vec3", | ||||||
|  |       "x": -460, | ||||||
|  |       "y": -20, | ||||||
|  |       "z": 0 | ||||||
|  |     }, | ||||||
|  |     "_lrot": { | ||||||
|  |       "__type__": "cc.Quat", | ||||||
|  |       "x": 0, | ||||||
|  |       "y": 0, | ||||||
|  |       "z": 0, | ||||||
|  |       "w": 1 | ||||||
|  |     }, | ||||||
|  |     "_lscale": { | ||||||
|  |       "__type__": "cc.Vec3", | ||||||
|  |       "x": 1, | ||||||
|  |       "y": 1, | ||||||
|  |       "z": 1 | ||||||
|  |     }, | ||||||
|  |     "_layer": 33554432, | ||||||
|  |     "_euler": { | ||||||
|  |       "__type__": "cc.Vec3", | ||||||
|  |       "x": 0, | ||||||
|  |       "y": 0, | ||||||
|  |       "z": 0 | ||||||
|  |     }, | ||||||
|  |     "_id": "" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.UITransform", | ||||||
|  |     "_name": "", | ||||||
|  |     "_objFlags": 0, | ||||||
|  |     "node": { | ||||||
|  |       "__id__": 1 | ||||||
|  |     }, | ||||||
|  |     "_enabled": true, | ||||||
|  |     "__prefab": { | ||||||
|  |       "__id__": 3 | ||||||
|  |     }, | ||||||
|  |     "_contentSize": { | ||||||
|  |       "__type__": "cc.Size", | ||||||
|  |       "width": 240, | ||||||
|  |       "height": 50.4 | ||||||
|  |     }, | ||||||
|  |     "_anchorPoint": { | ||||||
|  |       "__type__": "cc.Vec2", | ||||||
|  |       "x": 0, | ||||||
|  |       "y": 1 | ||||||
|  |     }, | ||||||
|  |     "_id": "" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.CompPrefabInfo", | ||||||
|  |     "fileId": "004ckstpVLVI/GFNPQu6Ut" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.Label", | ||||||
|  |     "_name": "", | ||||||
|  |     "_objFlags": 0, | ||||||
|  |     "node": { | ||||||
|  |       "__id__": 1 | ||||||
|  |     }, | ||||||
|  |     "_enabled": true, | ||||||
|  |     "__prefab": { | ||||||
|  |       "__id__": 5 | ||||||
|  |     }, | ||||||
|  |     "_customMaterial": null, | ||||||
|  |     "_srcBlendFactor": 2, | ||||||
|  |     "_dstBlendFactor": 4, | ||||||
|  |     "_color": { | ||||||
|  |       "__type__": "cc.Color", | ||||||
|  |       "r": 255, | ||||||
|  |       "g": 255, | ||||||
|  |       "b": 255, | ||||||
|  |       "a": 255 | ||||||
|  |     }, | ||||||
|  |     "_string": "这是一个昵称", | ||||||
|  |     "_horizontalAlign": 0, | ||||||
|  |     "_verticalAlign": 0, | ||||||
|  |     "_actualFontSize": 40, | ||||||
|  |     "_fontSize": 40, | ||||||
|  |     "_fontFamily": "Arial", | ||||||
|  |     "_lineHeight": 40, | ||||||
|  |     "_overflow": 0, | ||||||
|  |     "_enableWrapText": true, | ||||||
|  |     "_font": null, | ||||||
|  |     "_isSystemFontUsed": true, | ||||||
|  |     "_spacingX": 0, | ||||||
|  |     "_isItalic": false, | ||||||
|  |     "_isBold": false, | ||||||
|  |     "_isUnderline": false, | ||||||
|  |     "_underlineHeight": 2, | ||||||
|  |     "_cacheMode": 0, | ||||||
|  |     "_id": "" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.CompPrefabInfo", | ||||||
|  |     "fileId": "cbYokkXAdJ4KKFtl4bKb6h" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.Widget", | ||||||
|  |     "_name": "", | ||||||
|  |     "_objFlags": 0, | ||||||
|  |     "node": { | ||||||
|  |       "__id__": 1 | ||||||
|  |     }, | ||||||
|  |     "_enabled": true, | ||||||
|  |     "__prefab": { | ||||||
|  |       "__id__": 7 | ||||||
|  |     }, | ||||||
|  |     "_alignFlags": 8, | ||||||
|  |     "_target": null, | ||||||
|  |     "_left": 20, | ||||||
|  |     "_right": 0, | ||||||
|  |     "_top": 0, | ||||||
|  |     "_bottom": 0, | ||||||
|  |     "_horizontalCenter": 0, | ||||||
|  |     "_verticalCenter": 0, | ||||||
|  |     "_isAbsLeft": true, | ||||||
|  |     "_isAbsRight": true, | ||||||
|  |     "_isAbsTop": true, | ||||||
|  |     "_isAbsBottom": true, | ||||||
|  |     "_isAbsHorizontalCenter": true, | ||||||
|  |     "_isAbsVerticalCenter": true, | ||||||
|  |     "_originalWidth": 0, | ||||||
|  |     "_originalHeight": 0, | ||||||
|  |     "_alignMode": 2, | ||||||
|  |     "_lockFlags": 0, | ||||||
|  |     "_id": "" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.CompPrefabInfo", | ||||||
|  |     "fileId": "04BVJ/YxxGgJB9RdmtoR81" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "26da1px6w1GPbLW+8ZL8KuJ", | ||||||
|  |     "_name": "", | ||||||
|  |     "_objFlags": 0, | ||||||
|  |     "node": { | ||||||
|  |       "__id__": 1 | ||||||
|  |     }, | ||||||
|  |     "_enabled": true, | ||||||
|  |     "__prefab": { | ||||||
|  |       "__id__": 9 | ||||||
|  |     }, | ||||||
|  |     "_id": "" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.CompPrefabInfo", | ||||||
|  |     "fileId": "fcJVJHKllGEpVqSAW4IqSW" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.Button", | ||||||
|  |     "_name": "", | ||||||
|  |     "_objFlags": 0, | ||||||
|  |     "node": { | ||||||
|  |       "__id__": 1 | ||||||
|  |     }, | ||||||
|  |     "_enabled": true, | ||||||
|  |     "__prefab": { | ||||||
|  |       "__id__": 11 | ||||||
|  |     }, | ||||||
|  |     "clickEvents": [ | ||||||
|  |       { | ||||||
|  |         "__id__": 12 | ||||||
|  |       } | ||||||
|  |     ], | ||||||
|  |     "_interactable": true, | ||||||
|  |     "_transition": 0, | ||||||
|  |     "_normalColor": { | ||||||
|  |       "__type__": "cc.Color", | ||||||
|  |       "r": 255, | ||||||
|  |       "g": 255, | ||||||
|  |       "b": 255, | ||||||
|  |       "a": 255 | ||||||
|  |     }, | ||||||
|  |     "_hoverColor": { | ||||||
|  |       "__type__": "cc.Color", | ||||||
|  |       "r": 211, | ||||||
|  |       "g": 211, | ||||||
|  |       "b": 211, | ||||||
|  |       "a": 255 | ||||||
|  |     }, | ||||||
|  |     "_pressedColor": { | ||||||
|  |       "__type__": "cc.Color", | ||||||
|  |       "r": 255, | ||||||
|  |       "g": 255, | ||||||
|  |       "b": 255, | ||||||
|  |       "a": 255 | ||||||
|  |     }, | ||||||
|  |     "_disabledColor": { | ||||||
|  |       "__type__": "cc.Color", | ||||||
|  |       "r": 124, | ||||||
|  |       "g": 124, | ||||||
|  |       "b": 124, | ||||||
|  |       "a": 255 | ||||||
|  |     }, | ||||||
|  |     "_normalSprite": null, | ||||||
|  |     "_hoverSprite": null, | ||||||
|  |     "_pressedSprite": null, | ||||||
|  |     "_disabledSprite": null, | ||||||
|  |     "_duration": 0.1, | ||||||
|  |     "_zoomScale": 0.9, | ||||||
|  |     "_target": null, | ||||||
|  |     "_id": "" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.CompPrefabInfo", | ||||||
|  |     "fileId": "e9vctIZBRDxr9zs4vEXaKZ" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.ClickEvent", | ||||||
|  |     "target": { | ||||||
|  |       "__id__": 1 | ||||||
|  |     }, | ||||||
|  |     "component": "", | ||||||
|  |     "_componentId": "26da1px6w1GPbLW+8ZL8KuJ", | ||||||
|  |     "handler": "handleClick", | ||||||
|  |     "customEventData": "" | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     "__type__": "cc.PrefabInfo", | ||||||
|  |     "root": { | ||||||
|  |       "__id__": 1 | ||||||
|  |     }, | ||||||
|  |     "asset": { | ||||||
|  |       "__id__": 0 | ||||||
|  |     }, | ||||||
|  |     "fileId": "a2/F/h+4pOXoCz6HE2/FCp" | ||||||
|  |   } | ||||||
|  | ] | ||||||
| @@ -0,0 +1,13 @@ | |||||||
|  | { | ||||||
|  |   "ver": "1.1.39", | ||||||
|  |   "importer": "prefab", | ||||||
|  |   "imported": true, | ||||||
|  |   "uuid": "b91571d9-7804-4e62-b9d4-eef2f8f0cadd", | ||||||
|  |   "files": [ | ||||||
|  |     ".json" | ||||||
|  |   ], | ||||||
|  |   "subMetas": {}, | ||||||
|  |   "userData": { | ||||||
|  |     "syncNodeName": "RoomItem" | ||||||
|  |   } | ||||||
|  | } | ||||||
							
								
								
									
										12
									
								
								apps/client/assets/resources/prefab/Room.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								apps/client/assets/resources/prefab/Room.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | |||||||
|  | { | ||||||
|  |   "ver": "1.1.0", | ||||||
|  |   "importer": "directory", | ||||||
|  |   "imported": true, | ||||||
|  |   "uuid": "d4aded25-46cd-4911-b695-170d2eb72fd6", | ||||||
|  |   "files": [], | ||||||
|  |   "subMetas": {}, | ||||||
|  |   "userData": { | ||||||
|  |     "compressionType": {}, | ||||||
|  |     "isRemoteBundle": {} | ||||||
|  |   } | ||||||
|  | } | ||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user