add dead state
This commit is contained in:
+16
-36
@@ -58,12 +58,20 @@ app.ws('/ws', async (req, res) => {
|
||||
})
|
||||
|
||||
function laneScenario() {
|
||||
// TODO: proper respawn
|
||||
const playerLogic = function playerLogic() {
|
||||
const entity = this
|
||||
if (entity.dead) {
|
||||
entity.respawn()
|
||||
}
|
||||
}
|
||||
|
||||
const entity1 = new Entity({
|
||||
id: '1',
|
||||
health: 100,
|
||||
height: 80,
|
||||
logic: playerLogic,
|
||||
maxHealth: 100,
|
||||
position: new Vector2(500, 150),
|
||||
spawnPosition: new Vector2(500, 150),
|
||||
radius: 50,
|
||||
team: Team.blue,
|
||||
})
|
||||
@@ -72,10 +80,10 @@ function laneScenario() {
|
||||
|
||||
const entity2 = new Entity({
|
||||
id: '2',
|
||||
health: 100,
|
||||
height: 80,
|
||||
logic: playerLogic,
|
||||
maxHealth: 100,
|
||||
position: new Vector2(1600, 1800),
|
||||
spawnPosition: new Vector2(1600, 1800),
|
||||
radius: 50,
|
||||
team: Team.red,
|
||||
})
|
||||
@@ -107,30 +115,10 @@ function laneScenario() {
|
||||
midSouthWall.id = 'midSouthWall'
|
||||
game.addTerrain(midSouthWall)
|
||||
|
||||
// TODO: proper death and respawn
|
||||
const playerLogic = function playerLogic() {
|
||||
const entity = this
|
||||
if (entity.health <= 0) {
|
||||
if (entity.id == '1' || entity.id == '2') {
|
||||
entity.health = entity.maxHealth
|
||||
if (entity.id == '1') {
|
||||
entity.teleport(new Vector2(500, 150))
|
||||
}
|
||||
if (entity.id == '2') {
|
||||
entity.teleport(new Vector2(1600, 1800))
|
||||
}
|
||||
if (entity.id == '3') {
|
||||
entity.teleport(new Vector2(1800, 1600))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entity1.logic = playerLogic
|
||||
entity2.logic = playerLogic
|
||||
|
||||
const blueMinionLogic = function minionLogic() {
|
||||
const entity = this
|
||||
if (entity.dead) { entity.despawn() }
|
||||
|
||||
let goal = new Vector2(1900, 1900)
|
||||
if (entity.position.x < 800 || entity.position.y < 1100) {
|
||||
goal = new Vector2(850, 1150)
|
||||
@@ -139,14 +127,12 @@ function laneScenario() {
|
||||
const direction = goal.clone().sub(entity.position).normalize().multiplyScalar(75)
|
||||
const subGoal = entity.position.clone().add(direction)
|
||||
entity.attackAction(subGoal.x, subGoal.y)
|
||||
|
||||
if (entity.health <= 0) {
|
||||
entity.despawn()
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -155,10 +141,6 @@ function laneScenario() {
|
||||
const direction = goal.clone().sub(entity.position).normalize().multiplyScalar(75)
|
||||
const subGoal = entity.position.clone().add(direction)
|
||||
entity.attackAction(subGoal.x, subGoal.y)
|
||||
|
||||
if (entity.health <= 0) {
|
||||
entity.despawn()
|
||||
}
|
||||
}
|
||||
|
||||
const minionTemplate = {
|
||||
@@ -177,7 +159,6 @@ function laneScenario() {
|
||||
team: Team.blue,
|
||||
position: new Vector2(200, 200),
|
||||
})
|
||||
// blueMinion.scheduledPathfinding = game.entities.length % game.tickRate
|
||||
|
||||
const blueMeleeMinion = new Entity({
|
||||
...minionTemplate,
|
||||
@@ -193,7 +174,6 @@ function laneScenario() {
|
||||
team: Team.red,
|
||||
position: new Vector2(1800, 1800),
|
||||
})
|
||||
// redMinion.scheduledPathfinding = game.entities.length % game.tickRate
|
||||
|
||||
const redMeleeMinion = new Entity({
|
||||
...minionTemplate,
|
||||
|
||||
Reference in New Issue
Block a user