import { _decorator, Component } from 'cc'; import { DragSource } from '../../core/ui/drag/DragSource'; import List from '../../core/ui/virtualList/List'; import { FormationHeroItem } from './FormationHeroItem'; import { FormationOne } from './FormationOne'; const { ccclass, property } = _decorator; /** * 英雄拖拽中辅助组件 * @author 袁浩 */ @ccclass('HeroDragingHelper') export class HeroDragingHelper extends Component { @property({ tooltip: "武将列表", type: List }) public list: List; @property({ tooltip: "阵位列表", type: [FormationOne] }) public formationList: FormationOne[] = []; public onDraging(source: DragSource, inTarget: boolean) { let helper = (source.getComponent(FormationHeroItem) || source.getComponent(FormationOne)).helper; helper && (helper.node.active = inTarget); this.list.scrollView.enabled = !inTarget; this.checkSame(source, inTarget); } public onDrop(source: DragSource) { this.list.scrollView.enabled = true; this.checkSame(source, false); } private checkSame(dragSource: DragSource, isInTarget: boolean = false) { for (let i = 0; i < this.formationList.length; i++) { this.formationList[i].checkSame(dragSource, isInTarget); } } }