mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
提交拖拽阵法
This commit is contained in:
parent
1683ec01a0
commit
c4437fef5e
@ -958,7 +958,7 @@
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 64.845,
|
||||
"y": 74.983,
|
||||
"z": 0
|
||||
},
|
||||
"_lrot": {
|
||||
@ -1111,7 +1111,7 @@
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 550,
|
||||
"height": 400
|
||||
"height": 420
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
|
@ -169,8 +169,8 @@
|
||||
],
|
||||
"value": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 110,
|
||||
"y": 110,
|
||||
"x": 130,
|
||||
"y": 130,
|
||||
"z": 0
|
||||
}
|
||||
},
|
||||
@ -281,7 +281,7 @@
|
||||
],
|
||||
"value": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 110,
|
||||
"x": 130,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
}
|
||||
@ -393,8 +393,8 @@
|
||||
],
|
||||
"value": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 110,
|
||||
"y": -110,
|
||||
"x": 130,
|
||||
"y": -130,
|
||||
"z": 0
|
||||
}
|
||||
},
|
||||
@ -506,7 +506,7 @@
|
||||
"value": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 110,
|
||||
"y": 130,
|
||||
"z": 0
|
||||
}
|
||||
},
|
||||
@ -730,7 +730,7 @@
|
||||
"value": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": -110,
|
||||
"y": -130,
|
||||
"z": 0
|
||||
}
|
||||
},
|
||||
@ -841,8 +841,8 @@
|
||||
],
|
||||
"value": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": -110,
|
||||
"y": 110,
|
||||
"x": -130,
|
||||
"y": 130,
|
||||
"z": 0
|
||||
}
|
||||
},
|
||||
@ -953,7 +953,7 @@
|
||||
],
|
||||
"value": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": -110,
|
||||
"x": -130,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
}
|
||||
@ -1065,8 +1065,8 @@
|
||||
],
|
||||
"value": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": -110,
|
||||
"y": -110,
|
||||
"x": -130,
|
||||
"y": -130,
|
||||
"z": 0
|
||||
}
|
||||
},
|
||||
@ -1115,8 +1115,8 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 360,
|
||||
"height": 360
|
||||
"width": 400,
|
||||
"height": 400
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
@ -1198,8 +1198,8 @@
|
||||
"_paddingRight": 20,
|
||||
"_paddingTop": 20,
|
||||
"_paddingBottom": 20,
|
||||
"_spacingX": 10,
|
||||
"_spacingY": 10,
|
||||
"_spacingX": 30,
|
||||
"_spacingY": 30,
|
||||
"_verticalDirection": 1,
|
||||
"_horizontalDirection": 1,
|
||||
"_constraint": 1,
|
||||
|
@ -36,12 +36,15 @@
|
||||
{
|
||||
"__id__": 28
|
||||
},
|
||||
{
|
||||
"__id__": 32
|
||||
},
|
||||
{
|
||||
"__id__": 30
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 33
|
||||
"__id__": 35
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@ -646,12 +649,33 @@
|
||||
"havePet": {
|
||||
"__id__": 14
|
||||
},
|
||||
"drag": {
|
||||
"__id__": 30
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"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",
|
||||
"_name": "",
|
||||
@ -662,11 +686,11 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 31
|
||||
"__id__": 33
|
||||
},
|
||||
"clickEvents": [
|
||||
{
|
||||
"__id__": 32
|
||||
"__id__": 34
|
||||
}
|
||||
],
|
||||
"_interactable": true,
|
||||
|
@ -26,19 +26,22 @@
|
||||
},
|
||||
{
|
||||
"__id__": 14
|
||||
},
|
||||
{
|
||||
"__id__": 20
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 20
|
||||
"__id__": 26
|
||||
},
|
||||
{
|
||||
"__id__": 22
|
||||
"__id__": 28
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 24
|
||||
"__id__": 30
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@ -71,7 +74,7 @@
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "选中",
|
||||
"_name": "不可选中",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": {
|
||||
@ -145,7 +148,7 @@
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "b4vJnGQvdKv4MXp8xLg6zf"
|
||||
"fileId": "89jo3ZLIBHkoSIJ8ht6gAw"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
@ -164,9 +167,9 @@
|
||||
"_dstBlendFactor": 4,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 0,
|
||||
"g": 0,
|
||||
"b": 0,
|
||||
"r": 255,
|
||||
"g": 82,
|
||||
"b": 82,
|
||||
"a": 255
|
||||
},
|
||||
"_spriteFrame": {
|
||||
@ -190,7 +193,7 @@
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "01wxgAoWhO+qLRM5Jr3rH1"
|
||||
"fileId": "f95xraDe1BKrLfx/ZQuwwz"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
@ -200,14 +203,14 @@
|
||||
"asset": {
|
||||
"__id__": 0
|
||||
},
|
||||
"fileId": "fcC3JxewdM1K8tKbhV80+3",
|
||||
"fileId": "aeZLGO3ZRLEovu6SQVdYcK",
|
||||
"instance": null,
|
||||
"targetOverrides": null,
|
||||
"nestedPrefabInstanceRoots": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "背景",
|
||||
"_name": "选中",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": {
|
||||
@ -267,6 +270,142 @@
|
||||
"__prefab": {
|
||||
"__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": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 100,
|
||||
@ -289,11 +428,11 @@
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 8
|
||||
"__id__": 14
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 12
|
||||
"__id__": 18
|
||||
},
|
||||
"_customMaterial": null,
|
||||
"_srcBlendFactor": 2,
|
||||
@ -353,14 +492,14 @@
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 15
|
||||
"__id__": 21
|
||||
},
|
||||
{
|
||||
"__id__": 17
|
||||
"__id__": 23
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 19
|
||||
"__id__": 25
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@ -397,11 +536,11 @@
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 14
|
||||
"__id__": 20
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 16
|
||||
"__id__": 22
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
@ -425,11 +564,11 @@
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 14
|
||||
"__id__": 20
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 18
|
||||
"__id__": 24
|
||||
},
|
||||
"_customMaterial": null,
|
||||
"_srcBlendFactor": 2,
|
||||
@ -485,7 +624,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 21
|
||||
"__id__": 27
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
@ -513,12 +652,15 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 23
|
||||
"__id__": 29
|
||||
},
|
||||
"spine": {
|
||||
"__id__": 17
|
||||
"__id__": 23
|
||||
},
|
||||
"select": {
|
||||
"__id__": 8
|
||||
},
|
||||
"noselect": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_id": ""
|
@ -1,7 +1,7 @@
|
||||
[
|
||||
{
|
||||
"__type__": "cc.Prefab",
|
||||
"_name": "IntoBattleView",
|
||||
"_name": "阵法选择页面",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_native": "",
|
||||
@ -13,7 +13,7 @@
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "IntoBattleView",
|
||||
"_name": "阵法选择页面",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": null,
|
@ -8,6 +8,6 @@
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"syncNodeName": "IntoBattleView"
|
||||
"syncNodeName": "阵法选择页面"
|
||||
}
|
||||
}
|
@ -44,6 +44,11 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
get isDie(){ return this._isDie}
|
||||
set isDie(value:boolean){
|
||||
this._isDie = value;
|
||||
if(this.isDie){
|
||||
//如果死亡则关闭状态机
|
||||
//关闭状态机
|
||||
this.fsm.close();
|
||||
}
|
||||
}
|
||||
|
||||
//受击回调
|
||||
|
@ -39,6 +39,8 @@ export default class GRoleDefault extends GRoleBase<{}>{
|
||||
//设置死亡状态
|
||||
this.fsmAnim.isDie = value;
|
||||
if(this.isDie){
|
||||
//关闭状态机
|
||||
this.fsm.close();
|
||||
//死亡回调
|
||||
this.killBack.forEach(fun => fun(this));
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "eacc8f2a-91b5-4bb6-b11b-6f1c688fdcf0",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
import { JNGSyncProtoBase } from "../../../../components/JNComponent";
|
||||
import GRoleBase from "../GRoleBase";
|
||||
|
||||
|
||||
/**
|
||||
* 扩展类基类 用于代码动态添加 角色脚本的类
|
||||
*/
|
||||
export default class GRoleExpandBase<T> extends JNGSyncProtoBase<T>{
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "bba56115-aac1-4e5e-bc8e-087bf92232a3",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "90bf5822-cd37-491b-a89b-182bbcec4c49",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "edf60f56-5d3e-48d1-90b4-6deef4b5635c",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@ -16,6 +16,10 @@ import { v3 } from "cc";
|
||||
import { v2 } from "cc";
|
||||
import GFSMOnHookMode from "./OnHook/GFSMOnHookMode";
|
||||
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;
|
||||
|
||||
//挂机模式状态
|
||||
@ -99,6 +103,16 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
||||
//是否允许攻击
|
||||
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{
|
||||
|
||||
//初始化战斗
|
||||
@ -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.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();
|
||||
|
||||
}
|
||||
|
||||
//更新玩家宠物
|
||||
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?: {}){
|
||||
super.onSyncUpdate(dt,frame,input);
|
||||
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 pos:Vec2 = this.getInfo(type).tactical.getPosition(index);
|
||||
if(!pos) return;
|
||||
let role = instantiate(this.rolePrefab);
|
||||
|
||||
let entity = role.getComponent(GRoleDefault);
|
||||
//初始化
|
||||
entity.onInit(type,info,tactical,index);
|
||||
@ -190,8 +264,11 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
||||
entity.addKillBackEvent(this.onRoleKillBack.bind(this))
|
||||
|
||||
this.addGObject(entity,tactical.getPosition(index));
|
||||
|
||||
this.getOnesRole(type).push(entity);
|
||||
|
||||
return entity;
|
||||
|
||||
}
|
||||
|
||||
//获取配置
|
||||
@ -251,6 +328,10 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
||||
if(role.isValid)
|
||||
role.node.destroy()
|
||||
},3000)
|
||||
|
||||
//清理
|
||||
this.onClearCache();
|
||||
|
||||
// //如果没有敌人则生成敌人
|
||||
// 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(){
|
||||
if(!this.isAllowAttack) return [];
|
||||
|
@ -27,7 +27,7 @@ export default class PlayerTacticalData extends BaseData{
|
||||
onSaveTacticalInfo(ov:PlayerTacticalOV){
|
||||
|
||||
if(!ov.tacticalData){
|
||||
ov.tacticalData = JSON.stringify(this.getTacticalInfo());
|
||||
ov.tacticalData = JSON.stringify(this.getInitTacticalInfo());
|
||||
}
|
||||
this.info = {
|
||||
...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]
|
||||
}
|
||||
getTacticalInfo():number[]{
|
||||
return this.info.roles;
|
||||
}
|
||||
|
||||
}
|
@ -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){
|
||||
//移除宠物
|
||||
@ -84,6 +100,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);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,6 +2,9 @@ import { _decorator, Component, Node } from 'cc';
|
||||
import { PlayerTacticalItem } from './PlayerTacticalItem';
|
||||
import { app } from '../../../App';
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -20,6 +23,7 @@ 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));
|
||||
});
|
||||
|
||||
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 {
|
||||
this.offEvent();
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import JNScrollViewItem from '../../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollViewItem';
|
||||
import { PlayerPetOV } from '../../../consts/API';
|
||||
import JNScrollViewItem from '../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollViewItem';
|
||||
import { PlayerPetOV } from '../../consts/API';
|
||||
import { sp } from 'cc';
|
||||
import { app } from '../../../App';
|
||||
import { UIPetAnim } from '../../../consts/GData';
|
||||
import { app } from '../../App';
|
||||
import { UIPetAnim } from '../../consts/GData';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('PetIconItem')
|
||||
export class PetIconItem extends JNScrollViewItem<PlayerPetOV> {
|
||||
@ccclass('IntoBattlePetIcon')
|
||||
export class IntoBattlePetIcon extends JNScrollViewItem<PlayerPetOV> {
|
||||
|
||||
@property(sp.Skeleton)
|
||||
spine:sp.Skeleton;
|
||||
@ -16,11 +16,20 @@ export class PetIconItem extends JNScrollViewItem<PlayerPetOV> {
|
||||
@property(Node)
|
||||
select:Node;
|
||||
|
||||
//不可选中节点
|
||||
@property(Node)
|
||||
noselect:Node;
|
||||
|
||||
//是否被选中
|
||||
isSelect:boolean = false;
|
||||
|
||||
//是否不可选中
|
||||
isNoSelect:boolean = false;
|
||||
|
||||
onLoad(){
|
||||
this.onUpdateSelect();
|
||||
this.noselect.active = false;
|
||||
this.select.active = false;
|
||||
}
|
||||
|
||||
start(): void {
|
||||
@ -34,6 +43,7 @@ export class PetIconItem extends JNScrollViewItem<PlayerPetOV> {
|
||||
onUpdateSelect(){
|
||||
|
||||
this.select.active = this.isSelect;
|
||||
this.noselect.active = this.isNoSelect;
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ import JNLayerBase from '../../../../extensions/ngame/assets/ngame/ui/base/JNLay
|
||||
import { Prefab } from 'cc';
|
||||
import PlayerPetData from '../../data/PlayerPetData';
|
||||
import JNScrollView from '../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollView';
|
||||
import { PetIconItem } from '../Consts/Pet/PetIconItem';
|
||||
import { NodeEventType } from 'cc';
|
||||
import { sp } from 'cc';
|
||||
import { app } from '../../App';
|
||||
@ -11,6 +10,7 @@ import { PlayerPetOV } from '../../consts/API';
|
||||
import { UIPetAnim } from '../../consts/GData';
|
||||
import { GUI } from '../UIConfig';
|
||||
import PlayerTacticalData from '../../data/PlayerTacticalData';
|
||||
import { IntoBattlePetIcon } from './IntoBattlePetIcon';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//上阵页面
|
||||
@ -55,36 +55,50 @@ export class IntoBattleView extends JNLayerBase {
|
||||
this.pets = PlayerPetData.getIns().getData();
|
||||
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.onUpdateSelect();
|
||||
|
||||
}
|
||||
|
||||
//刷新选中
|
||||
onUpdateSelect(){
|
||||
|
||||
//默认都不选中
|
||||
this.views.getItems<PetIconItem>().forEach(item => {
|
||||
this.views.getItems<IntoBattlePetIcon>().forEach(item => {
|
||||
item.isSelect = false;
|
||||
item.onUpdateSelect();
|
||||
})
|
||||
|
||||
//设置选中
|
||||
if(this.index != -1){
|
||||
let current = this.views.getItems<PetIconItem>()[this.index]
|
||||
let current = this.views.getItems<IntoBattlePetIcon>()[this.index]
|
||||
current.isSelect = true;
|
||||
current.onUpdateSelect();
|
||||
}
|
||||
|
||||
//显示选中宠物
|
||||
this.spine.skeletonData = app.battleRes.roleSpine[this.pets[this.index].petTbId];
|
||||
this.spine.setAnimation(0,UIPetAnim.std,true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//点击Item
|
||||
onClickItem(index:number){
|
||||
|
||||
//判断是否不可选中
|
||||
if(this.views.getItems<IntoBattlePetIcon>()[index].isNoSelect) {
|
||||
app.layer.Open(GUI.Tips,{text:"当前宠物已上阵"})
|
||||
return;
|
||||
}
|
||||
|
||||
//设置当前选中
|
||||
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);
|
||||
|
@ -1,5 +1,5 @@
|
||||
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{
|
||||
View = "View",
|
||||
@ -28,31 +28,29 @@ export enum GUI{
|
||||
}
|
||||
|
||||
|
||||
//常用动画
|
||||
const BackOutScale:JNLayerAnimInfo = {
|
||||
front:JNLayerAnim.BackOutOpen,
|
||||
back:JNLayerAnim.BackInClose
|
||||
}
|
||||
|
||||
|
||||
//系统UI
|
||||
const UISystemConfig:{ [key: string]: JNLayerInfo; } = {
|
||||
[GUI.Tips]:{
|
||||
layer:GLayer.Tips,
|
||||
uri: "prefab/ui/系统页面/提示/TipsView",
|
||||
anims:{
|
||||
front:JNLayerAnim.BackOutOpen,
|
||||
back:JNLayerAnim.BackInClose
|
||||
}
|
||||
anims:BackOutScale
|
||||
},
|
||||
[GUI.SelectionBox]:{
|
||||
layer:GLayer.Tips,
|
||||
uri: "prefab/ui/系统页面/选择提示/SelectionBox",
|
||||
anims:{
|
||||
front:JNLayerAnim.BackOutOpen,
|
||||
back:JNLayerAnim.BackInClose
|
||||
},
|
||||
anims:BackOutScale,
|
||||
},
|
||||
[GUI.Login]:{
|
||||
layer:GLayer.Popup,
|
||||
uri: "prefab/ui/系统页面/LoginView",
|
||||
anims:{
|
||||
front:JNLayerAnim.BackOutOpen,
|
||||
back:JNLayerAnim.BackInClose
|
||||
}
|
||||
anims:BackOutScale
|
||||
},
|
||||
[GUI.Loading]:{
|
||||
layer:GLayer.View,
|
||||
@ -67,7 +65,7 @@ const UISystemConfig:{ [key: string]: JNLayerInfo; } = {
|
||||
//主页UI
|
||||
const UIMainConfig:{ [key: string]: JNLayerInfo; } = {
|
||||
[GUI.MainChat]:{
|
||||
layer:GLayer.View,
|
||||
layer:GLayer.Popup,
|
||||
uri: "prefab/ui/主页/聊天/MainChatView",
|
||||
anims:{
|
||||
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)}
|
||||
}
|
||||
},
|
||||
[GUI.IntoBattleView]:{
|
||||
layer:GLayer.Popup,
|
||||
uri: "prefab/ui/阵法/阵法选择页面",
|
||||
anims:BackOutScale,
|
||||
},
|
||||
}
|
||||
|
||||
//新手引导页面
|
||||
@ -84,18 +87,12 @@ const UINoviceConfig:{ [key: string]: JNLayerInfo; } = {
|
||||
[GUI.NoviceNamingView]:{
|
||||
layer:GLayer.Popup,
|
||||
uri: "prefab/ui/新手引导页面/NoviceNamingView",
|
||||
anims:{
|
||||
front:JNLayerAnim.BackOutOpen,
|
||||
back:JNLayerAnim.BackInClose
|
||||
}
|
||||
anims:BackOutScale
|
||||
},
|
||||
[GUI.NoviceSelectPetView]:{
|
||||
layer:GLayer.Popup,
|
||||
uri: "prefab/ui/新手引导页面/NoviceSelectPetView",
|
||||
anims:{
|
||||
front:JNLayerAnim.BackOutOpen,
|
||||
back:JNLayerAnim.BackInClose
|
||||
}
|
||||
anims:BackOutScale
|
||||
},
|
||||
|
||||
}
|
||||
@ -121,14 +118,6 @@ export const UIConfig:{ [key: string]: JNLayerInfo; } = {
|
||||
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, //系统页面
|
||||
...UINoviceConfig, //新手引导页面
|
||||
...UIMainConfig, //主页面
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit bb05b446537ccc00b5745f3af2ee2fdcca81dc09
|
||||
Subproject commit 01a31870c404967092e5c87fc91650bae868bbad
|
Loading…
x
Reference in New Issue
Block a user