This commit is contained in:
PC-20230316NUNE\Administrator
2023-10-23 18:56:01 +08:00
parent ac94959a45
commit 77d44ee300
328 changed files with 16429 additions and 2 deletions

View File

@@ -0,0 +1,17 @@
import { Vec2 } from "cc";
import GObject from "./base/GObject";
import { v3 } from "cc";
export default class GBaseMode extends GObject<{}> {
//添加对象到场景中
addGObject(obj: GObject<{}>,pos?:Vec2){
this.node.addChild(obj.node);
if(pos){
obj.node.setWorldPosition(v3(pos.x,pos.y,0));
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "4ec90971-34c8-4746-b0c6-af2dbfb23ec4",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,14 @@
import Singleton from "../../../extensions/ngame/assets/ngame/util/Singleton";
export enum BattleMode{
//PVP 模式
PVP,
}
//全局战斗模式管理器
export default class GBattleModeManager extends Singleton {
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "9e4513c8-8f5d-4fb7-a210-106d50d4a7c6",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "ca2cc88c-3cee-4223-927a-3a5ca27ffee3",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,87 @@
import { _decorator } from "cc";
import GBaseMode from "../GBaseMode";
import { GTactical } from "../entity/GTactical";
import { Prefab } from "cc";
import GRoleEntity from "../base/role/impl/GRoleEntity";
import { instantiate } from "cc";
import { Vec2 } from "cc";
const { ccclass, property } = _decorator;
//PVP 角色
export enum GPVPModePlayerEnum{
PLAYER, //玩家
ENEMY, //敌人
}
//PVP 玩家信息
export interface GPVPModePlayerInfo{
//阵法
tactical: GTactical;
//宠物列表
roles: any[];
}
/**
* PVP 模式
*/
@ccclass('GPVPMode')
export default class GPVPMode extends GBaseMode{
@property(Prefab)
rolePrefab: Prefab = null;
//玩家信息
playerInfo: GPVPModePlayerInfo = { tactical: GTactical.getTactical1(),roles: [{},{},{}] };
//敌方信息
enemyInfo: GPVPModePlayerInfo = { tactical: GTactical.getTactical2(true),roles: [{},{},{}] };
//玩家宠物
playerRoles: GRoleEntity[] = [];
//敌方宠物
enemyRoles: GRoleEntity[] = [];
//玩家位置
playerPos: Vec2 = new Vec2(-400,0);
//敌方位置
enemyPos: Vec2 = new Vec2(400,0);
onSyncInitSuccess(): void {
//初始化战斗
console.log("GPVPMode 模式初始化");
//生成玩家
this.playerInfo.roles.forEach((info,index) => this.onGenRole(GPVPModePlayerEnum.PLAYER,index+1))
this.enemyInfo.roles.forEach((info,index) => this.onGenRole(GPVPModePlayerEnum.ENEMY,index+1))
}
//生成角色
onGenRole(type: GPVPModePlayerEnum,index:number) {
let pos:Vec2 = this.getInfo(type).tactical.getPosition(index);
if(!pos) return;
let role = instantiate(this.rolePrefab);
let entity = role.getComponent(GRoleEntity)
this.addGObject(entity,this.getInfo(type).tactical.getPosition(index,this.getTacticalPos(type)));
}
//获取配置
getInfo(type: GPVPModePlayerEnum): GPVPModePlayerInfo {
if(type == GPVPModePlayerEnum.PLAYER) return this.playerInfo;
if(type == GPVPModePlayerEnum.ENEMY) return this.enemyInfo;
}
//获取位置
getTacticalPos(type: GPVPModePlayerEnum):Vec2{
if(type == GPVPModePlayerEnum.PLAYER) return this.playerPos;
if(type == GPVPModePlayerEnum.ENEMY) return this.enemyPos;
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "31e6d29e-41d4-4d7d-a24a-b37f9c0caabd",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "4a00fcca-5d44-43da-a085-2aece0aaf683",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,7 @@
import { JNGSyncProtoBase } from "../../App";
export default class GObject<T> extends JNGSyncProtoBase<T>{
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "465eb18e-e84c-4cbf-930f-9490c5f51510",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "a178786e-130e-4422-b7cd-1fab35d66c76",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,6 @@
//状态机基类
export default abstract class GFSMBase{
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "6b762164-9367-4f6b-a168-8b715ac9d5b5",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "03218a59-18c0-42bc-aa22-117d45bc314a",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,9 @@
import GFSMBase from "../GFSMBase";
//角色状态机实现
export default class GFSMRoleController extends GFSMBase{
//状态机更新
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "bf6010d3-4d2e-4ecf-abc4-a4e770ebd5df",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "4c6a60ae-2e26-4c45-8d64-1d7a9b32e7be",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,27 @@
import { _decorator, sp } from "cc";
import { JNGSyncProtoBase } from "../../../App";
import GObject from "../GObject";
import { BehaviorStatus } from "../../../../../extensions/Behavior Creator/runtime/main";
const { ccclass, property } = _decorator;
//角色基类
export default abstract class GRoleBase<T> extends GObject<T>{
@property(sp.Skeleton)
spine:sp.Skeleton;
onLoad(){
super.onLoad();
if(!this.spine) this.spine = this.node.getComponent(sp.Skeleton);
//如果没有生成则直接销毁
this.node.removeFromParent();
}
//攻击
public onAttack(data){
return BehaviorStatus.Success;
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "15e9145c-4eb8-485d-99eb-6d709b3991e7",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "b2af28db-e925-419f-81b8-3bf755a3224f",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,16 @@
import { _decorator } from "cc";
import GRoleBase from "../GRoleBase";
const { ccclass, property } = _decorator;
/**
* 基础实现
*/
@ccclass('GRoleEntity')
export default class GRoleEntity extends GRoleBase<{}> {
onLoad(){
super.onLoad();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "c6d20914-49fe-45ea-9bf2-750de7cc7ed2",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "5edb3581-4314-4923-8efb-b0b37d182533",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,78 @@
import { v2 } from "cc";
import { Vec2 } from "cc";
//阵法类
export class GTactical{
tactical:number[][];
//阵法位置
static pos:Vec2[][] = [
[v2(-100,150),v2(0,150),v2(100,150)],
[v2(-100,0),v2(0,0),v2(100,0)],
[v2(-100,-150),v2(0,-150),v2(100,-150)],
];
constructor(tactical:number[][]){
this.tactical = tactical;
}
//获取阵法
static getTactical(isReversed:boolean = false): GTactical{
let tactical = [
[0,0,3],
[0,0,1],
[0,0,2],
];
if(isReversed){
tactical = this.getTacticalFlipX(tactical);
}
return new GTactical(tactical);
}
//获取阵法
static getTactical1(isReversed:boolean = false): GTactical{
let tactical = [
[0,3,0],
[0,1,0],
[0,2,0],
];
if(isReversed){
tactical = this.getTacticalFlipX(tactical);
}
return new GTactical(tactical);
}
//获取阵法
static getTactical2(isReversed:boolean = false): GTactical{
let tactical = [
[0,0,3],
[0,1,0],
[2,0,0],
];
if(isReversed){
tactical = this.getTacticalFlipX(tactical);
}
return new GTactical(tactical);
}
//阵法取反
static getTacticalFlipX(tactical:number[][]){
return tactical.map(row => row.reverse());
}
//返回阵法位置
getPosition(index:number,father:Vec2 = v2(0,0)){
for(let i = 0;i < 3;i++){
for(let j = 0;j < 3;j++){
let tag = this.tactical[i][j];
if(tag == index){
return father.clone().add(GTactical.pos[i][j].clone());
}
}
}
return null;
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "1b621f7a-3cbd-4165-8a3e-5765f08bf19f",
"files": [],
"subMetas": {},
"userData": {}
}