ddd
This commit is contained in:
@@ -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<ecs.Comp>(
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user