add visualRadius
This commit is contained in:
+13
-11
@@ -30,9 +30,10 @@ export default class Ability {
|
||||
name: 'Straight Shot',
|
||||
castTime: 0.25,
|
||||
cooldown: 1,
|
||||
damage: 10,
|
||||
damage: 83,
|
||||
radius: 60,
|
||||
range: 1200,
|
||||
visualRadius: 20,
|
||||
speed: 2000,
|
||||
effect: function straightShotEffect(caster, cursor) {
|
||||
const ability = this
|
||||
@@ -47,6 +48,7 @@ export default class Ability {
|
||||
position: caster.position.clone(),
|
||||
radius: ability.radius,
|
||||
speed: ability.speed,
|
||||
visualRadius: ability.visualRadius,
|
||||
})
|
||||
|
||||
projectile.destination = caster.position.clone().add(cursor.clone().sub(caster.position).normalize().multiplyScalar(ability.range + caster.radius))
|
||||
@@ -58,13 +60,13 @@ export default class Ability {
|
||||
static rangedAttack = new Ability({
|
||||
id: 'ranged_attack',
|
||||
name: 'Ranged Attack',
|
||||
castTime: 0.25,
|
||||
cooldown: 1.25,
|
||||
damage: 25,
|
||||
castTime: (1.6 * 0.18839),
|
||||
cooldown: 1.6,
|
||||
damage: 60,
|
||||
moveCancelable: true,
|
||||
radius: 5,
|
||||
range: 500,
|
||||
speed: 600,
|
||||
speed: 2000,
|
||||
effect: function rangedAttackEffect(caster, cursor) {
|
||||
const ability = this
|
||||
const target = caster.closestTargetTo(cursor, ability.range)
|
||||
@@ -110,11 +112,11 @@ export default class Ability {
|
||||
static shieldThrow = new Ability({
|
||||
id: 'shield_throw',
|
||||
name: 'Shield Throw',
|
||||
castTime: 0.15,
|
||||
castTime: 0.25,
|
||||
cooldown: 5,
|
||||
radius: 20,
|
||||
range: 1000,
|
||||
speed: 2000,
|
||||
radius: 110,
|
||||
range: 1025,
|
||||
speed: 2400,
|
||||
effect: function shieldThrowEffect(caster, cursor) {
|
||||
const ability = this
|
||||
const shieldThrowReturn = function shieldThrowReturn(projectile, homingTarget) {
|
||||
@@ -146,9 +148,9 @@ export default class Ability {
|
||||
static blink = new Ability({
|
||||
id: 'blink',
|
||||
name: 'Blink',
|
||||
castTime: 1,
|
||||
castTime: 0.25,
|
||||
cooldown: 2,
|
||||
range: 400,
|
||||
range: 475,
|
||||
effect: function blinkEffect(caster, cursor) {
|
||||
const ability = this
|
||||
const direction = cursor.clone().sub(caster.position)
|
||||
|
||||
+6
-1
@@ -13,11 +13,12 @@ export default class Entity {
|
||||
health = null
|
||||
height = 40
|
||||
maxHealth = 1
|
||||
memory = {} // TODO: WARNING: currently only used for minions (code smell?)
|
||||
memory = {}
|
||||
position = null
|
||||
radius = 0
|
||||
speed = 400
|
||||
team = Team.neutral
|
||||
visualRadius = null
|
||||
|
||||
#attacking = false
|
||||
#dest = null
|
||||
@@ -39,6 +40,9 @@ export default class Entity {
|
||||
if (this.health == null) {
|
||||
this.health = this.maxHealth
|
||||
}
|
||||
if (this.visualRadius == null) {
|
||||
this.visualRadius = this.radius
|
||||
}
|
||||
}
|
||||
|
||||
get destination() { return this.#dest }
|
||||
@@ -90,6 +94,7 @@ export default class Entity {
|
||||
|
||||
castAction(slot, cursor, halt = false) {
|
||||
const ability = this.abilities[slot]
|
||||
if (ability == null) { return }
|
||||
|
||||
if (this.casting != null) {
|
||||
const abilityBeingCasted = this.casting.ability
|
||||
|
||||
+18
-30
@@ -37,24 +37,29 @@ app.ws('/ws', async (req, res) => {
|
||||
console.log(message)
|
||||
}
|
||||
|
||||
let delay = 0
|
||||
// if(message.id == '1') {
|
||||
// delay = 45
|
||||
// }
|
||||
|
||||
if (message.action == 'attack') {
|
||||
entity.attackAction(new Vector2(message.x, message.y))
|
||||
setTimeout(() => entity.attackAction(new Vector2(message.x, message.y)), delay)
|
||||
}
|
||||
|
||||
if (message.action == 'cast') {
|
||||
entity.castAction(message.slot, new Vector2(message.x, message.y))
|
||||
setTimeout(() => entity.castAction(message.slot, new Vector2(message.x, message.y)), delay)
|
||||
}
|
||||
|
||||
if (message.action == 'halt') {
|
||||
entity.haltAction()
|
||||
setTimeout(() => entity.haltAction(), delay)
|
||||
}
|
||||
|
||||
if (message.action == 'stop') {
|
||||
entity.stopAction()
|
||||
setTimeout(() => entity.stopAction(), delay)
|
||||
}
|
||||
|
||||
if (message.action == 'move') {
|
||||
entity.moveAction(new Vector2(message.x, message.y))
|
||||
setTimeout(() => entity.moveAction(new Vector2(message.x, message.y)), delay)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -68,13 +73,13 @@ function laneScenario() {
|
||||
game.spawnEntity(player1)
|
||||
player1.attackAction(new Vector2(500, 150))
|
||||
|
||||
// const player2 = new Entity(Template.player({
|
||||
// id: '2',
|
||||
// spawnPosition: new Vector2(1600, 1800),
|
||||
// team: Team.red,
|
||||
// }))
|
||||
// game.spawnEntity(player2)
|
||||
// player2.attackAction(new Vector2(1600, 1800))
|
||||
const player2 = new Entity(Template.player({
|
||||
id: '2',
|
||||
spawnPosition: new Vector2(1600, 1800),
|
||||
team: Team.red,
|
||||
}))
|
||||
game.spawnEntity(player2)
|
||||
player2.attackAction(new Vector2(1600, 1800))
|
||||
|
||||
const midWallStart = new Vector2(600, 600)
|
||||
const midWallEnd = new Vector2(1400, 1400)
|
||||
@@ -116,24 +121,7 @@ function laneScenario() {
|
||||
game.spawnEntity(new Entity(Template.minion(Team.red, { ranged: true, route: redRoute })))
|
||||
}
|
||||
}
|
||||
// game.logic = gameLogic
|
||||
|
||||
// const uBottomPoints = [
|
||||
// midSouthWallPoints.at(0).clone().sub(midWallThickness),
|
||||
// midSouthWallPoints.at(1).clone().sub(midWallThickness),
|
||||
// midNorthWallPoints.at(-2).clone().add(midWallThickness),
|
||||
// midNorthWallPoints.at(-1).clone().add(midWallThickness),
|
||||
// ]
|
||||
// const uBottom = new Terrain(uBottomPoints)
|
||||
// uBottom.id = 'uBottom'
|
||||
// game.addTerrain(uBottom)
|
||||
|
||||
const minion = new Entity({...Template.minion(Team.red, { ranged: true }), logic: null})
|
||||
minion.teleport(new Vector2(850, 250))
|
||||
game.spawnEntity(minion)
|
||||
|
||||
player1.stopAction()
|
||||
player1.castAction(1, new Vector2(850, 250))
|
||||
game.logic = gameLogic
|
||||
}
|
||||
|
||||
app.listen(port, () => {
|
||||
|
||||
+8
-2
@@ -6,12 +6,13 @@ export default class Projectile {
|
||||
id = crypto.randomUUID()
|
||||
after = null
|
||||
height = 50
|
||||
memory = {} // TODO: WARNING: currently only used for hit detection (code smell?)
|
||||
memory = {}
|
||||
onCollide = null
|
||||
owner = null
|
||||
position = new Vector2()
|
||||
radius = 5
|
||||
speed = 1000
|
||||
visualRadius = null
|
||||
|
||||
#dest = null
|
||||
#homingTarget = null
|
||||
@@ -28,6 +29,9 @@ export default class Projectile {
|
||||
|
||||
constructor(options = {}) {
|
||||
Object.entries(options).forEach(([key, value]) => this[key] = value)
|
||||
if (this.visualRadius == null) {
|
||||
this.visualRadius = this.radius
|
||||
}
|
||||
}
|
||||
|
||||
checkCollisions(collider) {
|
||||
@@ -39,7 +43,7 @@ export default class Projectile {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
collider() {
|
||||
return new SAT.Circle(new SAT.Vector(this.position.x, this.position.y), this.radius)
|
||||
}
|
||||
@@ -72,6 +76,8 @@ export default class Projectile {
|
||||
}
|
||||
|
||||
#move() {
|
||||
if (this.destination == null) { return }
|
||||
|
||||
const speed = (this.speed / (this.game?.tickBudget ?? 1000))
|
||||
const prevPos = this.position.clone()
|
||||
if (this.position.distanceTo(this.destination) < speed) {
|
||||
|
||||
+3
-1
@@ -10,9 +10,10 @@ export default class Template {
|
||||
logic: this.#minionLogic(options.route),
|
||||
maxHealth: options.ranged ? 300 : 450,
|
||||
position: team == Team.blue ? new Vector2(200, 200) : new Vector2(1800, 1800),
|
||||
radius: options.ranged ? 46 : 48,
|
||||
radius: 48,
|
||||
speed: 325,
|
||||
team,
|
||||
visualRadius: options.ranged ? 36 : 38,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +30,7 @@ export default class Template {
|
||||
maxHealth: 600,
|
||||
spawnPosition: new Vector2(500, 150),
|
||||
radius: 65,
|
||||
visualRadius: 40,
|
||||
...overrides,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user