add minion routing
This commit is contained in:
+19
-16
@@ -31,17 +31,19 @@ app.ws('/ws', async (req, res) => {
|
||||
const message = JSON.parse(rawData)
|
||||
const entity = message.id != null ? game.entities.find((e) => e.id == message.id) : null
|
||||
if (entity == null) {
|
||||
console.log({ error: { reason: 'Invalid ID', message } })
|
||||
console.error({ error: { reason: 'Invalid ID', message } })
|
||||
return
|
||||
}
|
||||
console.log(message)
|
||||
else {
|
||||
console.log(message)
|
||||
}
|
||||
|
||||
if (message.action == 'attack') {
|
||||
entity.attackAction(message.x, message.y)
|
||||
entity.attackAction(new Vector2(message.x, message.y))
|
||||
}
|
||||
|
||||
if (message.action == 'cast') {
|
||||
entity.castAction(message.slot, message.x, message.y)
|
||||
entity.castAction(message.slot, new Vector2(message.x, message.y))
|
||||
}
|
||||
|
||||
if (message.action == 'halt') {
|
||||
@@ -53,7 +55,7 @@ app.ws('/ws', async (req, res) => {
|
||||
}
|
||||
|
||||
if (message.action == 'move') {
|
||||
entity.moveAction(message.x, message.y)
|
||||
entity.moveAction(new Vector2(message.x, message.y))
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -65,6 +67,7 @@ function laneScenario() {
|
||||
team: Team.blue,
|
||||
}))
|
||||
game.spawnEntity(player1)
|
||||
player1.attackAction(new Vector2(500, 150))
|
||||
|
||||
const player2 = new Entity(Template.player({
|
||||
id: '2',
|
||||
@@ -72,12 +75,10 @@ function laneScenario() {
|
||||
team: Team.red,
|
||||
}))
|
||||
game.spawnEntity(player2)
|
||||
player2.attackAction(new Vector2(1600, 1800))
|
||||
|
||||
player1.attackAction(500, 150)
|
||||
player2.attackAction(1600, 1800)
|
||||
|
||||
const midWallStart = new Vector2(400, 400)
|
||||
const midWallEnd = new Vector2(1600, 1600)
|
||||
const midWallStart = new Vector2(600, 600)
|
||||
const midWallEnd = new Vector2(1400, 1400)
|
||||
const midWallMiddle = new Vector2(800, 1200)
|
||||
const midWallThickness = midWallEnd.clone().sub(midWallStart).rotateAround(new Vector2(), -Math.PI / 2).normalize().multiplyScalar(50)
|
||||
const midWallPoints = [
|
||||
@@ -89,13 +90,13 @@ function laneScenario() {
|
||||
midWallStart.clone().add(midWallThickness),
|
||||
]
|
||||
|
||||
const midNorthWallOffset = new Vector2(-200, 200)
|
||||
const midNorthWallOffset = new Vector2(-400, 400)
|
||||
const midNorthWallPoints = midWallPoints.map((p) => p.clone().add(midNorthWallOffset))
|
||||
const midNorthWall = new Terrain(midNorthWallPoints)
|
||||
midNorthWall.id = 'midNorthWall'
|
||||
game.addTerrain(midNorthWall)
|
||||
|
||||
const midSouthWallOffset = new Vector2(200, -200)
|
||||
const midSouthWallOffset = new Vector2(0, 0)
|
||||
const midSouthWallPoints = midWallPoints.map((p) => p.clone().add(midSouthWallOffset))
|
||||
const midSouthWall = new Terrain(midSouthWallPoints)
|
||||
midSouthWall.id = 'midSouthWall'
|
||||
@@ -104,14 +105,16 @@ function laneScenario() {
|
||||
const gameLogic = function gameLogic() {
|
||||
const game = this
|
||||
|
||||
const blueRoute = [new Vector2(600, 1350), new Vector2(1900, 1900)]
|
||||
const redRoute = [new Vector2(600, 1350), new Vector2(100, 100)]
|
||||
if ([(0 * game.tickRate), (1 * game.tickRate), (2 * game.tickRate)].includes(game.currentTick % (30 * game.tickRate))) {
|
||||
game.spawnEntity(new Entity(Template.minion(Team.blue, { ranged: false })))
|
||||
game.spawnEntity(new Entity(Template.minion(Team.red, { ranged: false })))
|
||||
game.spawnEntity(new Entity(Template.minion(Team.blue, { ranged: false, route: blueRoute })))
|
||||
game.spawnEntity(new Entity(Template.minion(Team.red, { ranged: false, route: redRoute })))
|
||||
}
|
||||
|
||||
if ([(3 * game.tickRate), (4 * game.tickRate), (5 * game.tickRate)].includes(game.currentTick % (30 * game.tickRate))) {
|
||||
game.spawnEntity(new Entity(Template.minion(Team.blue, { ranged: true })))
|
||||
game.spawnEntity(new Entity(Template.minion(Team.red, { ranged: true })))
|
||||
game.spawnEntity(new Entity(Template.minion(Team.blue, { ranged: true, route: blueRoute })))
|
||||
game.spawnEntity(new Entity(Template.minion(Team.red, { ranged: true, route: redRoute })))
|
||||
}
|
||||
}
|
||||
game.logic = gameLogic
|
||||
|
||||
Reference in New Issue
Block a user