再次清理英雄,切换到像素
This commit is contained in:
@@ -10,7 +10,10 @@ export enum GameEvent {
|
||||
/** 游戏服务器连接成功 */
|
||||
GameServerConnected = "GameServerConnected",
|
||||
/** 登陆成功 */
|
||||
|
||||
LoginSuccess = "LoginSuccess",
|
||||
MAP_MOVE_END_LEFT = "MAP_MOVE_END_LEFT",
|
||||
MAP_MOVE_END_RIGHT = "MAP_MOVE_END_RIGHT",
|
||||
MSSelected = "MSSelected",
|
||||
LifeChange = "LifeChange",
|
||||
CastSkill = "CastSkill",
|
||||
|
||||
@@ -246,7 +246,7 @@ export const SkillSet = {
|
||||
|
||||
6003:{uuid:6003,name:"射击",for_hero:false,sp_name:"arrow",AtkedType:AtkedType.atked,path:"3037",quality:Quality.WHITE, TType:TType.Frontline,maxC:1,
|
||||
TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.single,CdType:CdType.cd,AType:AType.linear,EType:EType.collision,fname:"max",flash:false,with:0,
|
||||
debuff:0,deV:0,deC:0,deR:100,in:8,ap:100,cd:5,hit_num:1,hit:2,hited:3,buV:0,buC:0,buR:100,speed:720,cost:10,info:"向最前方敌人释放箭矢,造成100%攻击的伤害"},
|
||||
debuff:0,deV:0,deC:0,deR:100,in:8,ap:100,cd:5,hit_num:1,hit:1,hited:3,buV:0,buC:0,buR:100,speed:720,cost:10,info:"向最前方敌人释放箭矢,造成100%攻击的伤害"},
|
||||
|
||||
6004:{uuid:6004,name:"护盾",for_hero:true,sp_name:"shield",AtkedType:AtkedType.atked,path:"3045",quality:Quality.BLUE, TType:TType.Frontline,maxC:1,
|
||||
TGroup:TGroup.Team,SType:SType.shield,act:"max",DTType:DTType.single,CdType:CdType.cd,AType:AType.fixedStart,EType:EType.animationEnd,fname:"max",flash:false,with:0,
|
||||
@@ -274,7 +274,7 @@ export const SkillSet = {
|
||||
6011:{uuid:6011,name:"攻击",for_hero:false,sp_name:"atk2",AtkedType:AtkedType.atked,path:"3036",quality:Quality.WHITE, TType:TType.Frontline,maxC:1,
|
||||
TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.single,CdType:CdType.cd,AType:AType.fixedStart,EType:EType.animationEnd,fname:"max",flash:false,with:0,
|
||||
debuff:0,deV:0,deC:0,deR:100,in:8,ap:100,cd:5,hit_num:1,hit:1,hited:0.2,buV:0,buC:0,buR:100,speed:720,cost:10,info:"向最前方敌人扔出石斧,造成100%攻击的伤害"},
|
||||
6020:{uuid:6020,name:"烈焰斩击",for_hero:false,sp_name:"max_fireatk",AtkedType:AtkedType.atked,path:"3036",quality:Quality.WHITE, TType:TType.Frontline,maxC:1,
|
||||
6020:{uuid:6020,name:"烈焰斩击",for_hero:false,sp_name:"max_fireatk",AtkedType:AtkedType.fire,path:"3036",quality:Quality.WHITE, TType:TType.Frontline,maxC:1,
|
||||
TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.single,CdType:CdType.cd,AType:AType.fixedStart,EType:EType.animationEnd,fname:"max",flash:false,with:0,
|
||||
debuff:0,deV:0,deC:0,deR:100,in:8,ap:100,cd:5,hit_num:1,hit:1,hited:0.2,buV:0,buC:0,buR:100,speed:720,cost:10,info:"向最前方敌人扔出石斧,造成100%攻击的伤害"},
|
||||
|
||||
@@ -295,11 +295,11 @@ export const SkillSet = {
|
||||
TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.single,CdType:CdType.cd,AType:AType.linear,EType:EType.collision,fname:"max",flash:false,with:90,
|
||||
debuff:DebuffAttr.FROST,deV:1,deC:0,deR:100,in:1,ap:100,cd:1,hit_num:1,hit:1,hited:0.3,buV:0,buC:0,buR:100,speed:720,cost:10,info:"召唤大火球攻击前方所有敌人,造成200%攻击的伤害,20%几率冰冻敌人"},
|
||||
|
||||
6025:{uuid:6025,name:"烈焰射击",for_hero:false,sp_name:"arrow_yellow",AtkedType:AtkedType.atked,path:"3014",quality:Quality.GREEN, TType:TType.Frontline,maxC:1,
|
||||
6025:{uuid:6025,name:"烈焰射击",for_hero:false,sp_name:"arrow_yellow",AtkedType:AtkedType.fire,path:"3014",quality:Quality.GREEN, TType:TType.Frontline,maxC:1,
|
||||
TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.single,CdType:CdType.power,AType:AType.linear,EType:EType.collision,fname:"max",flash:false,with:90,
|
||||
debuff:DebuffAttr.STUN,deV:0.5,deC:0,deR:50,in:1,ap:100,cd:5,hit_num:1,hit:1,hited:0.3,buV:0,buC:0,buR:100,speed:720,cost:10,info:"召唤大火球攻击前方所有敌人,造成200%攻击的伤害,20%几率眩晕敌人"},
|
||||
|
||||
6026:{uuid:6026,name:"火墙", for_hero:true, sp_name:"firewall",AtkedType:AtkedType.atked,path:"3040",quality:Quality.BLUE, TType:TType.Frontline,maxC:1,
|
||||
6026:{uuid:6026,name:"火墙", for_hero:true, sp_name:"max_fwall",AtkedType:AtkedType.atked,path:"3040",quality:Quality.BLUE, TType:TType.Frontline,maxC:1,
|
||||
TGroup:TGroup.Ally,SType:SType.damage,act:"atk",DTType:DTType.range,CdType:CdType.cd,AType:AType.fixedEnd,EType:EType.timeEnd,fname:"max",flash:false,with:90,
|
||||
debuff:0,deV:0,deC:0,deR:100,in:10,ap:50,cd:5,hit_num:1,hit:1,hited:1,buV:0,buC:0,buR:100,speed:720,cost:10,info:"在最前方敌人位置,召唤一堵火墙,持续10秒,每秒造成50%攻击伤害"},
|
||||
|
||||
@@ -311,14 +311,18 @@ export const SkillSet = {
|
||||
TGroup:TGroup.Ally,SType:SType.damage,act:"atk",DTType:DTType.range,CdType:CdType.power,AType:AType.fixedEnd,EType:EType.animationEnd,fname:"max",flash:false,with:90,
|
||||
debuff:DebuffAttr.BACK,deV:0,deC:0,deR:100,in:3,ap:100,cd:5,hit_num:1,hit:1,hited:0.3,buV:0,buC:0,buR:100,speed:720,cost:10,info:"在最前方敌人位置,召唤水柱攻击敌人,每秒造成100%攻击的伤害,50%几率击退敌人"},
|
||||
|
||||
6029:{uuid:6029,name:"陨石术",for_hero:true, sp_name:"max_yunshi",AtkedType:AtkedType.atked,path:"3123",quality:Quality.BLUE, TType:TType.Frontline,maxC:1,
|
||||
6029:{uuid:6029,name:"陨石术",for_hero:true, sp_name:"max_yunshi",AtkedType:AtkedType.fire,path:"3123",quality:Quality.BLUE, TType:TType.Frontline,maxC:1,
|
||||
TGroup:TGroup.Ally,SType:SType.damage,act:"atk",DTType:DTType.range,CdType:CdType.power,AType:AType.fixedEnd,EType:EType.animationEnd,fname:"max",flash:false,with:90,
|
||||
debuff:0,deV:0,deC:0,deR:100,in:3,ap:500,cd:5,hit_num:1,hit:1,hited:0.3,buV:0,buC:0,buR:100,speed:720,cost:10,info:"在最前方敌人位置,召唤陨石攻击敌人,造成500%攻击的伤害"},
|
||||
debuff:0,deV:0,deC:0,deR:100,in:3,ap:500,cd:5,hit_num:0,hit:1,hited:0.3,buV:0,buC:0,buR:100,speed:720,cost:10,info:"在最前方敌人位置,召唤陨石攻击敌人,造成500%攻击的伤害"},
|
||||
|
||||
6030:{uuid:6030,name:"冰墙", for_hero:false, sp_name:"icet",AtkedType:AtkedType.atked,path:"3050",quality:Quality.GREEN, TType:TType.Frontline,maxC:1,
|
||||
TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.range,CdType:CdType.cd,AType:AType.linear,EType:EType.animationEnd,fname:"max",flash:false,with:90,
|
||||
debuff:DebuffAttr.BACK,deV:0,deC:0,deR:100,in:1,ap:400,cd:5,hit_num:1,hit:1,hited:0.3,buV:0,buC:0,buR:100,speed:720,cost:10,info:"在最前方敌人位置,召唤冰墙攻击敌人,造成200%攻击的伤害,50%几率击退敌人"},
|
||||
//召唤取消
|
||||
6031:{uuid:6031,name:"剑雨",for_hero:true, sp_name:"max_jianyu",AtkedType:AtkedType.fire,path:"3123",quality:Quality.BLUE, TType:TType.Frontline,maxC:1,
|
||||
TGroup:TGroup.Ally,SType:SType.damage,act:"max",DTType:DTType.range,CdType:CdType.power,AType:AType.fixedEnd,EType:EType.animationEnd,fname:"max",flash:false,with:90,
|
||||
debuff:0,deV:0,deC:0,deR:100,in:3,ap:500,cd:5,hit_num:0,hit:1,hited:0.3,buV:0,buC:0,buR:100,speed:720,cost:10,info:"在最前方敌人位置,召唤陨石攻击敌人,造成500%攻击的伤害"},
|
||||
|
||||
//召唤取消
|
||||
// 6031:{uuid:6031,name:"召唤骷髅",for_hero:true,sp_name:"zhaohuan",AtkedType:AtkedType.atked,path:"3018",quality:Quality.GREEN, TType:TType.Frontline,maxC:1,
|
||||
// TGroup:TGroup.Self,SType:SType.zhaohuan,act:"max",DTType:DTType.single,CdType:CdType.power,AType:AType.fixedStart,EType:EType.animationEnd,fname:"max_blue",flash:true,with:90,
|
||||
// debuff:0,deV:0,deC:0,deR:100,in:0.8,ap:70,cd:60,hit_num:1,hit:1,hited:1,buV:0,buC:0,buR:100,speed:720,hero:5221,cost:10,info:"召唤一个骷髅战士为我方而战"},
|
||||
|
||||
@@ -52,7 +52,7 @@ export const getHeroListByCalled = (count:number,called:any[])=>{
|
||||
|
||||
export const HeroList = [5021,5022,5023,5024,5025,5026,5027,5028]
|
||||
export const MonList = [5201,5202,5203,5204,5205,5206,5219,5220,5221,5222,5223,5224,5225,5226,5227]
|
||||
export const Masters = [5001,5002,5005,5009,5010,5011]
|
||||
export const Masters = [5001,5002,5005,5008,5009,5010,5011]
|
||||
|
||||
export const HeroPos={
|
||||
0:{pos:v3(-290,0,0)},
|
||||
@@ -272,7 +272,7 @@ export const HeroInfo = {
|
||||
// buff:[],info:"刀类专精,易伤效果额外持续1次"},
|
||||
|
||||
5005:{uuid:5005,name:"幽灵射手",path:"a4", quality:HQuality.BLUE,lv:1,kind:2,
|
||||
type:HType.remote,hp:100,ap:15,dis:400,cd:1,speed:100,skills:[6003,6003],
|
||||
type:HType.remote,hp:100,ap:15,dis:400,cd:1,speed:100,skills:[6025,6031],
|
||||
buff:[],info:"说明"},
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@ export const HeroInfo = {
|
||||
buff:[],info:"说明"},
|
||||
|
||||
5008:{uuid:5008,name:"火焰法师",path:"zh2", quality:HQuality.BLUE,lv:1,kind:2,
|
||||
type:HType.mage,hp:100,ap:15,dis:400,cd:1.5,speed:100,skills:[6022,6002],
|
||||
type:HType.mage,hp:100,ap:15,dis:400,cd:1.5,speed:100,skills:[6022,6029],
|
||||
buff:[],info:"说明"},
|
||||
|
||||
5009:{uuid:5009,name:"风暴精灵",path:"d1", quality:HQuality.BLUE,lv:1,kind:2,
|
||||
|
||||
@@ -32,8 +32,6 @@ export class BuffComp extends Component {
|
||||
buff_cd:number=0;
|
||||
wind_cd:number=0;
|
||||
speek_time:number=0;
|
||||
HeroView:HeroViewComp=null!
|
||||
hp_bar:any=null
|
||||
|
||||
timer:Timer=new Timer(2);
|
||||
buff_keys:any[]=["by1","by2","by3"]
|
||||
@@ -45,11 +43,9 @@ export class BuffComp extends Component {
|
||||
}
|
||||
|
||||
info_init(){
|
||||
this.HeroView=this.node.getComponent(HeroViewComp)
|
||||
this.top_node = this.node.getChildByName("top");
|
||||
let hp_y=this.node.getComponent(UITransform).height
|
||||
this.top_node.setPosition(0,hp_y,0)
|
||||
this.hp_bar=this.top_node.getChildByName("hp").getComponent(ProgressBar)
|
||||
// this.top_node.getChildByName("hp").active=(this.node.getComponent(HeroViewComp).fac == 1 ? true : false)
|
||||
|
||||
// this.vmdata_update()
|
||||
@@ -60,7 +56,7 @@ export class BuffComp extends Component {
|
||||
}
|
||||
update(deltaTime: number) {
|
||||
if(smc.mission.pause) return
|
||||
this.hp_show()
|
||||
|
||||
if(this.wind_cd > 0 ) this.wind_cd -= deltaTime;
|
||||
if(this.wind_cd <= 0 && this.node.getChildByName("wind").active){
|
||||
this.node.getChildByName("wind").active = false;
|
||||
@@ -75,15 +71,7 @@ export class BuffComp extends Component {
|
||||
// this.in_speek(deltaTime)
|
||||
// this.vmdata_update()
|
||||
}
|
||||
hp_show(){
|
||||
// if(this.node.getComponent(HeroViewComp).fac == 0) return
|
||||
let hp=this.HeroView.currentHp;
|
||||
let hp_max=this.HeroView.currentHpMax;
|
||||
let hp_progress= hp/hp_max;
|
||||
this.hp_bar.progress = hp_progress;
|
||||
if(this.HeroView.is_boss) return
|
||||
this.top_node.getChildByName("hp").active = (hp == hp_max) ? false : true;
|
||||
}
|
||||
|
||||
show_shield(val:boolean){
|
||||
this.node.getChildByName("shielded").active=val
|
||||
}
|
||||
@@ -133,20 +121,20 @@ export class BuffComp extends Component {
|
||||
var path = "game/skills/dead";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
node.setScale(node.scale.x*0.5,node.scale.y*0.5)
|
||||
let pos = v3(this.node.position.x,this.node.position.y+30,this.node.position.z);
|
||||
node.parent = this.node.parent;
|
||||
node.setPosition(pos);
|
||||
}
|
||||
in_atked(anm:string="atked") {
|
||||
in_atked(anm:string="atked",scale:number=1) {
|
||||
var path = "game/skills/"+anm;
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
let pos =v3(15,30);
|
||||
node.setPosition(pos)
|
||||
node.parent = this.node;
|
||||
node.setScale(node.scale.x*scale,node.scale.y)
|
||||
node.setPosition(this.node.position.x,this.node.position.y+30,this.node.position.z)
|
||||
node.parent = this.node.parent;
|
||||
}
|
||||
in_iced(t:number=1,ap:number=0) {
|
||||
console.log("[buffcomp]:in_iced",this.HeroView.hero_name,t,ap)
|
||||
var path = "game/skills/iced";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
@@ -166,7 +154,8 @@ export class BuffComp extends Component {
|
||||
var path = "game/skills/yun";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
node.setPosition(v3(0,0));
|
||||
let height=this.node.getComponent(UITransform).height
|
||||
node.setPosition(v3(0,height));
|
||||
node.getComponent(timedCom).time = t;
|
||||
node.getComponent(timedCom).ap = ap;
|
||||
node.parent = this.node;
|
||||
|
||||
@@ -228,8 +228,16 @@ export class HeroViewComp extends CCComp {
|
||||
this.in_stop(dt);
|
||||
// 处理伤害队列
|
||||
this.processDamageQueue();
|
||||
|
||||
}
|
||||
hp_show(){
|
||||
// if(this.node.getComponent(HeroViewComp).fac == 0) return
|
||||
let hp=this.currentHp;
|
||||
let hp_max=this.currentHpMax;
|
||||
let hp_progress= hp/hp_max;
|
||||
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar).progress = hp_progress;
|
||||
// this.node.getChildByName("top").getChildByName("hp").active = (hp == hp_max) ? false : true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
get isActive() {
|
||||
@@ -343,17 +351,15 @@ export class HeroViewComp extends CCComp {
|
||||
switch(buff){
|
||||
case BuffAttr.ATK:
|
||||
this.ap=this.check_atrr(BuffAttr.ATK)
|
||||
|
||||
break
|
||||
case BuffAttr.ATK_CD:
|
||||
this.cd=this.check_atrr(BuffAttr.ATK_CD)
|
||||
|
||||
break
|
||||
case BuffAttr.HP:
|
||||
let diff=this.check_atrr(BuffAttr.HP)-this.currentHpMax
|
||||
this.currentHpMax=this.check_atrr(BuffAttr.HP)
|
||||
this.currentHp+=diff
|
||||
|
||||
let diff=this.check_atrr(BuffAttr.HP)-this.currentHpMax
|
||||
this.currentHpMax=this.check_atrr(BuffAttr.HP)
|
||||
this.currentHp+=diff
|
||||
this.hp_show()
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -409,6 +415,7 @@ export class HeroViewComp extends CCComp {
|
||||
this.currentHp+=real_hp;
|
||||
this.BUFFCOMP.tooltip(TooltipTypes.health,real_hp.toFixed(0));
|
||||
}
|
||||
this.hp_show()
|
||||
// this.update_vm
|
||||
}
|
||||
|
||||
@@ -636,13 +643,28 @@ export class HeroViewComp extends CCComp {
|
||||
}else{
|
||||
this.ent.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// this.update_vm
|
||||
this.back()
|
||||
this.showDamage(damage, is_crit,atked_anm);
|
||||
|
||||
}
|
||||
//后退
|
||||
back(){
|
||||
if(this.fac==FacSet.MON) {
|
||||
let tx=this.node.position.x+5
|
||||
if(tx > 320) tx=320
|
||||
tween(this.node).to(0.1, { position:v3(tx,this.node.position.y,0)}).start()
|
||||
}
|
||||
if(this.fac==FacSet.HERO) {
|
||||
let tx=this.node.position.x-5
|
||||
if(tx < -320) tx=-320
|
||||
tween(this.node).to(0.1, { position:v3(tx,this.node.position.y,0)}).start()
|
||||
}
|
||||
}
|
||||
//伤害计算 debuff 易伤
|
||||
count_damage(remainingDamage:number){
|
||||
let damage = 0;
|
||||
@@ -840,7 +862,8 @@ export class HeroViewComp extends CCComp {
|
||||
/** 立即显示伤害效果 */
|
||||
private showDamageImmediate(damage: number, isCrit: boolean,anm:string="atked") {
|
||||
// this.as.atked()
|
||||
this.BUFFCOMP.in_atked(anm)
|
||||
this.hp_show()
|
||||
this.BUFFCOMP.in_atked(anm,this.fac==FacSet.HERO?1:-1)
|
||||
this.atked_count++;
|
||||
if (isCrit) {
|
||||
this.BUFFCOMP.hp_tip(TooltipTypes.crit, damage.toFixed(0), damage);
|
||||
|
||||
@@ -157,36 +157,36 @@ export class CardComp extends CCComp {
|
||||
this.do_card_bg_show(HeroInfo[uuid].quality)
|
||||
show.getChildByName("coins").active=false
|
||||
var icon_path = "game/heros/heros/"+HeroInfo[uuid].path
|
||||
resources.load(icon_path, sp.SkeletonData, (err, skeleton) => {
|
||||
if (err) {
|
||||
console.error("[CardComp]: 加载骨骼数据失败:", err);
|
||||
return;
|
||||
}
|
||||
console.log("[CardComp]: 加载骨骼数据成功:", skeleton)
|
||||
// 检查节点是否仍然存在
|
||||
const maskNode = show.getChildByName("mask");
|
||||
if (!maskNode) {
|
||||
console.error("[CardComp]: mask节点不存在");
|
||||
return;
|
||||
}
|
||||
// resources.load(icon_path, sp.SkeletonData, (err, skeleton) => {
|
||||
// if (err) {
|
||||
// console.error("[CardComp]: 加载骨骼数据失败:", err);
|
||||
// return;
|
||||
// }
|
||||
// console.log("[CardComp]: 加载骨骼数据成功:", skeleton)
|
||||
// // 检查节点是否仍然存在
|
||||
// const maskNode = show.getChildByName("mask");
|
||||
// if (!maskNode) {
|
||||
// console.error("[CardComp]: mask节点不存在");
|
||||
// return;
|
||||
// }
|
||||
|
||||
const heroNode = maskNode.getChildByName("hero");
|
||||
if (!heroNode) {
|
||||
console.error("[CardComp]: hero节点不存在");
|
||||
return;
|
||||
}
|
||||
// const heroNode = maskNode.getChildByName("hero");
|
||||
// if (!heroNode) {
|
||||
// console.error("[CardComp]: hero节点不存在");
|
||||
// return;
|
||||
// }
|
||||
|
||||
const spine = heroNode.getComponent(sp.Skeleton);
|
||||
if (!spine) {
|
||||
console.error("[CardComp]: hero节点上没有找到SkinnedMeshRenderer组件");
|
||||
return;
|
||||
}
|
||||
// const spine = heroNode.getComponent(sp.Skeleton);
|
||||
// if (!spine) {
|
||||
// console.error("[CardComp]: hero节点上没有找到SkinnedMeshRenderer组件");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (spine) {
|
||||
spine.skeletonData = skeleton;
|
||||
spine.setAnimation(0, "Idle", true);
|
||||
}
|
||||
});
|
||||
// if (spine) {
|
||||
// spine.skeletonData = skeleton;
|
||||
// spine.setAnimation(0, "Idle", true);
|
||||
// }
|
||||
// });
|
||||
// resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
// const sprite = show.getChildByName("mask").getChildByName("hero").getComponent(Sprite);
|
||||
// sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[uuid].path);
|
||||
|
||||
@@ -176,13 +176,17 @@ export class HeroUiComp extends CCComp {
|
||||
private loadHeroIcon(iconNode: Node, heroPath: string) {
|
||||
iconNode.parent.getChildByName("iconbg").active=false
|
||||
const icon_path = "game/heros/heros/"+heroPath
|
||||
resources.load(icon_path, sp.SkeletonData, (err, skeleton) => {
|
||||
const spine = iconNode.getComponent(sp.Skeleton);
|
||||
if (spine) {
|
||||
spine.skeletonData = skeleton;
|
||||
spine.setAnimation(0, "Idle", true);
|
||||
}
|
||||
});
|
||||
// resources.load(icon_path, sp.SkeletonData, (err, skeleton) => {
|
||||
// if(err) return
|
||||
// const spine = iconNode.getComponent(sp.Skeleton);
|
||||
// if (spine) {
|
||||
// spine.skeletonData = skeleton;
|
||||
// spine.setAnimation(0, "Idle", true);
|
||||
// }
|
||||
// else{
|
||||
// console.error("[HeroUiComp]: loadHeroIcon error",err)
|
||||
// }
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,94 @@
|
||||
import { _decorator, CCInteger, Component, Node } from 'cc';
|
||||
import { _decorator, CCBoolean, CCInteger, Component, Node } from 'cc';
|
||||
import { oops } from 'db://oops-framework/core/Oops';
|
||||
import { GameEvent } from '../common/config/GameEvent';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('move')
|
||||
export class move extends Component {
|
||||
@property({ type: CCInteger })
|
||||
speed:number=2
|
||||
speed: number = 2;
|
||||
|
||||
@property({ type: CCInteger })
|
||||
maxX:number=640
|
||||
maxX: number = 640;
|
||||
|
||||
@property({ type: CCInteger })
|
||||
minX:number=-640
|
||||
minX: number = -640;
|
||||
|
||||
@property({ type: CCInteger })
|
||||
sc: number = 1; // 1: 从左到右, -1: 从右到左
|
||||
@property({ type: CCBoolean })
|
||||
isMove:boolean=false
|
||||
protected onLoad(): void {
|
||||
oops.message.on(GameEvent.MAP_MOVE_END_LEFT, this.onMapMoveEndLeft, this);
|
||||
oops.message.on(GameEvent.MAP_MOVE_END_RIGHT, this.onMapMoveEndRight, this);
|
||||
}
|
||||
start() {
|
||||
|
||||
// 根据移动方向设置初始位置
|
||||
}
|
||||
onMapMoveEndLeft() {
|
||||
if(this.sc==-1){
|
||||
this.isMove=true
|
||||
this.setInitialPosition()
|
||||
}
|
||||
}
|
||||
onMapMoveEndRight() {
|
||||
if(this.sc==1){
|
||||
this.isMove=true
|
||||
this.setInitialPosition()
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 根据移动方向设置初始位置
|
||||
*/
|
||||
setInitialPosition() {
|
||||
if (this.sc > 0) {
|
||||
// 从左到右移动,起点为 minX
|
||||
this.node.setPosition(this.minX, this.node.position.y);
|
||||
} else if (this.sc < 0) {
|
||||
// 从右到左移动,起点为 maxX
|
||||
this.node.setPosition(this.maxX, this.node.position.y);
|
||||
}
|
||||
}
|
||||
|
||||
update(dt: number) {
|
||||
this.node.setPosition(this.node.position.x+dt*this.speed,this.node.position.y)
|
||||
if(this.node.position.x >= this.maxX){
|
||||
this.node.setPosition(this.minX,this.node.position.y)
|
||||
// 更新位置
|
||||
if(this.isMove){
|
||||
const newX = this.node.position.x + dt * this.speed * this.sc;
|
||||
this.node.setPosition(newX, this.node.position.y);
|
||||
// 检查边界并重置位置
|
||||
this.checkBoundaries();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查边界并重置位置
|
||||
*/
|
||||
checkBoundaries() {
|
||||
if (this.sc > 0) {
|
||||
// 从左到右移动,到达右边界后回到左边界
|
||||
if (this.node.position.x >= this.maxX) {
|
||||
this.node.setPosition(this.minX, this.node.position.y);
|
||||
this.isMove=false
|
||||
oops.message.dispatchEvent(GameEvent.MAP_MOVE_END_LEFT)
|
||||
}
|
||||
} else if (this.sc < 0) {
|
||||
// 从右到左移动,到达左边界后回到右边界
|
||||
if (this.node.position.x <= this.minX) {
|
||||
this.node.setPosition(this.maxX, this.node.position.y);
|
||||
this.isMove=false
|
||||
oops.message.dispatchEvent(GameEvent.MAP_MOVE_END_RIGHT)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态改变移动方向
|
||||
* @param direction 1: 从左到右, -1: 从右到左
|
||||
*/
|
||||
changeDirection(direction: number) {
|
||||
this.sc = direction;
|
||||
this.setInitialPosition();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user