From 55542871efa338cc179d328011187a49ce90edfd Mon Sep 17 00:00:00 2001 From: walkpan Date: Thu, 18 Jul 2024 08:38:58 +0800 Subject: [PATCH] ddd --- assets/resources/game/map/map_rpg.prefab | 250 +++++++++++++++--- assets/resources/game/player/player.prefab | 4 +- .../script/game/common/SingletonModuleComp.ts | 4 +- assets/script/game/data.meta | 9 + assets/script/game/data/data.ts | 35 +++ assets/script/game/data/data.ts.meta | 9 + assets/script/game/data/dataModelComp.ts | 46 ++++ assets/script/game/data/dataModelComp.ts.meta | 9 + assets/script/game/data/dataViewComp.ts | 26 ++ assets/script/game/data/dataViewComp.ts.meta | 9 + assets/script/game/data/dataViewVM.ts | 23 ++ assets/script/game/data/dataViewVM.ts.meta | 9 + assets/script/game/initialize/Initialize.ts | 8 +- .../game/initialize/view/LoadingViewComp.ts | 5 +- assets/script/game/map/view/MapViewComp.ts | 3 +- assets/script/game/role/Role.ts | 16 +- assets/script/game/role/view/RoleViewComp.ts | 8 +- .../role/view/RoleViewUIControllerComp.ts | 14 - 18 files changed, 409 insertions(+), 78 deletions(-) create mode 100644 assets/script/game/data.meta create mode 100644 assets/script/game/data/data.ts create mode 100644 assets/script/game/data/data.ts.meta create mode 100644 assets/script/game/data/dataModelComp.ts create mode 100644 assets/script/game/data/dataModelComp.ts.meta create mode 100644 assets/script/game/data/dataViewComp.ts create mode 100644 assets/script/game/data/dataViewComp.ts.meta create mode 100644 assets/script/game/data/dataViewVM.ts create mode 100644 assets/script/game/data/dataViewVM.ts.meta diff --git a/assets/resources/game/map/map_rpg.prefab b/assets/resources/game/map/map_rpg.prefab index a1fe1f50..8cc75b27 100644 --- a/assets/resources/game/map/map_rpg.prefab +++ b/assets/resources/game/map/map_rpg.prefab @@ -28,17 +28,17 @@ "_active": true, "_components": [ { - "__id__": 58 + "__id__": 66 }, { - "__id__": 60 + "__id__": 68 }, { - "__id__": 62 + "__id__": 70 } ], "_prefab": { - "__id__": 64 + "__id__": 72 }, "_lpos": { "__type__": "cc.Vec3", @@ -197,17 +197,17 @@ "_active": true, "_components": [ { - "__id__": 51 + "__id__": 59 }, { - "__id__": 53 + "__id__": 61 }, { - "__id__": 55 + "__id__": 63 } ], "_prefab": { - "__id__": 57 + "__id__": 65 }, "_lpos": { "__type__": "cc.Vec3", @@ -254,17 +254,17 @@ "__id__": 38 }, { - "__id__": 42 + "__id__": 50 } ], "_active": true, "_components": [ { - "__id__": 48 + "__id__": 56 } ], "_prefab": { - "__id__": 50 + "__id__": 58 }, "_lpos": { "__type__": "cc.Vec3", @@ -973,15 +973,19 @@ "_parent": { "__id__": 7 }, - "_children": [], - "_active": true, - "_components": [ + "_children": [ { "__id__": 39 } ], + "_active": true, + "_components": [ + { + "__id__": 47 + } + ], "_prefab": { - "__id__": 41 + "__id__": 49 }, "_lpos": { "__type__": "cc.Vec3", @@ -1012,6 +1016,190 @@ }, "_id": "" }, + { + "__type__": "cc.Node", + "_name": "data", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": { + "__id__": 38 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 40 + }, + { + "__id__": 42 + }, + { + "__id__": 44 + } + ], + "_prefab": { + "__id__": 46 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -186.807, + "y": -525.104, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_mobility": 0, + "_layer": 1, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 39 + }, + "_enabled": true, + "__prefab": { + "__id__": 41 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 84.51171875, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "99+7M3vtBKVKL1+HWxsqgs" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 39 + }, + "_enabled": true, + "__prefab": { + "__id__": 43 + }, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_string": "label", + "_horizontalAlign": 1, + "_verticalAlign": 1, + "_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, + "_enableOutline": false, + "_outlineColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_outlineWidth": 2, + "_enableShadow": false, + "_shadowColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_shadowOffset": { + "__type__": "cc.Vec2", + "x": 2, + "y": 2 + }, + "_shadowBlur": 2, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "0a/R7r3dhB140c/1czByKm" + }, + { + "__type__": "545c05XsG9GDJispEGWKvYv", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 39 + }, + "_enabled": true, + "__prefab": { + "__id__": 45 + }, + "templateMode": false, + "watchPath": "data.name", + "labelType": "cc.Label", + "watchPathArr": [], + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "b5tQWW68RLQ5wXfJLcSi2h" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "c506SM3uVMs4Dt+gEWBotY", + "instance": null, + "targetOverrides": null, + "nestedPrefabInstanceRoots": null + }, { "__type__": "cc.UITransform", "_name": "", @@ -1022,7 +1210,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 40 + "__id__": 48 }, "_contentSize": { "__type__": "cc.Size", @@ -1065,14 +1253,14 @@ "_active": true, "_components": [ { - "__id__": 43 + "__id__": 51 }, { - "__id__": 45 + "__id__": 53 } ], "_prefab": { - "__id__": 47 + "__id__": 55 }, "_lpos": { "__type__": "cc.Vec3", @@ -1109,11 +1297,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 42 + "__id__": 50 }, "_enabled": true, "__prefab": { - "__id__": 44 + "__id__": 52 }, "_contentSize": { "__type__": "cc.Size", @@ -1137,11 +1325,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 42 + "__id__": 50 }, "_enabled": true, "__prefab": { - "__id__": 46 + "__id__": 54 }, "_id": "" }, @@ -1172,7 +1360,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 49 + "__id__": 57 }, "_contentSize": { "__type__": "cc.Size", @@ -1213,7 +1401,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 52 + "__id__": 60 }, "_contentSize": { "__type__": "cc.Size", @@ -1241,7 +1429,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 54 + "__id__": 62 }, "camera": { "__id__": 3 @@ -1256,7 +1444,7 @@ "__id__": 38 }, "entityLayer": { - "__id__": 45 + "__id__": 53 }, "isFollowPlayer": true, "_id": "" @@ -1275,7 +1463,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 56 + "__id__": 64 }, "_id": "" }, @@ -1306,7 +1494,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 59 + "__id__": 67 }, "_contentSize": { "__type__": "cc.Size", @@ -1334,7 +1522,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 61 + "__id__": 69 }, "_cameraComponent": { "__id__": 3 @@ -1356,7 +1544,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 63 + "__id__": 71 }, "_alignFlags": 45, "_target": null, diff --git a/assets/resources/game/player/player.prefab b/assets/resources/game/player/player.prefab index 203aa968..5869d3ec 100644 --- a/assets/resources/game/player/player.prefab +++ b/assets/resources/game/player/player.prefab @@ -250,8 +250,8 @@ }, "_lscale": { "__type__": "cc.Vec3", - "x": 0.3, - "y": 0.3, + "x": 0.2, + "y": 0.2, "z": 1 }, "_mobility": 0, diff --git a/assets/script/game/common/SingletonModuleComp.ts b/assets/script/game/common/SingletonModuleComp.ts index 8c0dc157..9e288455 100644 --- a/assets/script/game/common/SingletonModuleComp.ts +++ b/assets/script/game/common/SingletonModuleComp.ts @@ -9,7 +9,7 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec import { Initialize } from "../initialize/Initialize"; import { GameMap } from "../map/GameMap"; import { Role } from "../role/Role"; - +import { data } from "../data/data"; /** 游戏模块 */ @ecs.register('SingletonModule') export class SingletonModuleComp extends ecs.Comp { @@ -19,6 +19,8 @@ export class SingletonModuleComp extends ecs.Comp { map: GameMap = null!; /** 游戏主角 */ own: Role = null; + /** 游戏数据 */ + data:data = null!; reset() { } } diff --git a/assets/script/game/data.meta b/assets/script/game/data.meta new file mode 100644 index 00000000..cd323577 --- /dev/null +++ b/assets/script/game/data.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.2.0", + "importer": "directory", + "imported": true, + "uuid": "7d9b27df-701e-44ee-8732-b53f9d22cca2", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/script/game/data/data.ts b/assets/script/game/data/data.ts new file mode 100644 index 00000000..43de0b38 --- /dev/null +++ b/assets/script/game/data/data.ts @@ -0,0 +1,35 @@ +import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; +import { dataModelComp } from "./dataModelComp"; +import { dataViewComp } from "./dataViewComp"; +/** data 模块 */ +@ecs.register(`data`) +export class data extends ecs.Entity { + /** ---------- 数据层 ---------- */ + dataModel!: dataModelComp; + + /** ---------- 业务层 ---------- */ + // dataBll!: dataBllComp; + + /** ---------- 视图层 ---------- */ + dataView!: dataViewComp; + + /** 实始添加的数据层组件 */ + protected init() { + this.addComponents(dataViewComp,dataModelComp); + } + + /** 模块资源释放 */ + destroy() { + // 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放 + super.destroy(); + } +} + +/** data 模块业务逻辑系统组件,如无业务逻辑处理可删除此对象 */ +export class EcsdataSystem extends ecs.System { + constructor() { + super(); + + // this.add(new ecs.ComblockSystem()); + } +} diff --git a/assets/script/game/data/data.ts.meta b/assets/script/game/data/data.ts.meta new file mode 100644 index 00000000..7b361e0a --- /dev/null +++ b/assets/script/game/data/data.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "cb9afa42-2112-471e-b86c-79407ba6abd4", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/script/game/data/dataModelComp.ts b/assets/script/game/data/dataModelComp.ts new file mode 100644 index 00000000..1fb03927 --- /dev/null +++ b/assets/script/game/data/dataModelComp.ts @@ -0,0 +1,46 @@ +import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; +import { VM } from "../../../../extensions/oops-plugin-framework/assets/libs/model-view/ViewModel"; + +/** 数据层对象 */ +@ecs.register('dataModel') +export class dataModelComp extends ecs.Comp { + /** 提供 MVVM 组件使用的数据 */ + private vm: dataVM = new dataVM(); + + /** 显示数据添加到 MVVM 框架中监视 */ + vmAdd() { + console.log("dataModelComp vmAdd"); + VM.add(this.vm, "data"); + } + + /** 显示数据从 MVVM 框架中移除 */ + vmRemove() { + VM.remove("data"); + } + + /** 数据层组件移除时,重置所有数据为默认值 */ + reset() { + for (var key in this.vm) { + delete this.vm[key]; + } + } +} + +class dataVM { + /** 英雄名称 */ + name: string = "数据测试"; + /** 当前等级 */ + porwer: number = 0; + /** 当前经验 */ + def: number = 0; + /** 下级经验 */ + speed: number = 0; + + reset() { + this.name = ""; + this.porwer = 0; + this.def = 0; + this.speed = 0; + } + +} \ No newline at end of file diff --git a/assets/script/game/data/dataModelComp.ts.meta b/assets/script/game/data/dataModelComp.ts.meta new file mode 100644 index 00000000..b958d579 --- /dev/null +++ b/assets/script/game/data/dataModelComp.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "0aefc30a-9392-4ada-b3d0-8c15625e8cfc", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/script/game/data/dataViewComp.ts b/assets/script/game/data/dataViewComp.ts new file mode 100644 index 00000000..9e49af71 --- /dev/null +++ b/assets/script/game/data/dataViewComp.ts @@ -0,0 +1,26 @@ +import { _decorator } from "cc"; +import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; +import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; + +const { ccclass, property } = _decorator; + +/** 视图层对象 */ +@ccclass('dataViewComp') +@ecs.register('dataView', true) +export class dataViewComp extends CCComp { + /** 视图层逻辑代码分离演示 */ + start() { + var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象 + // this.on(ModuleEvent.Cmd, this.onHandler, this); + } + + /** 全局消息逻辑处理 */ + private onHandler(event: string, args: any) { + console.log(event, args); + } + + /** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */ + reset() { + this.node.destroy(); + } +} \ No newline at end of file diff --git a/assets/script/game/data/dataViewComp.ts.meta b/assets/script/game/data/dataViewComp.ts.meta new file mode 100644 index 00000000..edad6608 --- /dev/null +++ b/assets/script/game/data/dataViewComp.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "8ae6d033-ff0f-44d5-9ff7-c57751bd4ea1", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/script/game/data/dataViewVM.ts b/assets/script/game/data/dataViewVM.ts new file mode 100644 index 00000000..d2bf2537 --- /dev/null +++ b/assets/script/game/data/dataViewVM.ts @@ -0,0 +1,23 @@ +import { _decorator } from "cc"; +import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; +import { CCVMParentComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCVMParentComp"; + +const { ccclass, property } = _decorator; + +/** 视图层对象 - 支持 MVVM 框架的数据绑定 */ +@ccclass('dataViewVMComp') +@ecs.register('dataViewVM', false) +export class dataViewVMComp extends CCVMParentComp { + /** 脚本控制的界面 MVVM 框架绑定数据 */ + data: any = {}; + + /** 视图层逻辑代码分离演示 */ + start() { + // var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象 + } + + /** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */ + reset() { + this.node.destroy(); + } +} \ No newline at end of file diff --git a/assets/script/game/data/dataViewVM.ts.meta b/assets/script/game/data/dataViewVM.ts.meta new file mode 100644 index 00000000..bb04b7c1 --- /dev/null +++ b/assets/script/game/data/dataViewVM.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "4209bcee-3867-4c0b-83c9-a4eeee989328", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/script/game/initialize/Initialize.ts b/assets/script/game/initialize/Initialize.ts index a87c5ecf..f9351ad3 100644 --- a/assets/script/game/initialize/Initialize.ts +++ b/assets/script/game/initialize/Initialize.ts @@ -11,7 +11,7 @@ import { AsyncQueue, NextFunction } from "../../../../extensions/oops-plugin-fra import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { UIID } from "../common/config/GameUIConfig"; import { LoadingViewComp } from "./view/LoadingViewComp"; - +import {data} from "../data/data"; /** * 游戏进入初始化模块 * 1、热更新 @@ -20,10 +20,12 @@ import { LoadingViewComp } from "./view/LoadingViewComp"; @ecs.register(`Initialize`) export class Initialize extends ecs.Entity { LoadingView!: LoadingViewComp; - + data:data=null!; protected init() { - var queue: AsyncQueue = new AsyncQueue(); + this.data=ecs.getEntity(data); + this.data.dataModel.vmAdd(); + var queue: AsyncQueue = new AsyncQueue(); // 加载自定义资源 this.loadCustom(queue); // 加载多语言包 diff --git a/assets/script/game/initialize/view/LoadingViewComp.ts b/assets/script/game/initialize/view/LoadingViewComp.ts index 3c837599..b22ece12 100644 --- a/assets/script/game/initialize/view/LoadingViewComp.ts +++ b/assets/script/game/initialize/view/LoadingViewComp.ts @@ -4,14 +4,14 @@ * @LastEditors: dgflash * @LastEditTime: 2022-08-17 13:46:25 */ -import { _decorator } from "cc"; +import { _decorator ,v3,Vec3} from "cc"; import { oops } from "../../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { CCVMParentComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCVMParentComp"; import { UIID } from "../../common/config/GameUIConfig"; import { smc } from "../../common/SingletonModuleComp"; import { GameMap } from "../../map/GameMap"; - +import { Role } from "../../role/Role"; const { ccclass, property } = _decorator; /** 游戏资源加载 */ @@ -51,7 +51,6 @@ export class LoadingViewComp extends CCVMParentComp { start() { this.loadRes(); } - /** 加载资源 */ private async loadRes() { this.data.progress = 0; diff --git a/assets/script/game/map/view/MapViewComp.ts b/assets/script/game/map/view/MapViewComp.ts index 1b3139bc..2976cc8f 100644 --- a/assets/script/game/map/view/MapViewComp.ts +++ b/assets/script/game/map/view/MapViewComp.ts @@ -28,7 +28,6 @@ export class MapViewComp extends CCComp { start() { this.scene = this.getComponent(MapViewScene); - this.addHero(); } @@ -36,7 +35,7 @@ export class MapViewComp extends CCComp { private mapLoaded() { - + } /** 添加玩家 */ diff --git a/assets/script/game/role/Role.ts b/assets/script/game/role/Role.ts index 25a7d640..407ecc3b 100644 --- a/assets/script/game/role/Role.ts +++ b/assets/script/game/role/Role.ts @@ -15,7 +15,6 @@ import Charactor from "../map/view/map/charactor/Charactor"; import { RoleModelComp } from "./model/RoleModelComp"; import { RoleSpine } from "./view/RoleSpine"; import { RoleViewComp } from "./view/RoleViewComp"; -import { RoleViewUIControllerComp } from "./view/RoleViewUIControllerComp"; /** 角色实体 */ @ecs.register(`Role`) @@ -24,7 +23,6 @@ export class Role extends ecs.Entity { RoleModel!: RoleModelComp; // 视图层 RoleView!: RoleViewComp; - RoleViewUIController!: RoleViewUIControllerComp; protected init() { this.addComponents( @@ -57,17 +55,5 @@ export class Role extends ecs.Entity { } } - /** 摇撼控制 */ - loadJoystick() { - var uic: UICallbacks = { - onAdded: (node: Node, params: any) => { - var comp = node.getComponent(RoleViewUIControllerComp) as ecs.Comp; - this.add(comp); - } - }; - oops.gui.open(UIID.Role_Controller, null, uic); - } - removeJoystick() { - oops.gui.remove(UIID.Role_Controller); - } + } \ No newline at end of file diff --git a/assets/script/game/role/view/RoleViewComp.ts b/assets/script/game/role/view/RoleViewComp.ts index 88b0fe90..53153040 100644 --- a/assets/script/game/role/view/RoleViewComp.ts +++ b/assets/script/game/role/view/RoleViewComp.ts @@ -28,13 +28,7 @@ export class RoleViewComp extends CCComp { this.charactor = this.getComponent(Charactor); } - /** - * 摇杆移动 - * @param dir 移动方向 - */ - runJoystick(dir: Vec3) { - this.charactor.joystick(dir); - } + reset() { this.node.destroy(); diff --git a/assets/script/game/role/view/RoleViewUIControllerComp.ts b/assets/script/game/role/view/RoleViewUIControllerComp.ts index abdecced..17a273c5 100644 --- a/assets/script/game/role/view/RoleViewUIControllerComp.ts +++ b/assets/script/game/role/view/RoleViewUIControllerComp.ts @@ -10,31 +10,17 @@ import { ecs } from '../../../../../extensions/oops-plugin-framework/assets/libs import { CCComp } from '../../../../../extensions/oops-plugin-framework/assets/module/common/CCComp'; import { smc } from '../../common/SingletonModuleComp'; import { Role } from '../Role'; -import { JoystickDataType, RoleViewUIJoystick, SpeedType } from './RoleViewUIJoystick'; const { ccclass, property } = _decorator; @ccclass("RoleViewUIControllerComp") @ecs.register('RoleViewUIController', false) export class RoleViewUIControllerComp extends CCComp { - @property({ type: RoleViewUIJoystick }) - joystick: RoleViewUIJoystick = null!; private target: Role = null!; start() { this.target = smc.own; - this.joystick.onController = (event: EventTouch, data: JoystickDataType) => { - switch (data.type) { - case SpeedType.NORMAL: - case SpeedType.FAST: - this.target.RoleView.runJoystick(data.vector); - break; - case SpeedType.STOP: - this.target.RoleView.runJoystick(Vec3.ZERO); - break; - } - } } onDestroy() {