去掉原先的monster文件夹下面文件

This commit is contained in:
2024-09-11 10:41:49 +08:00
parent f5a8cb20de
commit b5406bd9af
38 changed files with 17 additions and 5200 deletions

View File

@@ -1,9 +0,0 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "a3329190-800f-450a-a5a0-90a4b59ddd4b",
"files": [],
"subMetas": {},
"userData": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +0,0 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "42a5e9a1-8664-4eee-ab17-56cb55b545b2",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "hero"
}
}

View File

@@ -1,6 +0,0 @@
skeleton.png
size:86,55
filter:Linear,Linear
pma:true
bb
bounds:2,2,82,51

View File

@@ -1,12 +0,0 @@
{
"ver": "1.0.1",
"importer": "*",
"imported": true,
"uuid": "958e8fe7-e356-4285-aa30-1ec62e24f36e",
"files": [
".atlas",
".json"
],
"subMetas": {},
"userData": {}
}

View File

@@ -1,102 +0,0 @@
{
"skeleton": {
"hash": "jMvRjm/pTv0",
"spine": "4.2.35",
"x": -0.82,
"y": 24.4,
"width": 15.52,
"height": 9.6,
"images": "",
"audio": ""
},
"bones": [
{ "name": "root" },
{ "name": "bone", "parent": "root", "y": 24, "scaleX": 1.0139, "scaleY": 1.0139 }
],
"slots": [
{ "name": "bb", "bone": "bone", "attachment": "bb" }
],
"skins": [
{
"name": "default",
"attachments": {
"bb": {
"bb": { "x": 6.85, "y": 5.13, "scaleX": 0.1867, "scaleY": 0.1857, "width": 82, "height": 51 }
}
}
}
],
"animations": {
"atk": {
"bones": {
"bone": {
"scale": [
{},
{ "time": 0.2, "x": 0.682 },
{ "time": 0.4667, "x": 1.06 },
{ "time": 0.6 }
],
"shear": [
{},
{ "time": 0.2, "y": 29.28 },
{ "time": 0.4667, "y": -30 },
{ "time": 0.6 }
]
}
}
},
"atk2": {
"bones": {
"bone": {
"translate": [
{},
{ "time": 0.2, "x": -8 },
{ "time": 0.3333, "x": 20 },
{ "time": 0.6 }
],
"scale": [
{},
{ "time": 0.2, "x": 0.87 },
{ "time": 0.3333, "x": 1.085 },
{ "time": 0.6 }
]
}
}
},
"magic": {
"bones": {
"bone": {
"rotate": [
{},
{ "time": 0.5, "value": 25.28 },
{ "time": 0.6667 }
]
}
}
},
"max": {
"bones": {
"bone": {
"scale": [
{},
{ "time": 0.5, "x": 0.789, "y": 0.789 },
{ "time": 0.6667, "x": 1.233, "y": 1.233 },
{ "time": 0.8333, "x": 0.986, "y": 0.986 }
]
}
}
},
"move": {
"bones": {
"bone": {
"scale": [
{},
{ "time": 0.3333, "x": 1.085, "y": 0.993 },
{ "time": 0.6667, "x": 0.888, "y": 0.986 },
{ "time": 1 }
]
}
}
}
}
}

View File

@@ -1,11 +0,0 @@
{
"ver": "1.2.6",
"importer": "spine-data",
"imported": true,
"uuid": "a80809a8-64bf-4c66-b49e-7aa837d821dd",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1,42 +0,0 @@
{
"ver": "1.0.26",
"importer": "image",
"imported": true,
"uuid": "a2c2ea64-e32d-425c-87be-2e57155a04b2",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "a2c2ea64-e32d-425c-87be-2e57155a04b2@6c48a",
"displayName": "skeleton",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "repeat",
"wrapModeT": "repeat",
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0,
"isUuid": true,
"imageUuidOrDatabaseUri": "a2c2ea64-e32d-425c-87be-2e57155a04b2",
"visible": false
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"hasAlpha": true,
"type": "texture",
"fixAlphaTransparencyArtifacts": false,
"redirect": "a2c2ea64-e32d-425c-87be-2e57155a04b2@6c48a"
}
}

View File

@@ -19,8 +19,8 @@ const { ccclass, property } = _decorator;
@ccclass('Main') @ccclass('Main')
export class Main extends Root { export class Main extends Root {
start() { start() {
if (DEBUG) profiler.showStats(); // if (DEBUG) profiler.showStats();
PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb // PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb
// // | EPhysics2DDrawFlags.Pair // // | EPhysics2DDrawFlags.Pair
// |EPhysics2DDrawFlags.CenterOfMass // |EPhysics2DDrawFlags.CenterOfMass
// |EPhysics2DDrawFlags.Joint // |EPhysics2DDrawFlags.Joint

View File

@@ -10,7 +10,6 @@ import { Initialize } from "../initialize/Initialize";
import { GameMap } from "../map/GameMap"; import { GameMap } from "../map/GameMap";
import { BoxSet } from "./config/BoxSet"; import { BoxSet } from "./config/BoxSet";
import { Role } from "../Role/Role"; import { Role } from "../Role/Role";
import { Monster } from "../monster/Monster";
import { v3 } from "cc"; import { v3 } from "cc";
// import { Role } from "../role/Role"; // import { Role } from "../role/Role";

View File

@@ -87,8 +87,6 @@ export class HeroBuffComp extends CCComp {
if(b.skill_uuid==buff.skill_uuid){ if(b.skill_uuid==buff.skill_uuid){
b.time=buff.time; b.time=buff.time;
if(buff.atk>0){ if(buff.atk>0){
this.node.getChildByName("avatar").setScale(1.2,1.2)
this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#F16F6F");
this.mv.atk+=(buff.atk+buff.args.atk-b.atk); this.mv.atk+=(buff.atk+buff.args.atk-b.atk);
} }
if(buff.hp>0){ if(buff.hp>0){
@@ -109,8 +107,6 @@ export class HeroBuffComp extends CCComp {
this.buffs.push(buff); this.buffs.push(buff);
if(buff.atk>0){ if(buff.atk>0){
this.mv.atk+=(buff.atk+buff.args.atk); this.mv.atk+=(buff.atk+buff.args.atk);
this.node.getChildByName("avatar").setScale(1.2,1.2)
this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#F16F6F");
} }
if(buff.hp>0){ if(buff.hp>0){
this.mv.hp+=(buff.hp+buff.args.hp); this.mv.hp+=(buff.hp+buff.args.hp);
@@ -128,8 +124,6 @@ export class HeroBuffComp extends CCComp {
buff_remove(index:number){ buff_remove(index:number){
if(this.buffs[index].atk>0){ if(this.buffs[index].atk>0){
this.mv.atk-=(this.buffs[index].atk+this.buffs[index].args.atk); this.mv.atk-=(this.buffs[index].atk+this.buffs[index].args.atk);
this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#FFFFFF");
this.node.getChildByName("avatar").setScale(1,1)
} }
if(this.buffs[index].shield>0){ if(this.buffs[index].shield>0){
this.mv.shield=0 this.mv.shield=0

View File

@@ -3,12 +3,10 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
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 { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { HeroCard } from "../monster/HeroCard";
import { HeroCardViewComp } from "../monster/HeroCardViewComp";
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager"; import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
import { CardList } from "../common/config/CardSet"; import { CardList } from "../common/config/CardSet";
import { HeroModelComp } from "../monster/HeroModelComp";
import { SkillSet } from "../common/config/SkillSet"; import { SkillSet } from "../common/config/SkillSet";
import { HeroModelComp } from "../hero/HeroModelComp";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
/** 视图层对象 */ /** 视图层对象 */
@@ -301,13 +299,13 @@ export class CardControllerComp extends CCComp {
// console.log("cards:",this.cards) // console.log("cards:",this.cards)
} }
check_card(index:number){ check_card(index:number){
let heros = ecs.query(ecs.allOf(HeroModelComp)) // let heros = ecs.query(ecs.allOf(HeroModelComp))
// let heross= ecs.query(ecs.allOf(MonsterViewComp)) // let heross= ecs.query(ecs.allOf(MonsterViewComp))
// console.log("heross",heross) // console.log("heross",heross)
if(heros.length >= 4&&this.cards[index].type == 1){ // if(heros.length >= 4&&this.cards[index].type == 1){
oops.gui.toast("英雄数量达到上限"); // oops.gui.toast("英雄数量达到上限");
return; // return;
} // }
if(!this.cards[index].alive) { if(!this.cards[index].alive) {
// console.log("card_index:",index,"card_alive:",this.cards[index].alive) // console.log("card_index:",index,"card_alive:",this.cards[index].alive)
return; return;

View File

@@ -2,7 +2,6 @@ import { _decorator ,Vec3,v3} 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 { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer"; import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
import { Monster } from "../monster/Monster";
import { BoxSet } from "../common/config/BoxSet"; import { BoxSet } from "../common/config/BoxSet";
import { smc } from "../common/SingletonModuleComp"; import { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
@@ -12,8 +11,8 @@ import { RandomManager } from "../../../../extensions/oops-plugin-framework/asse
import { Role } from "../Role/Role"; import { Role } from "../Role/Role";
import { Hero } from "../hero/Hero"; import { Hero } from "../hero/Hero";
import { HeroModelComp } from "../hero/HeroModelComp"; import { HeroModelComp } from "../hero/HeroModelComp";
import { MonsterModelComp } from "../monster/MonsterModelComp";
import { Mon } from "../mon/Mon"; import { Mon } from "../mon/Mon";
import { MonModelComp } from "../mon/MonModelComp";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
/** 视图层对象 */ /** 视图层对象 */
@@ -82,7 +81,7 @@ export class MapMonsterComp extends CCComp {
target_update(){ target_update(){
console.log("map ",smc.t_hero,smc.t_monster) console.log("map ",smc.t_hero,smc.t_monster)
let heros:any = ecs.query(ecs.allOf(HeroModelComp)); let heros:any = ecs.query(ecs.allOf(HeroModelComp));
let monsters:any =ecs.query(ecs.allOf(MonsterModelComp)); let monsters:any =ecs.query(ecs.allOf(MonModelComp));
let h_x=-1000 let h_x=-1000
let m_x=1000 let m_x=1000
let thi=9999 let thi=9999

View File

@@ -87,8 +87,6 @@ export class MonBuffComp extends CCComp {
if(b.skill_uuid==buff.skill_uuid){ if(b.skill_uuid==buff.skill_uuid){
b.time=buff.time; b.time=buff.time;
if(buff.atk>0){ if(buff.atk>0){
this.node.getChildByName("avatar").setScale(1.2,1.2)
this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#F16F6F");
this.mv.atk+=(buff.atk+buff.args.atk-b.atk); this.mv.atk+=(buff.atk+buff.args.atk-b.atk);
} }
if(buff.hp>0){ if(buff.hp>0){
@@ -109,8 +107,6 @@ export class MonBuffComp extends CCComp {
this.buffs.push(buff); this.buffs.push(buff);
if(buff.atk>0){ if(buff.atk>0){
this.mv.atk+=(buff.atk+buff.args.atk); this.mv.atk+=(buff.atk+buff.args.atk);
this.node.getChildByName("avatar").setScale(1.2,1.2)
this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#F16F6F");
} }
if(buff.hp>0){ if(buff.hp>0){
this.mv.hp+=(buff.hp+buff.args.hp); this.mv.hp+=(buff.hp+buff.args.hp);
@@ -128,8 +124,6 @@ export class MonBuffComp extends CCComp {
buff_remove(index:number){ buff_remove(index:number){
if(this.buffs[index].atk>0){ if(this.buffs[index].atk>0){
this.mv.atk-=(this.buffs[index].atk+this.buffs[index].args.atk); this.mv.atk-=(this.buffs[index].atk+this.buffs[index].args.atk);
this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#FFFFFF");
this.node.getChildByName("avatar").setScale(1,1)
} }
if(this.buffs[index].shield>0){ if(this.buffs[index].shield>0){
this.mv.shield=0 this.mv.shield=0

View File

@@ -2,7 +2,7 @@
"ver": "1.2.0", "ver": "1.2.0",
"importer": "directory", "importer": "directory",
"imported": true, "imported": true,
"uuid": "9addebc8-0dc6-46c3-b9d5-091539127714", "uuid": "365c3351-a0ac-4fd1-a400-9183a2085947",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": {} "userData": {}

View File

@@ -1,41 +0,0 @@
/*
* @Author: dgflash
* @Date: 2021-11-18 15:56:01
* @LastEditors: dgflash
* @LastEditTime: 2022-08-17 13:43:25
*/
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { Monster } from "./Monster";
/**
* 角色属性数据
*/
@ecs.register('BaseMonsterModel')
export class BaseMonsterModel extends ecs.Comp {
/** 角色编号 */
hp: number = 100;
/** 角色名 */
name: string = "base monster";
/** */
reset() {
this.hp = 100;
this.name = "";
}
}
@ecs.register('Monster')
export class MonsterUpgradeSystem extends ecs.ComblockSystem implements ecs.IEntityEnterSystem {
filter(): ecs.IMatcher {
return ecs.allOf(BaseMonsterModel);
}
entityEnter(e: Monster): void {
let MonsterModel = e.MonsterModel;
MonsterModel.name = "base monster"
console.log("MonsterUpgradeSystem", e);
e.remove(BaseMonsterModel);
}
}

View File

@@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "52aacfb8-cb73-4ce1-be54-3c2a83e83408",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -1,83 +0,0 @@
import { _decorator,Contact2DType,Collider2D ,IPhysics2DContact,v3, v2,Vec3} 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 { BoxSet } from "../common/config/BoxSet";
import { MonsterViewComp } from "./MonsterViewComp";
import { smc } from "../common/SingletonModuleComp";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('BoxRangComp')
@ecs.register('BoxRang', false)
export class BoxRangComp extends CCComp {
Hero_node: any=null!;
MonsterViewComp:MonsterViewComp = null!;
box_group:number = BoxSet.DEFAULT;
box_tag:number = BoxSet.ATK_RANGE;
offset_x:number = 300;
atk_range:number = 150;
/** 视图层逻辑代码分离演示 */
start() {
let collider = this.getComponent(Collider2D);
collider.group = this.box_group;
collider.tag = this.box_tag;
// collider.offset = v2(300*this.Hero_node.MonsterView.scale,collider.offset.y);
this.Hero_node = this.node.parent;
this.MonsterViewComp=this.Hero_node.getComponent(MonsterViewComp);
// console.log("range box",this.MonsterViewComp);
if (collider) {
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
collider.on(Contact2DType.PRE_SOLVE, this.onPreSolve, this);
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
}
}
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
// if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
// console.log(this.node.name+"onBeginContact: seft:"+selfCollider.group+"|other:"+otherCollider.group+"| tag: seft:"+selfCollider.tag+"|other:"+otherCollider.tag);
// this.MonsterViewComp.is_atking = true;
// if(Math.abs(otherCollider.node.position.x-selfCollider.node.position.x) < 120){
// this.MonsterViewComp.stop_cd = 0.1
// }
// }
}
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0 ){
// console.log(this.node.name+"onEndContact: seft:"+selfCollider.group+"|other:"+otherCollider.group+"| tag: seft:"+selfCollider.tag+"|other:"+otherCollider.tag);
this.MonsterViewComp.is_atking = false;
this.MonsterViewComp.enemy = null;
}
}
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
let scene =smc.map.MapView.scene.mapLayer!.node!
let other_pos = otherCollider.node.getWorldPosition() ;
let self_pos = this.node.getWorldPosition();
// console.log("onPreSolve:",self_pos,other_pos);
if(this.MonsterViewComp.enemy==null){
this.MonsterViewComp.enemy = otherCollider.node;
}else{
if(this.MonsterViewComp.enemy.isValid==false){
this.MonsterViewComp.enemy = otherCollider.node;
}
}
if(Math.abs(other_pos.x-self_pos.x) < this.atk_range){
this.MonsterViewComp.is_atking = true;
// this.MonsterViewComp.stop_cd = 0.1
}
}
}
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}

View File

@@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "330a455c-5623-4654-87a9-e37bf3a226f7",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -1,103 +0,0 @@
/*
* @Author: dgflash
* @Date: 2021-11-18 17:47:56
* @LastEditors: dgflash
* @LastEditTime: 2022-08-04 15:43:04
*/
import { instantiate, Node, Prefab, Vec3,v3,resources,SpriteFrame,Sprite,SpriteAtlas} 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";
import {HeroModelComp} from "./HeroModelComp";
import { BoxSet } from "../common/config/BoxSet";
import { MonsterBuffComp } from "./MonsterBuffComp";
/** 角色实体 */
@ecs.register(`Hero`)
export class Hero extends ecs.Entity {
// 数据层
HeroModel!: HeroModelComp;
// 视图层
MonsterView!: MonsterViewComp;
protected init() {
this.addComponents<ecs.Comp>(HeroModelComp);
}
destroy(): void {
this.remove(MonsterViewComp);
this.remove(HeroModelComp);
this.remove(MonsterBuffComp);
super.destroy();
}
/** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,layer:Node=smc.map.MapView.scene.entityLayer!.node!) {
// var path = "game/monster/"+prefab_path;
var path = "game/heros/hero";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.parent=layer
// let ratio=this.set_ratio(uuid);
node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*scale, node.getChildByName("avatar").scale.y,0);
node.setPosition(pos)
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
const url = 'game/heros/heros';
resources.load(url, SpriteAtlas, (err: any, atlas) => {
const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(smc.heros[uuid].path);
});
this.hero_init(uuid,node)
oops.message.dispatchEvent("hero_load",this)
}
set_ratio(uuid:number){
let ratio=1;
switch (smc.heros[uuid].level) {
case 2:
ratio=1.1
break;
case 3:
ratio=1.2
break;
case 4:
ratio=1.3
break;
case 5:
ratio=1.4
break;
default:
ratio=1
}
return ratio;
}
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
var mv = node.getComponent(MonsterViewComp)!;
var buff =node.getComponent(MonsterBuffComp)!;
mv.hero_uuid=uuid;
mv.speed =mv.ospeed = smc.heros[uuid].speed;
mv.hero_name= smc.heros[uuid].name;
buff.group= mv.box_group= BoxSet.HERO;
mv.hp= mv.hp_max = smc.heros[uuid].hp;
mv.level = smc.heros[uuid].level;
mv.atk = smc.heros[uuid].atk;
mv.atk_cd = smc.heros[uuid].atk_cd;
mv.power = smc.heros[uuid].power;
mv.type = smc.heros[uuid].type;
mv.skill_uuid = 9001;
mv.max_skill_uuid = smc.heros[uuid].max_skill_uuid;
mv.Tpos = v3(0,0,0);
mv.scale = 1;
// mv.change_name(smc.heros[uuid].name,1)
this.add(mv);
this.add(buff);
}
}

View File

@@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "a45699e6-eeb3-4af3-99a2-de740888bf56",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -6,11 +6,9 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/O
import { smc } from "../common/SingletonModuleComp"; import { smc } from "../common/SingletonModuleComp";
import { SkillSet } from "../common/config/SkillSet"; import { SkillSet } from "../common/config/SkillSet";
import { HeroCard } from "./HeroCard"; import { HeroCard } from "./HeroCard";
import { HeroModelComp } from "./HeroModelComp";
import { Hero } from "./Hero";
import { MonsterViewComp } from "./MonsterViewComp";
import { MapMonsterComp } from "../map/MapMonsterComp"; import { MapMonsterComp } from "../map/MapMonsterComp";
import { MapSkillComp } from "../map/MapSkillComp"; import { MapSkillComp } from "../map/MapSkillComp";
import { HeroModelComp } from "../hero/HeroModelComp";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
/** 视图层对象 */ /** 视图层对象 */

View File

@@ -1,26 +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";
/** 数据层对象 */
@ecs.register('HeroModel')
export class HeroModelComp extends ecs.Comp {
/** 提供 MVVM 组件使用的数据 */
// private vm: any = {};
// /** 显示数据添加到 MVVM 框架中监视 */
// vmAdd() {
// VM.add(this.vm, "HeroModelComp");
// }
// /** 显示数据从 MVVM 框架中移除 */
// vmRemove() {
// VM.remove("HeroModelComp");
// }
/** 数据层组件移除时,重置所有数据为默认值 */
reset() {
// for (var key in this.vm) {
// delete this.vm[key];
// }
}
}

View File

@@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "f7b9c48b-c4ed-4641-9f2f-ab5b317e7f0c",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -1,102 +0,0 @@
/*
* @Author: dgflash
* @Date: 2021-11-18 17:47:56
* @LastEditors: dgflash
* @LastEditTime: 2022-08-04 15:43:04
*/
import { instantiate, Node, Prefab, Vec3 ,v3,resources,SpriteFrame,Sprite,SpriteAtlas} 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";
import { BoxSet } from "../common/config/BoxSet";
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
import { MonsterBuffComp } from "./MonsterBuffComp";
/** 角色实体 */
@ecs.register(`Monster`)
export class Monster extends ecs.Entity {
// 数据层
MonsterModel!: MonsterModelComp;
// 视图层
MonsterView!: MonsterViewComp;
MonsterBuff!: MonsterBuffComp; // 移动
protected init() {
this.addComponents<ecs.Comp>( MonsterModelComp);
}
destroy(): void {
this.remove(MonsterViewComp);
this.remove(MonsterBuffComp);
super.destroy();
}
/** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,scale:number = -1,uuid:number=1001,layer:Node=smc.map.MapView.scene.entityLayer!.node!) {
// var path = "game/monster/"+prefab_path;
var path = "game/heros/hero";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.parent=layer
// var as = node.getComponent(MonsterSpine);
let ratio=this.set_ratio(uuid);
node.setScale(node.scale.x*scale*ratio, node.scale.y*ratio, 0);
// node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*scale, 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/heros';
resources.load(url, SpriteAtlas, (err: any, atlas) => {
const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(smc.heros[uuid].path);
});
this.hero_init(uuid,node)
oops.message.dispatchEvent("monster_load",this)
}
set_ratio(uuid:number){
let ratio=1;
switch (smc.heros[uuid].level) {
case 2:
ratio=1.05
break;
case 3:
ratio=1.1
break;
case 4:
ratio=1.15
break;
case 5:
ratio=1.2
break;
default:
ratio=1
}
return ratio;
}
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
var mv = node.getComponent(MonsterViewComp)!;
var buff =node.getComponent(MonsterBuffComp)!;
// console.log("hero_init",smc.heros,uuid)
mv.speed =mv.ospeed = smc.heros[uuid].speed;
mv.hero_name= smc.heros[uuid].name;
buff.group=mv.box_group= BoxSet.MONSTER;
mv.hp= mv.hp_max = smc.heros[uuid].hp;
mv.level = smc.heros[uuid].level;
mv.atk = smc.heros[uuid].atk;
mv.atk_cd = smc.heros[uuid].atk_cd;
mv.power = smc.heros[uuid].power;
mv.type = smc.heros[uuid].type;
mv.skill_uuid = 9001;
mv.max_skill_uuid = smc.heros[uuid].max_skill_uuid;
mv.scale = -1;
mv.Tpos = v3(0,0,0);
this.add(mv);
this.add(buff);
}
}

View File

@@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "e889d785-f34d-46f5-825c-8906863db245",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -1,154 +0,0 @@
/*
* @Author: dgflash
* @Date: 2021-11-18 17:42:59
* @LastEditors: dgflash
* @LastEditTime: 2022-08-17 12:36:18
*/
import { _decorator,Sprite,Color} 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 { MonsterSpine } from "./MonsterSpine";
import { Monster } from "./Monster";
import { Hero } from "./Hero";
import { MonsterModelComp } from "./MonsterModelComp";
import { BoxSet } from "../common/config/BoxSet";
import { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { Skill } from "../skills/Skill";
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
import { SkillCom } from "../skills/SkillCom";
import { BoxRangComp } from "./BoxRangComp";
import { Tooltip } from "../skills/Tooltip";
import { MonsterViewComp } from "./MonsterViewComp";
const { ccclass, property } = _decorator;
/** 角色显示组件 */
@ccclass('MonsterBuffComp') // 定义为 Cocos Creator 组件
@ecs.register('MonsterBuff', false) // 定义为 ECS 组件
export class MonsterBuffComp extends CCComp {
/** 角色动画 */
as: MonsterSpine = null!;
mv!: MonsterViewComp;
timer:Timer = new Timer(0.1);
buffs:any=[];
group:number=0;
/**
skill_uuid:number=0;
atk:number=0;
hp:number=0;
shield:number=0;
time:number=0;
**/
onLoad() {
this.as = this.node.getComponent(MonsterSpine);
this.mv= this.getComponent(MonsterViewComp);
} /** 视图层逻辑代码分离演示 */
start () {
}
add_buff(uuid:number=0,args:any[]){
// console.log("add_buff",smc.skills[uuid]);
let new_buff={
skill_uuid:uuid,
skill_name:smc.skills[uuid].name,
atk:smc.skills[uuid].atk,
hp:smc.skills[uuid].hp,
shield:smc.skills[uuid].shield,
time:smc.skills[uuid].bsd,
bcd:smc.skills[uuid].bcd,
sk_uuid:smc.skills[uuid].uuid,
args:args
}
this.buff_add(new_buff);
}
update(dt: number){
if (this.timer.update(dt)) {
this.buff_update()
}
}
reset() {
this.node.destroy();
}
buff_add(buff:any){
if(!this.node.isValid){ return }
let i = 0
if(this.buffs.length >=0){
this.buffs.forEach((b:any,index:number)=>{
if(b.skill_uuid==buff.skill_uuid){
b.time=buff.time;
if(buff.atk>0){
this.node.getChildByName("avatar").setScale(1.2,1.2)
this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#F16F6F");
this.mv.atk+=(buff.atk+buff.args.atk-b.atk);
}
if(buff.hp>0){
this.mv.hp+=(buff.hp+buff.args.hp);
this.mv.add_hp(buff.hp+buff.args.hp);
// this.mv.hp_max+=(buff.hp-b.hp);
}
if(buff.shield>0){
this.mv.shield=(buff.shield+buff.args.shield);
// this.mv.shield_max=(buff.shield+buff.args.shield);
}
i=index
}
})
}
if (i==0||this.buffs.length==0) {
this.buffs.push(buff);
if(buff.atk>0){
this.mv.atk+=(buff.atk+buff.args.atk);
this.node.getChildByName("avatar").setScale(1.2,1.2)
this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#F16F6F");
}
if(buff.hp>0){
this.mv.hp+=(buff.hp+buff.args.hp);
this.mv.add_hp(buff.hp+buff.args.hp);
// this.mv.hp_max+=buff.hp;
}
if(buff.shield>0){
this.mv.shield=(buff.shield+buff.args.shield);
// this.mv.shield_max=(buff.shield+buff.args.shield);
}
}
console.log("buff add:",this.mv);
}
buff_remove(index:number){
if(this.buffs[index].atk>0){
this.mv.atk-=(this.buffs[index].atk+this.buffs[index].args.atk);
this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#FFFFFF");
this.node.getChildByName("avatar").setScale(1,1)
}
if(this.buffs[index].shield>0){
this.mv.shield=0
// this.mv.shield_max-=(this.buffs[index].shield+this.buffs[index].args.shield);
}
// if(this.buffs[index].hp>0){
// this.mv.hp_max-=this.buffs[index].hp;
// }
console.log("buff remove:",this.mv,this.buffs[index]);
}
buff_update(){
this.buffs.forEach((buff:any,index:number)=>{
buff.time -= 0.1;
if(buff.time <= 0){
this.buff_remove(index);
}
})
this.buffs = this.buffs.filter((buff:any) => buff.time > 0);
// console.log(this.buffs,this.buffs);
}
}

View File

@@ -1 +0,0 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"265743f5-c04b-411d-9772-2c9bd0156a09","files":[],"subMetas":{},"userData":{}}

View File

@@ -1,29 +0,0 @@
/*
* @Author: dgflash
* @Date: 2021-11-18 15:56:01
* @LastEditors: dgflash
* @LastEditTime: 2022-08-17 13:43:25
*/
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
/**
* 角色属性数据
*/
@ecs.register('MonsterModel')
export class MonsterModelComp extends ecs.Comp {
/** 角色编号 */
id: number = -1;
/** 角色名 */
name: string = "monster";
/** speed */
// speed: number = 0;
/** 动画名资源 */
anim: string = "monster";
reset() {
this.id = -1;
// this.speed = 0;
this.name = "";
}
}

View File

@@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "b5f2873a-5007-436b-95ef-1e73281a374f",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -1,82 +0,0 @@
/*
* @Author: dgflash
* @Date: 2022-08-04 15:08:35
* @LastEditors: dgflash
* @LastEditTime: 2022-08-04 15:26:26
*/
import { Color, Component, EventTouch, sp, Vec3, _decorator } from "cc";
import { LayerUtil } from "../../../../extensions/oops-plugin-framework/assets/core/utils/LayerUtil";
import { smc } from "../../../script/game/common/SingletonModuleComp";
import MonsterSpineAnimator from "./MonsterSpineAnimator";
const { ccclass, property } = _decorator;
/**
* SPINE角色模型
*/
@ccclass('MonsterSpine')
export class MonsterSpine extends Component {
@property({ type: MonsterSpineAnimator, tooltip: '动画控制器' })
animator: MonsterSpineAnimator = null!;
private spine!: sp.Skeleton;
onLoad() {
// 角色控制组件
this.initAnimator();
// this.setSkin("magic");
// this.animator.play("idle", true);
LayerUtil.setNodeLayer(LayerUtil.MAP, this.node);
}
/** 初始化动画 */
protected initAnimator() {
this.spine = this.animator.getComponent(sp.Skeleton)!;
// console.log("MonsterSpine initAnimator", this.spine);
}
setSkin(value: string): void {
this.spine.setSkin(value);
}
play(animName: string, loop: boolean): void {
this.spine.setAnimation(0, animName, loop);
}
atk() {
this.spine.setAnimation(0, "atk2", false);
}
maxSkill () {
this.spine.setAnimation(0, "max", false);
}
setAlpha(value: number): void {
var color: Color = this.spine.color;
color.a = 255 * (value / 1);
this.spine.color = color;
}
setPos(value: Vec3): void {
this.node.position = value;
}
checkTouch(event: EventTouch): boolean {
return false;
}
onDestroy() {
this.node.destroy();
}
walk() {
}
idle() {
}
}

View File

@@ -1 +0,0 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"482c216c-bef6-49fb-9060-37777b818f83","files":[],"subMetas":{},"userData":{}}

View File

@@ -1,72 +0,0 @@
/*
* @Author: dgflash
* @Date: 2022-08-04 15:08:35
* @LastEditors: dgflash
* @LastEditTime: 2022-08-04 15:26:38
*/
import { sp, _decorator ,Component} from "cc";
const { ccclass, property, requireComponent, disallowMultiple } = _decorator;
/**
* Spine状态机组件主状态机trackIndex为0
*/
@ccclass
@disallowMultiple
@requireComponent(sp.Skeleton)
export default class MonsterSpineAnimator extends Component {
private animName: string = "move";
private loop: boolean = true;
private spine!: sp.Skeleton;
start() {
this.spine = this.getComponent(sp.Skeleton)!;
// console.log("MonsterSpineAnimator start");
this.playAnimation(this.animName, this.loop);
}
mixTime:number= 0.2;
protected onLoad(): void {
this.spine = this.getComponent(sp.Skeleton)!;
// this.spine?.setMix('atk', 'move', this.mixTime);
// this.spine?.setMix('move','atk', this.mixTime);
this.spine.setEndListener(trackEntry => {
var animationName = trackEntry.animation ? trackEntry.animation.name : "";
// console.log("[track %s][animation %s] end.", trackEntry.trackIndex, animationName);
if (animationName == "atk2" ||animationName == "magic"||animationName=="max") {
this.spine.setAnimation(0, "move", true);
}
});
}
lateUpdate(dt: number) {
//
}
play(animName: string, loop: boolean) {
if (animName) {
this.animName = animName;
this.loop = loop;
this.spine.setAnimation(0, this.animName, this.loop);
}
else {
}
}
/**
* 播放动画
* @override
* @param animName 动画名
* @param loop 是否循环播放
*/
protected playAnimation(animName: string, loop: boolean) {
// console.log("MonsterSpineAnimator playAnimation");
if (animName) {
// console.log("MonsterSpineAnimator playAnimation animName", animName);
this.animName = animName;
this.loop = loop;
this.spine.setAnimation(0, this.animName, this.loop);
}
else {
}
}
}

View File

@@ -1 +0,0 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"d3a795b7-3a93-41b0-be56-1d3f6666a1dd","files":[],"subMetas":{},"userData":{}}

View File

@@ -1,427 +0,0 @@
/*
* @Author: dgflash
* @Date: 2021-11-18 17:42:59
* @LastEditors: dgflash
* @LastEditTime: 2022-08-17 12:36:18
*/
import { Vec3, _decorator , v3,Collider2D,Contact2DType,Label,RigidBody2D ,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite} 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 { MonsterSpine } from "./MonsterSpine";
import { Monster } from "./Monster";
import { Hero } from "./Hero";
import { MonsterModelComp } from "./MonsterModelComp";
import { BoxSet } from "../common/config/BoxSet";
import { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { Skill } from "../skills/Skill";
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
import { SkillCom } from "../skills/SkillCom";
import { SkillSet } from "../common/config/SkillSet";
import { Tooltip } from "../skills/Tooltip";
import { MonsterBuffComp } from "./MonsterBuffComp";
import { MoveToComp } from "../common/ecs/position/MoveTo";
import { BoxRangComp } from "./BoxRangComp";
const { ccclass, property } = _decorator;
/** 角色显示组件 */
@ccclass('MonsterViewComp') // 定义为 Cocos Creator 组件
@ecs.register('MonsterView', false) // 定义为 ECS 组件
export class MonsterViewComp extends CCComp {
@property(Material)
hitFlashMaterial: Material;
orginalFlashMaterial: Material;
sprite: Sprite;
@property(Node)
BoxRang:Node =null!
buff:MonsterBuffComp =null!
is_role:boolean = false;
enemy_pos:Vec3=null!;
enemy:any=null!;
/** 角色动画 */
as: MonsterSpine = null!;
hero_uuid:number = 1001;
hero_name : string = "hero";
level:number =1;
scale: number = 1; /** 角色阵营 1hero -1 :monster */
type: number = 1; /**角色类型 1前排 2 后排 */
state: number = 1; /** 状态 1move ,2: act 3: stop */
hp: number = 100; /** 血量 */
hp_max: number = 100; /** 最大血量 */
hp_speed: number = 0; //每秒回复量
power: number = 0; /**能量**/
power_max: number = 1200; /** 能量最大值 */
power_speed: number = 1; //能量回复速度每0.1秒回复量
skill_name: string = "base"; //技能名称
max_skill_name: string = "base"; //大技能名称
skill_uuid:number = 9001;
max_skill_uuid:number = 1001;
atk: number = 10; /**攻击力 */
// atk_speed: number = 1;
atk_cd: number = 1.3; /**攻击速度 攻击间隔 */
atk_time: number = 0; /** 冷却时间 */
speed: number = 100; /** 角色移动速度 */
ospeed: number = 100; /** 角色初始速度 */
Tpos: Vec3 = v3(0,-60,0);
stop_cd: number = 0.5; /*停止倒计时*/
shield:number = 0; //护盾量
shield_max:number = 200;
shield_time:number = 0; //护盾持续时间
box_group:number = 2;
atk_range:number = 150;
private timer:Timer = new Timer(1); //计时器
private m_timer:Timer = new Timer(0.1);
is_dead:boolean = false; //是否摧毁
is_stop:boolean = false;
is_atking:boolean = false;
onLoad() {
this.as = this.getComponent(MonsterSpine);
this.buff=this.node.getComponent(MonsterBuffComp);
// this.BoxRang = this.node.getChildByName("range_box");
// this.BoxRang = this.node.getChildByName("range_box");
} /** 视图层逻辑代码分离演示 */
start () {
this.sprite = this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
this.node.getChildByName("top").setScale(this.scale,1);
// this.node.getChildByName("atk").setScale(this.scale,1);
// this.node.getChildByName("atk").getComponent(Label).string = this.atk.toString();
// this.node.getChildByName("hp_max").setScale(this.scale,1);
// this.node.getChildByName("hp_max").getComponent(Label).string=this.hp_max.toString();
this.orginalFlashMaterial = this.sprite.getRenderMaterial(0);
this.BoxRang.getComponent(BoxRangComp).box_group = this.box_group;
this.BoxRang.getComponent(BoxRangComp).atk_range = this.atk_range
// this.BoxRang.getComponent(BoxRangComp).offset_x = 300;
// console.log("monseter ",this.BoxRang);
// console.log("monseter ",this.BoxRang);
// if(this.box_group == BoxSet.MONSTER){
// this.enemy=smc.Role.RoleView.node
// // console.log("monster enemy ",this.enemy);
// }
this.buff.group=this.box_group
// 注册单个碰撞体的回调函数
let collider = this.getComponent(Collider2D);
collider.group = this.box_group;
if (collider) {
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
collider.on(Contact2DType.PRE_SOLVE, this.onPreSolve, this);
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
}
// this.node.getChildByName("level").getChildByName("level").getComponent(Label).string = this.level.toString();
}
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D) {
if(otherCollider.tag==BoxSet.SKILL_TAG &&selfCollider.tag!=BoxSet.SKILL_TAG){
if(selfCollider.group != otherCollider.group){
let skill = otherCollider.node.getComponent(SkillCom)!;
// console.log('onPostSolve',skill);
this.in_atked();
if(this.hp <= 0 ){
return
}
this.hp_change(skill.atk);
}
}
}
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D) { }
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
this.is_atking = true;
this.stop_cd = 0.1;
}
}
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
if(selfCollider.group == otherCollider.group&&otherCollider.tag == 0&&selfCollider.tag == 0){
let self_pos=selfCollider.node.getPosition();
let other_pos=otherCollider.node.getPosition();
// console.log('monster view group 相同');
switch (selfCollider.group) {
case BoxSet.HERO:
if(self_pos.x < other_pos.x){
// this.stop_cd=0.1
}
break;
case BoxSet.MONSTER:
if(self_pos.x > other_pos.x){
// this.stop_cd=0.1
}
break
}
}
}
update(dt: number){
if (this.timer.update(dt)) {
this.power_change(this.power_speed)
}
this.in_destroy();
this.in_shield();
this.in_stop(dt);
this.in_act(dt);
this.move(dt);
// if(this.m_timer.update(dt)){
// this.move_to()
// }
}
move(dt: number){
if(this.stop_cd > 0){
return
}
if (this.scale === 1 && this.node.position.x >= 120) {
return;
}
if(this.scale===-1&&this.node.position.x <= BoxSet.HERO_START){
return;
}
// if(this.enemy){
// return
// }
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y, this.node.position.z);
}
move_to(){
var move = this.ent.get(MoveToComp) || this.ent.add(MoveToComp);
move.target = v3(smc.Role.RoleView.node.position.x+10,smc.Role.RoleView.node.position.y);
move.node = this.node;
move.speed = this.ospeed;
// if(this.box_group == BoxSet.MONSTER){
// if(smc.t_hero.eid != 0){
// var move = this.ent.get(MoveToComp) || this.ent.add(MoveToComp);
// if(smc.t_hero.pos.x < this.node.position.x){
// // this.node.setScale(-Math.abs(this.node.scale.x),this.node.scale.y)
// move.target = v3(smc.t_hero.pos.x+20,smc.t_hero.pos.y);
// }else{
// // this.node.setScale(Math.abs(this.node.scale.x),this.node.scale.y)
// move.target = v3(smc.t_hero.pos.x-20,smc.t_hero.pos.y);
// }
// move.node = this.node;
// move.speed = this.ospeed;
// }
// }
// if(this.box_group == BoxSet.HERO){
// if(smc.t_monster.eid != 0){
// var move = this.ent.get(MoveToComp) || this.ent.add(MoveToComp);
// if(smc.t_monster.pos.x < this.node.position.x){
// // this.node.setScale(-Math.abs(this.node.scale.x),this.node.scale.y)
// move.target = v3(smc.t_monster.pos.x+20,smc.t_monster.pos.y);
// }else{
// // this.node.setScale(Math.abs(this.node.scale.x),this.node.scale.y)
// move.target = v3(smc.t_monster.pos.x-20,smc.t_monster.pos.y);
// }
// move.node = this.node;
// move.speed = this.ospeed;
// }
// }
}
power_change(power: number){
this.power += power;
if(this.power >= this.power_max){
this.as.maxSkill()
this.scheduleOnce(()=>{
this.do_max_skill();
},0.5)
this.power = 0
}
let power_progress= this.power/this.power_max;
this.node.getChildByName("top").getChildByName("power").getComponent(ProgressBar)!.progress = power_progress;
}
shoot(skill_uuid:number){
// console.log("monster shoot");
let skill = ecs.getEntity<Skill>(Skill);
let x=32
let pos = v3(35*this.scale,50)
let scale = this.scale
let speed =smc.skills[skill_uuid].speed;
let dis = smc.skills[skill_uuid].dis;
let atk = smc.skills[skill_uuid].atk+this.atk;
let angle=0
let t_pos:Vec3 = v3(0,0)
if(this.enemy){
if(!this.enemy.isValid){
console.log("move_to",this.enemy.isValid);
return
}
t_pos = v3(this.enemy.position.x-this.node.position.x,this.enemy.position.y-this.node.position.y)
angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
if(this.scale == -1){
angle = angle +180
}
}else{
t_pos=null
}
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos);
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
}
//使用max_skill
do_max_skill(){
let skill = ecs.getEntity<Skill>(Skill);
let x=32
let pos = v3(-40*this.scale,BoxSet.MAX_SKILL_SY)
let scale = this.scale
let speed =smc.skills[this.max_skill_uuid].speed;
let dis = smc.skills[this.max_skill_uuid].dis;
let atk = smc.skills[this.max_skill_uuid].atk+this.atk;
skill.load(pos,speed,dis,scale,this.node,this.max_skill_uuid,atk);
this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid);
}
in_act(dt: number) {
if(this.atk_time >= this.atk_cd){
if(this.is_atking){
this.atk_time = 0;
// console.log("atk_cd:"+this.atk_cd);
this.as.atk();
this.scheduleOnce(()=>{
this.shoot(this.skill_uuid);
},0.4)
}
}else{
this.atk_time += dt;
}
}
in_shield(){
let shield_progress= this.shield/this.shield_max;
this.node.getChildByName("top").getChildByName("shield").getComponent(ProgressBar)!.progress = shield_progress;
// if(this.shield <= 0){
// this.node.getChildByName("shield").active=false
// }else{
// this.node.getChildByName("shield").active=true
// }
}
hp_change(hp: number){
if(this.is_dead){
return;
}
let lhp=this.shield_change(hp);
if(lhp == 0){
return;
}
this.hp += lhp;
this.tooltip(1,hp.toString());
if(this.hp > this.hp_max){
this.hp = this.hp_max;
}
let hp_progress= this.hp/this.hp_max;
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
if(this.hp <= 0){
this.dead();
this.remove_smc_data()
this.is_dead = true;
setTimeout(() => {
this.ent.destroy();
}, 15);
}
}
remove_smc_data(){
if(smc.t_monster.eid == this.ent.eid){
smc.t_monster = {eid:0,pos:v3(0,0,0)}
}
if(smc.t_hero.eid == this.ent.eid){
smc.t_hero = {eid:0,pos:v3(0,0,0)}
}
}
add_hp(hp: number=0){
console.log("hero 加血动画");
this.tooltip(2,hp.toString());
let hp_progress= this.hp/this.hp_max;
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
}
shield_change(hp: number){
let ls=this.shield - hp;
if(ls <= 0){
this.shield = 0;
return ls;
}else{
this.shield = ls;
return 0;
}
}
tooltip(type:number=1,value:string="",s_uuid:number=1001){
// console.log("tooltip",type);
let tip =ecs.getEntity<Tooltip>(Tooltip);
let pos = this.node.getPosition();
let node =this.node.parent
pos.y=pos.y+60;
tip.load(pos,type,value,s_uuid,node);
}
get_monster_pos(){
return this.node.getPosition()
}
/** 静止时间 */
in_stop (dt: number) {
if(this.stop_cd > 0){
this.stop_cd -= dt;
if(this.stop_cd <= 0){
this.stop_cd = 0;
this.is_atking = false;
}
}
}
in_destroy(){
// switch (this.scale) {
// case -1:
// if(this.node.position.x < BoxSet.LETF_END){
// this.toDestroy();
// }
// break;
// case 1:
// if(this.node.position.x > BoxSet.RIGHT_END){
// this.toDestroy();
// }
// break;
// }
}
in_atked() {
if(this.is_role){
var path = "game/skills/atked";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
let pos = v3(0,60)
node.setPosition(pos)
node.parent = this.node;
}else{
this.sprite.setSharedMaterial(this.hitFlashMaterial, 0);
this.scheduleOnce(() => {
this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0);
}, 0.1);
}
}
dead(){
var path = "game/skills/dead";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.setPosition(this.node.position.x,this.node.position.y+30,this.node.position.z);
node.parent = this.node.parent;
}
toDestroy(){
}
reset() {
this.is_dead = false;
this.node.destroy();
}
}

View File

@@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "dc1b7210-4d5c-477c-81c5-7d6bb4bb823f",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -109,24 +109,24 @@ export class CSkillComp extends CCComp {
if(SkillSet[uuid].type==92){ //随机添加buff if(SkillSet[uuid].type==92){ //随机添加buff
let i = RandomManager.instance.getRandomInt(0,heros.length-1,3) let i = RandomManager.instance.getRandomInt(0,heros.length-1,3)
console.log("i %%length:",i,heros.length) console.log("i %%length:",i,heros.length)
heros[i].MonsterBuff.add_buff(uuid,args); heros[i].HeroBuff.add_buff(uuid,args);
}else{ }else{
for (let i = 0; i < heros.length; i++) { for (let i = 0; i < heros.length; i++) {
let hero = heros[i]; let hero = heros[i];
// console.log(" CSkillComp hero",hero); // console.log(" CSkillComp hero",hero);
if(SkillSet[uuid].type==91){ //血量最少单体 if(SkillSet[uuid].type==91){ //血量最少单体
console.log(" CSkillComp hero 91",hero,least_hp,t_hero); console.log(" CSkillComp hero 91",hero,least_hp,t_hero);
if(hero.MonsterView.hp < least_hp){ if(hero.HeroView.hp < least_hp){
least_hp = hero.MonsterView.hp least_hp = hero.HeroView.hp
t_hero = hero t_hero = hero
} }
}else{ //群体 }else{ //群体
hero.MonsterBuff.add_buff(uuid,args); hero.HeroBuff.add_buff(uuid,args);
} }
} }
if(t_hero){ //血量最少单体 if(t_hero){ //血量最少单体
t_hero.MonsterBuff.add_buff(uuid,args); t_hero.HeroBuff.add_buff(uuid,args);
} }
} }