加血技能完成 怪物动画减少

This commit is contained in:
walkpan
2024-09-15 23:25:34 +08:00
parent 417b5d85be
commit 2095393757
317 changed files with 36222 additions and 60962 deletions

View File

@@ -47,42 +47,26 @@ export class Role extends ecs.Entity {
var scene = smc.map.MapView.scene;
node.parent = scene.entityLayer!.node!;
node.setScale(node.scale.x, node.scale.y, node.scale.z);
// var as = node.getComponent(MonsterSpine);
node.setPosition(pos)
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
// const url = 'game/heros/player';
// resources.load(url, SpriteAtlas, (err: any, atlas) => {
// const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
// sprite.spriteFrame = atlas.getSpriteFrame(RoleSet[uuid].path);
// });
// var rv = node.getComponent(RoleViewComp)!;
// this.add(rv);
this.hero_init(uuid,node)
}
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
var mv = node.getComponent(RoleViewComp)!;
var buff =node.getComponent(RoleBuffComp)!;
mv.is_role=true;
mv.hero_uuid=uuid;
mv.speed =mv.ospeed = 0;
mv.hero_name= "role";
buff.group= mv.box_group= BoxSet.HERO;
mv.hp= mv.hp_max = smc.vm_data.role.hp;
mv.level = 1;
mv.atk = smc.vm_data.role.atk;
mv.atk_cd = smc.vm_data.role.atk_cd;
mv.power = smc.vm_data.role.power;
mv.type = 1;
mv.skill_uuid = 9001;
mv.max_skill_uuid = 9001;
mv.Tpos = v3(0,0,0);
mv.scale = 1;
mv.atk_range=1000;
// mv.change_name(smc.heros[uuid].name,1)
this.add(mv);
this.add(buff);
var rv = node.getComponent(RoleViewComp)!;
let role=smc.vm_data.role;
rv.hero_uuid=uuid;
rv.speed =rv.ospeed = 0;
rv.hero_name= "role";
rv.hp= rv.hp_max = role.hp;
rv.level = role.lv;
rv.atk = role.atk;
rv.atk_cd = role.atk_cd;
rv.power = role.power;
rv.skills = role.skills;
rv.skill = role.skill;
rv.atk_range=role.atk_range;
rv.power= role.power;
this.add(rv);
}
move(target: Vec3) {
var move = this.get(MoveToComp) || this.add(MoveToComp);

View File

@@ -18,7 +18,6 @@ import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { MoveToComp } from "../common/ecs/position/MoveTo";
import { RoleBuffComp } from "./RoleBuffComp";
import { RoleRangComp } from "./RoleRangComp";
import { Tooltip } from "../skills/Tooltip";
import { MonViewComp } from "../mon/MonViewComp";
@@ -37,16 +36,14 @@ export class RoleViewComp extends CCComp {
BoxRang:Node =null!
as:RoleSpine =null!;
buff:RoleBuffComp =null!
is_role:boolean = false;
enemy_pos:Vec3=null!;
enemy:any=null!;
/** 角色动画 */
hero_uuid:number = 1001;
hero_name : string = "hero";
hero_name : string = "role";
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; /** 血量 */
@@ -56,10 +53,14 @@ export class RoleViewComp extends CCComp {
power: number = 0; /**能量**/
power_max: number = 1200; /** 能量最大值 */
power_speed: number = 1; //能量回复速度每0.1秒回复量
skill_uuid:number = 1005;
max_skill_uuid:number = 1005;
skill:8001;
skills:{
1:{uuid:8001,cd:2,alive:true },
2:{uuid:8001,cd:2,alive:false},
3:{uuid:8001,cd:2,alive:false},
4:{uuid:8001,cd:2,alive:false},
5:{uuid:8001,cd:2,alive:false},
}
atk: number = 10; /**攻击力 */
// atk_speed: number = 1;
atk_cd: number = 1.3; /**攻击速度 攻击间隔 */
@@ -83,7 +84,6 @@ export class RoleViewComp extends CCComp {
is_atking:boolean = false;
onLoad() {
this.buff=this.node.getComponent(RoleBuffComp);
this.BoxRang = this.node.getChildByName("range_box");
this.as = this.node.getComponent(RoleSpine);
@@ -104,7 +104,6 @@ export class RoleViewComp extends CCComp {
// this.BoxRang.getComponent(RoleRangComp).offset_x = this.scale*smc.skills[this.skill_uuid].dis/3;
// console.log("monseter ",this.BoxRang);
this.buff.group=this.box_group
// 注册单个碰撞体的回调函数
let collider = this.getComponent(Collider2D);
collider.group = this.box_group;
@@ -159,7 +158,7 @@ export class RoleViewComp extends CCComp {
update(dt: number){
if (this.timer.update(dt)) {
this.power_change(this.power_speed)
}
this.in_destroy();
this.in_shield();
@@ -178,56 +177,32 @@ export class RoleViewComp extends CCComp {
}
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y, this.node.position.z);
}
power_change(power: number){
this.power += power;
if(this.power >= this.power_max&&this.check_enemy_alive()){
this.as.atk()
this.scheduleOnce(()=>{
this.do_max_skill();
},0.5)
this.power = 0
}
}
shoot(skill_uuid:number){
shoot(skill_uuid:number,y:number=0,x:number=0){
// console.log("mon shoot");
let skill = ecs.getEntity<Skill>(Skill);
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 {pos,angle,t_pos}=this.get_enemy_pos()
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos);
let {pos,t_pos}=this.get_enemy_pos()
pos.y=pos.y + y
pos.x=pos.x + x
skill.load(pos,BoxSet.HERO,this.node,skill_uuid,atk,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 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;
let {pos,angle,t_pos}=this.get_enemy_pos()
skill.load(pos,speed,dis,scale,this.node,this.max_skill_uuid,atk,angle,t_pos);
this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid);
}
get_enemy_pos(){
let pos = v3(35*this.scale,50)
let angle=0
let pos = v3(0,50)
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+pos.x),this.enemy.position.y-(this.node.position.y+pos.y)+BoxSet.ATK_Y)
angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
if(this.scale == -1){
angle = angle +180
}
t_pos = v3(this.enemy.position.x-(this.node.position.x),this.enemy.position.y-(this.node.position.y+pos.y)+BoxSet.ATK_Y)
}else{
t_pos=null
t_pos=v3(720,BoxSet.GAME_LINE)
}
return {pos,t_pos,angle}
return {pos,t_pos}
}
check_enemy_alive(){
if(this.enemy){
@@ -246,7 +221,7 @@ export class RoleViewComp extends CCComp {
// console.log("atk_cd:"+this.atk_cd);
this.as.atk();
this.scheduleOnce(()=>{
this.shoot(this.skill_uuid);
this.shoot(this.skill,-30);
},0.4)
}
}else{
@@ -254,7 +229,7 @@ export class RoleViewComp extends CCComp {
}
}
in_shield(){
}
hp_change(hp: number){
if(this.is_dead){
@@ -356,6 +331,9 @@ export class RoleViewComp extends CCComp {
var node = instantiate(prefab);
node.setPosition(this.node.position.x,this.node.position.y+30,this.node.position.z);
node.parent = this.node.parent;
}
heathed(){
}
toDestroy(){

View File

@@ -11,6 +11,7 @@ import { GameMap } from "../map/GameMap";
import { BoxSet } from "./config/BoxSet";
import { Role } from "../Role/Role";
import { v3 } from "cc";
import { Skill } from "../skills/Skill";
// import { Role } from "../role/Role";
// import { data } from "../data/data";
@@ -78,12 +79,22 @@ export class SingletonModuleComp extends ecs.Comp {
},
role:{
hp:3000,
hp_max:3000,
atk:10,
atk_cd:2,
atk_range:1000,
lv:1,
exp:0,
next_exp:100,
power:300,
atk_cd:2,
skill:1001,
skills:{
1:{uuid:8001,cd:2,alive:true },
2:{uuid:9002,cd:2,alive:false},
3:{uuid:9003,cd:2,alive:false},
4:{uuid:9004,cd:2,alive:false},
5:{uuid:9005,cd:2,alive:false},
}
},
/** 当前等级 */
cards:{

View File

@@ -1,22 +1,10 @@
export const MissionNum = [6]
export const MissionNum = [1,2]
export const MonsetList = {
// 1:{
// 1:[1001,1002,1003,1041,1042,1043],
// },
// 2:{
// 1:[1011,1012,1013,1041,1042,1043],
// },
// 3:{
// 1:[1041,1042,1043],
// },
// 4:{
// 1:[1021,1022,1023,1041,1042,1043],
// },
// 5:{
// 1:[1031,1032,1033,1041,1042,1043],
// },
6:{
1:[1021,1022,1023],
1:{
1:[1031,1032,1033,1011,1012,1013],
},
2:{
1:[1011,1012,1013,1031,1032,1033,],
},
}

View File

@@ -5,11 +5,14 @@ type
3 远距离攻击,碰撞后 持续,带击退功能
4 双技能技能1技能结束后触发2技能
5: 特殊技能,触发特殊弹窗选项
6: 近距离攻击,碰撞后
9 buff物品
91: 单体buff物品加最少血临时
92单体buff物品随机临时
93: 群体buff物品
94role buff
tg: 对象0 自己1同伴 2 自己和同伴3敌人4自己和对人
dis: 是否移动 1 移动 0 原地
sd 卡片技能图标持续时间
cd 卡片技能释放本技能cd
count卡片1次释放本技能数
@@ -23,73 +26,84 @@ path: 图片地址
*/
export const SkillSet={
1001:{uuid: 1001,path: "1001",type: 1,level: 1,name: "火球术",sp_name:"fire",info:"释放一个火球术攻击敌人",
dis:720,count:1,atk:10,hp:0,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:350, },
1002:{uuid: 1002,path: "1002",type: 1,level: 1,name: "寒冰箭",sp_name:"ice",info:"释放一个寒冰箭攻击敌人",
dis:720,count:1,atk:10,hp:0,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:350, },
1003:{uuid: 1003,path: "1003",type: 1,level: 1,name: "强效射击",sp_name:"b_arrow",info:"释放一个火球术攻击敌人",
dis:720,count:1,atk:10,hp:0,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:350, },
1004:{uuid: 1004,path: "1004",type: 1,level: 1,name: "奥术冲击",sp_name:"bm_ball",info:"释放一个寒冰箭攻击敌人",
dis:720,count:1,atk:10,hp:0,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:350, },
1005:{uuid: 1005,path: "1005",type: 1,level: 1,name: "猛击",sp_name:"b_atk",info:"释放一个寒冰箭攻击敌人",
dis:0,count:1,atk:10,hp:0,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:350, },
4011:{uuid: 4011,path: "1011",type: 1,level: 3,name: "火焰风暴",sp_name:"fire",info:"释放多个个火球术攻击敌人",
dis:720,count:5,atk:10,hp:0,shield:0,sd:10,cd:2,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:350, },
4012:{uuid: 4012,path: "1012",type: 1,level: 3,name: "冰晶风暴",sp_name:"ice",info:"释放多个个寒冰箭攻击敌人",
dis:720,count:5,atk:10,hp:0,shield:0,sd:10,cd:2,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:350, },
9001:{uuid: 9001,path: "1001",type: 1,level: 1,name: "劈砍",sp_name:"patk",info:"释放一个魔法球攻击敌人",
dis:720,count:1,atk:0,hp:0,shield:0,sd:0,cd:0,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:450,},
9002:{uuid: 9002,path: "1001",type: 1,level: 1,name: "魔法小球",sp_name:"mball",info:"释放一个魔法球攻击敌人",
dis:720,count:1,atk:0,hp:0,shield:0,sd:0,cd:0,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:450,},
9003:{uuid: 9003,path: "1001",type: 1,level: 1,name: "射击",sp_name:"arrow",info:"释放一个魔法球攻击敌人",
dis:720,count:1,atk:0,hp:0,shield:0,sd:0,cd:0,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:450,},
1001:{uuid: 1001,path: "1001",type: 1,tg:3,angle:true,level: 1,name: "火球术",sp_name:"fire",info:"释放一个火球术攻击敌人",
dis:1,count:1,in:0,run:0,atk:10,hp:0,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:600, },
1002:{uuid: 1002,path: "1002",type: 1,tg:3,angle:true,level: 1,name: "寒冰箭",sp_name:"ice",info:"释放一个寒冰箭攻击敌人",
dis:1,count:1,in:0,run:0,atk:10,hp:0,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:600, },
1003:{uuid: 1003,path: "1003",type: 1,tg:3,angle:true,level: 1,name: "强效射击",sp_name:"b_arrow",info:"释放一个火球术攻击敌人",
dis:1,count:1,in:0,run:1,atk:10,hp:0,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:600, },
1004:{uuid: 1004,path: "1004",type: 1,tg:3,angle:true,level: 1,name: "奥术冲击",sp_name:"bm_ball",info:"释放一个寒冰箭攻击敌人",
dis:1,count:1,in:0,run:0,atk:10,hp:0,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:600, },
2001:{uuid: 2001,path: "2001",type: 91,tg:1,angle:false,level: 1,name: "治愈术",sp_name:"heath",info:"释放一个寒冰箭攻击敌人",
dis:1,count:1,in:0,run:1,atk:10,hp:0,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:450, },
3001:{uuid: 3001,path: "3001",type: 1,tg:3,angle:true,level: 1,name: "三连击",sp_name:"patk",info:"释放一个魔法球攻击敌人",
dis:1,count:3,in:0.3,run:2,atk:0,hp:0,shield:0,sd:0,cd:0,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:600,},
4011:{uuid: 4011,path: "1011",type: 1,tg:3,angle:true,level: 3,name: "火焰风暴",sp_name:"fire",info:"释放多个个火球术攻击敌人",
dis:1,count:5,in:0,run:0,atk:10,hp:0,shield:0,sd:10,cd:2,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:600, },
4012:{uuid: 4012,path: "1012",type: 1,tg:3,angle:true,level: 3,name: "冰晶风暴",sp_name:"ice",info:"释放多个个寒冰箭攻击敌人",
dis:1,count:5,in:0,run:0,atk:10,hp:0,shield:0,sd:10,cd:2,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:600, },
9001:{uuid: 9001,path: "1001",type: 1,tg:3,angle:true,level: 1,name: "普攻",sp_name:"patk",info:"释放一个魔法球攻击敌人",
dis:1,count:1,in:0,run:0,atk:0,hp:0,shield:0,sd:0,cd:0,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:600,},
9002:{uuid: 9002,path: "1001",type: 1,tg:3,angle:true,level: 1,name: "魔法小球",sp_name:"mball",info:"释放一个魔法球攻击敌人",
dis:1,count:1,in:0,run:0,atk:0,hp:0,shield:0,sd:0,cd:0,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:600,},
9003:{uuid: 9003,path: "1001",type: 1,tg:3,angle:true,level: 1,name: "射击",sp_name:"arrow",info:"释放一个魔法球攻击敌人",
dis:1,count:1,in:0,run:1,atk:0,hp:0,shield:0,sd:0,cd:0,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:600,},
8001:{uuid: 8001,path: "8001",type: 1,tg:3,angle:true,level: 1,name: "飞刀",sp_name:"sword1",info:"释放一个魔法球攻击敌人",
dis:1,count:1,in:0,run:0,atk:0,hp:0,shield:0,sd:0,cd:0,bsd:0,bcd:0,sk_uuid:8001,sk_count:0,speed:600,},
6210:{uuid: 6210,path: "6210",type: 92,level: 1,name: "普通攻击石",sp_name:"",info:"",
dis:720,count:1,atk:10,hp:0,shield:0,sd:30,cd:1,bsd:5,bcd:1,sk_uuid:1001,sk_count:0,speed:350, },
dis:1,count:1,in:0,run:0,atk:10,hp:0,shield:0,sd:30,cd:1,bsd:5,bcd:1,sk_uuid:1001,sk_count:0,speed:600, },
6211:{uuid: 6211,path: "6211",type: 93,level: 3,name: "精炼攻击石",sp_name:"",info:"",
dis:720,count:1,atk:10,hp:0,shield:0,sd:30,cd:1,bsd:5,bcd:1,sk_uuid:1001,sk_count:0,speed:350, },
dis:1,count:1,in:0,run:0,atk:10,hp:0,shield:0,sd:30,cd:1,bsd:5,bcd:1,sk_uuid:1001,sk_count:0,speed:600, },
6005:{uuid: 6005,path: "6005",type: 93,level: 3,name: "钢盾",sp_name:"",info:"",
dis:720,count:1,atk:0,hp:0,shield:30,sd:30,cd:1,bsd:5,bcd:1,sk_uuid:1001,sk_count:0,speed:350, },
dis:1,count:1,in:0,run:0,atk:0,hp:0,shield:30,sd:30,cd:1,bsd:5,bcd:1,sk_uuid:1001,sk_count:0,speed:600, },
6006:{uuid: 6006,path: "6006",type: 94,level: 3,name: "魔法盾",sp_name:"",info:"",
dis:720,count:1,atk:0,hp:0,shield:30,sd:30,cd:1,bsd:5,bcd:1,sk_uuid:1001,sk_count:0,speed:350, },
dis:1,count:1,in:0,run:0,atk:0,hp:0,shield:30,sd:30,cd:1,bsd:5,bcd:1,sk_uuid:1001,sk_count:0,speed:600, },
6101:{uuid: 6101,path: "6101",type: 91,level: 1,name: "初级药水",sp_name:"",info:"",
dis:720,count:1,atk:0,hp:30,shield:0,sd:30,cd:5,bsd:5,bcd:1,sk_uuid:1001,sk_count:0,speed:350, },
dis:1,count:1,in:0,run:0,atk:0,hp:30,shield:0,sd:30,cd:5,bsd:5,bcd:1,sk_uuid:1001,sk_count:0,speed:600, },
6102:{uuid: 6102,path: "6102",type: 93,level: 3,name: "高级药水",sp_name:"",info:"",
dis:720,count:1,atk:0,hp:50,shield:0,sd:30,cd:5,bsd:5,bcd:1,sk_uuid:1001,sk_count:0,speed:350, },
dis:1,count:1,in:0,run:0,atk:0,hp:50,shield:0,sd:30,cd:5,bsd:5,bcd:1,sk_uuid:1001,sk_count:0,speed:600, },
}
export const AllItems={
6210:{uuid: 6210,path: "6210",type: 92,level: 3,name: "普通攻击石",sp_name:"",info:"",
dis:720,count:1,atk:0,hp:30,shield:0,sd:30,cd:1,bsd:0,bcd:1,sk_uuid:1001,sk_count:0,speed:350, },
dis:1,count:1,in:0,run:0,atk:0,hp:30,shield:0,sd:30,cd:1,bsd:0,bcd:1,sk_uuid:1001,sk_count:0,speed:600, },
6211:{uuid: 6211,path: "6211",type: 93,level: 4,name: "特效攻击石",sp_name:"",info:"",
dis:720,count:1,atk:5,hp:0,shield:0,sd:30,cd:1,bsd:0,bcd:1,sk_uuid:1001,sk_count:0,speed:350, },
dis:1,count:1,in:0,run:0,atk:5,hp:0,shield:0,sd:30,cd:1,bsd:0,bcd:1,sk_uuid:1001,sk_count:0,speed:600, },
6212:{uuid: 6212,path: "6212",type: 94,level: 4,name: "精炼攻击石",sp_name:"",info:"",
dis:720,count:1,atk:5,hp:0,shield:0,sd:30,cd:1,bsd:0,bcd:1,sk_uuid:1001,sk_count:0,speed:350, },
dis:1,count:1,in:0,run:0,atk:5,hp:0,shield:0,sd:30,cd:1,bsd:0,bcd:1,sk_uuid:1001,sk_count:0,speed:600, },
6213:{uuid: 6213,path: "6213",type: 92,level: 3,name: "普通生命石",sp_name:"",info:"",
dis:720,count:1,atk:0,hp:30,shield:0,sd:30,cd:1,bsd:0,bcd:1,sk_uuid:1001,sk_count:0,speed:350, },
dis:1,count:1,in:0,run:0,atk:0,hp:30,shield:0,sd:30,cd:1,bsd:0,bcd:1,sk_uuid:1001,sk_count:0,speed:600, },
6214:{uuid: 6214,path: "6214",type: 93,level: 4,name: "特效生命石",sp_name:"",info:"",
dis:720,count:1,atk:0,hp:30,shield:0,sd:30,cd:1,bsd:0,bcd:1,sk_uuid:1001,sk_count:0,speed:350, },
dis:1,count:1,in:0,run:0,atk:0,hp:30,shield:0,sd:30,cd:1,bsd:0,bcd:1,sk_uuid:1001,sk_count:0,speed:600, },
6215:{uuid: 6215,path: "6215",type: 94,level: 4,name: "精炼生命石",sp_name:"",info:"",
dis:720,count:1,atk:5,hp:30,shield:0,sd:30,cd:1,bsd:0,bcd:1,sk_uuid:1001,sk_count:0,speed:350, },
dis:1,count:1,in:0,run:0,atk:5,hp:30,shield:0,sd:30,cd:1,bsd:0,bcd:1,sk_uuid:1001,sk_count:0,speed:600, },
6216:{uuid: 6216,path: "6216",type: 92,level: 3,name: "普通全能石",sp_name:"",info:"",
dis:720,count:1,atk:5,hp:30,shield:0,sd:30,cd:1,bsd:0,bcd:1,sk_uuid:1001,sk_count:0,speed:350, },
dis:1,count:1,in:0,run:0,atk:5,hp:30,shield:0,sd:30,cd:1,bsd:0,bcd:1,sk_uuid:1001,sk_count:0,speed:600, },
6217:{uuid: 6217,path: "6217",type: 93,level: 4,name: "特效全能石",sp_name:"",info:"",
dis:720,count:1,atk:5,hp:30,shield:0,sd:30,cd:1,bsd:0,bcd:1,sk_uuid:1001,sk_count:0,speed:350, },
dis:1,count:1,in:0,run:0,atk:5,hp:30,shield:0,sd:30,cd:1,bsd:0,bcd:1,sk_uuid:1001,sk_count:0,speed:600, },
6218:{uuid: 6218,path: "6218",type: 94,level: 4,name: "精炼全能石",sp_name:"",info:"",
dis:720,count:1,atk:5,hp:30,shield:0,sd:30,cd:1,bsd:0,bcd:1,sk_uuid:1001,sk_count:0,speed:350, },
dis:1,count:1,in:0,run:0,atk:5,hp:30,shield:0,sd:30,cd:1,bsd:0,bcd:1,sk_uuid:1001,sk_count:0,speed:600, },
}

View File

@@ -2,7 +2,7 @@
export const HeroSet = {
9001: {
uuid: 9001, path: "k3", type: 1, level: 1, name: "战士", atk: 4, hp: 35, atk_dis: 30, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 1005, word: "守护", info: "自身护盾", atktype: 1,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 3001, word: "守护", info: "自身护盾", atktype: 1,
},
@@ -17,7 +17,7 @@ export const HeroSet = {
9031: {
uuid: 9005, path: "m2", type: 3, level: 1, name: "牧师", atk: 3, hp: 20, atk_dis: 200, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "治愈术", skill_uuid: 9002, max_skill_uuid: 1004, word: "守护", info: "自身护盾", atktype: 2
max_skill: "治愈术", skill_uuid: 9002, max_skill_uuid: 2001, word: "守护", info: "自身护盾", atktype: 2
},
@@ -29,53 +29,31 @@ export const HeroSet = {
}
export const MonSet = {
1001: {
uuid: 1001, path: "ge1", type: 1, level: 1, name: "战斗哥", atk: 4, hp: 30, atk_dis: 30, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 1005, word: "守护", info: "自身护盾", atktype: 1
},
1002: {
uuid: 1002, path: "ge2", type: 1, level: 1, name: "墨西哥", atk: 4, hp: 30, atk_dis: 30, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 1005, word: "守护", info: "自身护盾", atktype: 1
},
1003: {
uuid: 1003, path: "ge3", type: 1, level: 1, name: "铁头哥", atk: 4, hp: 30, atk_dis: 30, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 1005, word: "守护", info: "自身护盾", atktype: 1
},
1011: {
uuid: 1011, path: "orc1", type: 1, level: 1, name: "森林兽人", atk: 4, hp: 30, atk_dis: 30, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 1005, word: "守护", info: "自身护盾", atktype: 1
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 1001, word: "守护", info: "自身护盾", atktype: 1
},
1012: {
uuid: 1012, path: "orc2", type: 1, level: 1, name: "荒野兽人", atk: 4, hp: 30, atk_dis: 30, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 1005, word: "守护", info: "自身护盾", atktype: 1
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 1002, word: "守护", info: "自身护盾", atktype: 1
},
1013: {
uuid: 1013, path: "orc3", type: 1, level: 1, name: "兽人战士", atk: 4, hp: 30, atk_dis: 30, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 1005, word: "守护", info: "自身护盾", atktype: 1
},
1021: {
uuid: 1021, path: "gou1", type: 1, level: 1, name: "黄皮豺狼", atk: 4, hp: 30, atk_dis: 30, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 1005, word: "守护", info: "自身护盾", atktype: 1
},
1022: {
uuid: 1022, path: "gou2", type: 1, level: 1, name: "白皮豺狼", atk: 4, hp: 30, atk_dis: 30, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 1005, word: "守护", info: "自身护盾", atktype: 1
},
1023: {
uuid: 1023, path: "gou3", type: 1, level: 1, name: "灰皮豺狼", atk: 4, hp: 30, atk_dis: 30, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 1005, word: "守护", info: "自身护盾", atktype: 1
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 1003, word: "守护", info: "自身护盾", atktype: 1
},
1031: {
uuid: 1031, path: "gou1", type: 1, level: 1, name: "独眼巨人", atk: 4, hp: 30, atk_dis: 30, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 1005, word: "守护", info: "自身护盾", atktype: 1
uuid: 1031, path: "du1", type: 1, level: 1, name: "独眼巨人", atk: 4, hp: 30, atk_dis: 30, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 1004, word: "守护", info: "自身护盾", atktype: 1
},
1032: {
uuid: 1032, path: "gou2", type: 1, level: 1, name: "狂暴独眼", atk: 4, hp: 30, atk_dis: 30, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 1005, word: "守护", info: "自身护盾", atktype: 1
uuid: 1032, path: "du2", type: 1, level: 1, name: "狂暴独眼", atk: 4, hp: 30, atk_dis: 30, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 3001, word: "守护", info: "自身护盾", atktype: 1
},
1033: {
uuid: 1033, path: "gou3", type: 1, level: 1, name: "独眼首领", atk: 4, hp: 30, atk_dis: 30, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 1005, word: "守护", info: "自身护盾", atktype: 1
uuid: 1033, path: "du3", type: 1, level: 1, name: "独眼首领", atk: 4, hp: 30, atk_dis: 30, atk_cd: 2, power: 0, power_max: 10, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 3001, word: "守护", info: "自身护盾", atktype: 1
},
1041: {
uuid: 1041, path: "ys1", type: 1, level: 1, name: "火元素", atk: 4, hp: 30, atk_dis: 200, atk_cd: 2, power: 0, power_max: 10, speed: 30,

View File

@@ -72,7 +72,6 @@ export class BoxRangComp extends CCComp {
}
this.HeroViewComp.is_atking = true;
this.HeroViewComp.stop_cd = 0.1
this.HeroViewComp.as.change_default("idle");
}
}

View File

@@ -22,6 +22,7 @@ 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";
const { ccclass, property } = _decorator;
/** 角色显示组件 */
@@ -185,7 +186,7 @@ export class HeroViewComp extends CCComp {
if(this.enemy){
return
}
this.set_diry()
// this.set_diry()
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y+dt*this.dir_y, this.node.position.z);
}
set_diry(){
@@ -203,28 +204,104 @@ export class HeroViewComp extends CCComp {
this.as.atk()
this.to_speek(smc.skills[this.max_skill_uuid].name)
this.scheduleOnce(()=>{
this.do_max_skill();
this.handle_skill(this.max_skill_uuid);
},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,y:number=0){
skill_pos(){
return v3(0,35)
}
get_enemy_pos(){
let pos =this.skill_pos()
let t_pos:Vec3 = v3(720,BoxSet.GAME_LINE)
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+pos.y)+BoxSet.ATK_Y)
}
return {pos,t_pos}
}
get_hero_pos(hero:any){
let pos =this.skill_pos()
let t_pos:Vec3 = v3(720,BoxSet.GAME_LINE)
if(!hero.HeroView.node.isValid){
console.log("hero.heroView.node.isValid",hero.HeroView);
return
}else{
t_pos = v3(hero.HeroView.node.position.x-this.node.position.x,hero.HeroView.node.position.y-(this.node.position.y+pos.y)+BoxSet.ATK_Y)
}
return {pos,t_pos}
}
shoot(skill_uuid:number,y:number=0,x:number=0){
// console.log("mon shoot");
let skill = ecs.getEntity<Skill>(Skill);
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 {pos,angle,t_pos}=this.get_enemy_pos()
let {pos,t_pos}=this.get_enemy_pos()
pos.y=pos.y + y
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos);
pos.x=pos.x + x
skill.load(pos,BoxSet.HERO,this.node,skill_uuid,atk,t_pos);
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
}
to_add_buff(hero:any,s_uuid:number){
let skill = ecs.getEntity<Skill>(Skill);
let atk = smc.skills[s_uuid].atk+this.atk;
let {pos,t_pos}=this.get_hero_pos(hero)
skill.load(pos,BoxSet.HERO,this.node,this.max_skill_uuid,atk,t_pos);
hero.HeroView.add_hp(smc.skills[s_uuid].atk)
}
push_least_buff(skill:number){
let heros:any = ecs.query(ecs.allOf(HeroModelComp));
let least_hp:number=999999
let t_hero:any= null
if (heros.length > 0) {
if(smc.skills[skill].type==92){ //随机添加buff
let i = RandomManager.instance.getRandomInt(0,heros.length-1,3)
}else{
for (let i = 0; i < heros.length; i++) {
let hero = heros[i];
if(smc.skills[skill].type==91){ //血量最少单体
if(hero.HeroView.hp < least_hp){
least_hp = hero.HeroView.hp
t_hero = hero
}
}else{ //群体
this.to_add_buff(hero,skill)
}
}
if(t_hero){ //血量最少单体
this.to_add_buff(t_hero,skill)
}
}
}
}
//使用max_skill
do_max_skill(){
this.shoot(this.max_skill_uuid)
handle_skill(skill:number){
switch (smc.skills[skill].tg) {
case 0: //自己
break;
case 1: //伙伴
this.push_least_buff(skill)
break;
case 2: //自己和伙伴
break;
case 3: //敌人
this.shoot(skill)
break;
case 4: //敌人和自己
this.shoot(skill)
break;
}
}
to_speek(words:string,time:number=0.5){
this.speek_time=0.5
@@ -242,31 +319,14 @@ export class HeroViewComp extends CCComp {
this.node.getChildByName("tooltip").active=false;
}
}
get_enemy_pos(){
let pos = v3(35*this.scale,50)
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+pos.y)+BoxSet.ATK_Y)
angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
if(this.scale == -1){
angle = angle +180
}
}else{
t_pos=null
}
return {pos,t_pos,angle}
}
check_enemy_alive(){
if(this.enemy){
if(!this.enemy.isValid){
return false
}
return true
if(Math.abs(this.enemy.position.x-this.node.position.x) < this.atk_dis) return true;
return false
}else{
return false
}
@@ -278,7 +338,7 @@ export class HeroViewComp extends CCComp {
// console.log("atk_cd:"+this.atk_cd);
this.as.atk();
this.scheduleOnce(()=>{
this.shoot(this.skill_uuid);
this.handle_skill(this.skill_uuid)
},0.4)
}
}else{
@@ -309,9 +369,11 @@ export class HeroViewComp extends CCComp {
}, 15);
}
}
heathed(){
this.node.getChildByName("heathed").active=true
}
add_hp(hp: number=0){
console.log("hero 加血动画");
this.heathed();
this.hp+=hp;
if(this.hp > this.hp_max){
this.hp = this.hp_max;

View File

@@ -36,7 +36,7 @@ export class MapMonsterComp extends CCComp {
target_timer: Timer = new Timer(0.1);
setp_num:number = 5;
game_over:boolean = false;
start_ys:any[] = [120,80,40,0,-40,-80,-120];
start_ys:any[] = [100,50,0,-50,-100];
onLoad(){
// 监听全局事件
oops.message.on("other_add_monster", this.on_other_add_monster, this);

View File

@@ -71,9 +71,9 @@ export class BoxRangComp extends CCComp {
}
}
if(Math.abs(other_pos.x-self_pos.x) < this.MonViewComp.atk_dis){
this.MonViewComp.is_atking = true;
this.MonViewComp.stop_cd = 0.1
this.MonViewComp.as.change_default("idle");
}

View File

@@ -17,9 +17,7 @@ const { ccclass, property } = _decorator;
export class MonSpine extends Component {
@property(Animation)
animator: Animation = null!;
idle_clip: AnimationClip = null!;
atk_clip: AnimationClip = null!;
max_clip: AnimationClip = null!;
move_clip: AnimationClip = null!;
default_clip:string = "move";
@@ -27,10 +25,8 @@ export class MonSpine extends Component {
// 角色控制组件
this.initAnimator();
LayerUtil.setNodeLayer(LayerUtil.MAP, this.node);
this.idle_clip = this.animator.clips[0];
this.atk_clip = this.animator.clips[1];
this.max_clip = this.animator.clips[2];
this.move_clip = this.animator.clips[3];
this.atk_clip = this.animator.clips[0];
this.move_clip = this.animator.clips[1];
let animation = this.animator.getComponent(Animation);
animation.on(Animation.EventType.FINISHED, this.onAnimationEvent, this)
}
@@ -43,7 +39,7 @@ export class MonSpine extends Component {
onAnimationEvent(type: Animation.EventType, state: AnimationState){
if(type==Animation.EventType.FINISHED){
if(state.name==this.atk_clip.name||state.name==this.max_clip.name){
if(state.name==this.atk_clip.name){
this.default();
}
}
@@ -57,8 +53,8 @@ export class MonSpine extends Component {
}
}
idle(){
if(!this.animator.getState(this.idle_clip.name).isPlaying){
this.animator.play(this.idle_clip.name);
if(!this.animator.getState(this.move_clip.name).isPlaying){
this.animator.play(this.move_clip.name);
}
}
atk() {
@@ -69,8 +65,8 @@ export class MonSpine extends Component {
max(){
if(!this.animator.getState(this.max_clip.name).isPlaying){
this.animator.play(this.max_clip.name);
if(!this.animator.getState(this.atk_clip.name).isPlaying){
this.animator.play(this.atk_clip.name);
}
}

View File

@@ -175,7 +175,7 @@ export class MonViewComp extends CCComp {
if(this.scale===-1&&this.node.position.x <= BoxSet.HERO_START){
return;
}
this.set_diry()
// this.set_diry()
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y+dt*this.dir_y, this.node.position.z);
}
set_diry(){
@@ -200,26 +200,21 @@ export class MonViewComp extends CCComp {
// let power_progress= this.power/this.power_max;
// this.node.getChildByName("top").getChildByName("power").getComponent(ProgressBar)!.progress = power_progress;
}
shoot(skill_uuid:number){
shoot(skill_uuid:number,y:number=0,x:number=0){
// console.log("mon shoot");
let skill = ecs.getEntity<Skill>(Skill);
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 {pos,angle,t_pos}=this.get_enemy_pos()
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos);
pos.y=pos.y + y
pos.x=pos.x + x
skill.load(pos,BoxSet.MONSTER,this.node,skill_uuid,atk,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 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;
let {pos,angle,t_pos}=this.get_enemy_pos()
skill.load(pos,speed,dis,scale,this.node,this.max_skill_uuid,atk,angle,t_pos);
for(let i=0;i<smc.skills[this.max_skill_uuid].count;i++){
this.shoot(this.max_skill_uuid)
}
}
to_speek(words:string,time:number=0.5){
this.speek_time=0.5
@@ -247,12 +242,8 @@ export class MonViewComp extends CCComp {
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)
angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
if(this.scale == -1){
angle = angle +180
}
}else{
t_pos=null
t_pos=v3(-720,BoxSet.GAME_LINE)
}
return {pos,t_pos,angle}
}
@@ -261,7 +252,8 @@ export class MonViewComp extends CCComp {
if(!this.enemy.isValid){
return false
}
return true
if(Math.abs(this.enemy.position.x-this.node.position.x) < this.atk_dis) return true;
return false
}else{
return false
}

View File

@@ -73,10 +73,8 @@ export class CSkillComp extends CCComp {
let randian=Math.atan2(dir.y,dir.x)
angle = randian * (180 / Math.PI);
let scale = this.scale
let dis = smc.skills[this.skill_uuid].dis+this.dis;
let atk = smc.skills[this.skill_uuid].atk+this.atk;
let speed = smc.skills[this.skill_uuid].speed+this.speed;
skill.load(pos,speed,dis,scale,this.node,this.skill_uuid,atk,angle,t_pos);
skill.load(pos,scale,this.node,this.skill_uuid,atk,angle,t_pos);
}
add_buff(){
// 1 远距离攻击,碰撞后 结束

View File

@@ -29,35 +29,50 @@ export class Skill extends ecs.Entity {
this.remove(SkillCom);
super.destroy();
}
load(pos: Vec3 = Vec3.ZERO,speed:number = 100,
dis:number = 50,scale:number = 1,parent:Node,
uuid:number=1001,atk:number =10,angle = 0,
t_pos:Vec3 = null,run_type:number=0,)
load(pos: Vec3 = Vec3.ZERO,group:number,parent:Node,
uuid:number=1001,atk:number =10,t_pos:Vec3 = null)
{
var path = "game/skills/"+smc.skills[uuid].sp_name;
var prefab: Prefab = oops.res.get(path, Prefab)!;
// console.log("load skill :",path,prefab)
var node = instantiate(prefab);
// console.log("load skill parent.position :",parent.position)
pos=v3(pos.x,pos.y)
node.parent = parent;
node.setScale(scale,1)
//转换pos为世界坐标
node.setPosition(pos)
var sv = node.getComponent(SkillCom)!;
sv.speed = speed;
sv.dis = dis;
sv.scale = scale;
sv.atk = atk;
let scale =1
if(t_pos.x < pos.x){
scale= - 1
}
let angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
if(scale == -1){
angle = angle +180
}
if(!smc.skills[uuid].angle){
angle=0
}
sv.angle = angle;
console.log(smc.skills[uuid].name+"angle:"+angle)
sv.s_uuid = uuid;
sv.atk = atk;
node.setScale(v3(node.scale.x*scale,node.scale.y))
sv.speed=smc.skills[uuid].speed;
sv.dis=smc.skills[uuid].dis;
sv.run_type=smc.skills[uuid].run;
if(sv.dis == 0){
sv.run_type=2
}
sv.in_time=smc.skills[uuid].in;
sv.t_pos = t_pos; // 目标增量
sv.type = smc.skills[uuid].type;
sv.box_tag= BoxSet.SKILL_TAG;
sv.run_type== run_type;
if(scale == 1){
sv.box_group=BoxSet.HERO
}else{
sv.box_group=BoxSet.MONSTER
}
sv.box_group=group
// console.log("load skill :",sv)
this.add(sv);
}
}

View File

@@ -1,4 +1,4 @@
import { _decorator,Collider2D ,Contact2DType,v3,IPhysics2DContact,Vec3, tween} from "cc";
import { _decorator,Collider2D ,Contact2DType,v3,IPhysics2DContact,Vec3, tween, math} 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";
@@ -7,6 +7,7 @@ import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/
import { MoveToComp } from "../common/ecs/position/MoveTo";
import { MonModelComp } from "../mon/MonModelComp";
import { HeroViewComp } from "../hero/HeroViewComp";
import { SkillSet } from "../common/config/SkillSet";
const { ccclass, property } = _decorator;
@@ -19,6 +20,7 @@ export class SkillCom extends CCComp {
// // var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
// // this.on(ModuleEvent.Cmd, this.onHandler, this);
// }
s_uuid:number = 0;
speed:number = 200;
y_speed:number = 0;
x_speed:number = 0;
@@ -27,23 +29,24 @@ export class SkillCom extends CCComp {
atk:number = 10;
atk_count:number = 0;
angle:number = 0;
t_pos:Vec3 = null; // 目标增量
t_pos:Vec3 = v3(0,0,0); // 目标增量
is_destroy:boolean = false;
box_group:number = 0;
box_tag:number=0;
type:number = 1;
time:Timer = new Timer(0.01);
run_type:number = 0; // 0直线1贝塞尔曲线 2 不动
in_time:number = 1.5; // 不动技能持续时间
in_time:number = 0.3; // 不动技能持续时间
start() {
// console.log("skill start parent :",this.node.parent)
// console.log("skill start t position :",this.t_pos)
// console.log("skill start run_type",this.run_type)
this.x_speed=Math.cos(this.angle * Math.PI / 180) * this.speed-30*this.scale;
this.y_speed=Math.sin(this.angle * Math.PI / 180) * this.speed;
this.node.active=true
this.node.angle = this.angle;
let collider = this.getComponent(Collider2D);
collider.group = this.box_group;
// console.log("skill group",this.box_group)
collider.tag = this.box_tag;
collider.sensor = true;
if (collider) {
@@ -51,22 +54,40 @@ export class SkillCom extends CCComp {
// collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
}
if(this.t_pos){
this.x_speed=Math.cos(this.angle * Math.PI / 180) * this.speed-30*this.scale;
this.y_speed=Math.sin(this.angle * Math.PI / 180) * this.speed;
}else{
this.x_speed=this.speed
this.y_speed=0
if(this.run_type == 0){ //直线,默认直线,有特定目标 朝向目标直线
let time = 720 / this.speed;
let squaredDistance = this.t_pos.x * this.t_pos.x + this.t_pos.y * this.t_pos.y;
let distance = Math.sqrt(squaredDistance);
time = distance / this.speed;
let e_pos=v3(this.node.position.x+this.t_pos.x,this.node.position.y+this.t_pos.y)
tween(this.node).to( time,{ angle:this.angle,position: e_pos},
{
easing: "linear",
onUpdate: (target: Vec3, ratio: number) => { },
onComplete: (target?: object) => {
this.is_destroy=true
},
}
).start();
}
if(this.run_type == 1){
// console.log("skill run_type",this.run_type)
if(this.run_type == 1){ //贝塞尔曲线
console.log("skill bezierTo",this.t_pos)
let s_pos = v3(this.node.position.x,this.node.position.y)
let c_pos = v3(this.node.position.x,this.node.position.y)
let e_pos = v3(this.node.position.x+this.dis*this.scale,BoxSet.GAME_LINE-50)
SkillCom.bezierTo(this.node,2,s_pos,c_pos,e_pos,{onUpdate: (target: Vec3, ratio: number) => {
}
let c_pos = v3((this.t_pos.x+this.node.position.x)/2,this.node.position.y+100)
let e_pos = v3(this.node.position.x+this.t_pos.x,this.node.position.y+this.t_pos.y)
let time =Math.abs(this.t_pos.x/this.speed)
SkillCom.bezierTo(this.node,time,s_pos,c_pos,e_pos,{
onComplete: (target?: object) => {
this.is_destroy=true
},
}).start();
}
if(this.run_type == 2){
if(this.run_type == 2){ //原地不动的
tween(this.node).to( this.in_time,
{ position: new Vec3(this.node.position.x,this.node.position.y) },
{
@@ -76,38 +97,6 @@ export class SkillCom extends CCComp {
}
).start();
}
if(this.run_type == 0){
if(this.t_pos){
let l_x=Math.cos(this.angle * Math.PI / 180) * 50;
let l_y=Math.sin(this.angle * Math.PI / 180) * 50;
let squaredDistance = this.t_pos.x * this.t_pos.x + this.t_pos.y * this.t_pos.y;
let distance = Math.sqrt(squaredDistance);
let time = distance / this.speed-0.2;
//通过欧拉角 延长 目标点 增量
// this.t_pos.x=Math.cos(this.angle * Math.PI / 180) * this.dis;
// this.t_pos.y=Math.sin(this.angle * Math.PI / 180) * this.dis;
let e_pos=v3(this.node.position.x+l_x+this.t_pos.x,this.node.position.y+this.t_pos.y)
tween(this.node).to( 0.7,{ angle:this.angle,position: e_pos},
{
onUpdate: (target: Vec3, ratio: number) => { // onUpdate 接受当前缓动的进度
// 将缓动系统计算出的结果赋予 node 的位置
},
onComplete: (target?: object) => {
this.is_destroy=true
},
}
).start();
}else{
tween(this.node).to( this.dis/this.speed,
{ position: new Vec3(this.node.position.x+this.scale*this.dis,this.node.position.y) },
{
onComplete: (target?: object) => {
this.is_destroy=true
},
}
).start();
}
}
}
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
@@ -120,40 +109,13 @@ export class SkillCom extends CCComp {
}
}
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
// console.log("skill post contact")
// switch (selfCollider.group) {
// case BoxSet.HERO:
// switch (otherCollider.group){
// case BoxSet.MONSTER:
// case BoxSet.DEFAULT:
// setTimeout(() => {
// this.toDestroy()
// }, 10);
// break
// }
// break;
// case BoxSet.MONSTER:
// switch (otherCollider.group){
// case BoxSet.PLAYER:
// case BoxSet.HERO:
// case BoxSet.DEFAULT:
// setTimeout(() => {
// this.toDestroy()
// }, 10);
// break
// }
// }
}
update(deltaTime: number) {
// this.node.setScale(v3(this.scale,this.node.scale.y,this.node.scale.z))
// this.move(deltaTime)
this.toDestroy()
// this.t_move(deltaTime)
if (this.node.position.x > 400||this.node.position.x < -400||this.node.position.y > 1000||this.node.position.y < -100) {
this.is_destroy=true
}
}
t_move(dt: number){

View File

@@ -0,0 +1,29 @@
import { _decorator, Component, Node, sp ,Animation, AnimationState} from 'cc';
import { Timer } from '../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer';
const { ccclass, property ,} = _decorator;
@ccclass('anonce')
export class anonce extends Component {
timer:Timer=new Timer(0.5);
start() {
}
protected onLoad(): void {
}
update(deltaTime: number) {
if(this.node.active){
if(!this.node.getChildByName("skill").getComponent(Animation).getState("heathed").isPlaying){
this.node.getChildByName("skill").getComponent(Animation).play();
}
if (this.timer.update(deltaTime)) {
this.node.active=false;
}
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "9df173c3-eed0-4d48-9c27-e2ead9a9f68f",
"files": [],
"subMetas": {},
"userData": {}
}