Skip to content

Commit f03f3b1

Browse files
Visuals & temp icons for build/upgrade
1 parent 5139b05 commit f03f3b1

4 files changed

Lines changed: 22 additions & 91 deletions

File tree

client/src/playback/Actions.ts

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { vectorAdd, vectorLength, vectorMultiply, vectorSub, vectorMultiplyInPla
77
import Match from './Match'
88
import { Body } from './Bodies'
99
import { ATTACK_COLOR, TEAM_COLORS } from '../constants'
10+
import { getImageIfLoaded } from '../util/ImageLoader'
1011

1112
type ActionUnion = Exclude<ReturnType<typeof unionToAction>, null>
1213

@@ -151,24 +152,6 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
151152
)
152153
}
153154
},
154-
//[schema.Action.HEAL]: class Heal extends ToFromAction {
155-
// apply(round: Round): void {
156-
// // To discuss
157-
// }
158-
// drawToFrom(match: Match, ctx: CanvasRenderingContext2D, from: Vector, to: Vector, body: Body): void {
159-
// renderUtils.renderLine(
160-
// ctx,
161-
// renderUtils.getRenderCoords(from.x, from.y, match.currentRound.map.staticMap.dimension),
162-
// renderUtils.getRenderCoords(to.x, to.y, match.currentRound.map.staticMap.dimension),
163-
// {
164-
// color: HEAL_COLOR,
165-
// lineWidth: 0.05,
166-
// opacity: 0.5,
167-
// renderArrow: true
168-
// }
169-
// )
170-
// }
171-
//},
172155
[schema.Action.UnpaintAction]: class UnpaintAction extends Action<schema.UnpaintAction> {
173156
apply(round: Round): void {
174157
round.map.paint[this.actionData.loc()] = 0
@@ -206,24 +189,17 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
206189
[schema.Action.BuildAction]: class BuildAction extends Action<schema.BuildAction> {
207190
apply(round: Round): void {}
208191
draw(match: Match, ctx: CanvasRenderingContext2D): void {
209-
/*
210-
const radius = 3
211192
const map = match.currentRound.map
212-
const loc = map.indexToLocation(this.target)
213-
const coords = renderUtils.getRenderCoords(loc.x, loc.y, map.dimension, true)
193+
const body = match.currentRound.bodies.getById(this.actionData.id())
194+
const coords = renderUtils.getRenderCoords(body.pos.x, body.pos.y, map.dimension, false)
195+
const factor = match.getInterpolationFactor()
196+
const isEndpoint = factor == 0 || factor == 1
197+
const size = isEndpoint ? 1 : Math.max(factor * 2, 0.3)
198+
const alpha = isEndpoint ? 0.7 : factor < 0.5 ? factor : 1 - factor
214199

215-
// Get the trap color, assumes only opposite team can trigger
216-
const triggeredBot = match.currentRound.bodies.getById(this.robotId)
217-
ctx.strokeStyle = TEAM_COLORS[1 - (triggeredBot.team.id - 1)]
218-
219-
ctx.globalAlpha = 0.5
220-
ctx.fillStyle = WATER_COLOR
221-
ctx.beginPath()
222-
ctx.arc(coords.x, coords.y, radius, 0, 2 * Math.PI)
223-
ctx.fill()
224-
ctx.stroke()
200+
ctx.globalAlpha = alpha
201+
renderUtils.renderCenteredImageOrLoadingIndicator(ctx, getImageIfLoaded('icons/hammer.png'), coords, size)
225202
ctx.globalAlpha = 1
226-
*/
227203
}
228204
},
229205
[schema.Action.TransferAction]: class TransferAction extends Action<schema.TransferAction> {
@@ -282,6 +258,19 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
282258
const body = round.bodies.getById(towerId)
283259
body.level += 1
284260
}
261+
draw(match: Match, ctx: CanvasRenderingContext2D): void {
262+
const map = match.currentRound.map
263+
const body = match.currentRound.bodies.getById(this.actionData.id())
264+
const coords = renderUtils.getRenderCoords(body.pos.x, body.pos.y, map.dimension, false)
265+
const factor = match.getInterpolationFactor()
266+
const isEndpoint = factor == 0 || factor == 1
267+
const size = isEndpoint ? 1 : Math.max(factor * 2, 0.3)
268+
const alpha = isEndpoint ? 0.7 : factor < 0.5 ? factor : 1 - factor
269+
270+
ctx.globalAlpha = alpha
271+
renderUtils.renderCenteredImageOrLoadingIndicator(ctx, getImageIfLoaded('icons/gears.png'), coords, size)
272+
ctx.globalAlpha = 1
273+
}
285274
},
286275
[schema.Action.IndicatorStringAction]: class IndicatorStringAction extends Action<schema.IndicatorStringAction> {
287276
apply(round: Round): void {

client/src/playback/Bodies.ts

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -268,34 +268,6 @@ export class Body {
268268
this.drawHealthBar(match, overlayCtx)
269269
}
270270
}
271-
272-
/*
273-
if (this.carryingFlagId !== null) {
274-
renderUtils.renderCenteredImageOrLoadingIndicator(
275-
overlayCtx,
276-
getImageIfLoaded('resources/bread_outline_thick_64x64.png'),
277-
{ x: renderCoords.x, y: renderCoords.y },
278-
0.6
279-
)
280-
281-
if (config.showFlagCarryIndicator) {
282-
for (const direction of [
283-
{ x: 0.5, y: 0 },
284-
{ x: 0, y: 0.5 },
285-
{ x: -0.5, y: 0 },
286-
{ x: 0, y: -0.5 }
287-
]) {
288-
renderUtils.renderCarets(
289-
overlayCtx,
290-
{ x: renderCoords.x + 0.5, y: renderCoords.y + 0.5 },
291-
direction,
292-
2,
293-
this.team.id == 1 ? '#ff0000aa' : '#00ffffaa'
294-
)
295-
}
296-
}
297-
}
298-
*/
299271
}
300272

301273
private drawPath(match: Match, ctx: CanvasRenderingContext2D) {
@@ -551,11 +523,6 @@ export const BODY_DEFINITIONS: Record<schema.RobotType, typeof Body> = {
551523
hovered: boolean
552524
): void {
553525
super.draw(match, ctx, overlayCtx, config, selected, hovered)
554-
555-
const interpCoords = this.getInterpolatedCoords(match)
556-
// for (const [color, level, [dx, dy]] of levelIndicators) {
557-
// this.drawPetals(match, ctx, color, level, interpCoords.x + dx, interpCoords.y + dy)
558-
// }
559526
}
560527
},
561528

@@ -579,11 +546,6 @@ export const BODY_DEFINITIONS: Record<schema.RobotType, typeof Body> = {
579546
hovered: boolean
580547
): void {
581548
super.draw(match, ctx, overlayCtx, config, selected, hovered)
582-
583-
const interpCoords = this.getInterpolatedCoords(match)
584-
// for (const [color, level, [dx, dy]] of levelIndicators) {
585-
// this.drawPetals(match, ctx, color, level, interpCoords.x + dx, interpCoords.y + dy)
586-
// }
587549
}
588550
},
589551

@@ -607,11 +569,6 @@ export const BODY_DEFINITIONS: Record<schema.RobotType, typeof Body> = {
607569
hovered: boolean
608570
): void {
609571
super.draw(match, ctx, overlayCtx, config, selected, hovered)
610-
611-
const interpCoords = this.getInterpolatedCoords(match)
612-
// for (const [color, level, [dx, dy]] of levelIndicators) {
613-
// this.drawPetals(match, ctx, color, level, interpCoords.x + dx, interpCoords.y + dy)
614-
// }
615572
}
616573
},
617574

@@ -634,11 +591,6 @@ export const BODY_DEFINITIONS: Record<schema.RobotType, typeof Body> = {
634591
hovered: boolean
635592
): void {
636593
super.draw(match, ctx, overlayCtx, config, selected, hovered)
637-
638-
const interpCoords = this.getInterpolatedCoords(match)
639-
// for (const [color, level, [dx, dy]] of levelIndicators) {
640-
// this.drawPetals(match, ctx, color, level, interpCoords.x + dx, interpCoords.y + dy)
641-
// }
642594
}
643595
},
644596

@@ -661,11 +613,6 @@ export const BODY_DEFINITIONS: Record<schema.RobotType, typeof Body> = {
661613
hovered: boolean
662614
): void {
663615
super.draw(match, ctx, overlayCtx, config, selected, hovered)
664-
665-
const interpCoords = this.getInterpolatedCoords(match)
666-
// for (const [color, level, [dx, dy]] of levelIndicators) {
667-
// this.drawPetals(match, ctx, color, level, interpCoords.x + dx, interpCoords.y + dy)
668-
// }
669616
}
670617
},
671618

@@ -688,11 +635,6 @@ export const BODY_DEFINITIONS: Record<schema.RobotType, typeof Body> = {
688635
hovered: boolean
689636
): void {
690637
super.draw(match, ctx, overlayCtx, config, selected, hovered)
691-
692-
const interpCoords = this.getInterpolatedCoords(match)
693-
// for (const [color, level, [dx, dy]] of levelIndicators) {
694-
// this.drawPetals(match, ctx, color, level, interpCoords.x + dx, interpCoords.y + dy)
695-
// }
696638
}
697639
}
698640
}
5.34 KB
Loading
9.72 KB
Loading

0 commit comments

Comments
 (0)