add bbox checks to pathfinding graphs
This commit is contained in:
+43
-29
@@ -1,5 +1,4 @@
|
||||
import { Vector2 } from 'three'
|
||||
import Ability from './ability.js'
|
||||
import Entity from './entity.js'
|
||||
import Team from './team.js'
|
||||
import Template from './template.js'
|
||||
@@ -10,36 +9,51 @@ export class Dungeon {
|
||||
game.width = 3000
|
||||
game.height = 3000
|
||||
|
||||
const playerSpawn = new Vector2(game.width / 2, game.height / 2)
|
||||
game.spawnEntity(new Entity(Template.player({ id: '1', spawnPosition: playerSpawn, position: new Vector2(playerSpawn.x - 1300, playerSpawn.y - 500), team: Team.blue })))
|
||||
const dummyLogic = function dummyLogic() {
|
||||
const entity = this
|
||||
if (entity.position.x > 1250) {
|
||||
entity.moveAction(new Vector2(500, entity.position.y))
|
||||
}
|
||||
else if (entity.position.x < 550 || entity.destination == null) {
|
||||
entity.moveAction(new Vector2(1300, entity.position.y))
|
||||
}
|
||||
// const playerSpawn = new Vector2(game.width / 2, game.height / 2)
|
||||
// game.spawnEntity(new Entity(Template.player({ id: '1', spawnPosition: playerSpawn, position: new Vector2(playerSpawn.x - 1300, playerSpawn.y - 500), team: Team.blue })))
|
||||
// const dummyLogic = function dummyLogic() {
|
||||
// const entity = this
|
||||
// if (entity.position.x > 1250) {
|
||||
// entity.moveAction(new Vector2(500, entity.position.y))
|
||||
// }
|
||||
// else if (entity.position.x < 550 || entity.destination == null) {
|
||||
// entity.moveAction(new Vector2(1300, entity.position.y))
|
||||
// }
|
||||
|
||||
if (game.currentTick > 0 && game.currentTick % (6 * game.tickRate) == 0) {
|
||||
entity.castAction('q', playerSpawn)
|
||||
}
|
||||
// if (game.currentTick > 0 && game.currentTick % (6 * game.tickRate) == 0) {
|
||||
// entity.castAction('q', playerSpawn)
|
||||
// }
|
||||
// }
|
||||
// const dummy = { radius: 100, visualRadius: 50, abilities: { q: Ability.straightShot.id }, logic: dummyLogic }
|
||||
// game.spawnEntity(new Entity({ ...dummy, position: new Vector2(1 * (game.width / 5), 1 * (game.height / 4)) }))
|
||||
// game.spawnEntity(new Entity({ ...dummy, position: new Vector2(1 * (game.width / 5), 3 * (game.height / 4)) }))
|
||||
// game.addTerrain(new Terrain([
|
||||
// new Vector2(3.5 * (game.width / 10), 1.6 * (game.height / 5)),
|
||||
// new Vector2(3.5 * (game.width / 10), 1.4 * (game.height / 5)),
|
||||
// new Vector2(4 * (game.width / 10), 1.4 * (game.height / 5)),
|
||||
// new Vector2(4 * (game.width / 10), 1.6 * (game.height / 5)),
|
||||
// ]))
|
||||
// game.addTerrain(new Terrain([
|
||||
// new Vector2(3 * (game.width / 10), 2 * (game.height / 5)),
|
||||
// new Vector2(3 * (game.width / 10), 1 * (game.height / 5)),
|
||||
// new Vector2(4 * (game.width / 10), 1 * (game.height / 5)),
|
||||
// new Vector2(4 * (game.width / 10), 2 * (game.height / 5)),
|
||||
// ], false))
|
||||
|
||||
const from = new Vector2(100, 100)
|
||||
game.height = 2000
|
||||
game.spawnEntity(new Entity(Template.player({ id: '1', spawnPosition: from, pathfindingObstacleLimit: 1, pathfindingCooldown: 0 })))
|
||||
for (let i = 100; i < game.width; i += 300) {
|
||||
const highest = ((i - 100) % 600) == 0 ? 0 : 500
|
||||
const lowest = ((i - 100) % 600) == 0 ? 1500 : 2000
|
||||
game.addTerrain(new Terrain([
|
||||
new Vector2(i + 100, game.height - highest),
|
||||
new Vector2(i, game.height - highest),
|
||||
new Vector2(i, game.height - lowest),
|
||||
new Vector2(i + 100, game.height - lowest),
|
||||
]))
|
||||
}
|
||||
const dummy = { radius: 100, visualRadius: 50, abilities: { q: Ability.straightShot.id }, logic: dummyLogic }
|
||||
game.spawnEntity(new Entity({ ...dummy, position: new Vector2(1 * (game.width / 5), 1 * (game.height / 4)) }))
|
||||
game.spawnEntity(new Entity({ ...dummy, position: new Vector2(1 * (game.width / 5), 3 * (game.height / 4)) }))
|
||||
game.addTerrain(new Terrain([
|
||||
new Vector2(3.5 * (game.width / 10), 1.6 * (game.height / 5)),
|
||||
new Vector2(3.5 * (game.width / 10), 1.4 * (game.height / 5)),
|
||||
new Vector2(4 * (game.width / 10), 1.4 * (game.height / 5)),
|
||||
new Vector2(4 * (game.width / 10), 1.6 * (game.height / 5)),
|
||||
]))
|
||||
game.addTerrain(new Terrain([
|
||||
new Vector2(3 * (game.width / 10), 2 * (game.height / 5)),
|
||||
new Vector2(3 * (game.width / 10), 1 * (game.height / 5)),
|
||||
new Vector2(4 * (game.width / 10), 1 * (game.height / 5)),
|
||||
new Vector2(4 * (game.width / 10), 2 * (game.height / 5)),
|
||||
], false))
|
||||
|
||||
|
||||
game.start()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user