mirror of
https://gitee.com/dgflash/oops-framework.git
synced 2026-05-31 18:59:19 +08:00
将代码设计思路加到注释中,辅助有兴趣小伙伴学习
This commit is contained in:
@@ -1 +1,11 @@
|
||||
{"1":{"describe":"成功"},"2":{"describe":"服务器错误"},"3":{"describe":"数据库错误"}}
|
||||
{
|
||||
"1": {
|
||||
"describe": "成功"
|
||||
},
|
||||
"2": {
|
||||
"describe": "服务器错误"
|
||||
},
|
||||
"3": {
|
||||
"describe": "数据库错误"
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1584
assets/resources/gui/prefab/role_info_base.prefab
Normal file
1584
assets/resources/gui/prefab/role_info_base.prefab
Normal file
File diff suppressed because it is too large
Load Diff
13
assets/resources/gui/prefab/role_info_base.prefab.meta
Normal file
13
assets/resources/gui/prefab/role_info_base.prefab.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"ver": "1.1.35",
|
||||
"importer": "prefab",
|
||||
"imported": true,
|
||||
"uuid": "3ca889da-d664-4591-a123-063073c6609b",
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"syncNodeName": "role_info_base"
|
||||
}
|
||||
}
|
||||
@@ -18,5 +18,6 @@
|
||||
"role_lv": "Level",
|
||||
"role_hp": "HP",
|
||||
"role_power": "Power",
|
||||
"role_physical": "Physical",
|
||||
"role_agile": "Agile"
|
||||
}
|
||||
@@ -18,5 +18,6 @@
|
||||
"role_lv": "等级",
|
||||
"role_hp": "生命",
|
||||
"role_power": "力量",
|
||||
"role_physical": "体质",
|
||||
"role_agile": "敏捷"
|
||||
}
|
||||
@@ -10,9 +10,7 @@ import { SqlUtil } from "../../../core/common/storage/SqlUtil";
|
||||
import { engine } from "../../../core/Engine";
|
||||
import { ecs } from "../../../core/libs/ECS";
|
||||
import { VM } from "../../../core/libs/model-view/ViewModel";
|
||||
import { ViewUtil } from "../../../core/utils/ViewUtil";
|
||||
import { GameEvent } from "../../common/config/GameEvent";
|
||||
import { UIID } from "../../common/config/GameUIConfig";
|
||||
import { netConfig } from "../../common/net/NetConfig";
|
||||
import { Role } from "../../role/Role";
|
||||
import { Account } from "../Account";
|
||||
@@ -90,7 +88,11 @@ export class AccountNetDataSystem extends ecs.ComblockSystem implements ecs.IEnt
|
||||
role.RoleJobModel.id = data.jobId;
|
||||
|
||||
// 角色基础属性绑定到界面上显示
|
||||
VM.add(role.RoleModel.vm, "role");
|
||||
VM.add(role.RoleModel.vm, "Role");
|
||||
// 角色等级属性绑定到界面上显示
|
||||
VM.add(role.RoleLevelModel.vm, "RoleLevel");
|
||||
// 角色初始基础属性绑定到界面上显示
|
||||
VM.add(role.RoleBaseModel.vm, "RoleBase");
|
||||
|
||||
// 角色动画显示对象
|
||||
role.load();
|
||||
|
||||
@@ -26,5 +26,5 @@ export var UIConfigData: { [key: number]: UIConfig } = {
|
||||
[UIID.Netinstable]: { layer: LayerType.PopUp, prefab: "common/prefab/netinstable" },
|
||||
[UIID.Window]: { layer: LayerType.Dialog, prefab: "common/prefab/window" },
|
||||
[UIID.Demo]: { layer: LayerType.UI, prefab: "gui/prefab/demo" },
|
||||
[UIID.Demo_Role_Info]: { layer: LayerType.Dialog, prefab: "gui/prefab/role_info" },
|
||||
[UIID.Demo_Role_Info]: { layer: LayerType.UI, prefab: "gui/prefab/role_info" },
|
||||
}
|
||||
@@ -63,7 +63,6 @@ export class MoveToSystem extends ecs.ComblockSystem<ecs.Entity> implements ecs.
|
||||
return ecs.allOf(MoveToComp);
|
||||
}
|
||||
|
||||
|
||||
entityEnter(entities: ecs.Entity[]): void {
|
||||
for (let e of entities) {
|
||||
e.add(VariableMoveToComponent);
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
* @LastEditors: dgflash
|
||||
* @LastEditTime: 2022-01-29 18:04:58
|
||||
*/
|
||||
import { Component, EventTouch, _decorator } from "cc";
|
||||
import { Component, EventTouch, Prefab, _decorator } from "cc";
|
||||
import { resLoader } from "../../core/common/loader/ResLoader";
|
||||
import { engine } from "../../core/Engine";
|
||||
import { tips } from "../../core/gui/prompt/TipsManager";
|
||||
import { ecs } from "../../core/libs/ECS";
|
||||
import { ViewUtil } from "../../core/utils/ViewUtil";
|
||||
import { UIID } from "../common/config/GameUIConfig";
|
||||
import { SingletonModuleComp } from "../common/ecs/SingletonModuleComp";
|
||||
import { RoleAnimatorType } from "../role/model/RoleEnum";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -18,10 +19,18 @@ const { ccclass, property } = _decorator;
|
||||
export class Demo extends Component {
|
||||
private lang: boolean = true;
|
||||
|
||||
// onLoad() {
|
||||
// var path = "gui/prefab/role_info_base";
|
||||
// resLoader.load(path, Prefab, () => {
|
||||
// var node = ViewUtil.createPrefabNode(path);
|
||||
// node.parent = this.node;
|
||||
// });
|
||||
// }
|
||||
|
||||
/** 升级 */
|
||||
private btn_level_up(event: EventTouch, data: any) {
|
||||
var role = ecs.getSingleton(SingletonModuleComp).account.AccountModel.role;
|
||||
if (role.RoleLevelModel.lv < 100) role.RoleLevelModel.lv++;
|
||||
role.upgrade();
|
||||
}
|
||||
|
||||
/** 转职弓箭 */
|
||||
@@ -45,7 +54,7 @@ export class Demo extends Component {
|
||||
/** 攻击 */
|
||||
private btn_attack(event: EventTouch, data: any) {
|
||||
var role = ecs.getSingleton(SingletonModuleComp).account.AccountModel.role;
|
||||
role.RoleView.animator.setTrigger(RoleAnimatorType.Attack);
|
||||
role.attack();
|
||||
}
|
||||
|
||||
/** 打开角色界面 */
|
||||
|
||||
@@ -11,10 +11,12 @@ import { ViewUtil } from "../../core/utils/ViewUtil";
|
||||
import { MoveToComp } from "../common/ecs/position/MoveTo";
|
||||
import { RoleChangeJobComp } from "./bll/RoleChangeJob";
|
||||
import { RoleBaseModelComp } from "./model/RoleBaseModelComp";
|
||||
import { RoleAnimatorType } from "./model/RoleEnum";
|
||||
import { RoleJobModelComp } from "./model/RoleJobModelComp";
|
||||
import { RoleLevelModelComp } from "./model/RoleLevelModelComp";
|
||||
import { RoleModelComp } from "./model/RoleModelComp";
|
||||
import { RoleViewComp } from "./view/RoleViewComp";
|
||||
import { RoleViewInfoComp } from "./view/RoleViewInfoComp";
|
||||
|
||||
/**
|
||||
* 角色实体
|
||||
@@ -37,10 +39,12 @@ export class Role extends ecs.Entity {
|
||||
|
||||
// 视图层
|
||||
RoleView!: RoleViewComp;
|
||||
RoleViewInfo!: RoleViewInfoComp;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
// 初始化实体常住 ECS 组件,定义实体特性
|
||||
this.addComponents<ecs.Comp>(
|
||||
RoleModelComp,
|
||||
RoleBaseModelComp,
|
||||
@@ -48,7 +52,7 @@ export class Role extends ecs.Entity {
|
||||
RoleLevelModelComp);
|
||||
}
|
||||
|
||||
/** 加载角色显示对象 */
|
||||
/** 加载角色显示对象(cc.Component在创建后,添加到ECS框架中,使实体上任何一个ECS组件都可以通过 ECS API 获取到视图层对象 */
|
||||
load(): Node {
|
||||
var node = ViewUtil.createPrefabNode("game/battle/role");
|
||||
var mv = node.getComponent(RoleViewComp)!;
|
||||
@@ -57,6 +61,7 @@ export class Role extends ecs.Entity {
|
||||
return node;
|
||||
}
|
||||
|
||||
/** 移动(ECS System处理逻辑,分享功能独立的业务代码) */
|
||||
move(target: Vec3) {
|
||||
var move = this.add(MoveToComp);
|
||||
move.target = target;
|
||||
@@ -65,11 +70,11 @@ export class Role extends ecs.Entity {
|
||||
}
|
||||
|
||||
/** 攻击 */
|
||||
attack(target: Role) {
|
||||
// 战斗流程
|
||||
attack() {
|
||||
this.RoleView.animator.setTrigger(RoleAnimatorType.Attack);
|
||||
}
|
||||
|
||||
/** 转职 */
|
||||
/** 转职(ECS System处理逻辑,分享功能独立的业务代码) */
|
||||
changeJob(jobId: number) {
|
||||
var rcj = this.add(RoleChangeJobComp);
|
||||
rcj.jobId = jobId;
|
||||
@@ -77,6 +82,6 @@ export class Role extends ecs.Entity {
|
||||
|
||||
/** 角色升级 */
|
||||
upgrade() {
|
||||
|
||||
if (this.RoleLevelModel.lv < 100) this.RoleLevelModel.lv++;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,18 @@
|
||||
import { ecs } from "../../../core/libs/ECS";
|
||||
import { Role } from "../Role";
|
||||
|
||||
/** 角色转职 */
|
||||
/**
|
||||
* 角色转职
|
||||
*
|
||||
* 实现功能
|
||||
* 1、修改角色职业子模块的职业数据
|
||||
* 2、自动通过战斗属性框架更新角色战斗属性多模块的叠加值
|
||||
* 3、切换角色动画的职业武器
|
||||
*
|
||||
* 技术分析
|
||||
* 1、使用ecs.Comp做为业务输入参数的接口,可理解为一个对象成员方法接收了方法参数,通过ecs框架的特点,ecs.System 系统会监控自己关注的数据组件变化后,做对应的业务处理
|
||||
* 2、在角色实体上添加职业切换组件时触发业务逻辑的处理,完成后从角色实体上移除业务组件完成业务的生命周期。
|
||||
*/
|
||||
@ecs.register('RoleChangeJob')
|
||||
export class RoleChangeJobComp extends ecs.Comp {
|
||||
/** 职业编号 */
|
||||
|
||||
@@ -9,10 +9,22 @@ import { ecs } from "../../../core/libs/ECS";
|
||||
import { RoleAttributeType } from "./RoleEnum";
|
||||
import { RoleModelComp } from "./RoleModelComp";
|
||||
|
||||
/** 角色基础属性数据 */
|
||||
/**
|
||||
* 角色基础属性数据
|
||||
*
|
||||
* 实现功能
|
||||
* 1、角色初始创建时有随机的基础战斗属性
|
||||
* 2、基础战斗属性会独立显示数值
|
||||
*
|
||||
* 技术分析
|
||||
* 1、RoleModelComp.attributes 中设计了可扩展的角色战斗属性对象,这里分出来一个基础属性对象,是为了生成 VM 组件需要的数据格式,辅助视图层的显示逻辑
|
||||
* 2、这样设计用意是不在 RoleModelComp 对象中插入一个针对基础属性的 VM 数据。这里表达在新增需求时,尽量通过增量开发,不影响原有功能。在项目代码越来越多时,不容易因忽略某个点导致出现新问题。
|
||||
*/
|
||||
@ecs.register('RoleBaseModel')
|
||||
export class RoleBaseModelComp extends ecs.Comp {
|
||||
/** ----------一维属性---------- */
|
||||
/** 提供 VM 组件使用的数据 */
|
||||
vm: any = {};
|
||||
|
||||
/** 力量 */
|
||||
private _power: number = 0;
|
||||
public get power(): number {
|
||||
@@ -21,6 +33,7 @@ export class RoleBaseModelComp extends ecs.Comp {
|
||||
public set power(value: number) {
|
||||
this._power = value;
|
||||
this.ent.get(RoleModelComp).attributes.get(RoleAttributeType.power).base = value;
|
||||
this.vm[RoleAttributeType.power] = value;
|
||||
}
|
||||
|
||||
/** 体质 */
|
||||
@@ -31,6 +44,7 @@ export class RoleBaseModelComp extends ecs.Comp {
|
||||
public set physical(value: number) {
|
||||
this._physical = value;
|
||||
this.ent.get(RoleModelComp).attributes.get(RoleAttributeType.physical).base = value;
|
||||
this.vm[RoleAttributeType.physical] = value;
|
||||
}
|
||||
/** 敏捷 */
|
||||
private _agile: number = 0;
|
||||
@@ -40,11 +54,16 @@ export class RoleBaseModelComp extends ecs.Comp {
|
||||
public set agile(value: number) {
|
||||
this._agile = value;
|
||||
this.ent.get(RoleModelComp).attributes.get(RoleAttributeType.agile).base = value;
|
||||
this.vm[RoleAttributeType.agile] = value;
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.power = 0;
|
||||
this.physical = 0;
|
||||
this.agile = 0;
|
||||
|
||||
for (var key in this.vm) {
|
||||
delete this.vm[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,129 +11,10 @@ export enum RoleAttributeType {
|
||||
power = "power",
|
||||
/** 体质 */
|
||||
physical = "physical",
|
||||
/** 技巧 */
|
||||
skill = "skill",
|
||||
/** 精准 */
|
||||
precise = "precise",
|
||||
/** 敏捷 */
|
||||
agile = "agile",
|
||||
/** 意志 */
|
||||
will = "will",
|
||||
/** 行动次数最大值 */
|
||||
action = "action",
|
||||
/** 反击次数最大值 */
|
||||
catkNum = "catkNum",
|
||||
/** 能量 */
|
||||
sp = "sp",
|
||||
|
||||
/** 当前反击次数 */
|
||||
catkNumc = "catkNumc",
|
||||
/** 当前行动次数 */
|
||||
actionc = "actionc",
|
||||
/** 当前能量 */
|
||||
spc = "spc",
|
||||
|
||||
/** 生命最大值 */
|
||||
hp = "hp",
|
||||
/** 当前生命 */
|
||||
hpc = "hpc",
|
||||
/** 负重最大值 */
|
||||
weight = "weight",
|
||||
/** 当前负重 */
|
||||
weightc = "weightc",
|
||||
|
||||
/** 攻击 */
|
||||
ad = "ad",
|
||||
/** 攻击力比例加成 */
|
||||
adPro = "adPro",
|
||||
/** 附加伤害值 */
|
||||
adAttach = "adAttach",
|
||||
/** 附加伤害率 */
|
||||
adProAttach = "adProAttach",
|
||||
/** 护甲 */
|
||||
ar = "ar",
|
||||
/** 移动力 */
|
||||
move = "move",
|
||||
/** 命中概率 */
|
||||
hitPro = "hitPro",
|
||||
/** 命中值 */
|
||||
hit = "hit",
|
||||
/** 偏斜值 */
|
||||
skew = "skew",
|
||||
/** 偏斜概率 */
|
||||
skewPro = "skewPro",
|
||||
/** 暴击概率 */
|
||||
critPro = "critPro",
|
||||
/** 暴击伤害 */
|
||||
critDps = "critDps",
|
||||
/** 坚韧 */
|
||||
tenacity = "tenacity",
|
||||
/** 坚韧率 */
|
||||
tenacityPro = "tenacityPro",
|
||||
/** 格挡概率 */
|
||||
blockPro = "blockPro",
|
||||
/** 格挡值(格挡护甲) */
|
||||
block = "block",
|
||||
/** 招架概率 */
|
||||
parryPro = "parryPro",
|
||||
/** 招架值(招架护甲) */
|
||||
parry = "parry",
|
||||
/** 穿甲 */
|
||||
ap = "ap",
|
||||
/** 穿甲百分比 */
|
||||
apPro = "apPro",
|
||||
/** 治疗效果 */
|
||||
curePro = "curePro",
|
||||
/** 真实伤害 */
|
||||
dps = "dps",
|
||||
/** 真实伤害附加值 */
|
||||
dpsAttach = "dpsAttach",
|
||||
/** 真实伤害附加率 */
|
||||
dpsProAttach = "dpsProAttach",
|
||||
/** 速度 */
|
||||
speed = "speed",
|
||||
/** 减伤值 */
|
||||
hurt = "hurt",
|
||||
/** 减伤百分比 */
|
||||
hurtPro = "hurtPro",
|
||||
|
||||
/** ----------控制伤害流程属性---------- */
|
||||
/** 必命中 */
|
||||
certainHit = "certainHit",
|
||||
/** 必招架 */
|
||||
certainParry = "certainParry",
|
||||
/** 必格挡 */
|
||||
certainBlock = "certainBlock",
|
||||
/** 必暴击 */
|
||||
certainCriticalHit = "certainCriticalHit",
|
||||
/** 禁止招架 */
|
||||
unableParry = "unableParry",
|
||||
/** 禁止格挡 */
|
||||
unableBlock = "unableBlock",
|
||||
/** 禁止偏斜 */
|
||||
unableSkew = "unableSkew",
|
||||
|
||||
/** ----------控制功能流程属性---------- */
|
||||
/** 无法行动 */
|
||||
unableAction = "unableAction",
|
||||
/** 无法被选中 */
|
||||
unableSelect = "unableSelect",
|
||||
/** 无法反击 */
|
||||
unableCounterattack = "unableCounterattack",
|
||||
|
||||
/** ----------恢复功能流程属性---------- */
|
||||
/** 治疗点数 */
|
||||
replyTreatmentPoints = "replyTreatmentPoints",
|
||||
/** 治疗生命上限百分比 */
|
||||
replyHpcPro = "replyHpcPro",
|
||||
/** 治疗值是否使用释放者等级计算 */
|
||||
replyLevel = "replyLevel",
|
||||
/** 治疗某属性百分比 */
|
||||
replyAttributePro = "replyAttributePro",
|
||||
/** 治疗伤害 */
|
||||
replyHurt = "replyHurt",
|
||||
/** 受治疗效果 */
|
||||
replyResult = "replyResult"
|
||||
hp = "hp"
|
||||
}
|
||||
|
||||
/** 角色动作名 */
|
||||
|
||||
@@ -10,7 +10,13 @@ import { JsonUtil } from "../../../core/utils/JsonUtil";
|
||||
import { RoleAttributeType } from "./RoleEnum";
|
||||
import { RoleModelComp } from "./RoleModelComp";
|
||||
|
||||
/** 角色职业数据 */
|
||||
/**
|
||||
* 角色职业数据
|
||||
*
|
||||
* 实现功能
|
||||
* 1、影响角色力量、敏捷战斗属性
|
||||
* 2、影响角色动画武器
|
||||
*/
|
||||
@ecs.register('RoleJobModel')
|
||||
export class RoleJobModelComp extends ecs.Comp {
|
||||
static TableName: string = "arms";
|
||||
@@ -24,8 +30,9 @@ export class RoleJobModelComp extends ecs.Comp {
|
||||
|
||||
console.log(`【职业编号】${id},力量:${this.power},敏捷:${this.agile} `);
|
||||
|
||||
this.ent.get(RoleModelComp).attributes.get(RoleAttributeType.power).job = this.power;
|
||||
this.ent.get(RoleModelComp).attributes.get(RoleAttributeType.agile).job = this.agile;
|
||||
var attributes = this.ent.get(RoleModelComp).attributes;
|
||||
attributes.get(RoleAttributeType.power).job = this.power;
|
||||
attributes.get(RoleAttributeType.agile).job = this.agile;
|
||||
}
|
||||
|
||||
/** 职业编号编号 */
|
||||
@@ -37,7 +44,6 @@ export class RoleJobModelComp extends ecs.Comp {
|
||||
this.init(value);
|
||||
this._id = value;
|
||||
}
|
||||
|
||||
/** 职业名 */
|
||||
get armsName(): string {
|
||||
return this.data.armsName;
|
||||
|
||||
@@ -10,9 +10,21 @@ import { RoleAttributeType } from "./RoleEnum";
|
||||
import { RoleModelComp } from "./RoleModelComp";
|
||||
import { RoleTableLevelUp } from "./RoleTableLevelUp";
|
||||
|
||||
/** 角色等级数据 */
|
||||
/**
|
||||
* 角色等级数据
|
||||
*
|
||||
* 实现功能
|
||||
* 1、角色等级变化时、获取升级配置表中的生命附加值叠加到角色属性上
|
||||
*
|
||||
* 技术分析
|
||||
* 1、等级模块直接通过数据访问层的API获取到本地等级配置表数据,通过当前等级匹配到配置表中的等级配置数据
|
||||
* 2、获取到的等级配置数据中的生命附加值,叠加到角色战斗属性的等级模块附加值上
|
||||
*/
|
||||
@ecs.register('RoleLevelModel')
|
||||
export class RoleLevelModelComp extends ecs.Comp {
|
||||
/** 提供 VM 组件使用的数据 */
|
||||
vm: any = {};
|
||||
|
||||
/** 当前等级已获取的经验值 */
|
||||
private _exp: number = 0;
|
||||
public get exp(): number {
|
||||
@@ -20,20 +32,18 @@ export class RoleLevelModelComp extends ecs.Comp {
|
||||
}
|
||||
public set exp(value: number) {
|
||||
this._exp = value;
|
||||
this.ent.get(RoleModelComp).vm.exp = value;
|
||||
this.vm.exp = value;
|
||||
}
|
||||
|
||||
/** 等级 */
|
||||
private _lv: number = 0;
|
||||
/** 等级 */
|
||||
public get lv(): number {
|
||||
return this._lv;
|
||||
}
|
||||
public set lv(value: number) {
|
||||
this._lv = value;
|
||||
|
||||
var rm = this.ent.get(RoleModelComp);
|
||||
rm.attributes.get(RoleAttributeType.hp).level = this.rtlu.hp;
|
||||
rm.vm.lv = value;
|
||||
this.vm.lv = value;
|
||||
this.ent.get(RoleModelComp).attributes.get(RoleAttributeType.hp).level = this.rtlu.hp;
|
||||
}
|
||||
|
||||
private _rtlu: RoleTableLevelUp = null!;
|
||||
@@ -50,5 +60,9 @@ export class RoleLevelModelComp extends ecs.Comp {
|
||||
this.lv = 0;
|
||||
this.exp = 0;
|
||||
this._rtlu = null!;
|
||||
|
||||
for (var key in this.vm) {
|
||||
delete this.vm[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,17 @@ import { RoleNumeric } from "./attribute/RoleNumeric";
|
||||
import { RoleNumericMap } from "./attribute/RoleNumericMap";
|
||||
import { RoleAttributeType } from "./RoleEnum";
|
||||
|
||||
/** 角色当前叠加后的属性数据 */
|
||||
/**
|
||||
* 角色属性数据
|
||||
*
|
||||
* 实现功能
|
||||
* 1、角色唯一基础数据
|
||||
* 2、角色战斗属性数据
|
||||
* 3、角色VM组件绑定数据
|
||||
*
|
||||
* 技术分析
|
||||
* 1、使用ecs.Comp做为数据层的基类,是为了后续业务开发过程中,只要ecs.Entity对象中包含了当前数据组件,就可以通过 ecs.Entity.get(RoleModelComp) 的方式获取对应子模块的数据
|
||||
*/
|
||||
@ecs.register('RoleModel')
|
||||
export class RoleModelComp extends ecs.Comp {
|
||||
/** 提供 VM 组件使用的数据 */
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
/*
|
||||
* @Author: dgflash
|
||||
* @Date: 2021-12-02 11:08:00
|
||||
* @LastEditors: luobao
|
||||
* @LastEditTime: 2021-12-13 11:30:15
|
||||
* @Date: 2021-11-18 15:56:01
|
||||
* @LastEditors: dgflash
|
||||
* @LastEditTime: 2022-01-29 17:25:43
|
||||
*/
|
||||
|
||||
import { JsonUtil } from "../../../core/utils/JsonUtil";
|
||||
|
||||
/** 角色经验数据(策划Excel导出的Json静态数据) */
|
||||
|
||||
@@ -14,7 +14,7 @@ import { RoleNumericMap } from "./RoleNumericMap";
|
||||
* 2、任意模块的属性值修改时,自动角色属性更新后的数值和
|
||||
*/
|
||||
export class RoleNumeric {
|
||||
/** 值更新事件 */
|
||||
/** 数值更新事件 */
|
||||
onUpdate: Function = null!
|
||||
|
||||
/** 属性类型 */
|
||||
@@ -78,16 +78,6 @@ export class RoleNumeric {
|
||||
this.update();
|
||||
}
|
||||
|
||||
protected _decorator: number = 0;
|
||||
/** 战斗动态效果装饰属性 */
|
||||
get decorator(): number {
|
||||
return this._decorator;
|
||||
}
|
||||
set decorator(value: number) {
|
||||
this._decorator = value;
|
||||
this.update();
|
||||
}
|
||||
|
||||
protected _battle: number = 0;
|
||||
/** 战斗角色属性 */
|
||||
get battle(): number {
|
||||
@@ -98,6 +88,16 @@ export class RoleNumeric {
|
||||
this.update();
|
||||
}
|
||||
|
||||
protected _decorator: number = 0;
|
||||
/** 战斗动态效果装饰属性 */
|
||||
get decorator(): number {
|
||||
return this._decorator;
|
||||
}
|
||||
set decorator(value: number) {
|
||||
this._decorator = value;
|
||||
this.update();
|
||||
}
|
||||
|
||||
value: number = 0;
|
||||
|
||||
protected update() {
|
||||
|
||||
@@ -45,15 +45,9 @@ export class RoleNumericMap {
|
||||
var attr = this.attributes.get(type);
|
||||
if (attr == null) {
|
||||
switch (type) {
|
||||
case RoleAttributeType.power:
|
||||
attr = new RoleNumericPower(type, this);
|
||||
break;
|
||||
case RoleAttributeType.physical:
|
||||
attr = new RoleNumericPhysical(type, this);
|
||||
break;
|
||||
case RoleAttributeType.agile:
|
||||
attr = new RoleNumericAgile(type, this);
|
||||
break;
|
||||
default:
|
||||
attr = new RoleNumeric(type, this);
|
||||
break;
|
||||
@@ -80,16 +74,6 @@ export class RoleNumericMap {
|
||||
}
|
||||
}
|
||||
|
||||
/** 力量属性 */
|
||||
export class RoleNumericPower extends RoleNumeric {
|
||||
protected update(): void {
|
||||
super.update();
|
||||
|
||||
// 每点力量 = 0.5 攻击力,武器需求力量,如果武器需求力量>力量,则命中率=0%
|
||||
this.attributes.get(RoleAttributeType.ad).base = this.value * 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
/** 体质属性 */
|
||||
export class RoleNumericPhysical extends RoleNumeric {
|
||||
protected update(): void {
|
||||
@@ -98,14 +82,4 @@ export class RoleNumericPhysical extends RoleNumeric {
|
||||
// 每点体质 = 0.5 生命
|
||||
this.attributes.get(RoleAttributeType.hp).base = Math.floor(this.value * 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
/** 敏捷属性 */
|
||||
export class RoleNumericAgile extends RoleNumeric {
|
||||
protected update(): void {
|
||||
super.update();
|
||||
|
||||
// 每点敏捷 = 1 点偏斜值
|
||||
this.attributes.get(RoleAttributeType.skew).base = this.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,11 +24,11 @@ export class RoleViewComp extends CCComp {
|
||||
@property({ type: sp.Skeleton, tooltip: '角色动画' })
|
||||
spine: sp.Skeleton | null = null;
|
||||
|
||||
/** 动画状态机 */
|
||||
animator: RoleViewAnimatorComp = null!;
|
||||
|
||||
onLoad() {
|
||||
this.node.active = false;
|
||||
|
||||
this.animator = this.spine!.getComponent(RoleViewAnimatorComp)!;
|
||||
}
|
||||
|
||||
@@ -50,9 +50,17 @@ export class RoleViewComp extends CCComp {
|
||||
}
|
||||
|
||||
private onTouchEnd(event: EventTouch) {
|
||||
// 注:角色移动控制代码在RPG类游戏中,应该设计到地图模块监听触摸事件。因为测试代码只有一个角色,为了简少DEMO代码量,只表达程序设计思想
|
||||
var role = this.ent.get(RoleModelComp).ent as Role;
|
||||
var uit = this.node.parent!.getComponent(UITransform)!;
|
||||
role.move(v3(event.getUILocation().x - uit.contentSize.width / 2, event.getUILocation().y - uit.contentSize.height / 2));
|
||||
var x = event.getUILocation().x - uit.contentSize.width / 2;
|
||||
var y = event.getUILocation().y - uit.contentSize.height / 2;
|
||||
role.move(v3(x, y));
|
||||
|
||||
if (x < role.RoleView.node.position.x)
|
||||
role.RoleView.animator.left();
|
||||
else
|
||||
role.RoleView.animator.right();
|
||||
}
|
||||
|
||||
reset() {
|
||||
|
||||
@@ -19,13 +19,13 @@ export class RoleViewInfoComp extends CCComp {
|
||||
switch (event.target.name) {
|
||||
case "btn_levelup":
|
||||
var role = ecs.getSingleton(SingletonModuleComp).account.AccountModel.role;
|
||||
if (role.RoleLevelModel.lv < 100) role.RoleLevelModel.lv++;
|
||||
role.upgrade();
|
||||
break;
|
||||
case "btn_close":
|
||||
engine.gui.remove(UIID.Demo_Role_Info);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
event.propagationStopped = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user