mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-12-08 14:00:02 +00:00
提交拖拽阵法
This commit is contained in:
@@ -5,6 +5,10 @@ import { GUI } from '../../UIConfig';
|
||||
import { sp } from 'cc';
|
||||
import { UIPetAnim } from '../../../consts/GData';
|
||||
import PlayerPetData from '../../../data/PlayerPetData';
|
||||
import { Vec3 } from 'cc';
|
||||
import { NodeEventType } from 'cc';
|
||||
import { EventTouch } from 'cc';
|
||||
import JNodeDrag from '../../../../../extensions/ngame/assets/ngame/util/components/JNodeDrag';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('PlayerTacticalItem')
|
||||
@@ -21,12 +25,20 @@ export class PlayerTacticalItem extends Component {
|
||||
@property(Node)
|
||||
havePet:Node;
|
||||
|
||||
//拖拽
|
||||
@property(JNodeDrag)
|
||||
drag:JNodeDrag;
|
||||
|
||||
//当前上阵的宠物
|
||||
petId:number;
|
||||
|
||||
//初始位置
|
||||
initPos:Vec3;
|
||||
|
||||
//初始化阵法
|
||||
onInit(index:number){
|
||||
this.index = index;
|
||||
this.initPos = this.node.position;
|
||||
}
|
||||
|
||||
protected start(): void {
|
||||
@@ -64,6 +76,10 @@ export class PlayerTacticalItem extends Component {
|
||||
|
||||
//打开选择阵法宠物
|
||||
onClick(){
|
||||
|
||||
//如果拖拽了则不生效点击事件
|
||||
if(this.drag.isMove) return;
|
||||
|
||||
//如果没有宠物则弹出选择宠物 负责 删除宠物
|
||||
if(this.petId){
|
||||
//移除宠物
|
||||
@@ -83,6 +99,24 @@ export class PlayerTacticalItem extends Component {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//交换阵法
|
||||
onExchange(item:PlayerTacticalItem){
|
||||
let rootIndex = this.index;
|
||||
this.index = item.index;
|
||||
item.index = rootIndex;
|
||||
|
||||
//更新拖拽位置
|
||||
let rootOriginal = this.drag.original;
|
||||
this.drag.onUpdateOriginal(item.drag.original);
|
||||
item.drag.onUpdateOriginal(rootOriginal);
|
||||
}
|
||||
|
||||
addMoveEvent(fun:Function){
|
||||
this.drag.addMoveEvent((e) => {
|
||||
fun(this,e);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user