mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
生成野怪逻辑
This commit is contained in:
@@ -117,6 +117,12 @@ export class PlayerTacticalItem extends Component {
|
||||
fun(this,e);
|
||||
});
|
||||
}
|
||||
|
||||
addMoveEndEvent(fun:Function){
|
||||
this.drag.addMoveEndEvent((e) => {
|
||||
fun(this,e);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import { PlayerTacticalItem } from './PlayerTacticalItem';
|
||||
import { app } from '../../../App';
|
||||
import { PlayerTacticalEvent } from '../../../data/PlayerTacticalData';
|
||||
import PlayerTacticalData, { PlayerTacticalEvent } from '../../../data/PlayerTacticalData';
|
||||
import JNodeDrag from '../../../../../extensions/ngame/assets/ngame/util/components/JNodeDrag';
|
||||
import { EventTouch } from 'cc';
|
||||
import { UITransform } from 'cc';
|
||||
import { GUI } from '../../UIConfig';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**
|
||||
@@ -23,7 +24,10 @@ export class PlayerTacticalView extends Component {
|
||||
this.items = this.node.getComponentsInChildren(PlayerTacticalItem);
|
||||
this.items.forEach((item,index) => {
|
||||
item.onInit(index); //初始化阵法下标
|
||||
//添加移动事件
|
||||
item.addMoveEvent(this.onMoveItem.bind(this));
|
||||
//添加移动结束事件
|
||||
item.addMoveEndEvent(this.onMoveEndItem.bind(this));
|
||||
});
|
||||
|
||||
this.onUpdateView();
|
||||
@@ -53,6 +57,20 @@ export class PlayerTacticalView extends Component {
|
||||
|
||||
}
|
||||
|
||||
//子节点移动结束
|
||||
async onMoveEndItem(){
|
||||
|
||||
//移动结束则保存阵法
|
||||
let pets:number[] = PlayerTacticalData.getIns().getInitTacticalInfo();
|
||||
this.items.forEach(item => {
|
||||
pets[item.index] = item.petId || 0;
|
||||
})
|
||||
if(await PlayerTacticalData.getIns().UpdateTactical(pets)){
|
||||
app.layer.Open(GUI.Tips,{text:"保存阵法成功"});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
this.offEvent();
|
||||
}
|
||||
|
Reference in New Issue
Block a user