提交拖拽阵法

This commit is contained in:
PC-20230316NUNE\Administrator 2023-11-16 19:10:19 +08:00
parent 1683ec01a0
commit c4437fef5e
24 changed files with 509 additions and 96 deletions

View File

@ -958,7 +958,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 64.845, "y": 74.983,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@ -1111,7 +1111,7 @@
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 550, "width": 550,
"height": 400 "height": 420
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",

View File

@ -169,8 +169,8 @@
], ],
"value": { "value": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 110, "x": 130,
"y": 110, "y": 130,
"z": 0 "z": 0
} }
}, },
@ -281,7 +281,7 @@
], ],
"value": { "value": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 110, "x": 130,
"y": 0, "y": 0,
"z": 0 "z": 0
} }
@ -393,8 +393,8 @@
], ],
"value": { "value": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 110, "x": 130,
"y": -110, "y": -130,
"z": 0 "z": 0
} }
}, },
@ -506,7 +506,7 @@
"value": { "value": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 110, "y": 130,
"z": 0 "z": 0
} }
}, },
@ -730,7 +730,7 @@
"value": { "value": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": -110, "y": -130,
"z": 0 "z": 0
} }
}, },
@ -841,8 +841,8 @@
], ],
"value": { "value": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": -110, "x": -130,
"y": 110, "y": 130,
"z": 0 "z": 0
} }
}, },
@ -953,7 +953,7 @@
], ],
"value": { "value": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": -110, "x": -130,
"y": 0, "y": 0,
"z": 0 "z": 0
} }
@ -1065,8 +1065,8 @@
], ],
"value": { "value": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": -110, "x": -130,
"y": -110, "y": -130,
"z": 0 "z": 0
} }
}, },
@ -1115,8 +1115,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 360, "width": 400,
"height": 360 "height": 400
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@ -1198,8 +1198,8 @@
"_paddingRight": 20, "_paddingRight": 20,
"_paddingTop": 20, "_paddingTop": 20,
"_paddingBottom": 20, "_paddingBottom": 20,
"_spacingX": 10, "_spacingX": 30,
"_spacingY": 10, "_spacingY": 30,
"_verticalDirection": 1, "_verticalDirection": 1,
"_horizontalDirection": 1, "_horizontalDirection": 1,
"_constraint": 1, "_constraint": 1,

View File

@ -36,12 +36,15 @@
{ {
"__id__": 28 "__id__": 28
}, },
{
"__id__": 32
},
{ {
"__id__": 30 "__id__": 30
} }
], ],
"_prefab": { "_prefab": {
"__id__": 33 "__id__": 35
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@ -646,12 +649,33 @@
"havePet": { "havePet": {
"__id__": 14 "__id__": 14
}, },
"drag": {
"__id__": 30
},
"_id": "" "_id": ""
}, },
{ {
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "06AIrIH75LL7sccNjNaqQj" "fileId": "06AIrIH75LL7sccNjNaqQj"
}, },
{
"__type__": "a3a9dIzSOFPPpmZbiL9N5+m",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 31
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "9a6ssWQUFBYaDchwbOTiyH"
},
{ {
"__type__": "cc.Button", "__type__": "cc.Button",
"_name": "", "_name": "",
@ -662,11 +686,11 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 31 "__id__": 33
}, },
"clickEvents": [ "clickEvents": [
{ {
"__id__": 32 "__id__": 34
} }
], ],
"_interactable": true, "_interactable": true,

View File

@ -26,19 +26,22 @@
}, },
{ {
"__id__": 14 "__id__": 14
},
{
"__id__": 20
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 20 "__id__": 26
}, },
{ {
"__id__": 22 "__id__": 28
} }
], ],
"_prefab": { "_prefab": {
"__id__": 24 "__id__": 30
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@ -71,7 +74,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "选中", "_name": "不可选中",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"_parent": { "_parent": {
@ -145,7 +148,7 @@
}, },
{ {
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "b4vJnGQvdKv4MXp8xLg6zf" "fileId": "89jo3ZLIBHkoSIJ8ht6gAw"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
@ -164,9 +167,9 @@
"_dstBlendFactor": 4, "_dstBlendFactor": 4,
"_color": { "_color": {
"__type__": "cc.Color", "__type__": "cc.Color",
"r": 0, "r": 255,
"g": 0, "g": 82,
"b": 0, "b": 82,
"a": 255 "a": 255
}, },
"_spriteFrame": { "_spriteFrame": {
@ -190,7 +193,7 @@
}, },
{ {
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "01wxgAoWhO+qLRM5Jr3rH1" "fileId": "f95xraDe1BKrLfx/ZQuwwz"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
@ -200,14 +203,14 @@
"asset": { "asset": {
"__id__": 0 "__id__": 0
}, },
"fileId": "fcC3JxewdM1K8tKbhV80+3", "fileId": "aeZLGO3ZRLEovu6SQVdYcK",
"instance": null, "instance": null,
"targetOverrides": null, "targetOverrides": null,
"nestedPrefabInstanceRoots": null "nestedPrefabInstanceRoots": null
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "背景", "_name": "选中",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"_parent": { "_parent": {
@ -267,6 +270,142 @@
"__prefab": { "__prefab": {
"__id__": 10 "__id__": 10
}, },
"_contentSize": {
"__type__": "cc.Size",
"width": 110,
"height": 110
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "b4vJnGQvdKv4MXp8xLg6zf"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 8
},
"_enabled": true,
"__prefab": {
"__id__": 12
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_spriteFrame": {
"__uuid__": "7d8f9b89-4fd1-4c9f-a3ab-38ec7cded7ca@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "01wxgAoWhO+qLRM5Jr3rH1"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "fcC3JxewdM1K8tKbhV80+3",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_name": "背景",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 15
},
{
"__id__": 17
}
],
"_prefab": {
"__id__": 19
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 14
},
"_enabled": true,
"__prefab": {
"__id__": 16
},
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 100, "width": 100,
@ -289,11 +428,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 8 "__id__": 14
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 12 "__id__": 18
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
@ -353,14 +492,14 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 15 "__id__": 21
}, },
{ {
"__id__": 17 "__id__": 23
} }
], ],
"_prefab": { "_prefab": {
"__id__": 19 "__id__": 25
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@ -397,11 +536,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 14 "__id__": 20
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 16 "__id__": 22
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@ -425,11 +564,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 14 "__id__": 20
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 18 "__id__": 24
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
@ -485,7 +624,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 21 "__id__": 27
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@ -513,12 +652,15 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 23 "__id__": 29
}, },
"spine": { "spine": {
"__id__": 17 "__id__": 23
}, },
"select": { "select": {
"__id__": 8
},
"noselect": {
"__id__": 2 "__id__": 2
}, },
"_id": "" "_id": ""

View File

@ -1,7 +1,7 @@
[ [
{ {
"__type__": "cc.Prefab", "__type__": "cc.Prefab",
"_name": "IntoBattleView", "_name": "阵法选择页面",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"_native": "", "_native": "",
@ -13,7 +13,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "IntoBattleView", "_name": "阵法选择页面",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"_parent": null, "_parent": null,

View File

@ -8,6 +8,6 @@
], ],
"subMetas": {}, "subMetas": {},
"userData": { "userData": {
"syncNodeName": "IntoBattleView" "syncNodeName": "阵法选择页面"
} }
} }

View File

@ -44,6 +44,11 @@ export default abstract class GRoleBase<T> extends GObject<T>{
get isDie(){ return this._isDie} get isDie(){ return this._isDie}
set isDie(value:boolean){ set isDie(value:boolean){
this._isDie = value; this._isDie = value;
if(this.isDie){
//如果死亡则关闭状态机
//关闭状态机
this.fsm.close();
}
} }
//受击回调 //受击回调

View File

@ -39,6 +39,8 @@ export default class GRoleDefault extends GRoleBase<{}>{
//设置死亡状态 //设置死亡状态
this.fsmAnim.isDie = value; this.fsmAnim.isDie = value;
if(this.isDie){ if(this.isDie){
//关闭状态机
this.fsm.close();
//死亡回调 //死亡回调
this.killBack.forEach(fun => fun(this)); this.killBack.forEach(fun => fun(this));
} }

View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "eacc8f2a-91b5-4bb6-b11b-6f1c688fdcf0",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,11 @@
import { JNGSyncProtoBase } from "../../../../components/JNComponent";
import GRoleBase from "../GRoleBase";
/**
*
*/
export default class GRoleExpandBase<T> extends JNGSyncProtoBase<T>{
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "bba56115-aac1-4e5e-bc8e-087bf92232a3",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "90bf5822-cd37-491b-a89b-182bbcec4c49",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,18 @@
import { _decorator } from "cc";
import GRoleDefault from "../../GRoleDefault";
import GRoleExpandBase from "../GRoleExpandBase";
const { ccclass, property } = _decorator;
/**
*
*/
@ccclass('GRoleDefault')
export default class GRoleOnHookExpand extends GRoleExpandBase<{}>{
//角色Id
petId:number;
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "edf60f56-5d3e-48d1-90b4-6deef4b5635c",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -16,6 +16,10 @@ import { v3 } from "cc";
import { v2 } from "cc"; import { v2 } from "cc";
import GFSMOnHookMode from "./OnHook/GFSMOnHookMode"; import GFSMOnHookMode from "./OnHook/GFSMOnHookMode";
import { TB } from "../../../resources/config/data/schema"; import { TB } from "../../../resources/config/data/schema";
import PlayerTacticalData, { PlayerTacticalEvent } from "../../data/PlayerTacticalData";
import GRoleOnHookExpand from "../base/role/expand/OnHook/GRoleOnHookExpand";
import PlayerPetData from "../../data/PlayerPetData";
import { GUI } from "../../ui/UIConfig";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
//挂机模式状态 //挂机模式状态
@ -99,6 +103,16 @@ export default class GOnHookMode extends GBaseMode<{}>{
//是否允许攻击 //是否允许攻击
isAllowAttack:boolean = false; isAllowAttack:boolean = false;
//添加监听事件
addEvent(){
app.event.on(PlayerTacticalEvent.UPDATE_TACTICAL,this.onUpdatePlayerPet,this);
}
//移除监听事件
onDestroy(){
super.onDestroy();
app.event.off(PlayerTacticalEvent.UPDATE_TACTICAL,this.onUpdatePlayerPet,this);
}
onSyncInitSuccess():void{ onSyncInitSuccess():void{
//初始化战斗 //初始化战斗
@ -124,14 +138,45 @@ export default class GOnHookMode extends GBaseMode<{}>{
this.playerInfo = { tactical: GTactical.getTactical().setOffset(this.playerPos), roles: GRoleUtil.getGRoles([10004,10004,10004,10004,10003,10003]) }; this.playerInfo = { tactical: GTactical.getTactical().setOffset(this.playerPos), roles: GRoleUtil.getGRoles([10004,10004,10004,10004,10003,10003]) };
this.enemyInfo = { tactical: GTactical.getTactical(true).setOffset(this.enemyPos), roles: GRoleUtil.getGRoles([10002]) }; this.enemyInfo = { tactical: GTactical.getTactical(true).setOffset(this.enemyPos), roles: GRoleUtil.getGRoles([10002]) };
this.onUpdatePlayerPet();
//添加监听
this.addEvent();
//生成玩家 //生成玩家
this.playerInfo.roles.forEach((info,index) => this.onGenRole(GOnHookModePlayerEnum.PLAYER,index + 1,info)) // this.playerInfo.roles.forEach((info,index) => this.onGenRole(GOnHookModePlayerEnum.PLAYER,index + 1,info))
// //生成敌人 // //生成敌人
// this.onResetGenerateEnemy(); // this.onResetGenerateEnemy();
} }
//更新玩家宠物
onUpdatePlayerPet(){
//获取玩家阵容
let infos = PlayerTacticalData.getIns().getTacticalInfo();
//移除不再阵容中的宠物
let roles = [...this.getOnesRoleAlive(GOnHookModePlayerEnum.PLAYER)]
roles.forEach(role => {
let expand = role.getComponent(GRoleOnHookExpand);
//如果宠物不再阵容中 则 移除宠物
if(infos.indexOf(expand.petId) < 0){
//移除宠物
this.playerRoles.splice(this.playerRoles.indexOf(role),1);
role.isDie = true;
}
})
infos.forEach((petId,index) => {
if(petId){
this.onGenPlayerPet(index+1,petId);
}
})
}
//更新帧
onSyncUpdate(dt: number,frame:JNFrameInfo, input?: {}){ onSyncUpdate(dt: number,frame:JNFrameInfo, input?: {}){
super.onSyncUpdate(dt,frame,input); super.onSyncUpdate(dt,frame,input);
this.onUpdateMap(dt); this.onUpdateMap(dt);
@ -170,13 +215,42 @@ export default class GOnHookMode extends GBaseMode<{}>{
} }
//生成玩家宠物
onGenPlayerPet(index:number,petId:number){
//如果场上有这个宠物则更新阵法位置
let passRole:GRoleDefault;
this.playerRoles.forEach(role => {
if(role.getComponent(GRoleOnHookExpand).petId == petId)
passRole = role;
})
if(passRole){
//更新宠物阵法位置
passRole.tacticalIndex = index;
return;
}
//获取要生成的宠物
let info = PlayerPetData.getIns().petIdQueryPetInfo(petId);
if(!info){
app.layer.Open(GUI.Tips,{text:"未拥有当前上阵的宠物"});
return;
}
let role = this.onGenRole(GOnHookModePlayerEnum.PLAYER,index,TD.TbGRole.get(info.petTbId));
//向宠物添加 OnHook 扩展
let expand = role.node.addComponent(GRoleOnHookExpand);
expand.petId = petId;
}
//生成宠物 //生成宠物
onGenRole(type: GOnHookModePlayerEnum,index:number,info:TB.TbGRole) { onGenRole(type: GOnHookModePlayerEnum,index:number,info:TB.TbGRole):GRoleDefault {
let tactical = this.getInfo(type).tactical; let tactical = this.getInfo(type).tactical;
let pos:Vec2 = this.getInfo(type).tactical.getPosition(index); let pos:Vec2 = this.getInfo(type).tactical.getPosition(index);
if(!pos) return; if(!pos) return;
let role = instantiate(this.rolePrefab); let role = instantiate(this.rolePrefab);
let entity = role.getComponent(GRoleDefault); let entity = role.getComponent(GRoleDefault);
//初始化 //初始化
entity.onInit(type,info,tactical,index); entity.onInit(type,info,tactical,index);
@ -190,8 +264,11 @@ export default class GOnHookMode extends GBaseMode<{}>{
entity.addKillBackEvent(this.onRoleKillBack.bind(this)) entity.addKillBackEvent(this.onRoleKillBack.bind(this))
this.addGObject(entity,tactical.getPosition(index)); this.addGObject(entity,tactical.getPosition(index));
this.getOnesRole(type).push(entity); this.getOnesRole(type).push(entity);
return entity;
} }
//获取配置 //获取配置
@ -251,6 +328,10 @@ export default class GOnHookMode extends GBaseMode<{}>{
if(role.isValid) if(role.isValid)
role.node.destroy() role.node.destroy()
},3000) },3000)
//清理
this.onClearCache();
// //如果没有敌人则生成敌人 // //如果没有敌人则生成敌人
// if(this.getOnesRole(GOnHookModePlayerEnum.ENEMY).filter(role => !!role.get()).length <= 0){ // if(this.getOnesRole(GOnHookModePlayerEnum.ENEMY).filter(role => !!role.get()).length <= 0){
// //生成敌人 // //生成敌人
@ -258,6 +339,25 @@ export default class GOnHookMode extends GBaseMode<{}>{
// } // }
} }
//清理缓存
onClearCache(){
//清理宠物
let roles = [...this.playerRoles];
roles.forEach(role => {
if(!role.get()){
this.playerRoles.splice(this.playerRoles.indexOf(role),1);
}
})
roles = [...this.enemyRoles];
roles.forEach(role => {
if(!role.get()){
this.enemyRoles.splice(this.enemyRoles.indexOf(role),1);
}
})
}
//是否有怪物 //是否有怪物
isHaveEnemy(){ isHaveEnemy(){
if(!this.isAllowAttack) return []; if(!this.isAllowAttack) return [];

View File

@ -27,7 +27,7 @@ export default class PlayerTacticalData extends BaseData{
onSaveTacticalInfo(ov:PlayerTacticalOV){ onSaveTacticalInfo(ov:PlayerTacticalOV){
if(!ov.tacticalData){ if(!ov.tacticalData){
ov.tacticalData = JSON.stringify(this.getTacticalInfo()); ov.tacticalData = JSON.stringify(this.getInitTacticalInfo());
} }
this.info = { this.info = {
...ov, ...ov,
@ -63,8 +63,11 @@ export default class PlayerTacticalData extends BaseData{
} }
//获取初始化上阵信息 //获取初始化上阵信息
getTacticalInfo():number[]{ getInitTacticalInfo():number[]{
return [0,0,0,0,0,0,0,0,0] return [0,0,0,0,0,0,0,0,0]
} }
getTacticalInfo():number[]{
return this.info.roles;
}
} }

View File

@ -5,6 +5,10 @@ import { GUI } from '../../UIConfig';
import { sp } from 'cc'; import { sp } from 'cc';
import { UIPetAnim } from '../../../consts/GData'; import { UIPetAnim } from '../../../consts/GData';
import PlayerPetData from '../../../data/PlayerPetData'; 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; const { ccclass, property } = _decorator;
@ccclass('PlayerTacticalItem') @ccclass('PlayerTacticalItem')
@ -21,12 +25,20 @@ export class PlayerTacticalItem extends Component {
@property(Node) @property(Node)
havePet:Node; havePet:Node;
//拖拽
@property(JNodeDrag)
drag:JNodeDrag;
//当前上阵的宠物 //当前上阵的宠物
petId:number; petId:number;
//初始位置
initPos:Vec3;
//初始化阵法 //初始化阵法
onInit(index:number){ onInit(index:number){
this.index = index; this.index = index;
this.initPos = this.node.position;
} }
protected start(): void { protected start(): void {
@ -64,6 +76,10 @@ export class PlayerTacticalItem extends Component {
//打开选择阵法宠物 //打开选择阵法宠物
onClick(){ onClick(){
//如果拖拽了则不生效点击事件
if(this.drag.isMove) return;
//如果没有宠物则弹出选择宠物 负责 删除宠物 //如果没有宠物则弹出选择宠物 负责 删除宠物
if(this.petId){ 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);
});
}
} }

View File

@ -2,6 +2,9 @@ import { _decorator, Component, Node } from 'cc';
import { PlayerTacticalItem } from './PlayerTacticalItem'; import { PlayerTacticalItem } from './PlayerTacticalItem';
import { app } from '../../../App'; import { app } from '../../../App';
import { PlayerTacticalEvent } from '../../../data/PlayerTacticalData'; import { PlayerTacticalEvent } from '../../../data/PlayerTacticalData';
import JNodeDrag from '../../../../../extensions/ngame/assets/ngame/util/components/JNodeDrag';
import { EventTouch } from 'cc';
import { UITransform } from 'cc';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
/** /**
@ -20,6 +23,7 @@ export class PlayerTacticalView extends Component {
this.items = this.node.getComponentsInChildren(PlayerTacticalItem); this.items = this.node.getComponentsInChildren(PlayerTacticalItem);
this.items.forEach((item,index) => { this.items.forEach((item,index) => {
item.onInit(index); //初始化阵法下标 item.onInit(index); //初始化阵法下标
item.addMoveEvent(this.onMoveItem.bind(this));
}); });
this.onUpdateView(); this.onUpdateView();
@ -28,6 +32,27 @@ export class PlayerTacticalView extends Component {
} }
//移动子节点
onMoveItem(root:PlayerTacticalItem,e:EventTouch){
//获取接触的节点(除了自己)
this.items.forEach(item => {
//排除自己
if(item == root) return;
//排除在移动的节点
if(!(item.node.position.equals(item.drag.original))) return;
//检测接触
if(item.getComponent(UITransform).isHit(e.getUILocation())){
//如果手指接触了 则 将接触的阵法移动到自己
item.onExchange(root);
}
})
}
protected onDestroy(): void { protected onDestroy(): void {
this.offEvent(); this.offEvent();
} }

View File

@ -1,13 +1,13 @@
import { _decorator, Component, Node } from 'cc'; import { _decorator, Component, Node } from 'cc';
import JNScrollViewItem from '../../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollViewItem'; import JNScrollViewItem from '../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollViewItem';
import { PlayerPetOV } from '../../../consts/API'; import { PlayerPetOV } from '../../consts/API';
import { sp } from 'cc'; import { sp } from 'cc';
import { app } from '../../../App'; import { app } from '../../App';
import { UIPetAnim } from '../../../consts/GData'; import { UIPetAnim } from '../../consts/GData';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ccclass('PetIconItem') @ccclass('IntoBattlePetIcon')
export class PetIconItem extends JNScrollViewItem<PlayerPetOV> { export class IntoBattlePetIcon extends JNScrollViewItem<PlayerPetOV> {
@property(sp.Skeleton) @property(sp.Skeleton)
spine:sp.Skeleton; spine:sp.Skeleton;
@ -16,11 +16,20 @@ export class PetIconItem extends JNScrollViewItem<PlayerPetOV> {
@property(Node) @property(Node)
select:Node; select:Node;
//不可选中节点
@property(Node)
noselect:Node;
//是否被选中 //是否被选中
isSelect:boolean = false; isSelect:boolean = false;
//是否不可选中
isNoSelect:boolean = false;
onLoad(){ onLoad(){
this.onUpdateSelect(); this.onUpdateSelect();
this.noselect.active = false;
this.select.active = false;
} }
start(): void { start(): void {
@ -34,6 +43,7 @@ export class PetIconItem extends JNScrollViewItem<PlayerPetOV> {
onUpdateSelect(){ onUpdateSelect(){
this.select.active = this.isSelect; this.select.active = this.isSelect;
this.noselect.active = this.isNoSelect;
} }

View File

@ -3,7 +3,6 @@ import JNLayerBase from '../../../../extensions/ngame/assets/ngame/ui/base/JNLay
import { Prefab } from 'cc'; import { Prefab } from 'cc';
import PlayerPetData from '../../data/PlayerPetData'; import PlayerPetData from '../../data/PlayerPetData';
import JNScrollView from '../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollView'; import JNScrollView from '../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollView';
import { PetIconItem } from '../Consts/Pet/PetIconItem';
import { NodeEventType } from 'cc'; import { NodeEventType } from 'cc';
import { sp } from 'cc'; import { sp } from 'cc';
import { app } from '../../App'; import { app } from '../../App';
@ -11,6 +10,7 @@ import { PlayerPetOV } from '../../consts/API';
import { UIPetAnim } from '../../consts/GData'; import { UIPetAnim } from '../../consts/GData';
import { GUI } from '../UIConfig'; import { GUI } from '../UIConfig';
import PlayerTacticalData from '../../data/PlayerTacticalData'; import PlayerTacticalData from '../../data/PlayerTacticalData';
import { IntoBattlePetIcon } from './IntoBattlePetIcon';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
//上阵页面 //上阵页面
@ -55,35 +55,49 @@ export class IntoBattleView extends JNLayerBase {
this.pets = PlayerPetData.getIns().getData(); this.pets = PlayerPetData.getIns().getData();
this.views.refreshData(this.pets); this.views.refreshData(this.pets);
//设置不可选中
this.views.getItems<IntoBattlePetIcon>().forEach(item => {
if(PlayerTacticalData.getIns().getTacticalInfo().indexOf(item.data.petId) != -1)
item.isNoSelect = true; //如果在阵法里则不可选中
})
//向子节点添加点击事件 //向子节点添加点击事件
this.views.addItemEvent(NodeEventType.TOUCH_START,this.onClickItem.bind(this)); this.views.addItemEvent(NodeEventType.TOUCH_START,this.onClickItem.bind(this));
this.onUpdateSelect();
} }
//刷新选中 //刷新选中
onUpdateSelect(){ onUpdateSelect(){
//默认都不选中 //默认都不选中
this.views.getItems<PetIconItem>().forEach(item => { this.views.getItems<IntoBattlePetIcon>().forEach(item => {
item.isSelect = false; item.isSelect = false;
item.onUpdateSelect(); item.onUpdateSelect();
}) })
//设置选中 //设置选中
if(this.index != -1){ if(this.index != -1){
let current = this.views.getItems<PetIconItem>()[this.index] let current = this.views.getItems<IntoBattlePetIcon>()[this.index]
current.isSelect = true; current.isSelect = true;
current.onUpdateSelect(); current.onUpdateSelect();
}
//显示选中宠物 //显示选中宠物
this.spine.skeletonData = app.battleRes.roleSpine[this.pets[this.index].petTbId]; this.spine.skeletonData = app.battleRes.roleSpine[this.pets[this.index].petTbId];
this.spine.setAnimation(0,UIPetAnim.std,true); this.spine.setAnimation(0,UIPetAnim.std,true);
}
} }
//点击Item //点击Item
onClickItem(index:number){ onClickItem(index:number){
//判断是否不可选中
if(this.views.getItems<IntoBattlePetIcon>()[index].isNoSelect) {
app.layer.Open(GUI.Tips,{text:"当前宠物已上阵"})
return;
}
//设置当前选中 //设置当前选中
this.index = index; this.index = index;
@ -101,7 +115,7 @@ export class IntoBattleView extends JNLayerBase {
} }
//修改上阵信息 //修改上阵信息
await PlayerTacticalData.getIns().UpdateIndexTactical(this.index,this.pets[this.index].petId); await PlayerTacticalData.getIns().UpdateIndexTactical(this.tIndex,this.pets[this.index].petId);
//上阵完 关闭页面 //上阵完 关闭页面
app.layer.CloseNode(this.node); app.layer.CloseNode(this.node);

View File

@ -1,5 +1,5 @@
import { v3 } from "cc"; import { v3 } from "cc";
import { JNLayerAnim, JNLayerInfo } from "../../../extensions/ngame/assets/ngame/ui/JNLayer"; import { JNLayerAnim, JNLayerAnimInfo, JNLayerInfo } from "../../../extensions/ngame/assets/ngame/ui/JNLayer";
export enum GLayer{ export enum GLayer{
View = "View", View = "View",
@ -28,31 +28,29 @@ export enum GUI{
} }
//常用动画
const BackOutScale:JNLayerAnimInfo = {
front:JNLayerAnim.BackOutOpen,
back:JNLayerAnim.BackInClose
}
//系统UI //系统UI
const UISystemConfig:{ [key: string]: JNLayerInfo; } = { const UISystemConfig:{ [key: string]: JNLayerInfo; } = {
[GUI.Tips]:{ [GUI.Tips]:{
layer:GLayer.Tips, layer:GLayer.Tips,
uri: "prefab/ui/系统页面/提示/TipsView", uri: "prefab/ui/系统页面/提示/TipsView",
anims:{ anims:BackOutScale
front:JNLayerAnim.BackOutOpen,
back:JNLayerAnim.BackInClose
}
}, },
[GUI.SelectionBox]:{ [GUI.SelectionBox]:{
layer:GLayer.Tips, layer:GLayer.Tips,
uri: "prefab/ui/系统页面/选择提示/SelectionBox", uri: "prefab/ui/系统页面/选择提示/SelectionBox",
anims:{ anims:BackOutScale,
front:JNLayerAnim.BackOutOpen,
back:JNLayerAnim.BackInClose
},
}, },
[GUI.Login]:{ [GUI.Login]:{
layer:GLayer.Popup, layer:GLayer.Popup,
uri: "prefab/ui/系统页面/LoginView", uri: "prefab/ui/系统页面/LoginView",
anims:{ anims:BackOutScale
front:JNLayerAnim.BackOutOpen,
back:JNLayerAnim.BackInClose
}
}, },
[GUI.Loading]:{ [GUI.Loading]:{
layer:GLayer.View, layer:GLayer.View,
@ -67,7 +65,7 @@ const UISystemConfig:{ [key: string]: JNLayerInfo; } = {
//主页UI //主页UI
const UIMainConfig:{ [key: string]: JNLayerInfo; } = { const UIMainConfig:{ [key: string]: JNLayerInfo; } = {
[GUI.MainChat]:{ [GUI.MainChat]:{
layer:GLayer.View, layer:GLayer.Popup,
uri: "prefab/ui/主页/聊天/MainChatView", uri: "prefab/ui/主页/聊天/MainChatView",
anims:{ anims:{
front:JNLayerAnim.Enlarge, front:JNLayerAnim.Enlarge,
@ -76,6 +74,11 @@ const UIMainConfig:{ [key: string]: JNLayerInfo; } = {
backInfo:{key:"position",start:v3(0,0,0),end:v3(0,-1280,0)} backInfo:{key:"position",start:v3(0,0,0),end:v3(0,-1280,0)}
} }
}, },
[GUI.IntoBattleView]:{
layer:GLayer.Popup,
uri: "prefab/ui/阵法/阵法选择页面",
anims:BackOutScale,
},
} }
//新手引导页面 //新手引导页面
@ -84,18 +87,12 @@ const UINoviceConfig:{ [key: string]: JNLayerInfo; } = {
[GUI.NoviceNamingView]:{ [GUI.NoviceNamingView]:{
layer:GLayer.Popup, layer:GLayer.Popup,
uri: "prefab/ui/新手引导页面/NoviceNamingView", uri: "prefab/ui/新手引导页面/NoviceNamingView",
anims:{ anims:BackOutScale
front:JNLayerAnim.BackOutOpen,
back:JNLayerAnim.BackInClose
}
}, },
[GUI.NoviceSelectPetView]:{ [GUI.NoviceSelectPetView]:{
layer:GLayer.Popup, layer:GLayer.Popup,
uri: "prefab/ui/新手引导页面/NoviceSelectPetView", uri: "prefab/ui/新手引导页面/NoviceSelectPetView",
anims:{ anims:BackOutScale
front:JNLayerAnim.BackOutOpen,
back:JNLayerAnim.BackInClose
}
}, },
} }
@ -121,14 +118,6 @@ export const UIConfig:{ [key: string]: JNLayerInfo; } = {
backInfo:{key:"position",start:v3(0,0,0),end:v3(-720,0,0)} backInfo:{key:"position",start:v3(0,0,0),end:v3(-720,0,0)}
}, },
}, },
[GUI.IntoBattleView]:{
layer:GLayer.View,
uri: "prefab/ui/阵法/IntoBattleView",
anims:{
front:JNLayerAnim.BackOutOpen,
back:JNLayerAnim.BackInClose
},
},
...UISystemConfig, //系统页面 ...UISystemConfig, //系统页面
...UINoviceConfig, //新手引导页面 ...UINoviceConfig, //新手引导页面
...UIMainConfig, //主页面 ...UIMainConfig, //主页面

@ -1 +1 @@
Subproject commit bb05b446537ccc00b5745f3af2ee2fdcca81dc09 Subproject commit 01a31870c404967092e5c87fc91650bae868bbad