This commit is contained in:
sli97
2022-12-01 22:26:41 +08:00
parent 1a27f478d0
commit bdead4a6d1
256 changed files with 7972 additions and 387 deletions

View File

@@ -0,0 +1,2 @@
[InternetShortcut]
URL=https://docs.cocos.com/creator/manual/en/scripting/setup.html#custom-script-template

View File

@@ -0,0 +1,5 @@
{
"image": {
"type": "sprite-frame"
}
}

11
apps/client/.eslintrc Normal file
View File

@@ -0,0 +1,11 @@
{
"extends": "@antfu",
"rules": {
"curly": "off",
"no-console": "off",
"no-cond-assign": "off",
"no-useless-call": "off",
"@typescript-eslint/brace-style": "off",
"@typescript-eslint/consistent-type-imports": "off"
}
}

24
apps/client/.gitignore vendored Normal file
View File

@@ -0,0 +1,24 @@
#///////////////////////////
# Cocos Creator 3D Project
#///////////////////////////
library/
temp/
local/
build/
profiles/
native
#//////////////////////////
# NPM
#//////////////////////////
node_modules/
#//////////////////////////
# VSCode
#//////////////////////////
# .vscode/
#//////////////////////////
# WebStorm
#//////////////////////////
.idea/

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "e4b93ee1-f734-42e9-8468-c45a928b7b58",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
{
"ver": "1.1.39",
"importer": "scene",
"imported": true,
"uuid": "c6ff3dfa-c3a9-4c47-abc2-690531911090",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
{
"ver": "1.1.39",
"importer": "scene",
"imported": true,
"uuid": "43b185e1-294e-4f6e-a660-e27f4cc5e45c",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
{
"ver": "1.1.39",
"importer": "scene",
"imported": true,
"uuid": "6088b18f-3a16-4317-92e4-e7c904905e21",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
{
"ver": "1.1.39",
"importer": "scene",
"imported": true,
"uuid": "af1ea920-28ec-466e-9318-0fc537171240",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "a5ff1131-2769-49ad-92d3-4d7f4b7c2b24",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "b9842cc1-d805-42af-b6b9-b15d5dd32f65",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,23 @@
import { _decorator, Component } from 'cc';
import { EntityStateEnum } from '../Enum';
import StateMachine from './StateMachine';
const { ccclass, property } = _decorator;
@ccclass('EntityManager')
export abstract class EntityManager extends Component {
fsm: StateMachine
private _state: EntityStateEnum
get state() {
return this._state
}
set state(newState) {
this._state = newState
this.fsm.setParams(newState, true)
}
abstract init(...args: any[]): void
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "2e4eed53-d1b9-42ef-97aa-8d0a8da927f7",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,13 @@
export default class Singleton {
private static _instance: any = null
static GetInstance<T>(): T {
if (this._instance === null) {
this._instance = new this()
}
return this._instance
}
protected constructor() {
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "0ee5b84a-8971-410f-a39d-2cf96597dd45",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,48 @@
import { animation, AnimationClip, Sprite, SpriteFrame } from 'cc'
import DataManager from '../Global/DataManager'
import { ResourceManager } from '../Global/ResourceManager'
import { sortSpriteFrame } from '../Utils'
import StateMachine from './StateMachine'
/***
* unit:milisecond
*/
export const ANIMATION_SPEED = 1 / 10
/***
* 状态每组动画的承载容器持有SpriteAnimation组件执行播放
*/
export default class State {
private animationClip: AnimationClip
constructor(
private fsm: StateMachine,
private path: string,
private wrapMode: AnimationClip.WrapMode = AnimationClip.WrapMode.Normal,
private force: boolean = false,
) {
//生成动画轨道属性
const track = new animation.ObjectTrack()
track.path = new animation.TrackPath().toComponent(Sprite).toProperty('spriteFrame')
const spriteFrames = DataManager.Instance.textureMap.get(this.path)
const frames: Array<[number, SpriteFrame]> = sortSpriteFrame(spriteFrames).map((item, index) => [
index * ANIMATION_SPEED,
item,
])
track.channel.curve.assignSorted(frames)
//动画添加轨道
this.animationClip = new AnimationClip()
this.animationClip.name = this.path
this.animationClip.duration = frames.length * ANIMATION_SPEED
this.animationClip.addTrack(track)
this.animationClip.wrapMode = this.wrapMode
}
run() {
if (this.fsm.animationComponent.defaultClip?.name === this.animationClip.name && !this.force) {
return
}
this.fsm.animationComponent.defaultClip = this.animationClip
this.fsm.animationComponent.play()
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "226c1921-1459-4764-82e6-b1a11c5a73c2",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,91 @@
import { _decorator, Animation, Component } from 'cc'
import { EntityTypeEnum, FsmParamTypeEnum } from '../Enum'
const { ccclass } = _decorator
import State from './State'
import SubStateMachine from './SubStateMachine'
type ParamsValueType = boolean | number
export interface IParamsValue {
type: FsmParamTypeEnum
value: ParamsValueType
}
export const getInitParamsTrigger = () => {
return {
type: FsmParamTypeEnum.Trigger,
value: false,
}
}
export const getInitParamsNumber = () => {
return {
type: FsmParamTypeEnum.Number,
value: 0,
}
}
/***
* 流动图
* 1.entity的state或者direction改变触发setter
* 2.setter里触发fsm的setParams方法
* 3.setParams执行run方法run方法由子类重写
* 4.run方法会更改currentState然后触发currentState的setter
* 5-1.如果currentState是子状态机继续执行他的run方法run方法又会设置子状态机的currentState触发子状态run方法
* 5-2.如果是子状态run方法就是播放动画
*/
/***
* 有限状态机基类
*/
@ccclass('StateMachine')
export default abstract class StateMachine extends Component {
private _currentState: State | SubStateMachine = null
params: Map<string, IParamsValue> = new Map()
stateMachines: Map<string, SubStateMachine | State> = new Map()
animationComponent: Animation
type: EntityTypeEnum
getParams(paramName: string) {
if (this.params.has(paramName)) {
return this.params.get(paramName).value
}
}
setParams(paramName: string, value: ParamsValueType) {
if (this.params.has(paramName)) {
this.params.get(paramName).value = value
this.run()
this.resetTrigger()
}
}
get currentState() {
return this._currentState
}
set currentState(newState) {
if (!newState) {
return
}
this._currentState = newState
this._currentState.run()
}
/***
* 清空所有trigger
*/
resetTrigger() {
for (const [, value] of this.params) {
if (value.type === FsmParamTypeEnum.Trigger) {
value.value = false
}
}
}
/***
* 由子类重写方法目标是根据当前状态和参数修改currentState
*/
abstract init(...args: any[]): void
abstract run(): void
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "66538d45-0fcf-4ed2-8e47-a0a688ddaf3c",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,30 @@
import State from './State'
import StateMachine from './StateMachine'
/***
* 子有限状态机基类
* 用处例如有个idle的state但是有多个方向为了让主状态机更整洁可以把同类型的但具体不同的state都封装在子状态机中
*/
export default abstract class SubStateMachine {
private _currentState: State = null
stateMachines: Map<string, State> = new Map()
constructor(public fsm: StateMachine) {}
get currentState() {
return this._currentState
}
set currentState(newState) {
if (!newState) {
return
}
this._currentState = newState
this._currentState.run()
}
/***
* 具体类实现
*/
abstract run(): void
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "7f9fac71-9820-41b2-8b4d-2dc4185414ef",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "b0c3f1a6-89a2-4921-bf10-22ae7925cf6e",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "9265fd0c-f1ae-471b-afa0-7f17e87d408f",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,84 @@
import { _decorator } from 'cc'
import { EntityManager } from '../../Base/EntityManager'
import { EntityTypeEnum, EntityStateEnum, EventEnum } from '../../Enum'
import DataManager, { IBullet, IVec2 } from '../../Global/DataManager'
import EventManager from '../../Global/EventManager'
import ObjectPoolManager from '../../Global/ObjectPoolManager'
import { rad2Angle } from '../../Utils'
import { ExplosionManager } from '../Explosion/ExplosionManager'
import { BulletStateMachine } from './BulletStateMachine'
const { ccclass } = _decorator
@ccclass('BulletManager')
export class BulletManager extends EntityManager {
//静态数据
id: number
owner: number
type: EntityTypeEnum
//动态数据
position: IVec2
direction: IVec2
private angle: number
init({ id, owner, type }: IBullet) {
this.id = id
this.owner = owner
this.type = type
this.fsm = this.addComponent(BulletStateMachine)
this.fsm.init(type)
this.state = EntityStateEnum.Idle
this.node.active = false
EventManager.Instance.on(EventEnum.ExplosionBorn, this.handleExplosion, this)
}
handleExplosion(id: number, { x, y }: IVec2) {
if (this.id !== id) {
return
}
const explosion = ObjectPoolManager.Instance.get(EntityTypeEnum.Explosion)
const explosionManager = explosion.getComponent(ExplosionManager) || explosion.addComponent(ExplosionManager)
explosionManager.init(EntityTypeEnum.Explosion, {
x, y,
})
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) {
this.node.active = true
this.renderPosition(data)
this.renderDirection(data)
}
renderPosition(data: IBullet) {
this.node.setPosition(data.position.x, data.position.y)
}
renderDirection(data: IBullet) {
if (this.angle === undefined) {
const { x, y } = data.direction
const side = Math.sqrt(x * x + y * y)
this.angle = x > 0 ? rad2Angle(Math.asin(y / side)) : rad2Angle(Math.asin(- y / side)) + 180
}
this.node.setRotationFromEuler(0, 0, this.angle)
// let angle: number, sign: number
// if (x !== 0) {
// angle = x > 0 ? rad2Angle(Math.atan(y / x)) : rad2Angle(Math.atan(-y / x)) + 180
// sign = x > 0 ? 1 : -1
// } else {
// angle = rad2Angle(Math.PI / 2)
// sign = y > 0 ? 1 : -1
// }
// this.node.setRotationFromEuler(0, 0, sign * angle)
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "3cb4bec9-dd63-4ffe-9a28-8f8347cd327b",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,44 @@
import { _decorator, Animation } from 'cc'
import State from '../../Base/State'
import StateMachine, { getInitParamsTrigger } from '../../Base/StateMachine'
import { EntityTypeEnum, EntityStateEnum, ParamsNameEnum } from '../../Enum'
const { ccclass } = _decorator
@ccclass('BulletStateMachine')
export class BulletStateMachine extends StateMachine {
init(type: EntityTypeEnum) {
this.type = type
this.animationComponent = this.node.addComponent(Animation)
this.initParams()
this.initStateMachines()
this.initAnimationEvent()
}
initParams() {
this.params.set(ParamsNameEnum.Idle, getInitParamsTrigger())
}
initStateMachines() {
this.stateMachines.set(ParamsNameEnum.Idle, new State(this, `${this.type}${EntityStateEnum.Idle}`))
}
initAnimationEvent() {
}
run() {
switch (this.currentState) {
case this.stateMachines.get(ParamsNameEnum.Idle):
if (this.params.get(ParamsNameEnum.Idle).value) {
this.currentState = this.stateMachines.get(ParamsNameEnum.Idle)
} else {
this.currentState = this.currentState
}
break
default:
this.currentState = this.stateMachines.get(ParamsNameEnum.Idle)
break
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "531b884c-93b6-4d0e-a0fc-e8861eebf6e7",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "3302ce3a-fac5-42c6-8060-e3e8682cfcf1",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,17 @@
import { _decorator } from 'cc'
import { EntityManager } from '../../Base/EntityManager'
import { EntityTypeEnum, EntityStateEnum } from '../../Enum'
import { IVec2 } from '../../Global/DataManager'
import { ExplosionStateMachine } from './ExplosionStateMachine'
const { ccclass, property } = _decorator
@ccclass('ExplosionManager')
export class ExplosionManager extends EntityManager {
init(type: EntityTypeEnum, { x, y }: IVec2) {
this.node.setPosition(x, y)
this.fsm = this.addComponent(ExplosionStateMachine)
this.fsm.init(type)
this.state = EntityStateEnum.Idle
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "34e9e358-082f-4674-9e38-a3c27f8b013b",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,51 @@
import { _decorator, Animation } from 'cc'
import State from '../../Base/State'
import StateMachine, { getInitParamsTrigger } from '../../Base/StateMachine'
import { EntityTypeEnum, EntityStateEnum, ParamsNameEnum } from '../../Enum'
import ObjectPoolManager from '../../Global/ObjectPoolManager'
const { ccclass, property } = _decorator
@ccclass('ExplosionStateMachine')
export class ExplosionStateMachine extends StateMachine {
init(type: EntityTypeEnum) {
this.type = type
this.animationComponent = this.node.addComponent(Animation)
this.initParams()
this.initStateMachines()
this.initAnimationEvent()
}
initParams() {
this.params.set(ParamsNameEnum.Idle, getInitParamsTrigger())
}
initStateMachines() {
this.stateMachines.set(ParamsNameEnum.Idle, new State(this, `${this.type}${EntityStateEnum.Idle}`))
}
initAnimationEvent() {
this.animationComponent.on(Animation.EventType.FINISHED, () => {
const whiteList = [EntityStateEnum.Idle]
const name = this.animationComponent.defaultClip.name
if (whiteList.some(v => name.includes(v))) {
ObjectPoolManager.Instance.ret(this.node)
}
})
}
run() {
switch (this.currentState) {
case this.stateMachines.get(ParamsNameEnum.Idle):
if (this.params.get(ParamsNameEnum.Idle).value) {
this.currentState = this.stateMachines.get(ParamsNameEnum.Idle)
} else {
this.currentState = this.currentState
}
break
default:
this.currentState = this.stateMachines.get(ParamsNameEnum.Idle)
break
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "35a9f553-26d5-49c8-bcc0-d1011c07e124",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "5802fd2f-7823-4294-91c8-d71adca41319",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,113 @@
import { _decorator, instantiate, ProgressBar, Label } from 'cc';
import { EntityManager } from '../../Base/EntityManager';
import { EntityTypeEnum, EntityStateEnum, InputType } from '../../Enum';
import DataManager, { IPlayer, IVec2 } from '../../Global/DataManager';
import { rad2Angle } from '../../Utils';
import { WeaponManager } from '../Weapon/WeaponManager';
import { PlayerStateMachine } from './PlayerStateMachine';
const { ccclass } = _decorator;
@ccclass('PlayerManager')
export class PlayerManager extends EntityManager {
//静态数据
id: number
nickname: string
type: EntityTypeEnum
weaponType: EntityTypeEnum
bulletType: EntityTypeEnum
//动态数据
hp: number
position: IVec2
direction: IVec2
private hpBar: ProgressBar
private label: Label
private weapon: WeaponManager
get isSelf() {
return DataManager.Instance.myPlayerId === this.id
}
init(data: IPlayer) {
const { id, nickname, type, weaponType, bulletType } = data
this.id = id
this.nickname = nickname
this.type = type
this.weaponType = weaponType
this.bulletType = bulletType
this.hpBar = this.node.getComponentInChildren(ProgressBar)
this.label = this.node.getComponentInChildren(Label)
this.label.string = nickname
this.fsm = this.addComponent(PlayerStateMachine)
this.fsm.init(type)
this.state = EntityStateEnum.Idle
const weaponPrefab = DataManager.Instance.prefabMap.get(this.weaponType)
const weapon = instantiate(weaponPrefab)
weapon.setParent(this.node)
this.weapon = weapon.addComponent(WeaponManager)
this.weapon.init(data)
}
tick(dt: number) {
if (!this.isSelf) {
return
}
const { x, y } = DataManager.Instance.jm.input
DataManager.Instance.applyInput({
type: InputType.PlayerMove,
id: this.id,
direction: {
x,
y
},
dt
})
}
render(data: IPlayer) {
this.renderHP(data)
this.renderPosition(data)
this.renderDirection(data)
}
renderHP(data: IPlayer) {
this.hpBar.progress = data.hp / this.hpBar.totalLength
}
renderPosition(data: IPlayer) {
this.node.setPosition(data.position.x, data.position.y)
}
renderDirection(data: IPlayer) {
if (data.direction.x === 0 && data.direction.y === 0) {
this.state = EntityStateEnum.Idle
return
}
this.state = EntityStateEnum.Run
const { x, y } = data.direction
if (x !== 0) {
this.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 angle = rad2Angle(Math.asin(y / side))
this.weapon.node.setRotationFromEuler(0, 0, angle)
// const { x, y } = joystick.input
// let angle: number, sign: number
// if (x !== 0) {
// angle = rad2Angle(Math.atan(y / x))
// sign = joystick.input.x > 0 ? 1 : -1
// } else {
// angle = rad2Angle(Math.PI / 2)
// sign = joystick.input.y > 0 ? 1 : -1
// }
// this.node.setRotationFromEuler(0, 0, sign * angle)
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "4cc81cda-b869-4eb8-855e-126f16aa7a12",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,47 @@
import { _decorator, Animation, AnimationClip } from 'cc'
import State from '../../Base/State'
import StateMachine, { getInitParamsTrigger } from '../../Base/StateMachine'
import { EntityTypeEnum, EntityStateEnum, ParamsNameEnum } from '../../Enum'
const { ccclass } = _decorator
@ccclass('PlayerStateMachine')
export class PlayerStateMachine extends StateMachine {
init(type: EntityTypeEnum) {
this.type = type
this.animationComponent = this.node.addComponent(Animation)
this.initParams()
this.initStateMachines()
this.initAnimationEvent()
}
initParams() {
this.params.set(ParamsNameEnum.Idle, getInitParamsTrigger())
this.params.set(ParamsNameEnum.Run, getInitParamsTrigger())
}
initStateMachines() {
this.stateMachines.set(ParamsNameEnum.Idle, new State(this, `${this.type}${EntityStateEnum.Idle}`, AnimationClip.WrapMode.Loop))
this.stateMachines.set(ParamsNameEnum.Run, new State(this, `${this.type}${EntityStateEnum.Run}`, AnimationClip.WrapMode.Loop))
}
initAnimationEvent() {
}
run() {
switch (this.currentState) {
case this.stateMachines.get(ParamsNameEnum.Idle):
case this.stateMachines.get(ParamsNameEnum.Run):
if (this.params.get(ParamsNameEnum.Run).value) {
this.currentState = this.stateMachines.get(ParamsNameEnum.Run)
} else if (this.params.get(ParamsNameEnum.Idle).value) {
this.currentState = this.stateMachines.get(ParamsNameEnum.Idle)
} else {
this.currentState = this.currentState
}
break
default:
this.currentState = this.stateMachines.get(ParamsNameEnum.Idle)
break
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "3bdb087b-0d43-4b85-81e4-e480cd43405d",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "b8a46a8b-5505-436b-8870-2965599d2168",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,74 @@
import { _decorator, Node, Vec2, UITransform } from 'cc'
import { EntityManager } from '../../Base/EntityManager'
import { EntityTypeEnum, EntityStateEnum, EventEnum, InputType } from '../../Enum'
import DataManager, { IPlayer } from '../../Global/DataManager'
import EventManager from '../../Global/EventManager'
import { WeaponStateMachine } from './WeaponStateMachine'
const { ccclass } = _decorator
@ccclass('WeaponManager')
export class WeaponManager extends EntityManager {
owner: number
type: EntityTypeEnum
private body: Node
private anchor: Node
private point: Node
get isSelf() {
return DataManager.Instance.myPlayerId === this.owner
}
init({ id, weaponType }: IPlayer) {
this.owner = id
this.type = weaponType
this.node.setSiblingIndex(0)
this.body = this.node.getChildByName("Body")
this.anchor = this.body.getChildByName("Anchor")
this.point = this.anchor.getChildByName("Point")
this.fsm = this.body.addComponent(WeaponStateMachine)
this.fsm.init(weaponType)
this.state = EntityStateEnum.Idle
EventManager.Instance.on(EventEnum.WeaponShoot, this.handleWeaponShoot, this)
EventManager.Instance.on(EventEnum.BulletBorn, this.handleBulletBorn, this)
}
onDestroy() {
EventManager.Instance.off(EventEnum.WeaponShoot, this.handleWeaponShoot, this)
EventManager.Instance.off(EventEnum.BulletBorn, this.handleBulletBorn, this)
}
handleBulletBorn(owner: number) {
if (this.owner !== owner) {
return
}
this.state = EntityStateEnum.Attack
}
handleWeaponShoot() {
if (!this.isSelf) {
return
}
const pointWorldPos = this.point.getWorldPosition()
const pointStagePos = DataManager.Instance.stage.getComponent(UITransform).convertToNodeSpaceAR(pointWorldPos);
const anchorWorldPos = this.anchor.getWorldPosition()
const directionVec2 = new Vec2(pointWorldPos.x - anchorWorldPos.x, pointWorldPos.y - anchorWorldPos.y).normalize()
DataManager.Instance.applyInput({
type: InputType.WeaponShoot,
owner: this.owner,
position: {
x: pointStagePos.x,
y: pointStagePos.y
},
direction: {
x: directionVec2.x,
y: directionVec2.y
},
})
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "eefb7dfd-3b96-46cc-a83a-c5bafe656d8a",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,54 @@
import { _decorator, Animation, AnimationClip } from 'cc'
import State from '../../Base/State'
import StateMachine, { getInitParamsTrigger } from '../../Base/StateMachine'
import { EntityStateEnum, EntityTypeEnum, ParamsNameEnum } from '../../Enum'
import { WeaponManager } from './WeaponManager'
const { ccclass } = _decorator
@ccclass('WeaponStateMachine')
export class WeaponStateMachine extends StateMachine {
init(type: EntityTypeEnum) {
this.type = type
this.animationComponent = this.node.addComponent(Animation)
this.initParams()
this.initStateMachines()
this.initAnimationEvent()
}
initParams() {
this.params.set(ParamsNameEnum.Idle, getInitParamsTrigger())
this.params.set(ParamsNameEnum.Attack, getInitParamsTrigger())
}
initStateMachines() {
this.stateMachines.set(ParamsNameEnum.Idle, new State(this, `${this.type}${EntityStateEnum.Idle}`))
this.stateMachines.set(ParamsNameEnum.Attack, new State(this, `${this.type}${EntityStateEnum.Attack}`, AnimationClip.WrapMode.Normal, true))
}
initAnimationEvent() {
this.animationComponent.on(Animation.EventType.FINISHED, () => {
if (this.animationComponent.defaultClip.name.includes(EntityStateEnum.Attack)) {
this.node.parent.getComponent(WeaponManager).state = EntityStateEnum.Idle
}
})
}
run() {
switch (this.currentState) {
case this.stateMachines.get(ParamsNameEnum.Idle):
case this.stateMachines.get(ParamsNameEnum.Attack):
if (this.params.get(ParamsNameEnum.Attack).value) {
this.currentState = this.stateMachines.get(ParamsNameEnum.Attack)
} if (this.params.get(ParamsNameEnum.Idle).value) {
this.currentState = this.stateMachines.get(ParamsNameEnum.Idle)
} else {
this.currentState = this.currentState
}
break
default:
this.currentState = this.stateMachines.get(ParamsNameEnum.Idle)
break
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "1eed66f0-cb8f-4cc9-9f91-aa21b5c2883c",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "5b95c11b-0954-45ac-99ba-98df4825c906",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,77 @@
export enum FsmParamTypeEnum {
Number = 'Number',
Trigger = 'Trigger',
}
export enum EntityStateEnum {
Idle = 'Idle',
Run = 'Run',
Attack = 'Attack',
}
export enum ParamsNameEnum {
Idle = 'Idle',
Run = 'Run',
Attack = 'Attack',
}
export enum EventEnum {
WeaponShoot = 'WeaponShoot',
BulletBorn = 'BulletBorn',
ExplosionBorn = 'ExplosionBorn',
RoomJoin = 'RoomJoin',
GameStart = 'GameStart',
}
export enum EntityTypeEnum {
Map1 = 'Map1',
Player1 = 'Player1',
Player2 = 'Player2',
Weapon1 = 'Weapon1',
Weapon2 = 'Weapon2',
Bullet1 = 'Bullet1',
Bullet2 = 'Bullet2',
Explosion = 'Explosion',
JoyStick = 'JoyStick',
Shoot = 'Shoot',
}
export enum PrefabPathEnum {
Map1 = 'prefab/Map1',
Player1 = 'prefab/Player',
Player2 = 'prefab/Player',
Weapon1 = 'prefab/Weapon1',
Weapon2 = 'prefab/Weapon2',
Bullet1 = 'prefab/Bullet',
Bullet2 = 'prefab/Bullet',
Explosion = 'prefab/Explosion',
JoyStick = 'prefab/JoyStick',
Shoot = 'prefab/Shoot',
}
export enum TexturePathEnum {
Player1Idle = 'texture/player/player1/idle',
Player1Run = 'texture/player/player1/run',
Player2Idle = 'texture/player/player2/idle',
Player2Run = 'texture/player/player2/run',
Weapon1Idle = 'texture/weapon/weapon1/idle',
Weapon1Attack = 'texture/weapon/weapon1/attack',
Weapon2Idle = 'texture/weapon/weapon2/idle',
Weapon2Attack = 'texture/weapon/weapon2/attack',
Bullet1Idle = 'texture/bullet/bullet1',
Bullet2Idle = 'texture/bullet/bullet2',
ExplosionIdle = 'texture/explosion',
}
export enum InputType {
PlayerMove = 'PlayerMove',
WeaponShoot = 'WeaponShoot',
TimePast = 'TimePast',
}
export enum SceneEnum {
Login = 'Login',
Hall = 'Hall',
Room = 'Room',
Battle = 'Battle',
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "393286c2-7b09-44d1-955f-049e7e5b36ea",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "6262be8a-effd-4208-89cd-6532b055b4a0",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,173 @@
import { Node, Prefab, SpriteFrame } from 'cc'
import Singleton from '../Base/Singleton'
import { BulletManager } from '../Entity/Bullet/BulletManager'
import { PlayerManager } from '../Entity/Player/PlayerManager'
import { EntityTypeEnum, EventEnum, InputType } from '../Enum'
import { JoyStickManager } from '../UI/JoyStickManager'
import EventManager from './EventManager'
import { IData } from './NetworkManager'
export type IPlayer = Pick<PlayerManager, 'id' | 'nickname' | 'hp' | 'position' | 'direction' | 'type' | 'weaponType' | 'bulletType'>
export type IBullet = Pick<BulletManager, 'id' | 'owner' | 'position' | 'direction' | 'type'>
const PLAYER_SPEED = 100
const BULLET_SPEED = 600
const WEAPON_DAMAGE = 5
const PLAYER_RADIUS = 50
const BULLET_RADIUS = 10
export interface IVec2 {
x: number;
y: number
}
interface IState {
players: IPlayer[],
bullets: IBullet[],
nextBulletId: number
}
interface IPlayerMove {
type: InputType.PlayerMove
id: number;
direction: IVec2;
dt: number;
}
interface IWeaponShoot {
type: InputType.WeaponShoot
owner: number;
position: IVec2;
direction: IVec2;
}
interface ITimePast {
type: InputType.TimePast;
dt: number
}
export default class DataManager extends Singleton {
static get Instance() {
return super.GetInstance<DataManager>()
}
stage: Node
jm: JoyStickManager
prefabMap: Map<string, Prefab> = new Map()
textureMap: Map<string, SpriteFrame[]> = new Map()
playerMap: Map<number, PlayerManager> = new Map()
bulletMap: Map<number, BulletManager> = new Map()
myPlayerId = 1
roomInfo: IData
mapSize = {
x: 960,
y: 640,
}
state: IState = {
players: [{
id: 2,
nickname: "哈哈1",
position: {
x: -200,
y: -200
},
direction: {
x: 1,
y: 0
},
hp: 100,
type: EntityTypeEnum.Player1,
weaponType: EntityTypeEnum.Weapon1,
bulletType: EntityTypeEnum.Bullet1,
}, {
id: 1,
nickname: "哈哈2",
position: {
x: 200,
y: 200
},
direction: {
x: 0,
y: -1
},
hp: 100,
type: EntityTypeEnum.Player2,
weaponType: EntityTypeEnum.Weapon2,
bulletType: EntityTypeEnum.Bullet2,
}],
bullets: [],
nextBulletId: 1
}
applyInput(input: IPlayerMove | IWeaponShoot | ITimePast) {
switch (input.type) {
case InputType.PlayerMove: {
const { direction: { x, y }, dt, id } = input
const player = this.state.players.find(e => e.id === id)
if (!player) {
return
}
player.position.x += x * PLAYER_SPEED * dt
player.position.y += y * PLAYER_SPEED * dt
player.direction = { x, y }
break
}
case InputType.WeaponShoot: {
const { owner, position, direction } = input
const bullet: IBullet = {
id: this.state.nextBulletId++,
owner,
position,
direction,
type: this.playerMap.get(owner).bulletType
}
this.state.bullets.push(bullet)
EventManager.Instance.emit(EventEnum.BulletBorn, owner)
break
}
case InputType.TimePast: {
const { dt } = input
const { bullets, players } = this.state
for (let i = bullets.length - 1; i >= 0; i--) {
const bullet = bullets[i];
for (let j = players.length - 1; j >= 0; 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) {
EventManager.Instance.emit(EventEnum.ExplosionBorn, bullet.id, {
x: (player.position.x + bullet.position.x) / 2,
y: (player.position.y + bullet.position.y) / 2,
})
player.hp -= WEAPON_DAMAGE
bullets.splice(i, 1)
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) {
bullet.position.x += bullet.direction.x * BULLET_SPEED * dt
bullet.position.y += bullet.direction.y * BULLET_SPEED * dt
}
}
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "1682ed16-4e4f-46b3-8aca-92baecd30b9d",
"files": [],
"subMetas": {},
"userData": {}
}

View 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();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "2aa2e7de-b014-4ee7-a537-4bc99dbf9164",
"files": [],
"subMetas": {},
"userData": {}
}

View 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 })
}
})
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "588dfbf5-0456-472f-8382-746392fb1a06",
"files": [],
"subMetas": {},
"userData": {}
}

View 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)
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "01a37612-1a4a-45ee-8be8-3e3360996442",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,32 @@
import { _decorator, resources, Asset } from 'cc'
import Singleton from '../Base/Singleton'
export class ResourceManager extends Singleton {
static get Instance() {
return super.GetInstance<ResourceManager>()
}
loadRes<T extends Asset>(path: string, type: new (...args: any[]) => T) {
return new Promise<T>((resolve, reject) => {
resources.load(path, type, (err, res) => {
if (err) {
reject(err)
return
}
resolve(res)
})
})
}
loadDir<T extends Asset>(path: string, type: new (...args: any[]) => T) {
return new Promise<T[]>((resolve, reject) => {
resources.loadDir(path, type, (err, res) => {
if (err) {
reject(err)
return
}
resolve(res)
})
})
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "6278727d-3641-46d1-ae43-52b7829402d1",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "7129d004-4256-413c-a2e9-34ee8607d89d",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,151 @@
import { _decorator, Component, Node, Prefab, instantiate, SpriteFrame } from 'cc';
import { PlayerManager } from '../Entity/Player/PlayerManager';
import DataManager from '../Global/DataManager';
import { JoyStickManager } from '../UI/JoyStickManager';
import { ResourceManager } from '../Global/ResourceManager';
import { EntityTypeEnum, InputType, PrefabPathEnum, TexturePathEnum } from '../Enum';
import NetworkManager from '../Global/NetworkManager';
import ObjectPoolManager from '../Global/ObjectPoolManager';
import { BulletManager } from '../Entity/Bullet/BulletManager';
const { ccclass } = _decorator;
@ccclass('BattleManager')
export class BattleManager extends Component {
stage: Node
ui: Node
isInited = false
onLoad() {
this.stage = DataManager.Instance.stage = this.node.getChildByName("Stage")
this.ui = this.node.getChildByName("UI")
}
async start() {
this.clearGame()
await this.loadRes()
this.initScene()
await this.connectServer()
this.isInited = true
}
clearGame() {
this.stage.destroyAllChildren()
this.ui.destroyAllChildren()
}
async loadRes() {
const list = []
for (const type in PrefabPathEnum) {
const p = ResourceManager.Instance.loadRes(PrefabPathEnum[type], Prefab).then((prefab) => {
DataManager.Instance.prefabMap.set(type, prefab)
})
list.push(p)
}
for (const type in TexturePathEnum) {
const p = ResourceManager.Instance.loadDir(TexturePathEnum[type], SpriteFrame).then((spriteFrames) => {
DataManager.Instance.textureMap.set(type, spriteFrames)
})
list.push(p)
}
await Promise.all(list)
}
async initScene() {
this.initJoyStick()
this.initShoot()
this.initMap()
}
async connectServer() {
if (!await NetworkManager.Instance.connect().catch(() => false)) {
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)
const jm = DataManager.Instance.jm = joySitck.getComponent(JoyStickManager)
jm.init()
}
initShoot() {
const prefab = DataManager.Instance.prefabMap.get(EntityTypeEnum.Shoot)
const shoot = instantiate(prefab)
shoot.setParent(this.ui)
}
initMap() {
const prefab = DataManager.Instance.prefabMap.get(EntityTypeEnum.Map1)
const map = instantiate(prefab)
map.setParent(this.stage)
}
update(dt: number) {
if (!this.isInited) {
return
}
this.render()
this.tick(dt)
}
tick(dt: number) {
this.tickPlayer(dt)
this.tickGlobal(dt)
}
tickPlayer(dt: number) {
for (const p of DataManager.Instance.state.players) {
const playerManager = DataManager.Instance.playerMap.get(p.id)
if (!playerManager) {
return
}
playerManager.tick(dt)
}
}
tickGlobal(dt: number) {
DataManager.Instance.applyInput({
type: InputType.TimePast,
dt
})
}
render() {
this.renderPlayer()
this.renderBullet()
}
renderPlayer() {
for (const p of DataManager.Instance.state.players) {
let playerManager = DataManager.Instance.playerMap.get(p.id)
if (!playerManager) {
const playerPrefab = DataManager.Instance.prefabMap.get(p.type)
const player = instantiate(playerPrefab)
player.setParent(this.stage)
playerManager = player.addComponent(PlayerManager)
DataManager.Instance.playerMap.set(p.id, playerManager)
playerManager.init(p)
} else {
playerManager.render(p)
}
}
}
renderBullet() {
for (const b of DataManager.Instance.state.bullets) {
let bulletManager = DataManager.Instance.bulletMap.get(b.id)
if (!bulletManager) {
const bullet = ObjectPoolManager.Instance.get(b.type)
bulletManager = bullet.getComponent(BulletManager) || bullet.addComponent(BulletManager)
DataManager.Instance.bulletMap.set(b.id, bulletManager)
bulletManager.init(b)
} else {
bulletManager.render(b)
}
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "d8c46424-e6ab-4d22-af07-293ce98d8b5b",
"files": [],
"subMetas": {},
"userData": {}
}

View 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);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "a14b4d33-c5f8-455c-a935-dbfd7f3ab62b",
"files": [],
"subMetas": {},
"userData": {}
}

View 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);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "3be66806-c736-419c-b6cc-0dab1e13cbda",
"files": [],
"subMetas": {},
"userData": {}
}

View 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");
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "8ee1bd73-5b3b-48ad-a0a0-5a1d6a08da7d",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "03ce230a-7d62-422c-b453-aafdbec11e91",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,57 @@
import { _decorator, Component, Node, input, Input, EventTouch, Vec2, Vec3, UITransform } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('JoyStickManager')
export class JoyStickManager extends Component {
input: Vec2 = Vec2.ZERO
private body: Node
private stick: Node
private touchStartPos: Vec2
private defaultPos: Vec2
private radius: number = 0
init() {
this.body = this.node.getChildByName("Body")
this.stick = this.body.getChildByName("Stick")
const { x, y } = this.body.position
this.defaultPos = new Vec2(x, y)
this.radius = this.body.getComponent(UITransform).contentSize.x / 2
input.on(Input.EventType.TOUCH_START, this.onTouchMove, this);
input.on(Input.EventType.TOUCH_MOVE, this.onTouchMove, this);
input.on(Input.EventType.TOUCH_END, this.onTouchEnd, this);
}
onDestroy() {
input.off(Input.EventType.TOUCH_START, this.onTouchMove, this);
input.off(Input.EventType.TOUCH_MOVE, this.onTouchMove, this);
input.off(Input.EventType.TOUCH_END, this.onTouchEnd, this);
}
onTouchMove(e: EventTouch) {
const touchPos = e.touch.getUILocation()
if (!this.touchStartPos) {
this.touchStartPos = touchPos.clone()
this.body.setPosition(this.touchStartPos.x, this.touchStartPos.y);
}
const stickPos = new Vec2(touchPos.x - this.touchStartPos.x, touchPos.y - this.touchStartPos.y)
const len = stickPos.length()
if (len > this.radius) {
stickPos.multiplyScalar(this.radius / len)
}
this.stick.setPosition(stickPos.x, stickPos.y)
this.input = stickPos.clone().normalize()
}
onTouchEnd() {
this.body.setPosition(this.defaultPos.x, this.defaultPos.y)
this.stick.setPosition(0, 0)
this.touchStartPos = undefined
this.input = Vec2.ZERO
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "bfc9a6e3-7ecf-4422-af5c-670bff4ec928",
"files": [],
"subMetas": {},
"userData": {}
}

View 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
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "0b36580d-5fc7-40c1-9ac0-0fb78a685fd1",
"files": [],
"subMetas": {},
"userData": {}
}

View 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)
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "26da1a71-eb0d-463d-b2d6-fbc64bf0ab89",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,13 @@
import { _decorator, Component, Node } from 'cc';
import { EventEnum } from '../Enum';
import EventManager from '../Global/EventManager';
const { ccclass, property } = _decorator;
@ccclass('ShootManager')
export class ShootManager extends Component {
shoot() {
EventManager.Instance.emit(EventEnum.WeaponShoot)
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "f4c4bbdf-77d3-44a3-88c2-29f40401dab7",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "f395bd07-24d1-424e-bf3c-3276de3d9d22",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,11 @@
import { SpriteFrame } from "cc"
const INDEX_REG = /\((\d+)\)/
const getNumberWithinString = (str: string) => parseInt(str.match(INDEX_REG)?.[1] || '0')
export const sortSpriteFrame = (spriteFrame: Array<SpriteFrame>) =>
spriteFrame.sort((a, b) => getNumberWithinString(a.name) - getNumberWithinString(b.name))
export const rad2Angle = (rad: number) => rad / Math.PI * 180

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "2e280f2e-52a3-465a-acf5-fb412ef51d6b",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,15 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "361398e8-25a2-4476-a5dd-833ff68e087b",
"files": [],
"subMetas": {},
"userData": {
"isBundle": true,
"bundleName": "resources",
"priority": 8,
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "35ebed99-20d7-4d22-b7af-28eeb7960a84",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,142 @@
[
{
"__type__": "cc.Prefab",
"_name": "Bullet",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false,
"asyncLoadAssets": false
},
{
"__type__": "cc.Node",
"_name": "Bullet",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
},
{
"__id__": 4
}
],
"_prefab": {
"__id__": 6
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 110.951,
"y": 0,
"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": 100,
"height": 100
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "607/QqeHhEZJSeteJoUog1"
},
{
"__type__": "cc.Sprite",
"_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
},
"_spriteFrame": {
"__uuid__": "23c36f17-b533-41fc-ada4-4c3408ec5597@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "f4rVayGkpKJq+xMADzqU5V"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "bblSIxXVJAw4TCQ+fTNSBM"
}
]

View File

@@ -0,0 +1,13 @@
{
"ver": "1.1.39",
"importer": "prefab",
"imported": true,
"uuid": "099548f8-37b4-475d-86df-9ad4a5ecfd77",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "Bullet"
}
}

View File

@@ -0,0 +1,142 @@
[
{
"__type__": "cc.Prefab",
"_name": "Explosion",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false,
"asyncLoadAssets": false
},
{
"__type__": "cc.Node",
"_name": "Explosion",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
},
{
"__id__": 4
}
],
"_prefab": {
"__id__": 6
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 110.951,
"y": 0,
"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": 100,
"height": 100
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "607/QqeHhEZJSeteJoUog1"
},
{
"__type__": "cc.Sprite",
"_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
},
"_spriteFrame": {
"__uuid__": "2c4e3bb3-7336-4d4e-a8d7-3eafa95d846f@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "f4rVayGkpKJq+xMADzqU5V"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "bblSIxXVJAw4TCQ+fTNSBM"
}
]

View File

@@ -0,0 +1,13 @@
{
"ver": "1.1.39",
"importer": "prefab",
"imported": true,
"uuid": "147de574-5396-440e-af4f-e4af24888059",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "Explosion"
}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "9348a0ae-1f83-44fe-ae79-892e1db86d1a",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View 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"
}
]

View File

@@ -0,0 +1,13 @@
{
"ver": "1.1.39",
"importer": "prefab",
"imported": true,
"uuid": "7b0c739f-cf46-48f7-8c15-c97ab34268fe",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "PlayerItem"
}
}

View 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"
}
]

View File

@@ -0,0 +1,13 @@
{
"ver": "1.1.39",
"importer": "prefab",
"imported": true,
"uuid": "b91571d9-7804-4e62-b9d4-eef2f8f0cadd",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "RoomItem"
}
}

View File

@@ -0,0 +1,580 @@
[
{
"__type__": "cc.Prefab",
"_name": "JoyStick",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false,
"asyncLoadAssets": false
},
{
"__type__": "cc.Node",
"_name": "JoyStick",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [
{
"__id__": 2
}
],
"_active": true,
"_components": [
{
"__id__": 22
},
{
"__id__": 24
},
{
"__id__": 26
}
],
"_prefab": {
"__id__": 28
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -480,
"y": -320,
"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.Node",
"_name": "Body",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 3
},
{
"__id__": 11
}
],
"_active": true,
"_components": [
{
"__id__": 17
},
{
"__id__": 19
}
],
"_prefab": {
"__id__": 21
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 150,
"y": 150,
"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.Node",
"_name": "Base",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 4
},
{
"__id__": 6
},
{
"__id__": 8
}
],
"_prefab": {
"__id__": 10
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"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__": 3
},
"_enabled": true,
"__prefab": {
"__id__": 5
},
"_contentSize": {
"__type__": "cc.Size",
"width": 200,
"height": 200
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "6ejPyOfqRE25w9zJbDGdh3"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 3
},
"_enabled": true,
"__prefab": {
"__id__": 7
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 100
},
"_spriteFrame": {
"__uuid__": "d9e82fae-bcb5-4fed-82a9-fbed98c5e079@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "396m9Nih1MWY7F/ybvFrtB"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 3
},
"_enabled": true,
"__prefab": {
"__id__": 9
},
"_alignFlags": 45,
"_target": null,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_horizontalCenter": 0,
"_verticalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 256,
"_originalHeight": 256,
"_alignMode": 2,
"_lockFlags": 0,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "8aBKAmKmJBXaZ2Dk38BikC"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "2cvfYjo35GkoZTmD0R1ZON"
},
{
"__type__": "cc.Node",
"_name": "Stick",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 12
},
{
"__id__": 14
}
],
"_prefab": {
"__id__": 16
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 0.3,
"y": 0.3,
"z": 1
},
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 11
},
"_enabled": true,
"__prefab": {
"__id__": 13
},
"_contentSize": {
"__type__": "cc.Size",
"width": 256,
"height": 256
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "68QvW/9ZZAdJjB1N+Guag4"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 11
},
"_enabled": true,
"__prefab": {
"__id__": 15
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "d9e82fae-bcb5-4fed-82a9-fbed98c5e079@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "0eWKGBz4ZAersuhv4N5kwz"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "d4qE3f1kdGBLQFmhtG8C+3"
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 18
},
"_contentSize": {
"__type__": "cc.Size",
"width": 200,
"height": 200
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "e1c6xTNM1KiYCaRC1S5oje"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 20
},
"_alignFlags": 12,
"_target": null,
"_left": 50,
"_right": 0,
"_top": 0,
"_bottom": 50,
"_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": "e48MgFyt9PBKx5Ys0BJg4L"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "87eH76xUVLFb6r1A+7tq4F"
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 23
},
"_contentSize": {
"__type__": "cc.Size",
"width": 960,
"height": 640
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "205oXiJoZHkaJi8XBhtLEO"
},
{
"__type__": "bfc9abjfs9EIq9cZwv/Tsko",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 25
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "20KqWYRFJKzoRcoD115OfT"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 27
},
"_alignFlags": 45,
"_target": null,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_horizontalCenter": 0,
"_verticalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 960,
"_originalHeight": 640,
"_alignMode": 2,
"_lockFlags": 0,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "76WrdM2MBFXbRZNvn2wO8t"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "dcSQx/IBRN555vh0smiDUk"
}
]

View File

@@ -0,0 +1,13 @@
{
"ver": "1.1.39",
"importer": "prefab",
"imported": true,
"uuid": "230d01f4-702b-4295-b34c-d87e25305d63",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "JoyStick"
}
}

View File

@@ -0,0 +1,180 @@
[
{
"__type__": "cc.Prefab",
"_name": "Map1",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false,
"asyncLoadAssets": false
},
{
"__type__": "cc.Node",
"_name": "Map1",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
},
{
"__id__": 4
},
{
"__id__": 6
}
],
"_prefab": {
"__id__": 8
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"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": 960,
"height": 640
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "7ckWiSysVO96kRBBg+KESt"
},
{
"__type__": "cc.Sprite",
"_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
},
"_spriteFrame": {
"__uuid__": "155ebd7e-9357-4155-acfc-fb5438af3d48@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 2,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "26C4/mRGRLBr2jAzW8ztmg"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 7
},
"_alignFlags": 45,
"_target": null,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_horizontalCenter": 0,
"_verticalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 1000,
"_originalHeight": 1000,
"_alignMode": 2,
"_lockFlags": 0,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "ecteqJwWZC+a13hCI929/h"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "9dDZjW4/pG3qtXeK7m3DFi"
}
]

View File

@@ -0,0 +1,13 @@
{
"ver": "1.1.39",
"importer": "prefab",
"imported": true,
"uuid": "ab1c7b4f-35ac-4610-98a9-ea4b5b8170f8",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "Map1"
}
}

View File

@@ -0,0 +1,690 @@
[
{
"__type__": "cc.Prefab",
"_name": "Player",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false,
"asyncLoadAssets": false
},
{
"__type__": "cc.Node",
"_name": "Player",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 18
},
{
"__id__": 22
}
],
"_active": true,
"_components": [
{
"__id__": 28
},
{
"__id__": 30
}
],
"_prefab": {
"__id__": 32
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"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.Node",
"_name": "HP",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 3
}
],
"_active": true,
"_components": [
{
"__id__": 11
},
{
"__id__": 13
},
{
"__id__": 15
}
],
"_prefab": {
"__id__": 17
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 70,
"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.Node",
"_name": "Bar",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 4
},
{
"__id__": 6
},
{
"__id__": 8
}
],
"_prefab": {
"__id__": 10
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -50,
"y": 0,
"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__": 3
},
"_enabled": true,
"__prefab": {
"__id__": 5
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"height": 15
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "6eSfVOfMxPjb1oQVZ1z5hY"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 3
},
"_enabled": true,
"__prefab": {
"__id__": 7
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 0,
"b": 0,
"a": 255
},
"_spriteFrame": {
"__uuid__": "24a704da-2867-446d-8d1a-5e920c75e09d@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 1,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "267GXyiYJB6qxCg6pLEfLQ"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 3
},
"_enabled": true,
"__prefab": {
"__id__": 9
},
"_alignFlags": 8,
"_target": null,
"_left": 0,
"_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": "160ZgDPIFBEZ5Msv1mYMvN"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "35OAlXyaBOBpLPAOKsDZHk"
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 12
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"height": 15
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "ca65l+rt9Iz5il0zQDlfgE"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 14
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_spriteFrame": {
"__uuid__": "9fd900dd-221b-4f89-8f2c-fba34243c835@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 1,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "796J69Ia1LgrmmxsVBavZU"
},
{
"__type__": "cc.ProgressBar",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 16
},
"_barSprite": {
"__id__": 6
},
"_mode": 0,
"_totalLength": 100,
"_progress": 1,
"_reverse": false,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "d2mnLSm7RHF7V3bD57PvC5"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "29DaYGvxpFo5cOAmvhl1Uj"
},
{
"__type__": "cc.Node",
"_name": "Nickname",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 19
}
],
"_prefab": {
"__id__": 21
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"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__": 18
},
"_enabled": true,
"__prefab": {
"__id__": 20
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"height": 100
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "8blUJZ4nJKpKsLO2YpEChI"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "5adoggTLFPToeEZEIA7Yh3"
},
{
"__type__": "cc.Node",
"_name": "Label",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 23
},
{
"__id__": 25
}
],
"_prefab": {
"__id__": 27
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 98.845,
"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__": 22
},
"_enabled": true,
"__prefab": {
"__id__": 24
},
"_contentSize": {
"__type__": "cc.Size",
"width": 110.72,
"height": 50.4
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "2a/IDEWZRPcb6AKU5/XAlD"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 22
},
"_enabled": true,
"__prefab": {
"__id__": 26
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_string": "nickname",
"_horizontalAlign": 1,
"_verticalAlign": 1,
"_actualFontSize": 24,
"_fontSize": 24,
"_fontFamily": "Arial",
"_lineHeight": 40,
"_overflow": 0,
"_enableWrapText": true,
"_font": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_isItalic": false,
"_isBold": true,
"_isUnderline": false,
"_underlineHeight": 2,
"_cacheMode": 0,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "71ZjYMvjBES7FqZGSo1L00"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "03OAmogbVI5qDqTUJvplOC"
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 29
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"height": 100
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "43sIN2Al5OsJRxFqY+HJTV"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 31
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "f0f5e564-2d98-4de1-bb92-794eeb1acffc@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "48V6DZW5BPxIbiTPVjSL37"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "60xKi1fHZAl6spWUrSZzlZ"
}
]

View File

@@ -0,0 +1,13 @@
{
"ver": "1.1.39",
"importer": "prefab",
"imported": true,
"uuid": "d565d84f-56c4-4aa3-831c-99db0a0d2390",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "Player"
}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "d4aded25-46cd-4911-b695-170d2eb72fd6",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,275 @@
[
{
"__type__": "cc.Prefab",
"_name": "Shoot",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false,
"asyncLoadAssets": false
},
{
"__type__": "cc.Node",
"_name": "Shoot",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
},
{
"__id__": 4
},
{
"__id__": 6
},
{
"__id__": 8
},
{
"__id__": 11
}
],
"_prefab": {
"__id__": 13
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 330,
"y": -170,
"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": 200,
"height": 200
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "3ayBLC6LxFz7oq0ZzKG3NX"
},
{
"__type__": "cc.Sprite",
"_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": 100
},
"_spriteFrame": {
"__uuid__": "d9e82fae-bcb5-4fed-82a9-fbed98c5e079@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "63G/jWiFtOYLM6CEMTwaZ5"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 7
},
"_alignFlags": 36,
"_target": null,
"_left": 0,
"_right": 50,
"_top": 0,
"_bottom": 50,
"_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": "c6JBLKH2tKrZRkvm2uowFn"
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 9
},
"clickEvents": [
{
"__id__": 10
}
],
"_interactable": true,
"_transition": 3,
"_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": {
"__uuid__": "d9e82fae-bcb5-4fed-82a9-fbed98c5e079@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_hoverSprite": null,
"_pressedSprite": null,
"_disabledSprite": null,
"_duration": 0.1,
"_zoomScale": 0.9,
"_target": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "a6u7mmf6RAVatiJ06E5rQC"
},
{
"__type__": "cc.ClickEvent",
"target": {
"__id__": 1
},
"component": "",
"_componentId": "f4c4bvfd9NEo4jCKfQEAdq3",
"handler": "shoot",
"customEventData": ""
},
{
"__type__": "f4c4bvfd9NEo4jCKfQEAdq3",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 12
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "38y7yDAz5Eko6zTvyWDBpA"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "a02fCGCDhFvIHiQOXl0NzD"
}
]

Some files were not shown because too many files have changed in this diff Show More