diff --git a/JisolGameCocos/assets/resources/WorldCanvas.prefab b/JisolGameCocos/assets/resources/WorldCanvas.prefab index 58866229..aeb8dafb 100644 --- a/JisolGameCocos/assets/resources/WorldCanvas.prefab +++ b/JisolGameCocos/assets/resources/WorldCanvas.prefab @@ -3,6 +3,7 @@ "__type__": "cc.Prefab", "_name": "WorldCanvas", "_objFlags": 0, + "__editorExtras__": {}, "_native": "", "data": { "__id__": 1 @@ -160,6 +161,8 @@ "__uuid__": "a0d1e275-5512-493e-8e15-7d2db8beb48e", "__expectedType__": "cc.RenderTexture" }, + "_postProcess": null, + "_usePostProcess": false, "_cameraType": -1, "_trackingType": 0, "_id": "" @@ -338,7 +341,7 @@ "__id__": 3 }, "prefab": { - "__uuid__": "b882ecdb-012a-4d85-b799-e4da5991c0dd", + "__uuid__": "3520eceb-6d73-4cdc-b333-c80f737fee27", "__expectedType__": "cc.Prefab" }, "_id": "" diff --git a/JisolGameCocos/assets/resources/prefab/battle/mode/GOnHookMode.prefab b/JisolGameCocos/assets/resources/prefab/battle/mode/GOnHookMode.prefab index a39189b4..9131e63e 100644 --- a/JisolGameCocos/assets/resources/prefab/battle/mode/GOnHookMode.prefab +++ b/JisolGameCocos/assets/resources/prefab/battle/mode/GOnHookMode.prefab @@ -22,10 +22,13 @@ "_components": [ { "__id__": 2 + }, + { + "__id__": 4 } ], "_prefab": { - "__id__": 4 + "__id__": 6 }, "_lpos": { "__type__": "cc.Vec3", @@ -84,6 +87,28 @@ "__type__": "cc.CompPrefabInfo", "fileId": "36KI0wow1LqrcICgBTdo4H" }, + { + "__type__": "84547zJhY9O5JtlJy/NgK9H", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 5 + }, + "rolePrefab": { + "__uuid__": "e989c288-5957-41c1-953c-190622651f52", + "__expectedType__": "cc.Prefab" + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "2c2vLtN9BBeaqmvG+HAdVY" + }, { "__type__": "cc.PrefabInfo", "root": { diff --git a/JisolGameCocos/assets/script/battle/base/role/GRoleDefault.ts b/JisolGameCocos/assets/script/battle/base/role/GRoleDefault.ts index 0f7a2e45..e8753745 100644 --- a/JisolGameCocos/assets/script/battle/base/role/GRoleDefault.ts +++ b/JisolGameCocos/assets/script/battle/base/role/GRoleDefault.ts @@ -39,6 +39,10 @@ export default class GRoleDefault extends GRoleBase<{}>{ this._isDie = value; //设置死亡状态 this.fsmAnim.isDie = value; + if(this.isDie){ + //死亡回调 + this.killBack.forEach(fun => fun(this)); + } } //角色类型 @@ -60,6 +64,9 @@ export default class GRoleDefault extends GRoleBase<{}>{ //角色技能 skills:GSkillBase[] = []; + //宠物死亡回调 + killBack:((role:GRoleDefault) => {})[] = []; + onSyncLoad(){ super.onSyncLoad(); @@ -197,5 +204,10 @@ export default class GRoleDefault extends GRoleBase<{}>{ return null; } + //添加一个死亡回调 + addKillBackEvent(callback:(role:GRoleDefault) => {}){ + this.killBack.push(callback); + } + } diff --git a/JisolGameCocos/assets/script/battle/modes/GOnHookMode.ts b/JisolGameCocos/assets/script/battle/modes/GOnHookMode.ts index 64b09414..fd907d5b 100644 --- a/JisolGameCocos/assets/script/battle/modes/GOnHookMode.ts +++ b/JisolGameCocos/assets/script/battle/modes/GOnHookMode.ts @@ -1,7 +1,15 @@ +import { Vec2 } from "cc"; import { TableGRole } from "../../../resources/config/ts/TableGRole"; import GBaseMode from "../GBaseMode"; import { GRoleUtil } from "../entity/GRole"; import { GTactical } from "../entity/GTactical"; +import GRoleDefault from "../base/role/GRoleDefault"; +import { Prefab } from "cc"; +import { _decorator } from "cc"; +import { instantiate } from "cc"; +import { GPVPModePlayerEnum } from "./GPVPMode"; +import { JNFrameInfo } from "../../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame"; +const { ccclass, property } = _decorator; //角色 @@ -11,7 +19,7 @@ export enum GOnHookModePlayerEnum{ } //玩家信息 -export interface GOnHookPlayerInfo{ +export interface GOnHookInfo{ //阵法 tactical: GTactical; //宠物列表 @@ -21,23 +29,122 @@ export interface GOnHookPlayerInfo{ /** * 挂机模式 无限出现小怪 */ +@ccclass('GOnHookMode') export default class GOnHookMode extends GBaseMode<{}>{ + @property(Prefab) + rolePrefab: Prefab = null; + //玩家信息 - playerInfo; + playerInfo:GOnHookInfo; + //宠物信息 + enemyInfo:GOnHookInfo; + + //玩家宠物位置 + playerPos: Vec2 = new Vec2(400,0); + //怪物位置 + enemyPos: Vec2 = new Vec2(-400,0); + //玩家宠物 + playerRoles: GRoleDefault[] = []; + //敌方宠物 + enemyRoles: GRoleDefault[] = []; onSyncInitSuccess():void{ //初始化战斗 console.log("GOnHookMode 模式初始化"); - this.playerInfo = { tactical: GTactical.getTactical(), roles: GRoleUtil.getGRoles([10001,10001,10001,10001,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,10002,10002,10001,10004,10003]) }; //生成玩家 - // 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(); } + onSyncUpdate(dt: number,frame:JNFrameInfo, input?: {}){ + + + + } + + //生成宠物 + onGenRole(type: GOnHookModePlayerEnum,index:number,info:TableGRole) { + + 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); + + //绑定寻敌 + entity.onQueryEunmy = () => { + return this.getEnumy(entity,type); + } + + //绑定死亡回调 + entity.addKillBackEvent(this.onRoleKillBack.bind(this)) + + this.addGObject(entity,tactical.getPosition(index)); + this.getOnesRole(type).push(entity); + + } + + //获取配置 + getInfo(type: GOnHookModePlayerEnum): GOnHookInfo { + if(type == GOnHookModePlayerEnum.PLAYER) return this.playerInfo; + if(type == GOnHookModePlayerEnum.ENEMY) return this.enemyInfo; + } + + //获取阵营宠物 + getOnesRole(type: GOnHookModePlayerEnum):GRoleDefault[]{ + if(type == GOnHookModePlayerEnum.PLAYER) return this.playerRoles; + if(type == GOnHookModePlayerEnum.ENEMY) return this.enemyRoles; + } + + //获取敌人 + getEnumy(player:GRoleDefault,type:GOnHookModePlayerEnum):GRoleDefault{ + + let enumyOnes = GOnHookModePlayerEnum.ENEMY + //如果是ENEMY 则 它的敌人是 PLAYER + if(type == GOnHookModePlayerEnum.ENEMY) enumyOnes = GOnHookModePlayerEnum.PLAYER + + //获取敌人 + let roles = this.getOnesRole(enumyOnes); + + //返回敌人 + //获取我在第几排 + let playerXY = player.tactical.getXY(player.tacticalIndex); + //通过排数获取最近的敌人 + let sort = roles.filter(role => !!role.get()).sort((enumy1,enumy2) => { + let enumy1XY = enumy1.tactical.getXY(enumy1.tacticalIndex); + let enumy2XY = enumy2.tactical.getXY(enumy2.tacticalIndex); + return Math.abs((playerXY.y * 1000) - (enumy1XY.y * 1000)) + Math.abs((playerXY.x - enumy1XY.x)) - + Math.abs((playerXY.y * 1000) - (enumy2XY.y * 1000)) + Math.abs((playerXY.x - enumy2XY.x)) + }); + return sort[0] + + } + + //生成敌人 + onResetGenerateEnemy(){ + this.enemyRoles = []; + this.playerInfo.roles.forEach((info,index) => this.onGenRole(GOnHookModePlayerEnum.ENEMY,index + 1,info)) + } + + //角色死亡回调 + onRoleKillBack(role:GRoleDefault){ + //如果没有敌人则生成敌人 + if(this.getOnesRole(GOnHookModePlayerEnum.ENEMY).filter(role => !!role.get()).length <= 0){ + //生成敌人 + this.onResetGenerateEnemy(); + } + } + } diff --git a/JisolGameCocos/extensions/Pngyu/._mingwm10.dll b/JisolGameCocos/extensions/Pngyu/._mingwm10.dll new file mode 100644 index 00000000..8bea685f Binary files /dev/null and b/JisolGameCocos/extensions/Pngyu/._mingwm10.dll differ diff --git a/JisolGameCocos/extensions/Pngyu/Pngyu.exe b/JisolGameCocos/extensions/Pngyu/Pngyu.exe new file mode 100644 index 00000000..f5d04a59 Binary files /dev/null and b/JisolGameCocos/extensions/Pngyu/Pngyu.exe differ diff --git a/JisolGameCocos/extensions/Pngyu/Pngyu.ini b/JisolGameCocos/extensions/Pngyu/Pngyu.ini new file mode 100644 index 00000000..5d20c1a4 --- /dev/null +++ b/JisolGameCocos/extensions/Pngyu/Pngyu.ini @@ -0,0 +1,6 @@ +[options] +pngquant_path=./pngquant/pngquant.exe +imageoptim_integration=2 +imageoptim_path=/Applications/ImageOptim.app +num_thread=8 +force_execute_if_negative=false diff --git a/JisolGameCocos/extensions/Pngyu/QtCore4.dll b/JisolGameCocos/extensions/Pngyu/QtCore4.dll new file mode 100644 index 00000000..b691d2ed Binary files /dev/null and b/JisolGameCocos/extensions/Pngyu/QtCore4.dll differ diff --git a/JisolGameCocos/extensions/Pngyu/QtGui4.dll b/JisolGameCocos/extensions/Pngyu/QtGui4.dll new file mode 100644 index 00000000..65d8affd Binary files /dev/null and b/JisolGameCocos/extensions/Pngyu/QtGui4.dll differ diff --git a/JisolGameCocos/extensions/Pngyu/libgcc_s_dw2-1.dll b/JisolGameCocos/extensions/Pngyu/libgcc_s_dw2-1.dll new file mode 100644 index 00000000..8870ba74 Binary files /dev/null and b/JisolGameCocos/extensions/Pngyu/libgcc_s_dw2-1.dll differ diff --git a/JisolGameCocos/extensions/Pngyu/libstdc++-6.dll b/JisolGameCocos/extensions/Pngyu/libstdc++-6.dll new file mode 100644 index 00000000..f8e6c78a Binary files /dev/null and b/JisolGameCocos/extensions/Pngyu/libstdc++-6.dll differ diff --git a/JisolGameCocos/extensions/Pngyu/mingwm10.dll b/JisolGameCocos/extensions/Pngyu/mingwm10.dll new file mode 100644 index 00000000..e007a576 Binary files /dev/null and b/JisolGameCocos/extensions/Pngyu/mingwm10.dll differ diff --git a/JisolGameCocos/extensions/Pngyu/pngquant/pngquant.exe b/JisolGameCocos/extensions/Pngyu/pngquant/pngquant.exe new file mode 100644 index 00000000..f1f99b07 Binary files /dev/null and b/JisolGameCocos/extensions/Pngyu/pngquant/pngquant.exe differ