hero 死亡进入墓地 而不是摧毁,todo 受伤动画重做

This commit is contained in:
2024-11-15 10:17:06 +08:00
parent 425a8bac64
commit e907141580
6 changed files with 75 additions and 88 deletions

View File

@@ -19,11 +19,9 @@ import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/
import { SkillCom } from "../skills/SkillCom";
import { SkillSet } from "../common/config/SkillSet";
import { Tooltip } from "../skills/Tooltip";
import { MoveToComp } from "../common/ecs/position/MoveTo";
import { BoxRangComp } from "./BoxRangComp";
import { MonViewComp } from "../mon/MonViewComp";
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
import { TimerManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/TimerManager";
import { HeroSet } from "../common/config/heroSet";
const { ccclass, property } = _decorator;
/** 角色显示组件 */
@@ -47,6 +45,7 @@ export class HeroViewComp extends CCComp {
hero_uuid:number = 1001;
hero_name : string = "hero";
hero_type:number = 1;
level:number =1;
scale: number = 1; /** 角色阵营 1hero -1 :mon */
type: number = 1; /**角色类型 1前排 2 后排 */
@@ -203,18 +202,15 @@ export class HeroViewComp extends CCComp {
}
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
}
status_change(type:string){
if(this.status == type) return
this.status=type
if(type != "move"){
this.as.change_default("idle")
}else{
this.as.change_default("move")
}
}
update(dt: number){
if(!smc.vm_data.mission.play||smc.vm_data.pause||this.is_dead){
if(!smc.vm_data.mission.play||smc.vm_data.pause){
let pos =v3(this.scale*-9999,this.node.position.y,this.node.position.z)
this.node.setPosition(pos)
return
}
if(this.is_dead){
let pos =v3(this.scale*-9999,this.node.position.y,this.node.position.z)
this.node.setPosition(pos)
return
}
if (this.timer.update(dt)) {
@@ -231,13 +227,18 @@ export class HeroViewComp extends CCComp {
// this.hp_show()
this.move(dt);
// this.in_speek(dt);
// this.move_to()
// if(this.m_timer.update(dt)){
// this.move_to()
// }
}
status_change(type:string){
if(this.status == type) return
this.status=type
if(type != "move"){
this.as.change_default("idle")
}else{
this.as.change_default("move")
}
}
change_anm(){
if (this.anm_name == "max"){
this.as.max()
@@ -318,18 +319,7 @@ export class HeroViewComp extends CCComp {
this.node.getChildByName("top").getChildByName("hp").active = true;
}
}
move_to(target:any){
// if(this.stop_cd > 0){
// return
// }
// if(this.enemy){
// return
// }
var move = this.ent.get(MoveToComp) || this.ent.add(MoveToComp);
move.target = v3(target.x,target.y);
move.node = this.node;
move.speed = this.ospeed;
}
power_change(power: number){
this.power += power;
if(this.power >= this.power_max){
@@ -534,8 +524,7 @@ export class HeroViewComp extends CCComp {
this.is_dead = true;
// setTimeout(() => {
// this.ent.destroy();
// }, 15);
this.toDestroy()
// }, 15);
}
}
add_atk(atk: number,time:number=0){
@@ -606,31 +595,27 @@ export class HeroViewComp extends CCComp {
}
in_atked() {
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;
// this.sprite.setSharedMaterial(this.hitFlashMaterial, 0);
// this.scheduleOnce(() => {
// this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0);
// }, 0.1);
var path = "game/skills/atked";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
let pos =v3(0,30);
node.setPosition(pos)
node.parent = this.node;
}
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);
let pos = v3(this.node.position.x,this.node.position.y+30,this.node.position.z);
node.parent = this.node.parent;
node.setPosition(pos);
}
toDestroy(){
this.node.setPosition(this.scale*9999,this.node.position.y)
}
toAlive(){
this.node.setPosition(-1*this.scale*BoxSet.HERO_START,this.node.position.y)
let pos =v3(HeroSet.StartPos[this.hero_type],this.node.position.y,this.node.position.z)
this.node.setPosition(pos)
}
reset() {
this.is_dead = false;