dd
This commit is contained in:
@@ -34,5 +34,6 @@ export enum GameEvent {
|
||||
FightEnd = "FightEnd",
|
||||
MissionEnd = "MissionEnd",
|
||||
MissionComplete = "MissionComplete",//战斗结算完成
|
||||
CastHeroSkill = "CastHeroSkill",
|
||||
|
||||
}
|
||||
11
assets/script/game/common/config/MissionEvent.ts
Normal file
11
assets/script/game/common/config/MissionEvent.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* @Author: dgflash
|
||||
* @Date: 2021-11-23 15:28:39
|
||||
* @LastEditors: dgflash
|
||||
* @LastEditTime: 2022-01-26 16:42:00
|
||||
*/
|
||||
|
||||
/** 游戏事件 */
|
||||
export enum MissionEvent {
|
||||
CastHeroSkill = "CastHeroSkill",
|
||||
}
|
||||
9
assets/script/game/common/config/MissionEvent.ts.meta
Normal file
9
assets/script/game/common/config/MissionEvent.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "167eb23c-6d7e-4e30-96ca-06fec16eeaa8",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -2,19 +2,38 @@ import { oops } from "db://oops-framework/core/Oops";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { HeroViewComp } from "./HeroViewComp";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { CCComp } from "db://oops-framework/module/common/CCComp";
|
||||
import { MissionEvent } from "../common/config/MissionEvent";
|
||||
import { SkillConComp } from "./SkillConComp";
|
||||
import { SkillSet } from "../common/config/SkillSet";
|
||||
import { _decorator } from "cc";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
/**
|
||||
* 角色属性数据
|
||||
*/
|
||||
@ecs.register('HartModel')
|
||||
export class HartModelComp extends ecs.Comp {
|
||||
@ccclass('HartMode')
|
||||
@ecs.register('HartModelComp')
|
||||
export class HartModelComp extends CCComp {
|
||||
SkillCon:SkillConComp
|
||||
onLoad(){
|
||||
console.log("HartModel加载",this)
|
||||
this.on(GameEvent.FightReady,this.start,this)
|
||||
this.on(GameEvent.CastHeroSkill,this.cast_skill,this)
|
||||
}
|
||||
start(){
|
||||
oops.message.dispatchEvent(GameEvent.FightReady,this)
|
||||
this.SkillCon=this.node.getComponent(SkillConComp)
|
||||
console.log("hart start",this.SkillCon)
|
||||
}
|
||||
|
||||
cast_skill(e:string,uuid:any){
|
||||
console.log("hart cast_skill",uuid ,e)
|
||||
const config = SkillSet[uuid];
|
||||
this.SkillCon.castSkill(config)
|
||||
}
|
||||
|
||||
reset() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import { smc } from "../common/SingletonModuleComp";
|
||||
import { HeroModelComp } from "./HeroModelComp";
|
||||
import { HeroViewComp } from "./HeroViewComp";
|
||||
import { HeroInfo, HeroPos, HeroSet } from "../common/config/heroSet";
|
||||
import { MissionComp } from "../map/MissionComp";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
|
||||
@@ -21,9 +21,13 @@ export class SkillConComp extends CCComp {
|
||||
init(): void {
|
||||
oops.message.on(GameEvent.FightEnd, this.clear_timer, this);
|
||||
}
|
||||
start() {
|
||||
// console.log("SkillConComp start")
|
||||
onLoad(){
|
||||
this.HeroView=this.node.getComponent(HeroViewComp)
|
||||
console.log(this.HeroView.uuid+"=>"+this.HeroView.hero_name+"=> SkillConComp onLoad")
|
||||
}
|
||||
start() {
|
||||
this.HeroView=this.node.getComponent(HeroViewComp)
|
||||
console.log(this.HeroView.uuid+"=>"+this.HeroView.hero_name+"=> SkillConComp start")
|
||||
this.HeroEntity=this.HeroView.ent
|
||||
}
|
||||
|
||||
@@ -32,21 +36,21 @@ export class SkillConComp extends CCComp {
|
||||
if (this.HeroView.is_atking &&this.HeroView.at > this.HeroView.cd) {
|
||||
const config = SkillSet[this.HeroView.atk_skill];
|
||||
if (!config) return;
|
||||
this.castSkill(this.HeroView, this.HeroView.atk_skill, config);
|
||||
this.castSkill(config);
|
||||
this.HeroView.at = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** 施放技能 */
|
||||
private castSkill(view: HeroViewComp, skillId: number, config: typeof SkillSet[keyof typeof SkillSet]) {
|
||||
castSkill(config: typeof SkillSet[keyof typeof SkillSet]) {
|
||||
// console.log(view.uuid+"=>"+view.hero_name+"施放技能:"+config.uuid);
|
||||
if (config.TargetGroup === TargetGroup.Enemy) {
|
||||
view.playSkillEffect(config.uuid);
|
||||
this.doSkill(view,config);
|
||||
this.HeroView.playSkillEffect(config.uuid);
|
||||
this.doSkill(config);
|
||||
}
|
||||
|
||||
if (config.TargetGroup === TargetGroup.Ally) {
|
||||
const targets = this.selectAllyTargets(view, config);
|
||||
const targets = this.selectAllyTargets( config);
|
||||
if (targets.length === 0) return;
|
||||
|
||||
}
|
||||
@@ -55,24 +59,24 @@ export class SkillConComp extends CCComp {
|
||||
}
|
||||
|
||||
}
|
||||
private doSkill(view: HeroViewComp, config: typeof SkillSet[keyof typeof SkillSet]) {
|
||||
private doSkill(config: typeof SkillSet[keyof typeof SkillSet]) {
|
||||
|
||||
const skillEntity = ecs.getEntity<Skill>(Skill);
|
||||
const targets = this.selectEnemyTargets(view, config);
|
||||
const targets = this.selectEnemyTargets(config);
|
||||
if (targets.length === 0) return;
|
||||
skillEntity.load(
|
||||
new Vec3(view.node.position.x, view.node.position.y+BoxSet.ATK_Y, 0), // 起始位置
|
||||
view.box_group, // 阵营
|
||||
view.node.parent, // 父节点
|
||||
new Vec3(this.HeroView.node.position.x, this.HeroView.node.position.y+BoxSet.ATK_Y, 0), // 起始位置
|
||||
this.HeroView.box_group, // 阵营
|
||||
this.node.parent, // 父节点
|
||||
config.uuid, // 技能ID
|
||||
new Vec3(targets[0]?.get(HeroViewComp).node.position.x, targets[0]?.get(HeroViewComp).node.position.y, 0), // 目标位置
|
||||
view
|
||||
this.HeroView
|
||||
);
|
||||
// console.log("技能:"+config.uuid+"=>"+targets[0]?.get(HeroViewComp).hero_name);
|
||||
}
|
||||
|
||||
private selectEnemyTargets(View: HeroViewComp, config: typeof SkillSet[keyof typeof SkillSet]): ecs.Entity[] {
|
||||
const team = View.fac;
|
||||
private selectEnemyTargets(config: typeof SkillSet[keyof typeof SkillSet]): ecs.Entity[] {
|
||||
const team = this.HeroView.fac;
|
||||
const isEnemyTeam = team === 0 ? 1 : 0;
|
||||
const candidates= ecs.query(ecs.allOf(HeroViewComp)).filter(e => e.get(HeroViewComp).fac !== team);
|
||||
return this.filterFrontRow(candidates, isEnemyTeam);
|
||||
@@ -89,8 +93,8 @@ export class SkillConComp extends CCComp {
|
||||
Math.abs(e.get(HeroViewComp).node.position.x - keyPos) < 10
|
||||
);
|
||||
}
|
||||
private selectAllyTargets(View: HeroViewComp, config: typeof SkillSet[keyof typeof SkillSet]): ecs.Entity[] {
|
||||
const team = View.fac;
|
||||
private selectAllyTargets( config: typeof SkillSet[keyof typeof SkillSet]): ecs.Entity[] {
|
||||
const team = this.HeroView.fac;
|
||||
const candidates= ecs.query(ecs.allOf(HeroViewComp)).filter(e => e.get(HeroViewComp).fac === team);
|
||||
// 第二阶段:位置/血量等精细筛选
|
||||
switch(config.TargetType) {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { SkillSet } from "../common/config/SkillSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { MissionEvent } from "../common/config/MissionEvent";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -90,6 +93,7 @@ export class EquipsCompComp extends CCComp {
|
||||
this.boxs.getChildByName("ring").getChildByName("icon").active=false
|
||||
}
|
||||
update(dt: number): void {
|
||||
if(!smc.mission.play||smc.mission.pause) return
|
||||
if(this.skill1.uuid!=0){
|
||||
if(this.skill1.cd_time>0){
|
||||
this.skill1.cd_time-=dt
|
||||
@@ -189,7 +193,7 @@ export class EquipsCompComp extends CCComp {
|
||||
}
|
||||
do_skill(uuid:number){
|
||||
console.log("出发技能:",uuid)
|
||||
|
||||
oops.message.dispatchEvent(GameEvent.CastHeroSkill,uuid)
|
||||
}
|
||||
get_skill(e:GameEvent,data:any){
|
||||
console.log("get_skill")
|
||||
|
||||
@@ -10,14 +10,14 @@ import { CardControllerComp } from "./CardController";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
import { Hero } from "../hero/Hero";
|
||||
import { HartModelComp } from "../hero/HartModelComp";
|
||||
import { TimerManager } from "db://oops-framework/core/common/timer/TimerManager";
|
||||
import { HeroList } from "../common/config/heroSet";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
|
||||
@ccclass('MissionComp')
|
||||
@ecs.register('Mission', false)
|
||||
@ecs.register('MissionComp', false)
|
||||
export class MissionComp extends CCComp {
|
||||
VictoryComp:any = null;
|
||||
reward:number = 0;
|
||||
|
||||
@@ -4,7 +4,6 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { MissionComp } from "./MissionComp";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import { UIID } from "../common/config/GameUIConfig";
|
||||
import { PopViewParams, UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines";
|
||||
import { RewardComp} from "./RewardComp";
|
||||
import { HChipComp } from "../hero/HChipComp";
|
||||
import { MissionComp } from "./MissionComp";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
Reference in New Issue
Block a user