提交挂机模式

This commit is contained in:
PC-20230316NUNE\Administrator 2023-11-01 19:07:15 +08:00
parent 2825c1e1d4
commit 28f2509f14
13 changed files with 159 additions and 6 deletions

View File

@ -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": ""

View File

@ -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": {

View File

@ -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);
}
}

View File

@ -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();
}
}
}

Binary file not shown.

Binary file not shown.

View File

@ -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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.