boss需要改用spine 动画 先放一放
This commit is contained in:
@@ -11,7 +11,7 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
|
||||
import { MonSpine } from "./MonSpine";
|
||||
import { Mon } from "./Mon";
|
||||
import { MonModelComp } from "./MonModelComp";
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
import { BoxSet, GameSet } from "../common/config/BoxSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { Skill } from "../skills/Skill";
|
||||
@@ -32,8 +32,8 @@ export class MonViewComp extends CCComp {
|
||||
orginalFlashMaterial: Material;
|
||||
sprite: Sprite;
|
||||
|
||||
@property(Node)
|
||||
BoxRang:Node =null!
|
||||
// @property(Node)
|
||||
// BoxRang:Node =null!
|
||||
|
||||
is_role:boolean = false;
|
||||
enemy_pos:Vec3=null!;
|
||||
@@ -100,8 +100,8 @@ export class MonViewComp extends CCComp {
|
||||
// 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).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);
|
||||
@@ -119,7 +119,6 @@ export class MonViewComp extends CCComp {
|
||||
// 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) {
|
||||
@@ -138,19 +137,21 @@ export class MonViewComp extends CCComp {
|
||||
}
|
||||
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D) { }
|
||||
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
|
||||
if(selfCollider.group == otherCollider.group&&selfCollider.tag==otherCollider.tag){
|
||||
if(selfCollider.node.position.y < otherCollider.node.position.y){
|
||||
if(selfCollider.node.getSiblingIndex() < otherCollider.node.getSiblingIndex()){
|
||||
selfCollider.node.setSiblingIndex(otherCollider.node.getSiblingIndex()+1)
|
||||
// console.log("onPreSolve b:"+selfCollider.node.uuid+":"+selfCollider.node.getSiblingIndex()+"/"+otherCollider.node.uuid+":"+otherCollider.node.getSiblingIndex());
|
||||
}
|
||||
// if(selfCollider.group == otherCollider.group&&selfCollider.tag==otherCollider.tag){
|
||||
// if(selfCollider.node.position.y < otherCollider.node.position.y){
|
||||
// if(selfCollider.node.getSiblingIndex() < otherCollider.node.getSiblingIndex()){
|
||||
// selfCollider.node.setSiblingIndex(otherCollider.node.getSiblingIndex()+1)
|
||||
// // console.log("onPreSolve b:"+selfCollider.node.uuid+":"+selfCollider.node.getSiblingIndex()+"/"+otherCollider.node.uuid+":"+otherCollider.node.getSiblingIndex());
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
// }
|
||||
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
|
||||
this.stop_cd = 0.1;
|
||||
this.is_atking=true
|
||||
}
|
||||
}
|
||||
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
|
||||
|
||||
}
|
||||
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D) {}
|
||||
|
||||
|
||||
update(dt: number){
|
||||
@@ -161,13 +162,36 @@ export class MonViewComp extends CCComp {
|
||||
this.in_speek(dt);
|
||||
this.in_shield(dt);
|
||||
this.in_stop(dt);
|
||||
this.check_enemy_alive()
|
||||
this.atk_time += dt;
|
||||
this.in_atk(dt);
|
||||
this.hp_show()
|
||||
this.move(dt);
|
||||
|
||||
// if(this.m_timer.update(dt)){
|
||||
// this.move_to()
|
||||
// }
|
||||
}
|
||||
check_enemy_alive(){
|
||||
let dir = 320
|
||||
for (let i = 0; i < GameSet.ATK_LINES; i++) {
|
||||
let hero:any = smc.hero_pos[i];
|
||||
let x=Math.abs(hero.x-this.node.position.x)
|
||||
let y = Math.abs(hero.y-this.node.position.y)
|
||||
let squaredDistance =x*x+y*y
|
||||
let distance = Math.sqrt(squaredDistance);
|
||||
if(distance < dir){
|
||||
dir = distance
|
||||
this.enemy = hero
|
||||
}
|
||||
|
||||
}
|
||||
if(dir < this.atk_dis){
|
||||
this.is_atking=true
|
||||
}else{
|
||||
this.is_atking=false
|
||||
}
|
||||
}
|
||||
hp_show(){
|
||||
if(this.hp == this.hp_max){
|
||||
this.node.getChildByName("top").getChildByName("hp").active = false;
|
||||
@@ -199,9 +223,9 @@ export class MonViewComp extends CCComp {
|
||||
return
|
||||
}
|
||||
this.power += power;
|
||||
if(this.power >= this.power_max&&this.check_enemy_alive()){
|
||||
if(this.power >= this.power_max){
|
||||
this.as.atk()
|
||||
this.to_speek(smc.skills[this.max_skill_uuid].name)
|
||||
// this.to_speek(smc.skills[this.max_skill_uuid].name)
|
||||
this.scheduleOnce(()=>{
|
||||
this.do_max_skill();
|
||||
},0.5)
|
||||
@@ -214,7 +238,7 @@ export class MonViewComp extends CCComp {
|
||||
// console.log("mon shoot");
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let atk = smc.skills[skill_uuid].atk+this.atk;
|
||||
let {pos,angle,t_pos}=this.get_enemy_pos()
|
||||
let {pos,t_pos}=this.get_enemy_pos()
|
||||
pos.y=pos.y + y
|
||||
pos.x=pos.x + x
|
||||
skill.load(pos,BoxSet.MONSTER,this.node,skill_uuid,atk,t_pos);
|
||||
@@ -242,33 +266,16 @@ export class MonViewComp extends CCComp {
|
||||
}
|
||||
get_enemy_pos(){
|
||||
let pos = v3(35*this.scale,25)
|
||||
let angle=0
|
||||
let t_pos:Vec3 = v3(0,0)
|
||||
let t_pos:Vec3 = v3(-720,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+pos.x)*1.1,(this.enemy.position.y-(this.node.position.y+pos.y)+BoxSet.ATK_Y)*1.1)
|
||||
}else{
|
||||
t_pos=v3(-720,BoxSet.GAME_LINE)
|
||||
}
|
||||
return {pos,t_pos,angle}
|
||||
}
|
||||
check_enemy_alive(){
|
||||
if(this.enemy){
|
||||
if(!this.enemy.isValid){
|
||||
return false
|
||||
}
|
||||
if(Math.abs(this.enemy.position.x-this.node.position.x) < this.atk_dis) return true;
|
||||
return false
|
||||
}else{
|
||||
return false
|
||||
t_pos = v3(this.enemy.x-this.node.position.x,this.enemy.y-this.node.position.y)
|
||||
}
|
||||
return {pos,t_pos}
|
||||
}
|
||||
|
||||
in_atk(dt: number) {
|
||||
if(this.atk_time >= this.atk_cd){
|
||||
if(this.is_atking&&this.check_enemy_alive()){
|
||||
if(this.is_atking){
|
||||
this.atk_time = 0;
|
||||
// console.log("atk_cd:"+this.atk_cd);
|
||||
this.as.atk();
|
||||
|
||||
Reference in New Issue
Block a user