Preparation for changing collision system.

This commit is contained in:
genxium 2022-09-23 16:42:44 +08:00
parent 58add91a54
commit 85c94a9e5d
8 changed files with 28 additions and 169 deletions

View File

@ -440,7 +440,7 @@
"array": [
0,
0,
209.7912853806815,
216.05530045313827,
0,
0,
0,

View File

@ -37,7 +37,6 @@ module.export = cc.Class({
const self = this;
self.contactedControlledPlayers = [];
self.contactedNPCPlayers = [];
self.coveringShelterZReducers = [];
self.computedNewDifferentPosLocalToParentWithinCurrentFrame = null;
self.actionMangerSingleton = new cc.ActionManager();
@ -93,25 +92,6 @@ module.export = cc.Class({
}
},
_addCoveringShelterZReducer(comp) {
const self = this;
for (let coveringShelterZReducer of self.coveringShelterZReducers) {
if (coveringShelterZReducer._id == comp._id) {
return false;
}
}
self.coveringShelterZReducers.push(comp);
return true;
},
_removeCoveringShelterZReducer(comp) {
const self = this;
self.coveringShelterZReducers = self.coveringShelterZReducers.filter((coveringShelterZReducer) => {
return coveringShelterZReducer._id != comp._id;
});
return true;
},
_addContactedBarrier(collider) {
const self = this;
if (!self.contactedBarriers) {
@ -379,14 +359,6 @@ module.export = cc.Class({
case "PolygonBoundaryBarrier":
playerScriptIns._addContactedBarrier(other);
break;
case "PolygonBoundaryShelter":
break;
case "PolygonBoundaryShelterZReducer":
playerScriptIns._addCoveringShelterZReducer(other);
if (1 == playerScriptIns.coveringShelterZReducers.length) {
setLocalZOrder(self.node, 2);
}
break;
default:
break;
}
@ -406,14 +378,6 @@ module.export = cc.Class({
case "PolygonBoundaryBarrier":
playerScriptIns._removeContactedBarrier(other);
break;
case "PolygonBoundaryShelter":
break;
case "PolygonBoundaryShelterZReducer":
playerScriptIns._removeCoveringShelterZReducer(other);
if (0 == playerScriptIns.coveringShelterZReducers.length) {
setLocalZOrder(self.node, 5);
}
break;
default:
break;
}

View File

@ -1,5 +1,6 @@
const i18n = require('LanguageData');
i18n.init(window.language); // languageID should be equal to the one we input in New Language ID input field
cc.Class({
extends: cc.Component,

View File

@ -1,6 +1,8 @@
const i18n = require('LanguageData');
i18n.init(window.language); // languageID should be equal to the one we input in New Language ID input field
const collisions = require('./modules/Collisions');
window.ALL_MAP_STATES = {
VISUAL: 0, // For free dragging & zooming.
EDITING_BELONGING: 1,
@ -56,14 +58,6 @@ cc.Class({
type: cc.Prefab,
default: null,
},
polygonBoundaryShelterPrefab: {
type: cc.Prefab,
default: null,
},
polygonBoundaryShelterZReducerPrefab: {
type: cc.Prefab,
default: null,
},
keyboardInputControllerNode: {
type: cc.Node,
default: null
@ -355,6 +349,9 @@ cc.Class({
self.toRollbackRenderFrameId1 = null;
self.toRollbackInputFrameId1 = null;
self.latestCollisionSys = new collisions.Collisions();
self.chaserCollisionSys = new collisions.Collisions();
self.transitToState(ALL_MAP_STATES.VISUAL);
self.battleState = ALL_BATTLE_STATES.WAITING;
@ -386,8 +383,7 @@ cc.Class({
const mapNode = self.node;
const canvasNode = mapNode.parent;
cc.director.getCollisionManager().enabled = true;
cc.director.getCollisionManager().enabledDebugDraw = CC_DEBUG;
cc.director.getCollisionManager().enabled = false;
// self.musicEffectManagerScriptIns = self.node.getComponent("MusicEffectManager");
self.musicEffectManagerScriptIns = null;

View File

@ -334,10 +334,6 @@ window.battleEntityTypeNameToGlobalGid = {};
TileCollisionManager.prototype.extractBoundaryObjects = function (withTiledMapNode) {
let toRet = {
barriers: [],
shelters: [],
shelterChainTails: [],
shelterChainHeads: [],
sheltersZReducer: [],
frameAnimations: [],
grandBoundaries: [],
};
@ -404,8 +400,6 @@ TileCollisionManager.prototype.extractBoundaryObjects = function (withTiledMapNo
var currentObjectGroupUnderTile = mapInfo._parseObjectGroup(ch);
gidBoundariesMap[parentGid] = {
barriers: [],
shelters: [],
sheltersZReducer: [],
};
for (let oidx = 0; oidx < currentObjectGroupUnderTile._objects.length; ++oidx) {
const oo = currentObjectGroupUnderTile._objects[oidx];
@ -429,22 +423,6 @@ TileCollisionManager.prototype.extractBoundaryObjects = function (withTiledMapNo
brToPushTmp.boundaryType = boundaryType;
gidBoundariesMap[parentGid].barriers.push(brToPushTmp);
break;
case "shelter":
let shToPushTmp = [];
for (let shidx = 0; shidx < polylinePoints.length; ++shidx) {
shToPushTmp.push(cc.v2(oo.x, oo.y).add(polylinePoints[shidx]));
}
shToPushTmp.boundaryType = boundaryType;
gidBoundariesMap[parentGid].shelters.push(shToPushTmp);
break;
case "shelter_z_reducer":
let shzrToPushTmp = [];
for (let shzridx = 0; shzridx < polylinePoints.length; ++shzridx) {
shzrToPushTmp.push(cc.v2(oo.x, oo.y).add(polylinePoints[shzridx]));
}
shzrToPushTmp.boundaryType = boundaryType;
gidBoundariesMap[parentGid].sheltersZReducer.push(shzrToPushTmp);
break;
default:
break;
}
@ -510,22 +488,6 @@ TileCollisionManager.prototype.extractBoundaryObjects = function (withTiledMapNo
toPushBarriers.boundaryType = boundaryType;
toRet.barriers.push(toPushBarriers);
break;
case "shelter":
let toPushShelters = [];
for (let kk = 0; kk < polylinePoints.length; ++kk) {
toPushShelters.push(this.continuousObjLayerOffsetToContinuousMapNodePos(withTiledMapNode, object.offset.add(polylinePoints[kk])));
}
toPushShelters.boundaryType = boundaryType;
toRet.shelters.push(toPushShelters);
break;
case "shelter_z_reducer":
let toPushSheltersZReducer = [];
for (let kkk = 0; kkk < polylinePoints.length; ++kkk) {
toPushSheltersZReducer.push(this.continuousObjLayerOffsetToContinuousMapNodePos(withTiledMapNode, object.offset.add(polylinePoints[kkk])));
}
toPushSheltersZReducer.boundaryType = boundaryType;
toRet.sheltersZReducer.push(toPushSheltersZReducer);
break;
default:
break;
}
@ -585,23 +547,6 @@ TileCollisionManager.prototype.extractBoundaryObjects = function (withTiledMapNo
}
toRet.barriers.push(brToPushTmp);
}
for (let shidx = 0; shidx < gidBoundaries.shelters.length; ++shzridx) {
const theShelter = gidBoundaries.shelters[shidx]; // An array of cc.v2 points.
let shToPushTmp = [];
for (let tshidx = 0; tshidx < theShelter.length; ++tshidx) {
shToPushTmp.push(topLeftOfWholeTsxTileInMapNode.add(cc.v2(theShelter[tshidx].x, -theShelter[tshidx].y)));
}
toRet.shelters.push(shToPushTmp);
}
for (let shzridx = 0; shzridx < gidBoundaries.sheltersZReducer.length; ++shzridx) {
const theShelter = gidBoundaries.sheltersZReducer[shzridx]; // An array of cc.v2 points.
let shzrToPushTmp = [];
for (let tshzridx = 0; tshzridx < theShelter.length; ++tshzridx) {
shzrToPushTmp.push(topLeftOfWholeTsxTileInMapNode.add(cc.v2(theShelter[tshzridx].x, -theShelter[tshzridx].y)));
}
toRet.sheltersZReducer.push(shzrToPushTmp);
}
continue;
default:
@ -683,47 +628,6 @@ TileCollisionManager.prototype.initMapNodeByTiledBoundaries = function(mapScript
frameAnimInType.push(animNode);
}
for (let boundaryObj of extractedBoundaryObjs.shelterChainTails) {
const newShelter = cc.instantiate(mapScriptIns.polygonBoundaryShelterPrefab);
const newBoundaryOffsetInMapNode = cc.v2(boundaryObj[0].x, boundaryObj[0].y);
newShelter.setPosition(newBoundaryOffsetInMapNode);
newShelter.setAnchorPoint(cc.v2(0, 0));
const newShelterColliderIns = newShelter.getComponent(cc.PolygonCollider);
newShelterColliderIns.points = [];
for (let p of boundaryObj) {
newShelterColliderIns.points.push(p.sub(newBoundaryOffsetInMapNode));
}
newShelter.pTiledLayer = boundaryObj.pTiledLayer;
newShelter.tileDiscretePos = boundaryObj.tileDiscretePos;
if (null != boundaryObj.imageObject) {
newShelter.imageObject = boundaryObj.imageObject;
newShelter.tailOrHead = "tail";
window.addToGlobalShelterChainVerticeMap(newShelter.imageObject.imageObjectNode); // Deliberately NOT adding at the "traversal of shelterChainHeads".
}
newShelter.boundaryObj = boundaryObj;
mapScriptIns.node.addChild(newShelter);
}
for (let boundaryObj of extractedBoundaryObjs.shelterChainHeads) {
const newShelter = cc.instantiate(mapScriptIns.polygonBoundaryShelterPrefab);
const newBoundaryOffsetInMapNode = cc.v2(boundaryObj[0].x, boundaryObj[0].y);
newShelter.setPosition(newBoundaryOffsetInMapNode);
newShelter.setAnchorPoint(cc.v2(0, 0));
const newShelterColliderIns = newShelter.getComponent(cc.PolygonCollider);
newShelterColliderIns.points = [];
for (let p of boundaryObj) {
newShelterColliderIns.points.push(p.sub(newBoundaryOffsetInMapNode));
}
newShelter.pTiledLayer = boundaryObj.pTiledLayer;
newShelter.tileDiscretePos = boundaryObj.tileDiscretePos;
if (null != boundaryObj.imageObject) {
newShelter.imageObject = boundaryObj.imageObject;
newShelter.tailOrHead = "head";
}
newShelter.boundaryObj = boundaryObj;
mapScriptIns.node.addChild(newShelter);
}
mapScriptIns.barrierColliders = [];
for (let boundaryObj of extractedBoundaryObjs.barriers) {
const newBarrier = cc.instantiate(mapScriptIns.polygonBoundaryBarrierPrefab);
@ -739,19 +643,6 @@ TileCollisionManager.prototype.initMapNodeByTiledBoundaries = function(mapScript
mapScriptIns.node.addChild(newBarrier);
}
for (let boundaryObj of extractedBoundaryObjs.sheltersZReducer) {
const newShelter = cc.instantiate(mapScriptIns.polygonBoundaryShelterZReducerPrefab);
const newBoundaryOffsetInMapNode = cc.v2(boundaryObj[0].x, boundaryObj[0].y);
newShelter.setPosition(newBoundaryOffsetInMapNode);
newShelter.setAnchorPoint(cc.v2(0, 0));
const newShelterColliderIns = newShelter.getComponent(cc.PolygonCollider);
newShelterColliderIns.points = [];
for (let p of boundaryObj) {
newShelterColliderIns.points.push(p.sub(newBoundaryOffsetInMapNode));
}
mapScriptIns.node.addChild(newShelter);
}
const allLayers = tiledMapIns.getLayers();
for (let layer of allLayers) {
const layerType = layer.getProperty("type");
@ -759,10 +650,6 @@ TileCollisionManager.prototype.initMapNodeByTiledBoundaries = function(mapScript
case "barrier_and_shelter":
setLocalZOrder(layer.node, 3);
break;
case "shelter_preview":
layer.node.opacity = 100;
setLocalZOrder(layer.node, 500);
break;
default:
break;
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "da0a517f-5c74-4fc0-ba89-dbcee184b13e",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -33,20 +33,21 @@
"design-resolution-height": 640,
"design-resolution-width": 960,
"excluded-modules": [
"Spine Skeleton",
"Collider",
"DragonBones",
"RichText",
"Geom Utils",
"Mesh",
"MotionStreak",
"Physics",
"PageView",
"PageViewIndicator",
"RichText",
"Slider",
"Spine Skeleton",
"StudioComponent",
"VideoPlayer",
"WebView",
"Physics",
"StudioComponent",
"3D",
"Mesh",
"Geom Utils",
"3D Primitive"
],
"facebook": {
@ -74,7 +75,7 @@
"height": 640,
"width": 960
},
"start-scene": "current",
"use-customize-simulator": false,
"use-project-simulator-setting": false
"use-customize-simulator": true,
"use-project-simulator-setting": false,
"start-scene": "current"
}