dd
This commit is contained in:
@@ -2,9 +2,9 @@ import { v3, Vec3, _decorator ,Prefab,instantiate} from "cc";
|
|||||||
import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||||
import { CCComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
import { CCComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||||
import { smc } from "../../common/SingletonModuleComp";
|
import { smc } from "../../common/SingletonModuleComp";
|
||||||
import { Role } from "../../role/Role";
|
// import { Role } from "../../role/Role";
|
||||||
import { BoxSet } from "../../common/config/BoxSet";
|
import { BoxSet } from "../../common/config/BoxSet";
|
||||||
import { Hero } from "../../heros/Hero";
|
import { Hero } from "../../monster/Hero";
|
||||||
import { Monster } from "../../monster/Monster";
|
import { Monster } from "../../monster/Monster";
|
||||||
// import MapRoadUtils from "./map/road/MapRoadUtils";
|
// import MapRoadUtils from "./map/road/MapRoadUtils";
|
||||||
import { MapViewScene } from "./MapViewScene";
|
import { MapViewScene } from "./MapViewScene";
|
||||||
@@ -69,13 +69,13 @@ export class MapViewComp extends CCComp {
|
|||||||
|
|
||||||
if(smc.heros.length>0) {
|
if(smc.heros.length>0) {
|
||||||
console.log("heros load")
|
console.log("heros load")
|
||||||
let monster = ecs.getEntity<Monster>(Monster);
|
let hero = ecs.getEntity<Hero>(Hero);
|
||||||
let pos = v3(BoxSet.HERO_START,BoxSet.GAME_LINE)
|
let pos = v3(BoxSet.HERO_START,BoxSet.GAME_LINE)
|
||||||
let speed =smc.heros[0].speed
|
let speed =smc.heros[0].speed
|
||||||
let camp = 1
|
let camp = 1
|
||||||
let prefab_path = smc.heros[0].prefab_path
|
let prefab_path = smc.heros[0].prefab_path
|
||||||
let name = smc.heros[0].name
|
let name = smc.heros[0].name
|
||||||
monster.load(pos,speed,camp,prefab_path,name);
|
hero.load(pos,speed,camp,prefab_path,name);
|
||||||
smc.heros.splice(0,1)
|
smc.heros.splice(0,1)
|
||||||
}
|
}
|
||||||
smc.vm_data.hp.min = 100
|
smc.vm_data.hp.min = 100
|
||||||
|
|||||||
71
assets/script/game/monster/Hero.ts
Normal file
71
assets/script/game/monster/Hero.ts
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: dgflash
|
||||||
|
* @Date: 2021-11-18 17:47:56
|
||||||
|
* @LastEditors: dgflash
|
||||||
|
* @LastEditTime: 2022-08-04 15:43:04
|
||||||
|
*/
|
||||||
|
import { instantiate, Node, Prefab, Vec3 ,tween, v3,Collider2D,Contact2DType,PhysicsSystem2D,IPhysics2DContact, animation,Label,resources,SpriteFrame,Sprite} from "cc";
|
||||||
|
import { UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines";
|
||||||
|
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||||
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||||
|
import { UIID } from "../common/config/GameUIConfig";
|
||||||
|
import { smc } from "../common/SingletonModuleComp";
|
||||||
|
import { MonsterModelComp } from "./MonsterModelComp";
|
||||||
|
import { MonsterSpine } from "./MonsterSpine";
|
||||||
|
import { MonsterViewComp } from "./MonsterViewComp";
|
||||||
|
/** 角色实体 */
|
||||||
|
@ecs.register(`Hero`)
|
||||||
|
export class Hero extends ecs.Entity {
|
||||||
|
// 数据层
|
||||||
|
MonsterModel!: MonsterModelComp;
|
||||||
|
// 视图层
|
||||||
|
MonsterView!: MonsterViewComp;
|
||||||
|
|
||||||
|
protected init() {
|
||||||
|
this.addComponents<ecs.Comp>(
|
||||||
|
MonsterModelComp);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
destroy(): void {
|
||||||
|
this.remove(MonsterViewComp);
|
||||||
|
super.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 加载角色 */
|
||||||
|
load(pos: Vec3 = Vec3.ZERO,speed:number = 100,camp:number = 1,prefab_path:string = "monster",name:string="hero") {
|
||||||
|
// var path = "game/monster/"+prefab_path;
|
||||||
|
var path = "game/monster/hero";
|
||||||
|
|
||||||
|
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||||
|
var node = instantiate(prefab);
|
||||||
|
var scene = smc.map.MapView.scene;
|
||||||
|
node.parent = scene.entityLayer!.node!;
|
||||||
|
var as = node.getComponent(MonsterSpine);
|
||||||
|
|
||||||
|
node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*camp, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z);
|
||||||
|
node.setPosition(pos)
|
||||||
|
console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
|
||||||
|
const url = 'game/heros/hero/'+prefab_path+'/spriteFrame';
|
||||||
|
resources.load(url, SpriteFrame, (err: any, spriteFrame) => {
|
||||||
|
const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
|
||||||
|
|
||||||
|
sprite.spriteFrame = spriteFrame;
|
||||||
|
});
|
||||||
|
|
||||||
|
var mv = node.getComponent(MonsterViewComp)!;
|
||||||
|
mv.speed =mv.ospeed = speed;
|
||||||
|
mv.hero_name= name;
|
||||||
|
mv.camp = camp;
|
||||||
|
mv.Tpos = v3(0,0,0);
|
||||||
|
mv.change_name(name,camp)
|
||||||
|
this.add(mv);
|
||||||
|
smc.heros_in.push({name:mv.ent.name,eid:mv.ent.eid,pos_x:0})
|
||||||
|
oops.message.dispatchEvent("hero_load",this)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
9
assets/script/game/monster/Hero.ts.meta
Normal file
9
assets/script/game/monster/Hero.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.23",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "a45699e6-eeb3-4af3-99a2-de740888bf56",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user