|
|
@@ -77,6 +77,7 @@ define([ |
|
|
|
|
|
|
|
events.on('onGetMap', this.onGetMap.bind(this)); |
|
|
|
events.on('onToggleFullscreen', this.toggleScreen.bind(this)); |
|
|
|
events.on('onGetStats', this.adaptCameraMoveSpeed.bind(this)); |
|
|
|
|
|
|
|
let zoom = isMobile ? 1 : window.devicePixelRatio; |
|
|
|
this.width = $('body').width() * zoom; |
|
|
@@ -641,15 +642,14 @@ define([ |
|
|
|
let deltaY = this.moveTo.y - this.pos.y; |
|
|
|
|
|
|
|
if (deltaX !== 0 || deltaY !== 0) { |
|
|
|
let moveSpeed = this.moveSpeed; |
|
|
|
let distance = Math.max(Math.abs(deltaX), Math.abs(deltaY)); |
|
|
|
|
|
|
|
let moveSpeedMax = this.moveSpeedMax; |
|
|
|
if (distance > 100) |
|
|
|
moveSpeedMax *= 1.75; |
|
|
|
if (this.moveSpeed < moveSpeedMax) |
|
|
|
this.moveSpeed += this.moveSpeedInc; |
|
|
|
|
|
|
|
let moveSpeed = this.moveSpeed; |
|
|
|
|
|
|
|
let elapsed = time - this.lastTick; |
|
|
|
moveSpeed *= (elapsed / 16.67); |
|
|
|
|
|
|
@@ -821,6 +821,19 @@ define([ |
|
|
|
obj.sprite.parent.removeChild(obj.sprite); |
|
|
|
}, |
|
|
|
|
|
|
|
//Changes the moveSpeedMax and moveSpeedInc variables |
|
|
|
// sprintChance: 0 | moveSpeedMax: 1.5 | moveSpeedInc: 0.5 |
|
|
|
// sprintChance: 200 | moveSpeedMax: 5.5 | moveSpeedInc: 0.2 |
|
|
|
// Between these values we should follow an exponential curve for moveSpeedInc since |
|
|
|
// a higher chance will proc more often, meaning the buildup in distance becomes greater |
|
|
|
adaptCameraMoveSpeed: function ({ sprintChance }) { |
|
|
|
const factor = Math.sqrt(sprintChance); |
|
|
|
const maxValue = Math.sqrt(200); |
|
|
|
|
|
|
|
this.moveSpeedMax = 1.5 + ((sprintChance / 200) * 4); |
|
|
|
this.moveSpeedInc = 0.2 + (((maxValue - factor) / maxValue) * 0.3); |
|
|
|
}, |
|
|
|
|
|
|
|
render: function () { |
|
|
|
if (!this.stage) |
|
|
|
return; |
|
|
|