Compare commits
2 Commits
957cd6d453
...
bcc61c9589
| Author | SHA1 | Date | |
|---|---|---|---|
| bcc61c9589 | |||
| 331effddaa |
@@ -1,5 +1,4 @@
|
||||
import { _decorator, Component, Node, view, UITransform, Vec3, math, EventHandler, Graphics, Color, TweenEasing, Enum } from 'cc';
|
||||
import { SkillCom } from '../skills/SkillCom';
|
||||
import { smc } from '../common/SingletonModuleComp';
|
||||
import { AtkConCom } from '../skill/AtkConCom';
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -155,9 +154,9 @@ export class BezierMove extends Component {
|
||||
this._isMoving = false;
|
||||
// 触发移动完成事件
|
||||
// console.log("onMoveComplete")
|
||||
let scom=this.node.getComponent(SkillCom)
|
||||
|
||||
let acom=this.node.getComponent(AtkConCom)
|
||||
let skill=scom?scom:acom
|
||||
let skill=acom
|
||||
if(skill){
|
||||
skill.doDestroy()
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
import { oops } from "db://oops-framework/core/Oops"
|
||||
|
||||
export class Test{
|
||||
load_data_from_local() {
|
||||
let local_data = this.get_local_data()
|
||||
if(!local_data.data||!local_data.fight_heros||!local_data.heros||!local_data.items||!local_data.tals||!local_data.equips){
|
||||
return this.init_local_data()
|
||||
}
|
||||
return local_data
|
||||
}
|
||||
get_local_data(){
|
||||
let local_data ={
|
||||
user_id: "local_debug",
|
||||
openid: "local_debug",
|
||||
regist_time: Date.now(),
|
||||
data: JSON.parse(oops.storage.get("data")||null),
|
||||
fight_heros: JSON.parse(oops.storage.get("fight_heros")||null),
|
||||
heros: JSON.parse(oops.storage.get("heros")||null),
|
||||
items: JSON.parse(oops.storage.get("items")||null),
|
||||
tals: JSON.parse(oops.storage.get("tals")||null),
|
||||
equips: JSON.parse(oops.storage.get("equips")||null)
|
||||
}
|
||||
return local_data
|
||||
}
|
||||
init_local_data(){
|
||||
let init_data = {
|
||||
data : { score: 0, mission: 1, gold: 100, diamond: 100, meat: 0, exp: 0,},
|
||||
fight_heros: { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0 },
|
||||
heros: {
|
||||
5001: { uuid: 5001, lv: 1 },
|
||||
5005: { uuid: 5005, lv: 1 },
|
||||
5007: { uuid: 5007, lv: 1 }
|
||||
},
|
||||
items: {},
|
||||
tals: {},
|
||||
equips: {}
|
||||
}
|
||||
oops.storage.set("data", JSON.stringify(init_data.data))
|
||||
oops.storage.set("fight_heros", JSON.stringify(init_data.fight_heros))
|
||||
oops.storage.set("heros", JSON.stringify(init_data.heros))
|
||||
oops.storage.set("items", JSON.stringify(init_data.items))
|
||||
oops.storage.set("tals", JSON.stringify(init_data.tals))
|
||||
oops.storage.set("equips", JSON.stringify(init_data.equips))
|
||||
return this.get_local_data()
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "893646a7-1cf0-4c80-8fe1-39ac111130fc",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import { oops } from 'db://oops-framework/core/Oops';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('stoast')
|
||||
export class stoast extends Component {
|
||||
|
||||
|
||||
onAdded(args: any) {
|
||||
console.log("toast打开",args)
|
||||
}
|
||||
|
||||
private close() {
|
||||
oops.gui.removeByNode(this.node);
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "d26fa84f-22b4-4136-bb46-d7e978683365",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "7d9b27df-701e-44ee-8732-b53f9d22cca2",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
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<ecs.Comp>(dataViewComp,dataModelComp);
|
||||
}
|
||||
changeHp(min: number, max: number){
|
||||
var data = this.dataModel;
|
||||
}
|
||||
/** 模块资源释放 */
|
||||
destroy() {
|
||||
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
/** data 模块业务逻辑系统组件,如无业务逻辑处理可删除此对象 */
|
||||
export class EcsdataSystem extends ecs.System {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
// this.add(new ecs.ComblockSystem());
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "cb9afa42-2112-471e-b86c-79407ba6abd4",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { VM } from "../../../../extensions/oops-plugin-framework/assets/libs/model-view/ViewModel";
|
||||
import { CCVMParentComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCVMParentComp";
|
||||
|
||||
|
||||
/** 数据层对象 */
|
||||
@ecs.register('dataModel')
|
||||
export class dataModelComp extends CCVMParentComp {
|
||||
/** 提供 MVVM 组件使用的数据 */
|
||||
/** VM 组件绑定数据 */
|
||||
vm: any = {
|
||||
name : "数据测试",
|
||||
/** 当前等级 */
|
||||
porwer: 0,
|
||||
/** 当前经验 */
|
||||
def : 0,
|
||||
/** 下级经验 */
|
||||
speed : 0,
|
||||
hp: {
|
||||
min:50,
|
||||
max:100
|
||||
}
|
||||
};
|
||||
|
||||
/** 显示数据添加到 MVVM 框架中监视 */
|
||||
vmAdd() {
|
||||
console.log("dataModelComp vmAdd");
|
||||
VM.add(this.vm, "data");
|
||||
}
|
||||
changeHp(min: number, max: number) {
|
||||
this.vm.hp.min =this.vm.hp.min +min
|
||||
this.vm.hp.max =this.vm.hp.max +max
|
||||
}
|
||||
/** 显示数据从 MVVM 框架中移除 */
|
||||
vmRemove() {
|
||||
VM.remove("data");
|
||||
}
|
||||
|
||||
/** 数据层组件移除时,重置所有数据为默认值 */
|
||||
reset() {
|
||||
for (var key in this.vm) {
|
||||
delete this.vm[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "0aefc30a-9392-4ada-b3d0-8c15625e8cfc",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "8ae6d033-ff0f-44d5-9ff7-c57751bd4ea1",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "4209bcee-3867-4c0b-83c9-a4eeee989328",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
import { _decorator, Component, instantiate, Label, Node, Prefab, ProgressBar, tween, UITransform, v3, Vec3 } from 'cc';
|
||||
import { oops } from 'db://oops-framework/core/Oops';
|
||||
import { ecs } from 'db://oops-framework/libs/ecs/ECS';
|
||||
import { Tooltip } from '../skills/Tooltip';
|
||||
import { timedCom } from '../skills/timedCom';
|
||||
import { Tooltip } from '../skill/Tooltip';
|
||||
import { timedCom } from '../skill/timedCom';
|
||||
import { smc } from '../common/SingletonModuleComp';
|
||||
import { HeroViewComp } from './HeroViewComp';
|
||||
import { GameEvent } from '../common/config/GameEvent';
|
||||
import { Timer } from 'db://oops-framework/core/common/timer/Timer';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
|
||||
@@ -14,9 +14,6 @@ import { LoadingViewComp } from "./view/LoadingViewComp";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { WxCloudApi } from "../wx_clound_client_api/WxCloudApi";
|
||||
|
||||
import { Test } from "../common/Test";
|
||||
|
||||
// import {data} from "../data/data";
|
||||
/**
|
||||
* 游戏进入初始化模块
|
||||
* 1、热更新
|
||||
@@ -26,11 +23,7 @@ import { Test } from "../common/Test";
|
||||
export class Initialize extends ecs.Entity {
|
||||
LoadingView!: LoadingViewComp;
|
||||
|
||||
// data:data=null!;
|
||||
protected init() {
|
||||
|
||||
// this.data=ecs.getEntity<data>(data);
|
||||
// this.data.dataModel.vmAdd();
|
||||
var queue: AsyncQueue = new AsyncQueue();
|
||||
// 加载自定义资
|
||||
this.loadCustom(queue);
|
||||
|
||||
@@ -6,8 +6,9 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/O
|
||||
import { FightSet} from "../common/config/Mission";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
import { SkillCom } from "../skills/SkillCom";
|
||||
import { UIID } from "../common/config/GameUIConfig";
|
||||
import { AtkConCom } from "../skill/AtkConCom";
|
||||
import { SkillViewCom } from "../skill/SkillViewCom";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
|
||||
@@ -136,7 +137,8 @@ export class MissionComp extends CCComp {
|
||||
|
||||
private cleanComponents() {
|
||||
ecs.query(ecs.allOf(HeroViewComp)).forEach(entity => {entity.remove(HeroViewComp);entity.destroy()});
|
||||
ecs.query(ecs.allOf(SkillCom)).forEach(entity => {entity.remove(SkillCom);entity.destroy()});
|
||||
ecs.query(ecs.allOf(AtkConCom)).forEach(entity => {entity.remove(AtkConCom);entity.destroy()});
|
||||
ecs.query(ecs.allOf(SkillViewCom)).forEach(entity => {entity.remove(SkillViewCom);entity.destroy()});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { _decorator, CCBoolean, CCFloat, CCInteger, instantiate, Node, Prefab, v
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
import { getAttrs, RType, SkillSet } from "../common/config/SkillSet";
|
||||
import { RType, SkillSet } from "../common/config/SkillSet";
|
||||
import { AtkConCom } from "./AtkConCom";
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "144b4336-ce17-4dba-85ac-61361f404838",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import { _decorator, Animation, Component, Node } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('AnmEndCom')
|
||||
export class AnmEndCom extends Component {
|
||||
start() {
|
||||
|
||||
if(this.node.getComponent(Animation)){
|
||||
let anim = this.node.getComponent(Animation);
|
||||
// console.log("has anim",anim)
|
||||
anim.on(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
onAnimationFinished(){
|
||||
this.node.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "9a6c0cbd-2b5b-4ecd-85d3-c017de7a5b2a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { BoxSet, FacSet } from "../common/config/BoxSet";
|
||||
import { HType } from "../common/config/heroSet";
|
||||
import {Attrs, SkillSet } from "../common/config/SkillSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
import { SkillCom } from "./SkillCom";
|
||||
import { instantiate, Node, Prefab, Vec3 ,tween, v3,animation,Label,resources,SpriteFrame,Sprite} from "cc";
|
||||
|
||||
/** Skill 模块 */
|
||||
@ecs.register(`Skill`)
|
||||
export class Skill extends ecs.Entity {
|
||||
SkillView!: SkillCom;
|
||||
/** 实始添加的数据层组件 */
|
||||
protected init() {
|
||||
|
||||
}
|
||||
/** 模块资源释放 */
|
||||
destroy() {
|
||||
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
||||
this.remove(SkillCom);
|
||||
super.destroy();
|
||||
}
|
||||
load(
|
||||
startPos: Vec3, // 起始位置
|
||||
parent: Node, // 父节点
|
||||
uuid: number, // 技能ID
|
||||
targetPos: Vec3, // 目标位置
|
||||
caster:any=null, // 施法者
|
||||
angle:number=0,
|
||||
dmg:number=0
|
||||
) {
|
||||
|
||||
const config = SkillSet[uuid];
|
||||
if (!config) {
|
||||
console.error("[Skill] 技能配置不存在:", uuid);
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查施法者
|
||||
if (!caster) {
|
||||
console.error("[Skill] 施法者为空");
|
||||
return;
|
||||
}
|
||||
|
||||
// 加载预制体
|
||||
const path = `game/skill/atk/${config.sp_name}`;
|
||||
const prefab:Prefab = oops.res.get(path, Prefab);
|
||||
if (!prefab) {
|
||||
console.error("[Skill] 预制体加载失败:", path);
|
||||
return;
|
||||
}
|
||||
if(uuid==6001){
|
||||
console.log("load skill startPos",startPos)
|
||||
}
|
||||
const node = instantiate(prefab);
|
||||
var scene = smc.map.MapView.scene;
|
||||
// 设置节点属性
|
||||
node.parent = parent;
|
||||
node.setPosition(startPos);
|
||||
if(caster.fac==FacSet.MON){
|
||||
node.scale=v3(node.scale.x*-1,1,1)
|
||||
}else{
|
||||
if(caster.type==HType.warrior){
|
||||
if(caster.node.scale.x<0){
|
||||
node.scale=v3(node.scale.x*-1,node.scale.y,1)
|
||||
}
|
||||
}
|
||||
}
|
||||
node.angle+=angle
|
||||
// 添加技能组件
|
||||
const SComp = node.getComponent(SkillCom); // 初始化技能参数
|
||||
|
||||
// 只设置必要的运行时属性,配置信息通过 SkillSet[uuid] 访问
|
||||
Object.assign(SComp, {
|
||||
// 核心标识
|
||||
s_uuid: uuid,
|
||||
// 位置和施法者信息
|
||||
startPos: startPos,
|
||||
targetPos: targetPos,
|
||||
group: caster.box_group,
|
||||
fac: caster.fac,
|
||||
// 技能数值
|
||||
|
||||
});
|
||||
|
||||
this.add(SComp);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "e7bac796-7cc3-47b4-904b-85a95cc15390",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,274 +0,0 @@
|
||||
import { _decorator,Collider2D ,Contact2DType,v3,IPhysics2DContact,Vec3, tween, math, RigidBody2D, Animation, Tween} from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { Attrs, DTType, EType, SkillSet, SType, TGroup } from "../common/config/SkillSet";
|
||||
import { BoxSet, FacSet } from "../common/config/BoxSet";
|
||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
import { BezierMove } from "../BezierMove/BezierMove";
|
||||
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('SkillCom')
|
||||
@ecs.register('SkillCom')
|
||||
export class SkillCom extends CCComp {
|
||||
// 核心标识和配置
|
||||
s_uuid:number = 0;
|
||||
// 运行时状态(必须缓存的)
|
||||
is_destroy:boolean = false;
|
||||
startPos: Vec3 = v3(); // 起始位置
|
||||
targetPos: Vec3 = v3(); // 目标位置
|
||||
group:number = 0; //阵营
|
||||
fac:number=0; //阵营
|
||||
caster:any=null;
|
||||
|
||||
// 战斗相关运行时数据
|
||||
ap:number=0;
|
||||
burn_count:number=0;
|
||||
burn_value:number=0;
|
||||
stun_time:number=0;
|
||||
stun_ratio:number=0;
|
||||
frost_ratio:number=0;
|
||||
frost_time:number=0;
|
||||
run_time:number=0;
|
||||
hited_time:number=0;
|
||||
hit_count:number=0;
|
||||
caster_crit:number=0;
|
||||
caster_crit_d:number=0;
|
||||
puncture:number=0;
|
||||
puncture_damage:number=0;
|
||||
debuff_up:number=0;
|
||||
debuff_value:number=0;
|
||||
debuff_count:number=0;
|
||||
// 组件引用
|
||||
anim:Animation=null;
|
||||
tweenInstance:Tween<any> = null;
|
||||
private moveDirection: Vec3 | null = null; // 添加一个属性来存储移动方向
|
||||
|
||||
// 缓存的配置对象(避免重复查找)
|
||||
public skillConfig: any = null;
|
||||
private isInitialized: boolean = false;
|
||||
|
||||
protected onLoad(): void {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private initializeSkillConfig() {
|
||||
if (this.isInitialized) return;
|
||||
|
||||
// 缓存技能配置,避免重复查找
|
||||
this.skillConfig = SkillSet[this.s_uuid];
|
||||
if (!this.skillConfig) {
|
||||
// console.error("[SkillCom] 技能配置不存在:", this.s_uuid);
|
||||
return;
|
||||
}
|
||||
|
||||
this.isInitialized = true;
|
||||
// console.log("[SkillCom] 技能配置初始化完成:", this.s_uuid, this.skillConfig.name);
|
||||
}
|
||||
|
||||
start() {
|
||||
this.initializeSkillConfig();
|
||||
if (!this.skillConfig) return;
|
||||
this.node.setPosition(this.startPos.x,this.startPos.y,0)
|
||||
this.anim=this.node.getComponent(Animation)
|
||||
this.on(GameEvent.MissionEnd, this.doDestroy, this);
|
||||
this.node.active = true;
|
||||
let collider = this.getComponent(Collider2D);
|
||||
if(collider) {
|
||||
collider.group = this.group;
|
||||
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
}
|
||||
let bm=this.node.getComponent(BezierMove)
|
||||
// //console.log(this.group +"技能 collider ",collider);
|
||||
// switch(this.skillConfig.AType){
|
||||
// case AType.parabolic:
|
||||
// this.node.angle +=10
|
||||
// // bm.speed=700
|
||||
// if(this.group==BoxSet.MONSTER) {bm.controlPointSide=-1 }
|
||||
// bm.rotationSmoothness=0.6
|
||||
// bm.moveTo(this.targetPos)
|
||||
// break;
|
||||
// case AType.linear:
|
||||
// let s_x=this.startPos.x
|
||||
// let s_y=this.startPos.y
|
||||
// let t_x=this.targetPos.x
|
||||
// let t_y=this.targetPos.y
|
||||
// // 设定目标x
|
||||
// this.targetPos.x = 400;
|
||||
// if(this.group == BoxSet.MONSTER) {
|
||||
// bm.controlPointSide = -1;
|
||||
// this.targetPos.x = -400;
|
||||
// }
|
||||
// // 计算斜率
|
||||
// const k = (t_y - s_y) / (t_x - s_x);
|
||||
// // 按直线公式计算新的y
|
||||
// this.targetPos.y = k * (this.targetPos.x - s_x) + s_y;
|
||||
// bm.controlPointOffset=0
|
||||
// bm.rotationSmoothness=0.6
|
||||
// bm.moveTo(this.targetPos);
|
||||
// break;
|
||||
// case AType.StartEnd:
|
||||
// // 2段位移:先升高,然后移到目的地
|
||||
// this.node.setPosition(this.startPos.x > 360?300:this.startPos.x,0,0)
|
||||
// this.do_anim()
|
||||
// break;
|
||||
// case AType.fixedEnd:
|
||||
// this.node.setPosition(this.targetPos.x > 360?300:this.targetPos.x,0,0)
|
||||
// this.do_anim()
|
||||
// break;
|
||||
// case AType.fixedStart: //
|
||||
// if(this.s_uuid==6001){
|
||||
// console.log("skillcom startPos",this.startPos)
|
||||
// }
|
||||
// this.node.setPosition(this.startPos.x > 360?300:this.startPos.x,0,0)
|
||||
// this.do_anim()
|
||||
// break;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
do_anim(){
|
||||
if(this.node.getComponent(Animation)){
|
||||
let anim = this.node.getComponent(Animation);
|
||||
//console.log("[SkillCom]:has anim",anim)
|
||||
anim.on(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
||||
}
|
||||
|
||||
}
|
||||
onAnimationFinished(){
|
||||
// console.log("[SkillCom]:onAnimationFinished",this.s_uuid)
|
||||
if (!this.skillConfig) return;
|
||||
|
||||
if(this.skillConfig.EType==EType.timeEnd) return
|
||||
if(this.skillConfig.SType!=SType.damage){
|
||||
this.to_do_buff()
|
||||
}
|
||||
|
||||
this.is_destroy=true
|
||||
}
|
||||
to_do_buff(){
|
||||
if (!this.skillConfig) return;
|
||||
|
||||
switch(this.skillConfig.SType){
|
||||
case SType.shield:
|
||||
this.caster.add_shield(this.caster[Attrs.HP_MAX]*(100+this.skillConfig.buV/100))
|
||||
break;
|
||||
}
|
||||
}
|
||||
//单体伤害
|
||||
single_damage(target:HeroViewComp,is_range:boolean=false){
|
||||
// //console.log("[SkillCom]:onBeginContact hit_count:",this.hit_count,SkillSet[this.s_uuid].hit)
|
||||
// if(this.hit_count > 0&&!is_range) this.ap=this.ap*(50+this.puncture_damage)/100 // 穿刺后 伤害减半,过滤范围伤害
|
||||
if(target == null) return;
|
||||
if (!this.skillConfig) return;
|
||||
let ap=this.ap
|
||||
if(this.hit_count > 0 &&!is_range ){
|
||||
ap=ap*(50+this.puncture_damage)/100
|
||||
}
|
||||
// target.do_atked(ap,this.caster_crit,this.caster_crit_d,
|
||||
// this.burn_count,this.burn_value,
|
||||
// this.stun_time,this.stun_ratio,
|
||||
// this.frost_time,this.frost_ratio,
|
||||
// this.skillConfig.AtkedName
|
||||
// ) // ap 及暴击 属性已经在skill.ts 处理
|
||||
// console.log("[SkillCom]:single_damage t:tp:rtp",this.node.position,this.targetPos,target.node.position)
|
||||
if(this.skillConfig.debuff>0){
|
||||
let debuff=this.skillConfig
|
||||
let dev=debuff.deV*(100+this.debuff_value)/100
|
||||
let deR=debuff.deR+this.debuff_up
|
||||
dev=Math.round(dev*100)/100
|
||||
let deC=debuff.deC+this.debuff_count //dec只作为次数叠加
|
||||
// //console.log("[SkillCom]:debuff",this.skillConfig.name,debuff.debuff,deUP.deV,deUP.deC)
|
||||
target.addDebuff(debuff.debuff)
|
||||
}
|
||||
this.hit_count++
|
||||
// console.log("[SkillCom]:碰撞次数:技能次数:穿刺次数",this.hit_count,this.skillConfig.hit,this.puncture)
|
||||
if(this.hit_count>=(this.skillConfig.hit+this.puncture)&&(this.skillConfig.DTType!=DTType.range)&&(this.skillConfig.EType!=EType.animationEnd)&&(this.skillConfig.EType!=EType.timeEnd)) this.is_destroy=true // 技能命中次数
|
||||
}
|
||||
|
||||
onBeginContact (seCol: Collider2D, oCol: Collider2D) {
|
||||
// console.log(this.scale+"碰撞开始 ",seCol,oCol);
|
||||
if(seCol.node.position.x-oCol.node.position.x > 100 ) return
|
||||
let target = oCol.getComponent(HeroViewComp)
|
||||
if(oCol.group!=this.group){
|
||||
if(target == null) return;
|
||||
if (!this.skillConfig) return;
|
||||
// console.log("[SkillCom]:onBeginContact oCol||seCol",oCol.node.position,seCol.node.position)
|
||||
this.single_damage(target,this.skillConfig.DTType==DTType.range?true:false)
|
||||
// this.ent.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
update(deltaTime: number) {
|
||||
// 确保配置已初始化(处理 update 可能先于 start 执行的情况)
|
||||
if (!this.isInitialized) {
|
||||
this.initializeSkillConfig();
|
||||
if (!this.skillConfig) return;
|
||||
}
|
||||
|
||||
if(smc.mission.pause) {
|
||||
if(this.anim) this.anim.pause()
|
||||
return;
|
||||
}
|
||||
if(this.anim) this.anim.resume()
|
||||
if (!this.node || !this.node.isValid) return;
|
||||
|
||||
if(this.skillConfig.EType==EType.timeEnd){
|
||||
this.run_time+=deltaTime
|
||||
if(this.run_time>this.skillConfig.in){
|
||||
// //console.log("[SkillCom]: timeEnd destroy",this.s_uuid,this.run_time)
|
||||
this.is_destroy=true
|
||||
}
|
||||
}
|
||||
|
||||
//直线移动
|
||||
// if(this.skillConfig.AType == AType.linear) this.startLinearMove(deltaTime);
|
||||
this.toDestroy();
|
||||
}
|
||||
|
||||
toDestroy() {
|
||||
if(this.is_destroy){
|
||||
if (this.ent) {
|
||||
this.ent.destroy();
|
||||
} else {
|
||||
// 如果ent不存在,直接销毁节点
|
||||
if (this.node && this.node.isValid) {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
doDestroy(){
|
||||
// //console.log("[SkillCom]:doDestroy")
|
||||
this.is_destroy=true
|
||||
}
|
||||
to_console(value:any,value2:any=null,value3:any=null){
|
||||
//console.log("[SkillCom]:["+this.s_name+this.s_uuid+"]:",value,value2,value3)
|
||||
}
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.is_destroy = false;
|
||||
this.startPos.set();
|
||||
this.targetPos.set();
|
||||
this.moveDirection = null; // 重置移动方向
|
||||
this.skillConfig = null; // 清除配置缓存
|
||||
this.isInitialized = false; // 重置初始化状态
|
||||
// 先移除所有碰撞回调
|
||||
const collider = this.getComponent(Collider2D);
|
||||
if (collider) {
|
||||
collider.off(Contact2DType.BEGIN_CONTACT);
|
||||
}
|
||||
this.scheduleOnce(() => {
|
||||
this.node.destroy();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "45646a08-c887-40db-85be-d1ce6b7442c3",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('atked')
|
||||
export class atked extends Component {
|
||||
time = 0.3;
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
this.time = this.time - deltaTime;
|
||||
if(this.time <= 0)
|
||||
{
|
||||
this.node.destroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "65d6266f-bba6-4b98-8343-2a67642ec7eb",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "9efcc55e-db7c-4761-af6f-ee8bc2f1f63b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
import { _decorator, UI, UITransform } from "cc";
|
||||
import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { HeroViewComp } from "../../hero/HeroViewComp";
|
||||
import { SkillCom } from "../SkillCom";
|
||||
import { AtkConCom } from "../../skill/AtkConCom";
|
||||
import { SkillSet } from "../../common/config/SkillSet";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('AtkComComp')
|
||||
@ecs.register('AtkCom', false)
|
||||
export class AtkComComp 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) {
|
||||
// switch (event) {
|
||||
// case ModuleEvent.Cmd:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "b1d8ed59-0347-4bb6-ab9f-86276714afca",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import { timedCom } from './timedCom';
|
||||
import { HeroViewComp } from '../hero/HeroViewComp';
|
||||
import { smc } from '../common/SingletonModuleComp';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('debuff')
|
||||
export class debuff extends Component {
|
||||
base: timedCom = null
|
||||
hero:HeroViewComp = null
|
||||
deff_cd: number = 0
|
||||
ap: number = 0
|
||||
start() {
|
||||
this.base =this.node.getComponent(timedCom)
|
||||
this.hero = this.node.parent.getComponent(HeroViewComp)
|
||||
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
if(smc.mission.pause) return
|
||||
this.deff_cd += deltaTime
|
||||
if(this.deff_cd >=1){
|
||||
// this.node.setPosition(v3(-1000,0,0))
|
||||
if(this.hero){
|
||||
// this.hero.hp_less(Math.ceil(this.base.ap/this.base.time))
|
||||
// console.log("debuff 总扣血:"+this.base.ap+" 每秒: "+Math.ceil(this.base.ap/this.base.time))
|
||||
}
|
||||
this.deff_cd=0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "69132caf-02ba-40a8-a835-30baced39701",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
const { ccclass, property ,} = _decorator;
|
||||
|
||||
@ccclass('once')
|
||||
export class once extends Component {
|
||||
|
||||
start() {
|
||||
}
|
||||
protected onLoad(): void {
|
||||
|
||||
|
||||
}
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "6e0a995d-16c1-4554-8f80-29394f24213b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user