添加了几个英雄
This commit is contained in:
@@ -12,7 +12,7 @@ const { ccclass, property } = _decorator;
|
||||
export class BoxRangComp extends CCComp {
|
||||
Hero_node: any=null!;
|
||||
MonViewComp:MonViewComp = null!;
|
||||
box_group:number = BoxSet.DEFAULT;
|
||||
box_group:number = BoxSet.MONSTER;
|
||||
box_tag:number = BoxSet.ATK_RANGE;
|
||||
offset_x:number = 300;
|
||||
atk_range:number = 150;
|
||||
|
||||
@@ -32,7 +32,7 @@ export class MonBuffComp extends CCComp {
|
||||
|
||||
timer:Timer = new Timer(0.1);
|
||||
buffs:any=[];
|
||||
group:number=0;
|
||||
group:number=BoxSet.MONSTER;
|
||||
/**
|
||||
skill_uuid:number=0;
|
||||
atk:number=0;
|
||||
|
||||
@@ -17,45 +17,67 @@ 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 = "idle";
|
||||
|
||||
onLoad() {
|
||||
// 角色控制组件
|
||||
this.initAnimator();
|
||||
LayerUtil.setNodeLayer(LayerUtil.MAP, this.node);
|
||||
this.idle_clip = this.animator.clips[0];
|
||||
this.atk_clip = this.animator.clips[1];
|
||||
this.move_clip = this.animator.clips[0];
|
||||
this.max_clip = this.animator.clips[2];
|
||||
this.move_clip = this.animator.clips[3];
|
||||
let animation = this.animator.getComponent(Animation);
|
||||
animation.on(Animation.EventType.FINISHED, this.onAnimationEvent, this)
|
||||
}
|
||||
|
||||
/** 初始化动画 */
|
||||
protected initAnimator() {
|
||||
this.animator=this.node.getChildByName("mon").getComponent(Animation);
|
||||
this.animator=this.node.getChildByName("anm").getComponent(Animation);
|
||||
// console.log("mon spine init",this.animator);
|
||||
}
|
||||
|
||||
onAnimationEvent(type: Animation.EventType, state: AnimationState){
|
||||
if(type==Animation.EventType.FINISHED){
|
||||
if(state.name==this.atk_clip.name){
|
||||
this.move();
|
||||
if(state.name==this.atk_clip.name||state.name==this.max_clip.name){
|
||||
this.default();
|
||||
}
|
||||
}
|
||||
}
|
||||
change_default(value:string){
|
||||
this.default_clip=value;
|
||||
this.animator.play(this.default_clip);
|
||||
}
|
||||
default() {
|
||||
this.animator.play(this.default_clip);
|
||||
}
|
||||
idle(){
|
||||
if(!this.animator.getState(this.idle_clip.name).isPlaying){
|
||||
this.animator.play(this.idle_clip.name);
|
||||
}
|
||||
}
|
||||
atk() {
|
||||
if(!this.animator.getState(this.atk_clip.name).isPlaying){
|
||||
this.animator.play(this.atk_clip.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
max(){
|
||||
if(!this.animator.getState(this.max_clip.name).isPlaying){
|
||||
this.animator.play(this.max_clip.name);
|
||||
}
|
||||
}
|
||||
|
||||
move(){
|
||||
if(!this.animator.getState(this.move_clip.name).isPlaying){
|
||||
this.animator.play(this.move_clip.name);
|
||||
}
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
this.node.destroy();
|
||||
}
|
||||
|
||||
@@ -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 MonSpineAnimator extends Component {
|
||||
private animName: string = "move";
|
||||
private loop: boolean = true;
|
||||
private spine!: sp.Skeleton;
|
||||
start() {
|
||||
this.spine = this.getComponent(sp.Skeleton)!;
|
||||
// console.log("MonSpineAnimator 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("MonSpineAnimator playAnimation");
|
||||
if (animName) {
|
||||
// console.log("MonSpineAnimator playAnimation animName", animName);
|
||||
this.animName = animName;
|
||||
this.loop = loop;
|
||||
this.spine.setAnimation(0, this.animName, this.loop);
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"5fd6bb0b-8ab2-4ffe-8682-108d9e999004","files":[],"subMetas":{},"userData":{}}
|
||||
@@ -75,7 +75,7 @@ export class MonViewComp extends CCComp {
|
||||
shield_max:number = 200;
|
||||
shield_time:number = 0; //护盾持续时间
|
||||
|
||||
box_group:number = 2;
|
||||
box_group:number = BoxSet.MONSTER;
|
||||
atk_range:number = 150;
|
||||
private timer:Timer = new Timer(1); //计时器
|
||||
private m_timer:Timer = new Timer(0.1);
|
||||
@@ -91,7 +91,7 @@ export class MonViewComp extends CCComp {
|
||||
} /** 视图层逻辑代码分离演示 */
|
||||
start () {
|
||||
this.as.move()
|
||||
this.sprite = this.node.getChildByName("mon").getComponent(Sprite);
|
||||
this.sprite = this.node.getChildByName("anm").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();
|
||||
|
||||
Reference in New Issue
Block a user