mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 11:24:46 +00:00
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { _decorator, Component, Node } from 'cc';
|
|
import { app } from '../../../App';
|
|
import GRoleDefault from '../../../battle/base/role/GRoleDefault';
|
|
import { GData } from '../../../consts/GData';
|
|
import { v2 } from 'cc';
|
|
import { Prefab } from 'cc';
|
|
import { instantiate } from 'cc';
|
|
import { v3 } from 'cc';
|
|
import { ModeRenderHitText } from './ModeRenderHitText';
|
|
import { Vec2 } from 'cc';
|
|
import { GModeEvent, GModeHitInfo } from '../../../battle/modes/GMode';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('ModeRender')
|
|
export class ModeRender extends Component {
|
|
|
|
//受击预制体
|
|
@property(Prefab)
|
|
hitPrefab:Prefab;
|
|
|
|
onLoad(){
|
|
|
|
app.event.on(GModeEvent.HIT,this.onHit,this);
|
|
|
|
}
|
|
|
|
protected onDestroy(): void {
|
|
|
|
app.event.off(GModeEvent.HIT,this.onHit,this);
|
|
|
|
}
|
|
|
|
//受击
|
|
onHit(info:GModeHitInfo){
|
|
|
|
let rolePos = info.camera.worldToScreen(v3(info.world.x,info.world.y));
|
|
|
|
let hitNode = instantiate(this.hitPrefab);
|
|
|
|
this.node.addChild(hitNode);
|
|
hitNode.position = rolePos.add(v3(0,100,0));
|
|
|
|
hitNode.getComponent(ModeRenderHitText).setText(info.hit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|