Initial commit.

This commit is contained in:
genxium
2022-09-20 23:50:01 +08:00
commit e90a335c56
432 changed files with 101884 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
function NetworkDoctor(serverFps, clientUpsyncFps) {
this.serverFps = serverFps;
this.clientUpsyncFps = clientUpsyncFps;
this.millisPerServerFrame = parseInt(1000 / this.serverFps);
this._tooLongSinceLastFrameDiffReceivedThreshold = (this.millisPerServerFrame << 6);
this.setupFps = function(fps) {
this.serverFps = this.clientUpsyncFps = fps;
this.millisPerServerFrame = parseInt(1000 / this.serverFps);
this._tooLongSinceLastFrameDiffReceivedThreshold = (this.millisPerServerFrame << 6);
}
this._lastFrameDiffRecvTime = null;
this._tooLongSinceLastFrameDiffReceived = function() {
if (undefined === this._lastFrameDiffRecvTime || null === this._lastFrameDiffRecvTime) return false;
return (this._tooLongSinceLastFrameDiffReceivedThreshold <= (Date.now() - this._lastFrameDiffRecvTime));
};
this._consecutiveALittleLongFrameDiffReceivedIntervalCount = 0;
this._consecutiveALittleLongFrameDiffReceivedIntervalCountThreshold = 120;
this.onNewFrameDiffReceived = function(frameDiff) {
var now = Date.now();
if (undefined !== this._lastFrameDiffRecvTime && null !== this._lastFrameDiffRecvTime) {
var intervalFromLastFrameDiff = (now - this._lastFrameDiffRecvTime);
if ((this.millisPerServerFrame << 5) < intervalFromLastFrameDiff) {
++this._consecutiveALittleLongFrameDiffReceivedIntervalCount;
console.log('Medium delay, intervalFromLastFrameDiff is', intervalFromLastFrameDiff);
} else {
this._consecutiveALittleLongFrameDiffReceivedIntervalCount = 0;
}
}
this._lastFrameDiffRecvTime = now;
};
this._networkComplaintPrefix = "\nNetwork is not good >_<\n";
this.generateNetworkComplaint = function(excludeTypeConstantALittleLongFrameDiffReceivedInterval, excludeTypeTooLongSinceLastFrameDiffReceived) {
if (this.hasBattleStopped) return null;
var shouldComplain = false;
var ret = this._networkComplaintPrefix;
if (true != excludeTypeConstantALittleLongFrameDiffReceivedInterval && this._consecutiveALittleLongFrameDiffReceivedIntervalCountThreshold <= this._consecutiveALittleLongFrameDiffReceivedIntervalCount) {
this._consecutiveALittleLongFrameDiffReceivedIntervalCount = 0;
ret += "\nConstantly having a little long recv interval.\n";
shouldComplain = true;
}
if (true != excludeTypeTooLongSinceLastFrameDiffReceived && this._tooLongSinceLastFrameDiffReceived()) {
ret += "\nToo long since last received frameDiff.\n";
shouldComplain = true;
}
return (shouldComplain ? ret : null);
};
this.hasBattleStopped = false;
this.onBattleStopped = function() {
this.hasBattleStopped = true;
};
this.isClientSessionConnected = function() {
if (!window.game) return false;
if (!window.game.clientSession) return false;
return window.game.clientSession.connected;
};
}
window.NetworkDoctor = NetworkDoctor;

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "477c07c3-0d50-4d55-96f0-6eaf9f25e2da",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,585 @@
'use strict';
function _typeof6(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof6 = function _typeof6(obj) {
return typeof obj;
};
} else {
_typeof6 = function _typeof6(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof6(obj);
}
function _typeof5(obj) {
if (typeof Symbol === "function" && _typeof6(Symbol.iterator) === "symbol") {
_typeof5 = function _typeof5(obj) {
return _typeof6(obj);
};
} else {
_typeof5 = function _typeof5(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof6(obj);
};
}
return _typeof5(obj);
}
function _typeof4(obj) {
if (typeof Symbol === "function" && _typeof5(Symbol.iterator) === "symbol") {
_typeof4 = function _typeof4(obj) {
return _typeof5(obj);
};
} else {
_typeof4 = function _typeof4(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof5(obj);
};
}
return _typeof4(obj);
}
function _typeof3(obj) {
if (typeof Symbol === "function" && _typeof4(Symbol.iterator) === "symbol") {
_typeof3 = function _typeof3(obj) {
return _typeof4(obj);
};
} else {
_typeof3 = function _typeof3(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof4(obj);
};
}
return _typeof3(obj);
}
function _typeof2(obj) {
if (typeof Symbol === "function" && _typeof3(Symbol.iterator) === "symbol") {
_typeof2 = function _typeof2(obj) {
return _typeof3(obj);
};
} else {
_typeof2 = function _typeof2(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof3(obj);
};
}
return _typeof2(obj);
}
function _typeof(obj) {
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") {
_typeof = function _typeof(obj) {
return _typeof2(obj);
};
} else {
_typeof = function _typeof(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
};
}
return _typeof(obj);
}
var NetworkUtils = NetworkUtils || {};
window.NetworkUtils = NetworkUtils;
NetworkUtils.ArrayProto = Array.prototype;
NetworkUtils.ObjProto = Object.prototype;
NetworkUtils.hasOwn = NetworkUtils.ObjProto.hasOwnProperty;
NetworkUtils.toString = NetworkUtils.ObjProto.toString;
NetworkUtils.nativeForEach = NetworkUtils.ArrayProto.forEach;
NetworkUtils.slice = NetworkUtils.ArrayProto.slice;
NetworkUtils.nativeKeys = Object.keys;
NetworkUtils.nativeIsArray = Array.isArray;
NetworkUtils.isFunction = function(o) {
return typeof o == "function" || false;
};
NetworkUtils.isObject = function(o) {
var type = typeof o === 'undefined' ? 'undefined' : _typeof(o);
return type === 'function' || type === 'object' && !!o;
};
NetworkUtils.isArray = NetworkUtils.nativeIsArray || function(obj) {
return NetworkUtils.toString.call(obj) === '[object Array]';
};
NetworkUtils.isString = function(o) {
return typeof o === 'string';
};
NetworkUtils.isNotEmptyString = function(s) {
return NetworkUtils.isString(s) && s !== '';
};
NetworkUtils.each = function(o, fn, ctx) {
if (o == null) return;
if (NetworkUtils.nativeForEach && o.forEach === NetworkUtils.nativeForEach) {
o.forEach(fn, ctx);
} else if (o.length === +o.length) {
for (var i = 0, l = o.length; i < l; i++) {
if (i in o && fn.call(ctx, o[i], i, o) === {}) return;
}
} else {
for (var key in o) {
if (NetworkUtils.hasOwn.call(o, key)) {
if (fn.call(ctx, o[key], key, o) === {}) return;
}
}
}
};
NetworkUtils.numFormat = function(num) {
if (num > 9999) {
return Math.floor(num / 1000).toString() + 'K';
} else {
return num.toString();
}
}; //1000=>1,000
NetworkUtils.numberFmt = function(num) {
if (!/^(\+|-)?(\d+)(\.\d+)?$/.test(num)) {
return num;
}
var a = RegExp.$1,
b = RegExp.$2,
c = RegExp.$3,
re = new RegExp();
re.compile("(\\d)(\\d{3})(,|$)");
while (re.test(b)) {
b = b.replace(re, "$1,$2$3");
}
return a + "" + b + "" + c;
}; //1,000=>1000
NetworkUtils.fmtNumber = function(str) {
if (!NetworkUtils.isNotEmptyString(str)) return 0;
return parseInt(str.replace(/,/g, ''), 10);
};
NetworkUtils.defaults = function(obj) {
NetworkUtils.each(NetworkUtils.slice.call(arguments, 1), function(o) {
for (var k in o) {
if (obj[k] == null)
obj[k] = o[k];
}
});
return obj;
};
NetworkUtils.keys = function(obj) {
if (!NetworkUtils.isObject(obj)) return [];
if (NetworkUtils.nativeKeys) return NetworkUtils.nativeKeys(obj);
var keys = [];
for (var key in obj) {
if (NetworkUtils.hasOwn.call(obj, key)) keys.push(key);
}
return keys;
};
NetworkUtils.values = function(obj) {
var keys = NetworkUtils.keys(obj);
var length = keys.length;
var values = Array(length);
for (var i = 0; i < length; i++) {
values[i] = obj[keys[i]];
}
return values;
};
NetworkUtils.noop = function() {};
NetworkUtils.cutstr = function(str, len) {
var temp,
icount = 0,
patrn = /[^\x00-\xff]/,
strre = "";
for (var i = 0; i < str.length; i++) {
if (icount < len - 1) {
temp = str.substr(i, 1);
if (patrn.exec(temp) == null) {
icount = icount + 1;
} else {
icount = icount + 2;
}
strre += temp;
} else {
break;
}
}
if (str == strre) {
return strre;
} else {
return strre + "...";
}
};
NetworkUtils.clamp = function(n, min, max) {
if (n < min) return min;
if (n > max) return max;
return n;
};
NetworkUtils.Progress = {};
NetworkUtils.Progress.settings = {
minimum: 0.1,
trickle: true,
trickleRate: 0.3,
trickleSpeed: 100
};
NetworkUtils.Progress.status = null;
NetworkUtils.Progress.set = function(n) {
var progress = NetworkUtils.Progress;
n = NetworkUtils.clamp(n, progress.settings.minimum, 1);
progress.status = n;
progress.cb(progress.status);
return this;
};
NetworkUtils.Progress.inc = function(amount) {
var progress = NetworkUtils.Progress,
n = progress.status;
if (!n) {
return progress.start();
} else {
amount = (1 - n) * NetworkUtils.clamp(Math.random() * n, 0.1, 0.95);
n = NetworkUtils.clamp(n + amount, 0, 0.994);
return progress.set(n);
}
};
NetworkUtils.Progress.trickle = function() {
var progress = NetworkUtils.Progress;
return progress.inc(Math.random() * progress.settings.trickleRate);
};
NetworkUtils.Progress.start = function(cb) {
var progress = NetworkUtils.Progress;
progress.cb = cb || NetworkUtils.noop;
if (!progress.status) progress.set(0);
var _timer = function timer() {
if (progress.status === 1) {
clearTimeout(_timer);
_timer = null;
return;
}
progress.trickle();
work();
};
var work = function work() {
setTimeout(_timer, progress.settings.trickleSpeed);
};
if (progress.settings.trickle) work();
return this;
};
NetworkUtils.Progress.done = function() {
var progress = NetworkUtils.Progress;
return progress.inc(0.3 + 0.5 * Math.random()).set(1);
};
NetworkUtils.decode = decodeURIComponent;
NetworkUtils.encode = encodeURIComponent;
NetworkUtils.formData = function(o) {
var kvps = [],
regEx = /%20/g;
for (var k in o) {
if (!o[k]) continue;
kvps.push(NetworkUtils.encode(k).replace(regEx, "+") + "=" + NetworkUtils.encode(o[k].toString()).replace(regEx, "+"));
}
return kvps.join('&');
};
NetworkUtils.ajax = function(o) {
var xhr = cc.loader.getXMLHttpRequest();
o = Object.assign({
type: "GET",
data: null,
dataType: 'json',
progress: null,
contentType: "application/x-www-form-urlencoded"
}, o);
if (o.progress) NetworkUtils.Progress.start(o.progress);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status < 300) {
var res;
if (o.dataType == 'json') {
if (xhr.responseText) {
res = window.JSON ? window.JSON.parse(xhr.responseText) : eval(xhr.responseText);
}
} else {
res = xhr.responseText;
}
if (!!res) o.success(res);
if (o.progress) NetworkUtils.Progress.done();
} else {
if (o.error) o.error(xhr, xhr.status, xhr.statusText);
}
}
}; //if("withCredentials" in xhr) xhr.withCredentials = true;
var url = o.url,
data = null;
var isPost = o.type === "POST" || o.type === "PUT";
if (o.data) {
if (!isPost) {
url += "?" + NetworkUtils.formData(o.data);
data = null;
} else if (isPost && _typeof(o.data) === 'object') {
data = NetworkUtils.formData(o.data);
} else {
data = o.data;
}
}
xhr.open(o.type, url, true);
if (isPost) {
xhr.setRequestHeader("Content-Type", o.contentType);
}
xhr.timeout = 3000;
xhr.ontimeout = function() {
// XMLHttpRequest 超时
if ('function' === typeof o.timeout) {
o.timeout();
}
};
xhr.onerror = function() {
if ('function' === typeof o.error) {
o.error();
}
}
xhr.send(data);
return xhr;
};
NetworkUtils.get = function(url, data, success, error) {
if (NetworkUtils.isFunction(data)) {
error = success;
success = data;
data = {};
}
NetworkUtils.ajax({
url: url,
type: "GET",
data: data,
success: success,
error: error || NetworkUtils.noop
});
};
NetworkUtils.post = function(url, data, success, error, timeout) {
if (NetworkUtils.isFunction(data)) {
error = success;
success = data;
data = {};
}
NetworkUtils.ajax({
url: url,
type: "POST",
data: data,
success: success,
error: error || NetworkUtils.noop,
timeout: timeout
});
};
NetworkUtils.now = Date.now || function() {
return new Date().getTime();
};
NetworkUtils.same = function(s) {
return s;
};
NetworkUtils.parseCookieString = function(text) {
var cookies = {};
if (NetworkUtils.isString(text) && text.length > 0) {
var cookieParts = text.split(/;\s/g);
var cookieName;
var cookieValue;
var cookieNameValue;
for (var i = 0, len = cookieParts.length; i < len; i++) {
// Check for normally-formatted cookie (name-value)
cookieNameValue = cookieParts[i].match(/([^=]+)=/i);
if (cookieNameValue instanceof Array) {
try {
cookieName = NetworkUtils.decode(cookieNameValue[1]);
cookieValue = cookieParts[i].substring(cookieNameValue[1].length + 1);
} catch (ex) { // Intentionally ignore the cookie -
// the encoding is wrong
}
} else {
// Means the cookie does not have an =", so treat it as
// a boolean flag
cookieName = NetworkUtils.decode(cookieParts[i]);
cookieValue = '';
}
if (cookieName) {
cookies[cookieName] = cookieValue;
}
}
}
return cookies;
};
NetworkUtils.getCookie = function(name) {
if (!NetworkUtils.isNotEmptyString(name)) {
throw new TypeError('Cookie name must be a non-empty string');
}
var cookies = NetworkUtils.parseCookieString(document.cookie);
return cookies[name];
};
NetworkUtils.setCookie = function(name, value, options) {
if (!NetworkUtils.isNotEmptyString(name)) {
throw new TypeError('Cookie name must be a non-empty string');
}
options = options || {};
var expires = options['expires'];
var domain = options['domain'];
var path = options['path'];
if (!options['raw']) {
value = NetworkUtils.encode(String(value));
}
var text = name + '=' + value; // expires
var date = expires;
if (typeof date === 'number') {
date = new Date();
date.setDate(date.getDate() + expires);
}
if (date instanceof Date) {
text += '; expires=' + date.toUTCString();
} // domain
if (NetworkUtils.isNotEmptyString(domain)) {
text += '; domain=' + domain;
} // path
if (NetworkUtils.isNotEmptyString(path)) {
text += '; path=' + path;
} // secure
if (options['secure']) {
text += '; secure';
}
document.cookie = text;
return text;
};
NetworkUtils.removeCookie = function(name, options) {
options = options || {};
options['expires'] = new Date(0);
return NetworkUtils.setCookie(name, '', options);
};
NetworkUtils.dragNode = function(node) {
var isMoving = false,
size = cc.director.getVisibleSize(),
touchLoc = void 0,
oldPos = void 0,
moveToPos = void 0;
node.on(cc.Node.EventType.TOUCH_START, function(event) {
var touches = event.getTouches();
touchLoc = touches[0].getLocation();
oldPos = node.position;
});
node.on(cc.Node.EventType.TOUCH_MOVE, function(event) {
var touches = event.getTouches();
moveToPos = touches[0].getLocation();
isMoving = true;
});
node.on(cc.Node.EventType.TOUCH_END, function(event) {
isMoving = false;
});
return function() {
if (!isMoving) return;
var x = oldPos.x + moveToPos.x - touchLoc.x;
var xEdge = node.width * node.anchorX / 2;
if (Math.abs(x) < xEdge) {
node.x = x;
} else {
node.x = x > 0 ? xEdge : -xEdge;
isMoving = false;
}
if (node.height > size.height) {
var y = oldPos.y + moveToPos.y - touchLoc.y;
var yEdge = (node.height - size.height) / 2;
if (Math.abs(y) < yEdge) {
node.y = y;
} else {
node.y = y > 0 ? yEdge : -yEdge;
isMoving = false;
}
}
};
};
NetworkUtils.getQueryVariable = function(key) {
var query = cc.sys.platform == cc.sys.WECHAT_GAME ? '' : window.location.search.substring(1),
vars = query.split('&');
for (var i = 0, l = vars.length; i < l; i++) {
var pair = vars[i].split('=');
if (decodeURIComponent(pair[0]) === key) {
return decodeURIComponent(pair[1]);
}
}
};

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "c116dddb-470e-47de-af9b-560adb7c78fb",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,200 @@
"use strict";
window.getQueryParamDict = function() {
// Kindly note that only the first occurrence of duplicated keys will be picked up.
var query = cc.sys.platform == cc.sys.WECHAT_GAME ? '' : window.location.search.substring(1);
var kvPairs = query.split('&');
var toRet = {};
for (var i = 0; i < kvPairs.length; ++i) {
var kAndV = kvPairs[i].split('=');
if (undefined === kAndV || null === kAndV || 2 != kAndV.length) return;
var k = kAndV[0];
var v = decodeURIComponent(kAndV[1]);
toRet[k] = v;
}
return toRet;
}
let IS_USING_WKWECHAT_KERNEL = null;
window.isUsingWebkitWechatKernel = function() {
if (null == IS_USING_WKWECHAT_KERNEL) {
// The extraction of `browserType` might take a considerable amount of time in mobile browser kernels.
IS_USING_WKWECHAT_KERNEL = (cc.sys.BROWSER_TYPE_WECHAT == cc.sys.browserType);
}
return IS_USING_WKWECHAT_KERNEL;
};
let IS_USING_X5_BLINK_KERNEL = null;
window.isUsingX5BlinkKernel = function() {
if (null == IS_USING_X5_BLINK_KERNEL) {
// The extraction of `browserType` might take a considerable amount of time in mobile browser kernels.
IS_USING_X5_BLINK_KERNEL = (cc.sys.BROWSER_TYPE_MOBILE_QQ == cc.sys.browserType);
}
return IS_USING_X5_BLINK_KERNEL;
};
let IS_USING_X5_BLINK_KERNEL_OR_WKWECHAT_KERNEL = null;
window.isUsingX5BlinkKernelOrWebkitWeChatKernel = function() {
if (null == IS_USING_X5_BLINK_KERNEL_OR_WKWECHAT_KERNEL) {
// The extraction of `browserType` might take a considerable amount of time in mobile browser kernels.
IS_USING_X5_BLINK_KERNEL_OR_WKWECHAT_KERNEL = (cc.sys.BROWSER_TYPE_MOBILE_QQ == cc.sys.browserType || cc.sys.BROWSER_TYPE_WECHAT == cc.sys.browserType);
}
return IS_USING_X5_BLINK_KERNEL_OR_WKWECHAT_KERNEL;
};
window.getRandomInt = function(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
window.safelyAssignParent = function(proposedChild, proposedParent) {
if (proposedChild.parent == proposedParent) return false;
proposedChild.parent = proposedParent;
return true;
};
window.get2dRotation = function(aCCNode) {
// return aCCNode.rotation; // For cc2.0+
return aCCNode.angle; // For cc2.1+
};
window.set2dRotation = function(aCCNode, clockwiseAngle) {
// aCCNode.rotation = angle; // For cc2.0+
aCCNode.angle = -clockwiseAngle; // For cc2.1+
};
window.setLocalZOrder = function(aCCNode, zIndex) {
aCCNode.zIndex = zIndex; // For cc2.0+
};
window.getLocalZOrder = function(aCCNode) {
return aCCNode.zIndex; // For cc2.0+
};
window.safelyAddChild = function(proposedParent, proposedChild) {
if (proposedChild.parent == proposedParent) return false;
setLocalZOrder(proposedChild, getLocalZOrder(proposedParent) + 1);
proposedParent.addChild(proposedChild);
return true;
};
window.setVisible = function(aCCNode) {
aCCNode.opacity = 255;
};
window.setInvisible = function(aCCNode) {
aCCNode.opacity = 0;
};
window.randomProperty = function (obj) {
var keys = Object.keys(obj)
return obj[keys[ keys.length * Math.random() << 0]];
};
window.gidSpriteFrameMap = {};
window.getOrCreateSpriteFrameForGid = function(gid, tiledMapInfo, tilesElListUnderTilesets) {
if (null != gidSpriteFrameMap[gid]) return gidSpriteFrameMap[gid];
if (false == gidSpriteFrameMap[gid]) return null;
var tilesets = tiledMapInfo.getTilesets();
var targetTileset = null;
for (var i = 0; i < tilesets.length; ++i) {
// TODO: Optimize by binary search.
if (gid < tilesets[i].firstGid) continue;
if (i < tilesets.length - 1) {
if (gid >= tilesets[i + 1].firstGid) continue;
}
targetTileset = tilesets[i];
break;
}
if (!targetTileset) return null;
var tileIdWithinTileset = (gid - targetTileset.firstGid);
var tilesElListUnderCurrentTileset = tilesElListUnderTilesets[targetTileset.name + ".tsx"];
var targetTileEl = null;
for (var tileIdx = 0; tileIdx < tilesElListUnderCurrentTileset.length; ++tileIdx) {
var tmpTileEl = tilesElListUnderCurrentTileset[tileIdx];
if (tileIdWithinTileset != parseInt(tmpTileEl.id)) continue;
targetTileEl = tmpTileEl;
break;
}
var tileId = tileIdWithinTileset;
var tilesPerRow = (targetTileset.sourceImage.width / targetTileset._tileSize.width);
var row = parseInt(tileId / tilesPerRow);
var col = (tileId % tilesPerRow);
var offset = cc.v2(targetTileset._tileSize.width * col, targetTileset._tileSize.height * row);
var origSize = targetTileset._tileSize;
var rect = cc.rect(offset.x, offset.y, origSize.width, origSize.height);
var sf = new cc.SpriteFrame(targetTileset.sourceImage, rect, false /* rotated */ , cc.v2() /* DON'T use `offset` here or you will have an offsetted image from the `cc.Sprite.node.anchor`. */, origSize);
const data = {
origSize: targetTileset._tileSize,
spriteFrame: sf,
}
window.gidSpriteFrameMap[gid] = data;
return data;
}
window.gidAnimationClipMap = {};
window.getOrCreateAnimationClipForGid = function(gid, tiledMapInfo, tilesElListUnderTilesets) {
if (null != gidAnimationClipMap[gid]) return gidAnimationClipMap[gid];
if (false == gidAnimationClipMap[gid]) return null;
var tilesets = tiledMapInfo.getTilesets();
var targetTileset = null;
for (var i = 0; i < tilesets.length; ++i) {
// TODO: Optimize by binary search.
if (gid < tilesets[i].firstGid) continue;
if (i < tilesets.length - 1) {
if (gid >= tilesets[i + 1].firstGid) continue;
}
targetTileset = tilesets[i];
break;
}
if (!targetTileset) return null;
var tileIdWithinTileset = (gid - targetTileset.firstGid);
var tilesElListUnderCurrentTileset = tilesElListUnderTilesets[targetTileset.name + ".tsx"];
var targetTileEl = null;
for (var tileIdx = 0; tileIdx < tilesElListUnderCurrentTileset.length; ++tileIdx) {
var tmpTileEl = tilesElListUnderCurrentTileset[tileIdx];
if (tileIdWithinTileset != parseInt(tmpTileEl.id)) continue;
targetTileEl = tmpTileEl;
break;
}
if (!targetTileEl) return null;
var animElList = targetTileEl.getElementsByTagName("animation");
if (!animElList || 0 >= animElList.length) return null;
var animEl = animElList[0];
var uniformDurationSecondsPerFrame = null;
var totDurationSeconds = 0;
var sfList = [];
var frameElListUnderAnim = animEl.getElementsByTagName("frame");
var tilesPerRow = (targetTileset.sourceImage.width/targetTileset._tileSize.width);
for (var k = 0; k < frameElListUnderAnim.length; ++k) {
var frameEl = frameElListUnderAnim[k];
var tileId = parseInt(frameEl.attributes.tileid.value);
var durationSeconds = frameEl.attributes.duration.value/1000;
if (null == uniformDurationSecondsPerFrame) uniformDurationSecondsPerFrame = durationSeconds;
totDurationSeconds += durationSeconds;
var row = parseInt(tileId / tilesPerRow);
var col = (tileId % tilesPerRow);
var offset = cc.v2(targetTileset._tileSize.width*col, targetTileset._tileSize.height*row);
var origSize = targetTileset._tileSize;
var rect = cc.rect(offset.x, offset.y, origSize.width, origSize.height);
var sf = new cc.SpriteFrame(targetTileset.sourceImage, rect, false /* rotated */, cc.v2(), origSize);
sfList.push(sf);
}
var sampleRate = 1/uniformDurationSecondsPerFrame; // A.k.a. fps.
var animClip = cc.AnimationClip.createWithSpriteFrames(sfList, sampleRate);
// http://docs.cocos.com/creator/api/en/enums/WrapMode.html.
animClip.wrapMode = cc.WrapMode.Loop;
return {
origSize: targetTileset._tileSize,
animationClip: animClip,
};
};

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "c119f5bb-720a-4ac8-960f-6f5eeda0c360",
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,37 @@
"use strict";
if (CC_DEBUG) {
var backendAddress = {
PROTOCOL: 'http',
HOST: 'localhost',
PORT: "9992",
WS_PATH_PREFIX: "/tsrht",
};
var wechatAddress = {
PROTOCOL: "http",
HOST: "119.29.236.44",
PORT: "8089",
PROXY: "",
APPID_LITERAL: "appid=wx5432dc1d6164d4e",
};
} else {
var backendAddress = {
PROTOCOL: 'https',
HOST: 'tsrht.lokcol.com',
PORT: "443",
WS_PATH_PREFIX: "/tsrht",
};
var wechatAddress = {
PROTOCOL: "https",
HOST: "open.weixin.qq.com",
PORT: "",
PROXY: "",
APPID_LITERAL: "appid=wxe7063ab415266544",
};
}
window.language = "zh";
window.backendAddress = backendAddress;
window.wechatAddress = wechatAddress;

View File

@@ -0,0 +1,5 @@
{
"ver": "1.0.1",
"uuid": "1712c9ec-6940-4356-a87d-37887608f224",
"subMetas": {}
}

View File

@@ -0,0 +1,170 @@
"use strict";
var _ROUTE_PATH;
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
var constants = {
BGM: {
DIR_PATH: "resources/musicEffect/",
FILE_NAME: {
TREASURE_PICKEDUP: "TreasurePicked",
CRASHED_BY_TRAP_BULLET: "CrashedByTrapBullet",
HIGH_SCORE_TREASURE_PICKED:"HighScoreTreasurePicked",
COUNT_DOWN_10SEC_TO_END:"countDown10SecToEnd",
BGM: "BGM"
}
},
PLAYER_NAME: {
1: "Merdan",
2: "Monroe",
},
SOCKET_EVENT: {
CONTROL: "control",
SYNC: "sync",
LOGIN: "login",
CREATE: "create"
},
WECHAT: {
AUTHORIZE_PATH: "/connect/oauth2/authorize",
REDIRECT_RUI_KEY: "redirect_uri=",
RESPONSE_TYPE: "response_type=code",
SCOPE: "scope=snsapi_userinfo",
FIN: "#wechat_redirect"
},
ROUTE_PATH: (_ROUTE_PATH = {
PLAYER: "/player",
JSCONFIG: "/jsconfig",
API: "/api",
VERSION: "/v1",
SMS_CAPTCHA: "/SmsCaptcha",
INT_AUTH_TOKEN: "/IntAuthToken",
LOGIN: "/login",
LOGOUT: "/logout",
GET: "/get",
TUTORIAL: "/tutorial",
REPORT: "/report",
LIST: "/list",
READ: "/read",
PROFILE: "/profile",
WECHAT: "/wechat",
WECHATGAME: "/wechatGame",
FETCH: "/fetch",
}, _defineProperty(_ROUTE_PATH, "LOGIN", "/login"), _defineProperty(_ROUTE_PATH, "RET_CODE", "/retCode"), _defineProperty(_ROUTE_PATH, "REGEX", "/regex"), _defineProperty(_ROUTE_PATH, "SMS_CAPTCHA", "/SmsCaptcha"), _defineProperty(_ROUTE_PATH, "GET", "/get"), _ROUTE_PATH),
REQUEST_QUERY: {
ROOM_ID: "roomId",
TOKEN: "/token"
},
GAME_SYNC: {
SERVER_UPSYNC: 30,
CLIENT_UPSYNC: 30
},
RET_CODE: {
/**
* NOTE: The "RET_CODE"s from 1000-1015 are reserved for the websocket "WebsocketStdCloseCode"s.
*
* References
* - https://tools.ietf.org/html/rfc6455#section-7.4
* - https://godoc.org/github.com/gorilla/websocket#pkg-constants.
*/
"__comment__": "基础",
"OK": 9000,
"UNKNOWN_ERROR": 9001,
"INVALID_REQUEST_PARAM": 9002,
"IS_TEST_ACC": 9003,
"MYSQL_ERROR": 9004,
"NONEXISTENT_ACT": 9005,
"LACK_OF_DIAMOND": 9006,
"LACK_OF_GOLD": 9007,
"LACK_OF_ENERGY": 9008,
"NONEXISTENT_ACT_HANDLER": 9009,
"LOCALLY_NO_AVAILABLE_ROOM": 9010,
"LOCALLY_NO_SPECIFIED_ROOM": 9011,
"PLAYER_NOT_ADDABLE_TO_ROOM": 9012,
"PLAYER_NOT_READDABLE_TO_ROOM": 9013,
"PLAYER_NOT_FOUND": 9014,
"PLAYER_CHEATING": 9015,
"__comment__": "SMS",
"SMS_CAPTCHA_REQUESTED_TOO_FREQUENTLY": 5001,
"SMS_CAPTCHA_NOT_MATCH": 5002,
"INVALID_TOKEN": 2001,
"DUPLICATED": 2002,
"INCORRECT_HANDLE": 2004,
"NONEXISTENT_HANDLE": 2005,
"INCORRECT_PASSWORD": 2006,
"INCORRECT_CAPTCHA": 2007,
"INVALID_EMAIL_LITERAL": 2008,
"NO_ASSOCIATED_EMAIL": 2009,
"SEND_EMAIL_TIMEOUT": 2010,
"INCORRECT_PHONE_COUNTRY_CODE": 2011,
"NEW_HANDLE_CONFLICT": 2013,
"FAILED_TO_UPDATE": 2014,
"FAILED_TO_DELETE": 2015,
"FAILED_TO_CREATE": 2016,
"INCORRECT_PHONE_NUMBER": 2018,
"PASSWORD_RESET_CODE_GENERATION_PER_EMAIL_TOO_FREQUENTLY": 4000,
"TRADE_CREATION_TOO_FREQUENTLY": 4002,
"MAP_NOT_UNLOCKED": 4003,
"NOT_IMPLEMENTED_YET": 65535
},
ALERT: {
TIP_NODE: 'captchaTips',
TIP_LABEL: {
INCORRECT_PHONE_COUNTRY_CODE: '国家号不正确',
CAPTCHA_ERR: '验证码不正确',
PHONE_ERR: '手机号格式不正确',
TOKEN_EXPIRED: 'token已过期!',
SMS_CAPTCHA_FREEQUENT_REQUIRE: '请求过于频繁',
SMS_CAPTCHA_NOT_MATCH: '验证码不正确',
TEST_USER: '该账号为测试账号',
INCORRECT_PHONE_NUMBER: '手机号不正确',
LOG_OUT: '您已在其他地方登陆',
GAME_OVER: '游戏结束,您的得分是',
WECHAT_LOGIN_FAILS: "微信登录失败",
},
CONFIRM_BUTTON_LABEL: {
RESTART: '重新开始'
}
},
PLAYER: '玩家',
ONLINE: '在线',
NOT_ONLINE: '',
SPEED: {
NORMAL: 100,
PAUSE: 0
},
COUNTDOWN_LABEL: {
BASE: '倒计时 ',
MINUTE: '00',
SECOND: '30'
},
SCORE_LABEL: {
BASE: '分数 ',
PLUS_SCORE: 5,
MINUS_SECOND: 5,
INIT_SCORE: 0
},
TUTORIAL_STAGE: {
NOT_YET_STARTED: 0,
ENDED: 1,
},
};
window.constants = constants;

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "31ca9500-50c9-44f9-8d33-f9a969e53195",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "bd514df4-095e-4088-9060-d99397a29a4f",
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}