mirror of
https://github.com/genxium/DelayNoMore
synced 2024-12-26 03:39:00 +00:00
Preparation for changing collision system.
This commit is contained in:
parent
58add91a54
commit
85c94a9e5d
@ -440,7 +440,7 @@
|
|||||||
"array": [
|
"array": [
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
209.7912853806815,
|
216.05530045313827,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -37,7 +37,6 @@ module.export = cc.Class({
|
|||||||
const self = this;
|
const self = this;
|
||||||
self.contactedControlledPlayers = [];
|
self.contactedControlledPlayers = [];
|
||||||
self.contactedNPCPlayers = [];
|
self.contactedNPCPlayers = [];
|
||||||
self.coveringShelterZReducers = [];
|
|
||||||
|
|
||||||
self.computedNewDifferentPosLocalToParentWithinCurrentFrame = null;
|
self.computedNewDifferentPosLocalToParentWithinCurrentFrame = null;
|
||||||
self.actionMangerSingleton = new cc.ActionManager();
|
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) {
|
_addContactedBarrier(collider) {
|
||||||
const self = this;
|
const self = this;
|
||||||
if (!self.contactedBarriers) {
|
if (!self.contactedBarriers) {
|
||||||
@ -379,14 +359,6 @@ module.export = cc.Class({
|
|||||||
case "PolygonBoundaryBarrier":
|
case "PolygonBoundaryBarrier":
|
||||||
playerScriptIns._addContactedBarrier(other);
|
playerScriptIns._addContactedBarrier(other);
|
||||||
break;
|
break;
|
||||||
case "PolygonBoundaryShelter":
|
|
||||||
break;
|
|
||||||
case "PolygonBoundaryShelterZReducer":
|
|
||||||
playerScriptIns._addCoveringShelterZReducer(other);
|
|
||||||
if (1 == playerScriptIns.coveringShelterZReducers.length) {
|
|
||||||
setLocalZOrder(self.node, 2);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -406,14 +378,6 @@ module.export = cc.Class({
|
|||||||
case "PolygonBoundaryBarrier":
|
case "PolygonBoundaryBarrier":
|
||||||
playerScriptIns._removeContactedBarrier(other);
|
playerScriptIns._removeContactedBarrier(other);
|
||||||
break;
|
break;
|
||||||
case "PolygonBoundaryShelter":
|
|
||||||
break;
|
|
||||||
case "PolygonBoundaryShelterZReducer":
|
|
||||||
playerScriptIns._removeCoveringShelterZReducer(other);
|
|
||||||
if (0 == playerScriptIns.coveringShelterZReducers.length) {
|
|
||||||
setLocalZOrder(self.node, 5);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const i18n = require('LanguageData');
|
const i18n = require('LanguageData');
|
||||||
i18n.init(window.language); // languageID should be equal to the one we input in New Language ID input field
|
i18n.init(window.language); // languageID should be equal to the one we input in New Language ID input field
|
||||||
|
|
||||||
cc.Class({
|
cc.Class({
|
||||||
extends: cc.Component,
|
extends: cc.Component,
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
const i18n = require('LanguageData');
|
const i18n = require('LanguageData');
|
||||||
i18n.init(window.language); // languageID should be equal to the one we input in New Language ID input field
|
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 = {
|
window.ALL_MAP_STATES = {
|
||||||
VISUAL: 0, // For free dragging & zooming.
|
VISUAL: 0, // For free dragging & zooming.
|
||||||
EDITING_BELONGING: 1,
|
EDITING_BELONGING: 1,
|
||||||
@ -56,14 +58,6 @@ cc.Class({
|
|||||||
type: cc.Prefab,
|
type: cc.Prefab,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
polygonBoundaryShelterPrefab: {
|
|
||||||
type: cc.Prefab,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
polygonBoundaryShelterZReducerPrefab: {
|
|
||||||
type: cc.Prefab,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
keyboardInputControllerNode: {
|
keyboardInputControllerNode: {
|
||||||
type: cc.Node,
|
type: cc.Node,
|
||||||
default: null
|
default: null
|
||||||
@ -354,6 +348,9 @@ cc.Class({
|
|||||||
self.recentInputCacheMaxCount = 1024;
|
self.recentInputCacheMaxCount = 1024;
|
||||||
self.toRollbackRenderFrameId1 = null;
|
self.toRollbackRenderFrameId1 = null;
|
||||||
self.toRollbackInputFrameId1 = null;
|
self.toRollbackInputFrameId1 = null;
|
||||||
|
|
||||||
|
self.latestCollisionSys = new collisions.Collisions();
|
||||||
|
self.chaserCollisionSys = new collisions.Collisions();
|
||||||
|
|
||||||
self.transitToState(ALL_MAP_STATES.VISUAL);
|
self.transitToState(ALL_MAP_STATES.VISUAL);
|
||||||
|
|
||||||
@ -386,8 +383,7 @@ cc.Class({
|
|||||||
|
|
||||||
const mapNode = self.node;
|
const mapNode = self.node;
|
||||||
const canvasNode = mapNode.parent;
|
const canvasNode = mapNode.parent;
|
||||||
cc.director.getCollisionManager().enabled = true;
|
cc.director.getCollisionManager().enabled = false;
|
||||||
cc.director.getCollisionManager().enabledDebugDraw = CC_DEBUG;
|
|
||||||
// self.musicEffectManagerScriptIns = self.node.getComponent("MusicEffectManager");
|
// self.musicEffectManagerScriptIns = self.node.getComponent("MusicEffectManager");
|
||||||
self.musicEffectManagerScriptIns = null;
|
self.musicEffectManagerScriptIns = null;
|
||||||
|
|
||||||
|
@ -334,10 +334,6 @@ window.battleEntityTypeNameToGlobalGid = {};
|
|||||||
TileCollisionManager.prototype.extractBoundaryObjects = function (withTiledMapNode) {
|
TileCollisionManager.prototype.extractBoundaryObjects = function (withTiledMapNode) {
|
||||||
let toRet = {
|
let toRet = {
|
||||||
barriers: [],
|
barriers: [],
|
||||||
shelters: [],
|
|
||||||
shelterChainTails: [],
|
|
||||||
shelterChainHeads: [],
|
|
||||||
sheltersZReducer: [],
|
|
||||||
frameAnimations: [],
|
frameAnimations: [],
|
||||||
grandBoundaries: [],
|
grandBoundaries: [],
|
||||||
};
|
};
|
||||||
@ -404,8 +400,6 @@ TileCollisionManager.prototype.extractBoundaryObjects = function (withTiledMapNo
|
|||||||
var currentObjectGroupUnderTile = mapInfo._parseObjectGroup(ch);
|
var currentObjectGroupUnderTile = mapInfo._parseObjectGroup(ch);
|
||||||
gidBoundariesMap[parentGid] = {
|
gidBoundariesMap[parentGid] = {
|
||||||
barriers: [],
|
barriers: [],
|
||||||
shelters: [],
|
|
||||||
sheltersZReducer: [],
|
|
||||||
};
|
};
|
||||||
for (let oidx = 0; oidx < currentObjectGroupUnderTile._objects.length; ++oidx) {
|
for (let oidx = 0; oidx < currentObjectGroupUnderTile._objects.length; ++oidx) {
|
||||||
const oo = currentObjectGroupUnderTile._objects[oidx];
|
const oo = currentObjectGroupUnderTile._objects[oidx];
|
||||||
@ -429,22 +423,6 @@ TileCollisionManager.prototype.extractBoundaryObjects = function (withTiledMapNo
|
|||||||
brToPushTmp.boundaryType = boundaryType;
|
brToPushTmp.boundaryType = boundaryType;
|
||||||
gidBoundariesMap[parentGid].barriers.push(brToPushTmp);
|
gidBoundariesMap[parentGid].barriers.push(brToPushTmp);
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -510,22 +488,6 @@ TileCollisionManager.prototype.extractBoundaryObjects = function (withTiledMapNo
|
|||||||
toPushBarriers.boundaryType = boundaryType;
|
toPushBarriers.boundaryType = boundaryType;
|
||||||
toRet.barriers.push(toPushBarriers);
|
toRet.barriers.push(toPushBarriers);
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -585,23 +547,6 @@ TileCollisionManager.prototype.extractBoundaryObjects = function (withTiledMapNo
|
|||||||
}
|
}
|
||||||
toRet.barriers.push(brToPushTmp);
|
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;
|
continue;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -683,47 +628,6 @@ TileCollisionManager.prototype.initMapNodeByTiledBoundaries = function(mapScript
|
|||||||
frameAnimInType.push(animNode);
|
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 = [];
|
mapScriptIns.barrierColliders = [];
|
||||||
for (let boundaryObj of extractedBoundaryObjs.barriers) {
|
for (let boundaryObj of extractedBoundaryObjs.barriers) {
|
||||||
const newBarrier = cc.instantiate(mapScriptIns.polygonBoundaryBarrierPrefab);
|
const newBarrier = cc.instantiate(mapScriptIns.polygonBoundaryBarrierPrefab);
|
||||||
@ -739,19 +643,6 @@ TileCollisionManager.prototype.initMapNodeByTiledBoundaries = function(mapScript
|
|||||||
mapScriptIns.node.addChild(newBarrier);
|
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();
|
const allLayers = tiledMapIns.getLayers();
|
||||||
for (let layer of allLayers) {
|
for (let layer of allLayers) {
|
||||||
const layerType = layer.getProperty("type");
|
const layerType = layer.getProperty("type");
|
||||||
@ -759,10 +650,6 @@ TileCollisionManager.prototype.initMapNodeByTiledBoundaries = function(mapScript
|
|||||||
case "barrier_and_shelter":
|
case "barrier_and_shelter":
|
||||||
setLocalZOrder(layer.node, 3);
|
setLocalZOrder(layer.node, 3);
|
||||||
break;
|
break;
|
||||||
case "shelter_preview":
|
|
||||||
layer.node.opacity = 100;
|
|
||||||
setLocalZOrder(layer.node, 500);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
1
frontend/assets/scripts/modules/Collisions.js
Normal file
1
frontend/assets/scripts/modules/Collisions.js
Normal file
File diff suppressed because one or more lines are too long
9
frontend/assets/scripts/modules/Collisions.js.meta
Normal file
9
frontend/assets/scripts/modules/Collisions.js.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.5",
|
||||||
|
"uuid": "da0a517f-5c74-4fc0-ba89-dbcee184b13e",
|
||||||
|
"isPlugin": false,
|
||||||
|
"loadPluginInWeb": true,
|
||||||
|
"loadPluginInNative": true,
|
||||||
|
"loadPluginInEditor": false,
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
@ -33,20 +33,21 @@
|
|||||||
"design-resolution-height": 640,
|
"design-resolution-height": 640,
|
||||||
"design-resolution-width": 960,
|
"design-resolution-width": 960,
|
||||||
"excluded-modules": [
|
"excluded-modules": [
|
||||||
"Spine Skeleton",
|
"Collider",
|
||||||
"DragonBones",
|
"DragonBones",
|
||||||
"RichText",
|
"Geom Utils",
|
||||||
|
"Mesh",
|
||||||
"MotionStreak",
|
"MotionStreak",
|
||||||
|
"Physics",
|
||||||
"PageView",
|
"PageView",
|
||||||
"PageViewIndicator",
|
"PageViewIndicator",
|
||||||
|
"RichText",
|
||||||
"Slider",
|
"Slider",
|
||||||
|
"Spine Skeleton",
|
||||||
|
"StudioComponent",
|
||||||
"VideoPlayer",
|
"VideoPlayer",
|
||||||
"WebView",
|
"WebView",
|
||||||
"Physics",
|
|
||||||
"StudioComponent",
|
|
||||||
"3D",
|
"3D",
|
||||||
"Mesh",
|
|
||||||
"Geom Utils",
|
|
||||||
"3D Primitive"
|
"3D Primitive"
|
||||||
],
|
],
|
||||||
"facebook": {
|
"facebook": {
|
||||||
@ -74,7 +75,7 @@
|
|||||||
"height": 640,
|
"height": 640,
|
||||||
"width": 960
|
"width": 960
|
||||||
},
|
},
|
||||||
"start-scene": "current",
|
"use-customize-simulator": true,
|
||||||
"use-customize-simulator": false,
|
"use-project-simulator-setting": false,
|
||||||
"use-project-simulator-setting": false
|
"start-scene": "current"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user