dd
This commit is contained in:
26
assets/script/game/hero/FriendModel.ts
Normal file
26
assets/script/game/hero/FriendModel.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||||
|
import { VM } from "../../../../extensions/oops-plugin-framework/assets/libs/model-view/ViewModel";
|
||||||
|
|
||||||
|
/** 数据层对象 */
|
||||||
|
@ecs.register('FriendModel')
|
||||||
|
export class FriendModelComp extends ecs.Comp {
|
||||||
|
/** 提供 MVVM 组件使用的数据 */
|
||||||
|
private vm: any = {};
|
||||||
|
|
||||||
|
/** 显示数据添加到 MVVM 框架中监视 */
|
||||||
|
vmAdd() {
|
||||||
|
VM.add(this.vm, "FriendModel");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 显示数据从 MVVM 框架中移除 */
|
||||||
|
vmRemove() {
|
||||||
|
VM.remove("FriendModel");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 数据层组件移除时,重置所有数据为默认值 */
|
||||||
|
reset() {
|
||||||
|
for (var key in this.vm) {
|
||||||
|
delete this.vm[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
assets/script/game/hero/FriendModel.ts.meta
Normal file
9
assets/script/game/hero/FriendModel.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.23",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "8f0b0fe4-fa69-4f5b-95d1-833eaafa2103",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ import { BoxSet, FacSet } from "../common/config/BoxSet";
|
|||||||
import { HeroInfo } from "../common/config/heroSet";
|
import { HeroInfo } from "../common/config/heroSet";
|
||||||
import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp";
|
import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp";
|
||||||
import { SkillConComp } from "./SkillConComp";
|
import { SkillConComp } from "./SkillConComp";
|
||||||
|
import { FriendModelComp } from "./FriendModel";
|
||||||
/** 角色实体 */
|
/** 角色实体 */
|
||||||
@ecs.register(`Hero`)
|
@ecs.register(`Hero`)
|
||||||
|
|
||||||
@@ -72,6 +73,7 @@ export class Hero extends ecs.Entity {
|
|||||||
node.parent = scene.entityLayer!.node!
|
node.parent = scene.entityLayer!.node!
|
||||||
node.setPosition(pos)
|
node.setPosition(pos)
|
||||||
// console.log("hero load",pos)
|
// console.log("hero load",pos)
|
||||||
|
this.addComponents<ecs.Comp>(FriendModelComp);
|
||||||
var hv = node.getComponent(HeroViewComp)!;
|
var hv = node.getComponent(HeroViewComp)!;
|
||||||
let hero= HeroInfo[uuid] // 共用英雄数据
|
let hero= HeroInfo[uuid] // 共用英雄数据
|
||||||
hv.scale = scale;
|
hv.scale = scale;
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import { oops } from "db://oops-framework/core/Oops";
|
|||||||
import { GameEvent } from "../common/config/GameEvent";
|
import { GameEvent } from "../common/config/GameEvent";
|
||||||
import { FightConComp } from "../map/FightConComp";
|
import { FightConComp } from "../map/FightConComp";
|
||||||
import { EquipSpecialAttr } from "../common/config/Equips";
|
import { EquipSpecialAttr } from "../common/config/Equips";
|
||||||
|
import { FightSet } from "../common/config/Mission";
|
||||||
|
import { HeroPos } from "../common/config/heroSet";
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
|
|
||||||
@@ -308,7 +310,10 @@ export class HeroViewComp extends CCComp {
|
|||||||
this.to_drop()
|
this.to_drop()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
to_alive(){
|
||||||
|
this.is_dead=false
|
||||||
|
this.node.setPosition(HeroPos[0].pos)
|
||||||
|
}
|
||||||
//掉落物品
|
//掉落物品
|
||||||
to_drop(){
|
to_drop(){
|
||||||
// let Drops = getMonsterDrops(1, MonsterType.Normal, 1.2);
|
// let Drops = getMonsterDrops(1, MonsterType.Normal, 1.2);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { HeroViewComp } from "../hero/HeroViewComp";
|
|||||||
import { oops } from "db://oops-framework/core/Oops";
|
import { oops } from "db://oops-framework/core/Oops";
|
||||||
import { HeroPos } from "../common/config/heroSet";
|
import { HeroPos } from "../common/config/heroSet";
|
||||||
import { FightSet } from "../common/config/Mission";
|
import { FightSet } from "../common/config/Mission";
|
||||||
|
import { FriendModelComp } from "../hero/FriendModel";
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
/** 视图层对象 */
|
/** 视图层对象 */
|
||||||
@@ -21,14 +22,18 @@ export class MissionHeroCompComp extends CCComp {
|
|||||||
Friend_is_dead:boolean=false
|
Friend_is_dead:boolean=false
|
||||||
current_hero_uuid:number=0
|
current_hero_uuid:number=0
|
||||||
onLoad(){
|
onLoad(){
|
||||||
this.on(GameEvent.UseHeroCard,this.call_hero,this)
|
this.on(GameEvent.UseHeroCard,this.call_friend,this)
|
||||||
this.on(GameEvent.ChangeATK_FRIEND_LIVE_CD,this.change_friend_alive_cd,this)
|
this.on(GameEvent.ChangeATK_FRIEND_LIVE_CD,this.change_friend_alive_cd,this)
|
||||||
|
this.on(GameEvent.FightReady,this.fight_ready,this)
|
||||||
|
|
||||||
}
|
}
|
||||||
start() {
|
start() {
|
||||||
// this.test_call()
|
// this.test_call()
|
||||||
this.node.getChildByName("location").active=false
|
this.node.getChildByName("location").active=false
|
||||||
}
|
}
|
||||||
|
fight_ready(){
|
||||||
|
this.Friend_alive_cd=new Timer(FightSet.FRIEND_LIVE_CD)
|
||||||
|
}
|
||||||
protected update(dt: number): void {
|
protected update(dt: number): void {
|
||||||
if(smc.mission.status != 1) return
|
if(smc.mission.status != 1) return
|
||||||
if(this.Friend_is_dead){
|
if(this.Friend_is_dead){
|
||||||
@@ -38,17 +43,34 @@ export class MissionHeroCompComp extends CCComp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
change_friend_alive_cd(e:GameEvent,data:any){
|
change_friend_alive_cd(e:GameEvent,data:any){
|
||||||
console.log("change_friend_alive_cd",data)
|
console.log("change_friend_alive_cd",data)
|
||||||
this.Friend_alive_cd=new Timer(FightSet.FRIEND_LIVE_CD-data)
|
this.Friend_alive_cd=new Timer(FightSet.FRIEND_LIVE_CD-data)
|
||||||
}
|
}
|
||||||
|
|
||||||
init(){
|
private call_friend(event: string, args: any,freind_pos:number=0){
|
||||||
|
console.log("call_hero addHero",args.uuid)
|
||||||
|
let info:any={ap:0,hp:0,lv:0}
|
||||||
|
let hero = ecs.getEntity<Hero>(Hero);
|
||||||
|
let scale = 1
|
||||||
|
let pos:Vec3 = HeroPos[freind_pos].pos;
|
||||||
|
hero.load(pos,scale,args.uuid,info,freind_pos);
|
||||||
|
oops.message.dispatchEvent(GameEvent.HeroSelectEnd)
|
||||||
|
console.log("call_friend",hero)
|
||||||
|
}
|
||||||
|
|
||||||
|
alive_friend(){
|
||||||
|
this.Friend_is_dead=false
|
||||||
|
let heros = ecs.query(ecs.allOf(FriendModelComp))
|
||||||
|
for(let hero of heros){
|
||||||
|
let hv = hero.get(HeroViewComp)
|
||||||
|
if(hv.is_dead){
|
||||||
|
hv.to_alive()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
test_call(){
|
|
||||||
this.addHero(5010)
|
|
||||||
}
|
|
||||||
// show_heros_pos(event: string, args: any){
|
// show_heros_pos(event: string, args: any){
|
||||||
// console.log("show_heros_pos",args)
|
// console.log("show_heros_pos",args)
|
||||||
// this.current_hero_uuid=args.uuid
|
// this.current_hero_uuid=args.uuid
|
||||||
@@ -88,17 +110,19 @@ export class MissionHeroCompComp extends CCComp {
|
|||||||
|
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
call_hero(event: string, args: any){
|
|
||||||
// this.node.getChildByName("location").active=false
|
|
||||||
// console.log("call_hero",args)
|
// call_hero(event: string, args: any){
|
||||||
// let fight_pos=args
|
// // this.node.getChildByName("location").active=false
|
||||||
// this.timer.reset()
|
// // console.log("call_hero",args)
|
||||||
// let hero_list =HeroList
|
// // let fight_pos=args
|
||||||
// let x=RandomManager.instance.getRandomInt(0,hero_list.length,1)
|
// // this.timer.reset()
|
||||||
// // let uuid=args.uuid
|
// // let hero_list =HeroList
|
||||||
// // console.log("call_hero",uuid)
|
// // let x=RandomManager.instance.getRandomInt(0,hero_list.length,1)
|
||||||
this.addHero(args.uuid)
|
// // // let uuid=args.uuid
|
||||||
}
|
// // // console.log("call_hero",uuid)
|
||||||
|
// this.addHero(args.uuid)
|
||||||
|
// }
|
||||||
|
|
||||||
/** 添加英雄 */
|
/** 添加英雄 */
|
||||||
private addHero(uuid:number=1001,freind_pos:number=0) {
|
private addHero(uuid:number=1001,freind_pos:number=0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user