| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import { _decorator, Component, Node, Prefab, instantiate, Vec2, Vec3, UITransform, Sprite, UIOpacity, find } from 'cc';
- import { ResourceLoader } from '../core/resourceManager/ResourceLoader';
- import { UITween } from '../core/ui/tween/UITween';
- import { Window } from '../core/ui/window/Window';
- import { UnLockHeroItem } from './UnLockHeroItem';
- const { ccclass, property, requireComponent } = _decorator;
- /**武将解锁 */
- @ccclass('UnLockHero')
- @requireComponent(ResourceLoader)
- export class UnLockHero extends Component {
- @property({ type: Node, tooltip: "武将节点" }) heroNode: Node;
- @property({ type: Node, tooltip: "内容节点" }) contentNode: Node;
- @property({ type: Node, tooltip: "背景节点" }) bgNode: Node;
- @property({ type: Node, tooltip: "移除位置节点" }) targetNode: Node;
- @property({ type: UITween, tooltip: "关闭动画" }) tween: UITween;
- @property({ type: Window, tooltip: "关闭动画" }) win: Window;
- private res: ResourceLoader;
- private heroArr = [];
- private async openHandler(data: any) {
- this.tween.targetData[0].propsData.position = this.targetNode.position;
- this.res = this.getComponent(ResourceLoader);
- this.scheduleOnce(() => {
- this.win.close();
- }, 5);
- if (data.heroDatas.length) {
- if (data.heroDatas.length > 3) {
- this.contentNode.getComponent(UITransform).height = 610;
- }
- for (let i = 0; i < data.heroDatas.length; i++) {
- let prefab = await this.res.load<Prefab>('prefabs/ui/barracks/unLockHeroItem', Prefab);
- let node = instantiate(prefab);
- let item = node.getComponent(UnLockHeroItem);
- item.setData(data.heroDatas[i]);
- node.parent = this.heroNode;
- this.heroArr.push(item);
- }
- }
- }
- private onClose() {
- this.bgNode.active = false;
- }
- }
|