mirror of
https://gitee.com/dgflash/oops-framework.git
synced 2026-05-14 14:21:29 +08:00
.
This commit is contained in:
@@ -227,7 +227,7 @@
|
||||
"_priority": 1073741824,
|
||||
"_fov": 45,
|
||||
"_fovAxis": 0,
|
||||
"_orthoHeight": 419.7772828507795,
|
||||
"_orthoHeight": 481.2709620476611,
|
||||
"_near": 1,
|
||||
"_far": 2000,
|
||||
"_color": {
|
||||
|
||||
5
assets/script/game/role/RoleEvent.ts
Normal file
5
assets/script/game/role/RoleEvent.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
/** 角色模块全局事件 */
|
||||
export enum RoleEvent {
|
||||
/** 修改职业事件 */
|
||||
ChangeJob = "ChangeJob"
|
||||
}
|
||||
9
assets/script/game/role/RoleEvent.ts.meta
Normal file
9
assets/script/game/role/RoleEvent.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "a2e7abd7-21aa-4dfc-ab5c-6dd0dfba2a7c",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -5,9 +5,11 @@
|
||||
* @LastEditTime: 2022-01-29 11:46:38
|
||||
*/
|
||||
|
||||
import { Message } from "../../../core/common/event/MessageManager";
|
||||
import { ecs } from "../../../core/libs/ECS";
|
||||
import { RoleJobModelComp } from "../model/RoleJobModelComp";
|
||||
import { Role } from "../Role";
|
||||
import { RoleEvent } from "../RoleEvent";
|
||||
|
||||
/**
|
||||
* 角色转职
|
||||
@@ -38,17 +40,12 @@ export class RoleChangeJobSystem extends ecs.ComblockSystem implements ecs.IEnti
|
||||
|
||||
entityEnter(entities: Role[]): void {
|
||||
for (let e of entities) {
|
||||
// console.log("【转职前】角色属性");
|
||||
// e.RoleModel.toString();
|
||||
|
||||
// 数值更新
|
||||
e.RoleJobModel.id = e.RoleChangeJob.jobId;
|
||||
|
||||
// console.log("【转职后】角色属性");
|
||||
// e.RoleModel.toString();
|
||||
// 转职事件
|
||||
Message.dispatchEvent(RoleEvent.ChangeJob);
|
||||
|
||||
// 切换职业动画
|
||||
e.RoleView.animator.changeJob();
|
||||
e.remove(RoleChangeJobComp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ export class RoleViewAnimator extends AnimatorSpine {
|
||||
}
|
||||
|
||||
/** 当前动作换职业动画 */
|
||||
changeJob() {
|
||||
refresh() {
|
||||
// 状态机状态值未变时,不会触发状态变化事件,所以这里直接触发状态变化事件来触发后续流程
|
||||
this.onStateChange(this._ac.curState, this._ac.curState);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import { config } from "../../common/config/Config";
|
||||
import { CCComp } from "../../common/ecs/CCComp";
|
||||
import { RoleModelComp } from "../model/RoleModelComp";
|
||||
import { Role } from "../Role";
|
||||
import { RoleEvent } from "../RoleEvent";
|
||||
import { RoleViewAnimator } from "./RoleViewAnimator";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -33,6 +34,23 @@ export class RoleViewComp extends CCComp {
|
||||
this.node.active = false;
|
||||
this.animator = this.spine!.getComponent(RoleViewAnimator)!;
|
||||
this.animator.role = this.ent as Role;
|
||||
|
||||
this.on(RoleEvent.ChangeJob, this.onHandler, this);
|
||||
}
|
||||
|
||||
/** 全局事件处理器 */
|
||||
private onHandler(event: string, args: any) {
|
||||
switch (event) {
|
||||
case RoleEvent.ChangeJob:
|
||||
this.changeJob();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** 演示业务层通过事件控制视图层逻辑,避免两层代码直接偶合 */
|
||||
private changeJob() {
|
||||
// 切换职业动画
|
||||
this.animator.refresh();
|
||||
}
|
||||
|
||||
load() {
|
||||
|
||||
Reference in New Issue
Block a user