mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
更新无限地图
This commit is contained in:
@@ -8,13 +8,14 @@ import GButtleBase from "../bullet/GButtleBase";
|
||||
import { GFSMAnimBase } from "../fsm/GFSMAnimBase";
|
||||
import GFSMBase from "../fsm/GFSMBase";
|
||||
import GRoleDefault from "../role/GRoleDefault";
|
||||
import GNode from "../common/GNode";
|
||||
|
||||
//攻击子弹类
|
||||
export class GAttackBullet{
|
||||
|
||||
//创建子弹
|
||||
static create<T extends GButtleBase<{}>>(GClass:{new():T},data:{}):T{
|
||||
let bulletNode = new Node();
|
||||
let bulletNode = GNode.create();
|
||||
bulletNode.addComponent(UITransform);
|
||||
let bullet = bulletNode.addComponent(GClass);
|
||||
bullet.setData(data);
|
||||
|
@@ -8,7 +8,7 @@ import { v3 } from "cc";
|
||||
import { bezier } from "cc";
|
||||
import { v2 } from "cc";
|
||||
import { Vec2 } from "cc";
|
||||
import GEffectUtil from "../../effect/GEffectUtil";
|
||||
import GEffectUtil from "../common/GEffectUtil";
|
||||
import { TableGRoleAttackEffect } from "../../../../resources/config/ts/TableGRoleAttackEffect";
|
||||
import GDetection from "../common/GDetection";
|
||||
import { rect } from "cc";
|
||||
@@ -25,9 +25,9 @@ export default class GAttackParabolicRemote implements GAttackBase{
|
||||
let enemy = role.fsm.enemy;
|
||||
if(!enemy) return;
|
||||
|
||||
let image:SpriteFrame = app.role.bullets[info.attackArgs[0]];
|
||||
let image:SpriteFrame = app.battleRes.bullets[info.attackArgs[0]];
|
||||
let bang = {
|
||||
ske: app.role.effects[info.attackArgs[1]],
|
||||
ske: app.battleRes.effects[info.attackArgs[1]],
|
||||
info: TableGRoleAttackEffect.getConfig(info.attackArgs[1])
|
||||
};
|
||||
let bone = role.spine.findBone(info.attackArgs[2]);
|
||||
|
@@ -0,0 +1,31 @@
|
||||
import { UITransform } from "cc";
|
||||
import { Node } from "cc";
|
||||
import { sp } from "cc";
|
||||
import JNSkeleton from "../../../../../extensions/ngame/assets/ngame/sync/frame/game/spine/JNFrameSkeleton";
|
||||
import { GData } from "../../../GData";
|
||||
import GNode from "./GNode";
|
||||
|
||||
export default class GEffectUtil {
|
||||
|
||||
//创建一个Spine特效
|
||||
static create(spine:sp.SkeletonData):JNSkeleton{
|
||||
let effectNode = GNode.create();
|
||||
effectNode.addComponent(UITransform);
|
||||
let ske = effectNode.addComponent(JNSkeleton);
|
||||
ske.skeletonData = spine;
|
||||
ske.premultipliedAlpha = false;
|
||||
return ske;
|
||||
}
|
||||
|
||||
//创建只播放一次的Spine特效
|
||||
static createOne(spine:sp.SkeletonData):JNSkeleton{
|
||||
let ske = GEffectUtil.create(spine);
|
||||
ske.setCompleteListener(() => {
|
||||
ske.node.destroy();
|
||||
})
|
||||
return ske;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "c0673372-37f9-453a-b439-11234bc2d8a7",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
14
JisolGameCocos/assets/script/battle/base/common/GNode.ts
Normal file
14
JisolGameCocos/assets/script/battle/base/common/GNode.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Node } from "cc";
|
||||
import { GData } from "../../../GData";
|
||||
import { UITransform } from "cc";
|
||||
|
||||
|
||||
//Node 工具
|
||||
export default class GNode{
|
||||
static create():Node{
|
||||
let mapNode = new Node();
|
||||
mapNode.layer = GData.layer.World;
|
||||
return mapNode;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "4ab3e098-02a1-4274-8c17-bc2ac08f643b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -4,6 +4,7 @@ import JNSkeleton from "../../../../../extensions/ngame/assets/ngame/sync/frame/
|
||||
import { Node } from "cc";
|
||||
import GBaseMode from "../../GBaseMode";
|
||||
import { Vec2 } from "cc";
|
||||
import GNode from "./GNode";
|
||||
|
||||
|
||||
//Spine 工具
|
||||
@@ -18,7 +19,7 @@ export default class GSpine{
|
||||
//关闭当前角色原本的Spine
|
||||
role.spine.enabled = false;
|
||||
//添加新的spine
|
||||
let spineNode = new Node();
|
||||
let spineNode = GNode.create();
|
||||
role.node.addChild(spineNode);
|
||||
let another = spineNode.addComponent(JNSkeleton);
|
||||
another.skeletonData = spine;
|
||||
@@ -38,7 +39,7 @@ export default class GSpine{
|
||||
//创建一个Spine
|
||||
static onCreateSpine(spine:sp.SkeletonData):JNSkeleton{
|
||||
|
||||
let spineNode = new Node();
|
||||
let spineNode = GNode.create();
|
||||
let another = spineNode.addComponent(JNSkeleton);
|
||||
another.premultipliedAlpha = false;
|
||||
another.skeletonData = spine;
|
||||
|
@@ -1,7 +1,13 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import { JNGSyncBase } from '../../../../App';
|
||||
import { app, JNGSyncBase } from '../../../../App';
|
||||
import { SpriteFrame } from 'cc';
|
||||
import { Camera } from 'cc';
|
||||
import { TableGMap } from '../../../../../resources/config/ts/TableGMap';
|
||||
import { Sprite } from 'cc';
|
||||
import { UITransform } from 'cc';
|
||||
import { v3 } from 'cc';
|
||||
import { Vec2 } from 'cc';
|
||||
import { size } from 'cc';
|
||||
import GNode from '../GNode';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**
|
||||
@@ -16,25 +22,74 @@ export class GMapLoop extends JNGSyncBase<{}> {
|
||||
repeat:number = 1;
|
||||
//一块的地图宽度
|
||||
mapWidth:number = 100;
|
||||
//一块的地图高度
|
||||
mapHeight:number = 100;
|
||||
|
||||
//是否初始化
|
||||
isInit:boolean = false;
|
||||
//世界坐标Y轴
|
||||
worldY:number = 0;
|
||||
|
||||
//创建的地图列表{开始区块:地图图片}
|
||||
createMaps:Map<number,Node> = new Map();
|
||||
|
||||
|
||||
init(map:SpriteFrame,repeat:number){
|
||||
init(map:SpriteFrame,repeat:number = 1,width:number = 0,height:number = 0){
|
||||
this.map = map;
|
||||
this.isInit = true;
|
||||
this.repeat = repeat;
|
||||
this.mapWidth = map.width;
|
||||
this.mapWidth = width || this.map.width;
|
||||
this.mapHeight = height || this.map.height;
|
||||
}
|
||||
|
||||
//更新地图(世界坐标X)
|
||||
UpdateMap(x:number){
|
||||
UpdateMap(x:number,offsetX:number = 0,offsetY:number = 0){
|
||||
|
||||
//计算x在第几个区块
|
||||
let blockIndex = Math.floor((x + offsetX) / this.mapWidth);
|
||||
|
||||
//生成区块的列表
|
||||
let maps:number[] = [];
|
||||
for (let index = 0; index < 1 + (this.repeat * 2); index++) {
|
||||
maps.push(blockIndex + (index - this.repeat));
|
||||
}
|
||||
|
||||
//生成
|
||||
maps.forEach((blockIndex) => {
|
||||
this.createMap(blockIndex,offsetX,offsetY);
|
||||
})
|
||||
|
||||
//销毁其他地图
|
||||
let keys = Array.from(this.createMaps.keys());
|
||||
keys.forEach(key => {
|
||||
if(maps.indexOf(key) < 0){
|
||||
this.createMaps.get(key).destroy();
|
||||
this.createMaps.delete(key);
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
//生成区块地图
|
||||
createMap(blockIndex:number,offsetX:number = 0,offsetY:number = 0){
|
||||
//计算区块开始位置
|
||||
let start = (blockIndex * this.mapWidth) - offsetX;
|
||||
|
||||
if(!this.createMaps.get(blockIndex)){
|
||||
//生成地图
|
||||
let mapNode = GNode.create();
|
||||
let uiTransform = mapNode.addComponent(UITransform);
|
||||
uiTransform.anchorX = 0;
|
||||
this.node.addChild(mapNode);
|
||||
mapNode.worldPosition = v3(start,offsetY,0)
|
||||
let mapImage = mapNode.addComponent(Sprite);
|
||||
mapImage.spriteFrame = this.map;
|
||||
mapImage.sizeMode = Sprite.SizeMode.CUSTOM;
|
||||
uiTransform.contentSize = size(this.mapWidth,this.mapHeight);
|
||||
this.createMaps.set(blockIndex,mapNode);
|
||||
}else{
|
||||
this.createMaps.get(blockIndex).worldPosition = v3(start,offsetY,0)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -82,7 +82,7 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
//初始化
|
||||
protected init(role:TableGRole){
|
||||
if(this.spine)
|
||||
this.spine.skeletonData = app.role.skData[role.id];
|
||||
this.spine.skeletonData = app.battleRes.skData[role.id];
|
||||
}
|
||||
|
||||
//创建一个状态机
|
||||
|
@@ -27,7 +27,6 @@ export default class GRoleDefault extends GRoleBase<{}>{
|
||||
//能量条
|
||||
@property(ProgressBar)
|
||||
energyVolume:ProgressBar;
|
||||
|
||||
|
||||
//状态机
|
||||
fsm:GFSMDefault;
|
||||
@@ -43,10 +42,6 @@ export default class GRoleDefault extends GRoleBase<{}>{
|
||||
if(this.isDie){
|
||||
//死亡回调
|
||||
this.killBack.forEach(fun => fun(this));
|
||||
//死亡销毁
|
||||
JNFrameTime.getInstance().setTimeout(() => {
|
||||
this.node.destroy()
|
||||
},3000)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user