inflate ranges by entity radii
This commit is contained in:
+43
-42
@@ -66,25 +66,27 @@ function laneScenario() {
|
||||
}
|
||||
}
|
||||
|
||||
const entity1 = new Entity({
|
||||
id: '1',
|
||||
const playerTemplate = {
|
||||
height: 80,
|
||||
logic: playerLogic,
|
||||
maxHealth: 100,
|
||||
maxHealth: 600,
|
||||
spawnPosition: new Vector2(500, 150),
|
||||
radius: 65,
|
||||
}
|
||||
|
||||
const entity1 = new Entity({
|
||||
...playerTemplate,
|
||||
id: '1',
|
||||
spawnPosition: new Vector2(500, 150),
|
||||
radius: 50,
|
||||
team: Team.blue,
|
||||
})
|
||||
|
||||
game.spawnEntity(entity1)
|
||||
|
||||
const entity2 = new Entity({
|
||||
...playerTemplate,
|
||||
id: '2',
|
||||
height: 80,
|
||||
logic: playerLogic,
|
||||
maxHealth: 100,
|
||||
spawnPosition: new Vector2(1600, 1800),
|
||||
radius: 50,
|
||||
team: Team.red,
|
||||
})
|
||||
|
||||
@@ -115,39 +117,38 @@ function laneScenario() {
|
||||
midSouthWall.id = 'midSouthWall'
|
||||
game.addTerrain(midSouthWall)
|
||||
|
||||
const blueMinionLogic = function minionLogic() {
|
||||
const entity = this
|
||||
if (entity.dead) { entity.despawn() }
|
||||
const minionLogic = (team) => {
|
||||
const finalGoal = team == Team.blue ? new Vector2(1900, 1900) : new Vector2(100, 100)
|
||||
const subGoal = new Vector2(850, 1150)
|
||||
const subGoalCheck = team == Team.blue ? ((entity) => entity.position.x < 800 || entity.position.y < 1100) : ((entity) => entity.position.x > 900 || entity.position.y > 1200)
|
||||
|
||||
let goal = new Vector2(1900, 1900)
|
||||
if (entity.position.x < 800 || entity.position.y < 1100) {
|
||||
goal = new Vector2(850, 1150)
|
||||
return function builtMinionLogic() {
|
||||
const entity = this
|
||||
if (entity.dead) { entity.despawn() }
|
||||
|
||||
let goal = finalGoal
|
||||
if (subGoalCheck(entity)) {
|
||||
goal = subGoal
|
||||
}
|
||||
|
||||
const direction = goal.clone().sub(entity.position).normalize().multiplyScalar(100)
|
||||
const fakeDestination = entity.position.clone().add(direction)
|
||||
entity.attackAction(fakeDestination.x, fakeDestination.y)
|
||||
}
|
||||
|
||||
const direction = goal.clone().sub(entity.position).normalize().multiplyScalar(75)
|
||||
const subGoal = entity.position.clone().add(direction)
|
||||
entity.attackAction(subGoal.x, subGoal.y)
|
||||
}
|
||||
|
||||
const redMinionLogic = function minionLogic() {
|
||||
const entity = this
|
||||
if (entity.dead) { entity.despawn() }
|
||||
|
||||
let goal = new Vector2(100, 100)
|
||||
if (entity.position.x > 900 || entity.position.y > 1200) {
|
||||
goal = new Vector2(850, 1150)
|
||||
}
|
||||
|
||||
const direction = goal.clone().sub(entity.position).normalize().multiplyScalar(75)
|
||||
const subGoal = entity.position.clone().add(direction)
|
||||
entity.attackAction(subGoal.x, subGoal.y)
|
||||
}
|
||||
|
||||
const minionTemplate = {
|
||||
health: 20,
|
||||
maxHealth: 20,
|
||||
radius: 30,
|
||||
speed: 300,
|
||||
height: 40,
|
||||
maxHealth: 300,
|
||||
radius: 48,
|
||||
speed: 325,
|
||||
}
|
||||
|
||||
const meleeMinionTemplate = {
|
||||
...minionTemplate,
|
||||
height: 38,
|
||||
radius: 46,
|
||||
maxHealth: 450,
|
||||
}
|
||||
|
||||
const gameLogic = function gameLogic() {
|
||||
@@ -155,14 +156,14 @@ function laneScenario() {
|
||||
|
||||
const blueMinion = new Entity({
|
||||
...minionTemplate,
|
||||
logic: blueMinionLogic,
|
||||
logic: minionLogic(Team.blue),
|
||||
team: Team.blue,
|
||||
position: new Vector2(200, 200),
|
||||
})
|
||||
|
||||
const blueMeleeMinion = new Entity({
|
||||
...minionTemplate,
|
||||
logic: blueMinionLogic,
|
||||
...meleeMinionTemplate,
|
||||
logic: minionLogic(Team.blue),
|
||||
team: Team.blue,
|
||||
position: new Vector2(200, 200),
|
||||
})
|
||||
@@ -170,14 +171,14 @@ function laneScenario() {
|
||||
|
||||
const redMinion = new Entity({
|
||||
...minionTemplate,
|
||||
logic: redMinionLogic,
|
||||
logic: minionLogic(Team.red),
|
||||
team: Team.red,
|
||||
position: new Vector2(1800, 1800),
|
||||
})
|
||||
|
||||
const redMeleeMinion = new Entity({
|
||||
...minionTemplate,
|
||||
logic: redMinionLogic,
|
||||
...meleeMinionTemplate,
|
||||
logic: minionLogic(Team.red),
|
||||
team: Team.red,
|
||||
position: new Vector2(1800, 1800),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user