UI and other changes
This commit is contained in:
parent
87b5c11fcf
commit
215e24e246
79 changed files with 70023 additions and 2201 deletions
|
|
@ -1,42 +1,49 @@
|
|||
class_name ScarecrowHud
|
||||
extends Control
|
||||
## Bottom-left status for the scarecrow: health as pips, the fear ability as a circle that
|
||||
## sweeps full while it cools down and flashes when it is ready again, the patch hint with its
|
||||
## progress, and once the Sprint upgrade is bought a sprint line (ready, seconds left, or
|
||||
## recharging); plus a red screen tint when the scarecrow is hit. Bottom-right, the weapons:
|
||||
## the main ones by number, the one in hand marked, and how to switch; under them the off-hand
|
||||
## (pumpkin bombs, marked when one is ready, else its recharge) and its button. The ones not
|
||||
## bought yet are greyed out (with where to buy them: Upgrades.shop_of).
|
||||
## The scarecrow's part of the HUD, hand-drawn (Sketch):
|
||||
## * Top-left: its portrait in a ring that is the fear ability's charge: a dim ring with a blue
|
||||
## arc sweeping round while fear recharges, glowing blue when it's ready (a flash as it
|
||||
## becomes ready); greyed out while the scarecrow is down. Beside it the health bar, one
|
||||
## segment per point of max health (red filled, grey empty; while patching, the segments the
|
||||
## patch will fill fill in), and under it, once the Sprint upgrade is bought, a thin green
|
||||
## bar: the sprint's stamina (draining while sprinting, filling back while it recharges).
|
||||
## * Bottom-center: the hotbar, one slot per main weapon owned (locked ones aren't shown),
|
||||
## numbered by the key that picks it (ScarecrowCombat.owned_main: weapon_k picks slot k), the
|
||||
## one in hand highlighted; then past a divider the off-hand weapons owned (pumpkin bombs), in a
|
||||
## bolder frame, darkened from the top while a bomb recharges. Hidden in build mode (BuildHud
|
||||
## has the bottom then).
|
||||
## * A red tint over the screen when the scarecrow is hit.
|
||||
|
||||
const PIP := Vector2(22.0, 16.0)
|
||||
const PIP_GAP := 5.0
|
||||
const FEAR_RADIUS := 26.0
|
||||
## Extra height of the panel for the sprint line.
|
||||
const SPRINT_ROW := 30.0
|
||||
## The weapon panel, from the bottom-right corner: its row height, and its width (its height grows
|
||||
## with ScarecrowCombat.MAIN_WEAPONS / OFFHAND_WEAPONS, see _weapons_rect / _offhand_top).
|
||||
const WEAPON_PANEL_WIDTH := 320.0
|
||||
const WEAPON_ROW := 30.0
|
||||
const PORTRAIT_CENTER := Vector2(78.0, 76.0)
|
||||
const PORTRAIT_RADIUS := 50.0
|
||||
const FEAR_COLOR := Color(0.36, 0.74, 1.0)
|
||||
const BAR_ORIGIN := Vector2(146.0, 32.0)
|
||||
const SEGMENT := Vector2(54.0, 22.0)
|
||||
const SEGMENT_GAP := 8.0
|
||||
const SEGMENT_SKEW := 7.0
|
||||
## The health bar grows a segment per point of max health up to this width, then its segments
|
||||
## get narrower.
|
||||
const BAR_MAX_WIDTH := 360.0
|
||||
const STAMINA_HEIGHT := 6.0
|
||||
const HEALTH := Color(0.88, 0.14, 0.12)
|
||||
const EMPTY := Color(0.62, 0.62, 0.6, 0.85)
|
||||
const STAMINA := Color(0.3, 0.9, 0.25)
|
||||
const SLOT := Vector2(78.0, 72.0)
|
||||
const SLOT_GAP := 16.0
|
||||
const DIVIDER_GAP := 30.0
|
||||
const HOTBAR_BOTTOM := 22.0
|
||||
|
||||
var kit: Scarecrow
|
||||
## This machine's scarecrow's weapons.
|
||||
var combat: ScarecrowCombat
|
||||
var campaign: CampaignController
|
||||
## The health line's name ("Scarecrow"; in co-op "P1 Scarecrow" / "P2 Scarecrow").
|
||||
var label := "Scarecrow"
|
||||
## Set by FarmSim: the hotbar hides in build mode.
|
||||
var build: BuildMode
|
||||
|
||||
var _tint: ColorRect
|
||||
var _hp_label: Label
|
||||
var _fear_label: Label
|
||||
var _patch_label: Label
|
||||
var _sprint_label: Label
|
||||
var _weapon_title: Label
|
||||
var _weapon_rows: Array[Label] = []
|
||||
var _weapon_hint: Label
|
||||
var _offhand_title: Label
|
||||
var _offhand_rows: Array[Label] = []
|
||||
var _hit: float = 0.0
|
||||
var _ready_flash: float = 0.0
|
||||
var _time: float = 0.0
|
||||
|
||||
|
||||
func setup(p_kit: Scarecrow, p_campaign: CampaignController, p_combat: ScarecrowCombat = null) -> void:
|
||||
|
|
@ -71,102 +78,48 @@ func _ready() -> void:
|
|||
_tint.color = Color(0.85, 0.05, 0.0, 0.0)
|
||||
_tint.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
add_child(_tint)
|
||||
_hp_label = _label(22)
|
||||
_fear_label = _label(20)
|
||||
_patch_label = _label(20)
|
||||
_sprint_label = _label(20)
|
||||
_weapon_title = _label(18)
|
||||
_weapon_title.text = "Main weapon"
|
||||
for i in ScarecrowCombat.MAIN_WEAPONS.size():
|
||||
_weapon_rows.append(_label(20))
|
||||
_weapon_hint = _label(16)
|
||||
_weapon_hint.text = "Switch: Tab / 1-2 / d-pad down"
|
||||
_offhand_title = _label(18)
|
||||
_offhand_title.text = "Off-hand right mouse / LT"
|
||||
for i in ScarecrowCombat.OFFHAND_WEAPONS.size():
|
||||
_offhand_rows.append(_label(20))
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
_time += delta
|
||||
_hit = maxf(_hit - delta * 2.5, 0.0)
|
||||
_ready_flash = maxf(_ready_flash - delta * 2.0, 0.0)
|
||||
_tint.color.a = 0.22 * _hit
|
||||
if kit == null:
|
||||
return
|
||||
var base := _base()
|
||||
var s := campaign.state
|
||||
_hp_label.text = "%s %d/%d" % [label, kit.hp(), kit.max_hp()]
|
||||
_hp_label.position = base + Vector2(0.0, -34.0)
|
||||
if not kit.alive:
|
||||
_fear_label.text = "Fear"
|
||||
elif kit.fear_left == 0.0:
|
||||
_fear_label.text = "Fear Q / LB"
|
||||
else:
|
||||
_fear_label.text = "Fear %.0f s" % ceilf(kit.fear_left)
|
||||
_fear_label.position = base + Vector2(FEAR_RADIUS * 2.0 + 14.0, 34.0)
|
||||
if not kit.alive:
|
||||
_patch_label.text = "Patch"
|
||||
elif kit.patching:
|
||||
_patch_label.text = "Patching up..."
|
||||
elif kit.hp() >= kit.max_hp():
|
||||
_patch_label.text = "Patch (full health)"
|
||||
else:
|
||||
_patch_label.text = "Patch hold F / Y (%s)" % ResourceStore.describe(kit.config.costs.get("patch", {}))
|
||||
_patch_label.position = base + Vector2(FEAR_RADIUS * 2.0 + 14.0, 62.0)
|
||||
var body := kit.player
|
||||
_sprint_label.visible = _sprint_shown()
|
||||
if _sprint_label.visible:
|
||||
if not kit.alive:
|
||||
_sprint_label.text = "Sprint"
|
||||
elif body.sprinting:
|
||||
_sprint_label.text = "Sprinting %.1f s" % body.sprint_left
|
||||
elif body.sprint_recharge > 0.0:
|
||||
_sprint_label.text = "Sprint %.0f s" % ceilf(body.sprint_recharge)
|
||||
else:
|
||||
_sprint_label.text = "Sprint hold Shift / L3"
|
||||
_sprint_label.position = base + Vector2(0.0, 100.0)
|
||||
_update_weapons()
|
||||
queue_redraw()
|
||||
|
||||
|
||||
func _update_weapons() -> void:
|
||||
var shown := combat != null
|
||||
for l: Label in [_weapon_title, _weapon_hint, _offhand_title] + _weapon_rows + _offhand_rows:
|
||||
l.visible = shown
|
||||
if not shown:
|
||||
return
|
||||
var at := _weapons_rect().position
|
||||
_weapon_title.position = at + Vector2(12.0, 6.0)
|
||||
# weapon_1.. only picks the first SWITCH_ACTIONS.size() - 1 (Task #7 added more main weapons
|
||||
# than there are number keys): only those rows get a number, the rest just their name.
|
||||
var keyed := ScarecrowCombat.SWITCH_ACTIONS.size() - 1
|
||||
for k in _weapon_rows.size():
|
||||
var w := ScarecrowCombat.MAIN_WEAPONS[k]
|
||||
var text := "%d %s" % [k + 1, ScarecrowCombat.WEAPON_NAMES[w]] if k < keyed else ScarecrowCombat.WEAPON_NAMES[w]
|
||||
_weapon_row(_weapon_rows[k], text, w, w == combat.weapon)
|
||||
_weapon_rows[k].position = at + Vector2(30.0, 30.0 + k * WEAPON_ROW)
|
||||
_weapon_hint.position = at + Vector2(12.0, 30.0 + _weapon_rows.size() * WEAPON_ROW + 2.0)
|
||||
_offhand_title.position = at + Vector2(12.0, _offhand_top() + 6.0)
|
||||
for k in _offhand_rows.size():
|
||||
var w := ScarecrowCombat.OFFHAND_WEAPONS[k]
|
||||
var text := ScarecrowCombat.WEAPON_NAMES[w]
|
||||
if w == ScarecrowCombat.Weapon.PUMPKIN_BOMB and combat.owns(w) and combat.bomb_left > 0.0:
|
||||
text += " %.0f s" % ceilf(combat.bomb_left)
|
||||
_weapon_row(_offhand_rows[k], text, w, _offhand_lit(w))
|
||||
_offhand_rows[k].position = at + Vector2(30.0, _offhand_top() + 30.0 + k * WEAPON_ROW)
|
||||
## Whether the green stamina bar shows: only once the Sprint upgrade is bought.
|
||||
func stamina_shown() -> bool:
|
||||
var body := kit.player if kit != null else null
|
||||
return body != null and body.config != null and body.can_sprint()
|
||||
|
||||
|
||||
## A weapon's row: greyed out until it's bought, gold when it's in hand (lit).
|
||||
func _weapon_row(l: Label, text: String, w: int, lit: bool) -> void:
|
||||
var color := Color(0.95, 0.95, 0.95)
|
||||
if not combat.owns(w):
|
||||
var shop := Upgrades.shop_of(campaign.config, ScarecrowCombat.WEAPON_IDS[w]) if campaign != null else "workbench"
|
||||
text += " (%s)" % ("supply shed" if shop == "shed" else "workbench")
|
||||
color = Color(0.55, 0.55, 0.55)
|
||||
elif lit:
|
||||
color = Color(1.0, 0.85, 0.3)
|
||||
l.text = text
|
||||
l.add_theme_color_override("font_color", color)
|
||||
## The green bar's fill, 0..1: the sprint left while sprinting, its recharge after, else full.
|
||||
func stamina() -> float:
|
||||
if not stamina_shown():
|
||||
return 1.0
|
||||
var body := kit.player
|
||||
if body.sprinting:
|
||||
return clampf(body.sprint_left / maxf(body.config.sprint_time, 0.001), 0.0, 1.0)
|
||||
if body.sprint_recharge > 0.0:
|
||||
return clampf(1.0 - body.sprint_recharge / maxf(body.config.sprint_cooldown, 0.001), 0.0, 1.0)
|
||||
return 1.0
|
||||
|
||||
|
||||
## The hotbar's slots as shown, left to right: {weapon, key (the number that picks it; 0 for
|
||||
## the off-hand), offhand, selected}. Empty while it's hidden (build mode, no weapons).
|
||||
func slots() -> Array[Dictionary]:
|
||||
var out: Array[Dictionary] = []
|
||||
if combat == null or (build != null and build.active):
|
||||
return out
|
||||
var owned := combat.owned_main()
|
||||
for k in owned.size():
|
||||
out.append({"weapon": owned[k], "key": k + 1 if k < ScarecrowCombat.SWITCH_ACTIONS.size() - 1 else 0,
|
||||
"offhand": false, "selected": owned[k] == combat.weapon})
|
||||
for w in ScarecrowCombat.OFFHAND_WEAPONS:
|
||||
if combat.owns(w):
|
||||
out.append({"weapon": w, "key": 0, "offhand": true, "selected": _offhand_lit(w)})
|
||||
return out
|
||||
|
||||
|
||||
## Whether the off-hand weapon is in the off-hand and ready (a pumpkin bomb not recharging).
|
||||
|
|
@ -174,73 +127,110 @@ func _offhand_lit(w: int) -> bool:
|
|||
return w == combat.offhand and not (w == ScarecrowCombat.Weapon.PUMPKIN_BOMB and combat.bomb_left > 0.0)
|
||||
|
||||
|
||||
## Top of the off-hand section, under the main weapon rows and the switch hint (grows with
|
||||
## ScarecrowCombat.MAIN_WEAPONS.size()).
|
||||
func _offhand_top() -> float:
|
||||
return 30.0 + ScarecrowCombat.MAIN_WEAPONS.size() * WEAPON_ROW + 32.0
|
||||
|
||||
|
||||
func _weapons_rect() -> Rect2:
|
||||
var height := _offhand_top() + 30.0 + ScarecrowCombat.OFFHAND_WEAPONS.size() * WEAPON_ROW + 12.0
|
||||
return Rect2(size - Vector2(WEAPON_PANEL_WIDTH + 36.0, height + 26.0), Vector2(WEAPON_PANEL_WIDTH, height))
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
if kit == null:
|
||||
return
|
||||
var base := _base()
|
||||
var s := campaign.state
|
||||
var height := 146.0 + (SPRINT_ROW if _sprint_shown() else 0.0)
|
||||
draw_rect(Rect2(base - Vector2(14.0, 46.0), Vector2(340.0, height)), Color(0.0, 0.0, 0.0, 0.42))
|
||||
var frac := float(kit.hp()) / float(maxi(kit.max_hp(), 1))
|
||||
var full := Color(0.45, 0.9, 0.35) if frac > 0.5 else (Color(1.0, 0.8, 0.2) if frac > 0.25 else Color(1.0, 0.3, 0.2))
|
||||
full = full.lerp(Color.WHITE, _hit * 0.6)
|
||||
for i in kit.max_hp():
|
||||
var r := Rect2(base + Vector2(i * (PIP.x + PIP_GAP), 0.0), PIP)
|
||||
draw_rect(r, full if i < kit.hp() else Color(0.15, 0.15, 0.15, 0.8))
|
||||
draw_rect(r, Color(0.0, 0.0, 0.0, 0.9), false, 2.0)
|
||||
# Fear: dark disc, a sweep that fills while cooling down, bright when ready.
|
||||
var c := base + Vector2(FEAR_RADIUS, 32.0 + FEAR_RADIUS)
|
||||
_draw_portrait()
|
||||
_draw_health()
|
||||
_draw_hotbar()
|
||||
|
||||
|
||||
func _draw_portrait() -> void:
|
||||
var c := PORTRAIT_CENTER
|
||||
var r := PORTRAIT_RADIUS
|
||||
var box := Rect2(c - Vector2(r, r) * 0.98, Vector2(r, r) * 1.96)
|
||||
Sketch.icon(self, "portrait", box)
|
||||
if not kit.alive:
|
||||
draw_circle(c, r - 3.0, Color(0.16, 0.16, 0.16, 0.6))
|
||||
var ready := kit.fear_left == 0.0 and kit.alive
|
||||
draw_circle(c, FEAR_RADIUS, Color(0.08, 0.1, 0.14, 0.9))
|
||||
if ready:
|
||||
draw_circle(c, FEAR_RADIUS - 5.0, Color(0.55, 0.85, 1.0).lerp(Color.WHITE, _ready_flash))
|
||||
var pulse := 0.75 + 0.25 * sin(_time * 3.2)
|
||||
for k in 4:
|
||||
Sketch.circle(self, c, r + 3.0 + k * 3.5, Color(FEAR_COLOR, (0.32 - k * 0.07) * pulse), 4.5, 3.0 + k)
|
||||
Sketch.circle(self, c, r, Color(0.62, 0.9, 1.0).lerp(Color.WHITE, _ready_flash), 5.0, 1.0)
|
||||
else:
|
||||
draw_arc(c, FEAR_RADIUS - 8.0, -PI * 0.5, -PI * 0.5 + TAU * kit.fear_charge(), 48, Color(0.4, 0.6, 0.75), 9.0)
|
||||
draw_arc(c, FEAR_RADIUS + 3.0 + _ready_flash * 10.0, 0.0, TAU, 48, Color(1.0, 1.0, 1.0, 0.25 + 0.75 * _ready_flash), 2.5)
|
||||
if combat != null:
|
||||
var w := _weapons_rect()
|
||||
draw_rect(w, Color(0.0, 0.0, 0.0, 0.42))
|
||||
_draw_lit_row(w, 32.0 + ScarecrowCombat.MAIN_WEAPONS.find(combat.weapon) * WEAPON_ROW)
|
||||
var off := ScarecrowCombat.OFFHAND_WEAPONS.find(combat.offhand)
|
||||
if off >= 0 and _offhand_lit(combat.offhand):
|
||||
_draw_lit_row(w, _offhand_top() + 32.0 + off * WEAPON_ROW)
|
||||
Sketch.circle(self, c, r, Color(0.32, 0.42, 0.5, 0.85) if kit.alive else Color(0.4, 0.4, 0.4, 0.85), 5.0, 1.0)
|
||||
if kit.alive:
|
||||
Sketch.circle(self, c, r, FEAR_COLOR, 5.0, 2.0, -PI * 0.5, -PI * 0.5 + TAU * kit.fear_charge())
|
||||
if _ready_flash > 0.0:
|
||||
Sketch.circle(self, c, r + 6.0 + (1.0 - _ready_flash) * 18.0, Color(0.8, 0.95, 1.0, _ready_flash), 3.0, 4.0)
|
||||
Sketch.circle(self, c, r + 2.8, Color(Sketch.INK, 0.8), 1.5, 5.0)
|
||||
Sketch.circle(self, c, r - 2.8, Color(Sketch.INK, 0.8), 1.5, 6.0)
|
||||
|
||||
|
||||
func _draw_health() -> void:
|
||||
var top := maxi(kit.max_hp(), 1)
|
||||
var hp := kit.hp()
|
||||
var step := minf(SEGMENT.x + SEGMENT_GAP, (BAR_MAX_WIDTH + SEGMENT_GAP) / top)
|
||||
var seg := Vector2(maxf(step - SEGMENT_GAP, 4.0), SEGMENT.y)
|
||||
var width := step * top - SEGMENT_GAP
|
||||
var healing := 0
|
||||
var heal_frac := 0.0
|
||||
if kit.patching:
|
||||
var bar := Rect2(base + Vector2(FEAR_RADIUS * 2.0 + 14.0, 92.0), Vector2(210.0, 8.0))
|
||||
draw_rect(bar, Color(0.1, 0.1, 0.1, 0.9))
|
||||
draw_rect(Rect2(bar.position, Vector2(bar.size.x * kit.patch_elapsed / kit.config.patch_time, bar.size.y)), Color(0.45, 1.0, 0.4))
|
||||
healing = mini(kit.config.patch_heal, top - hp)
|
||||
heal_frac = clampf(kit.patch_elapsed / maxf(kit.config.patch_time, 0.001), 0.0, 1.0)
|
||||
var full := HEALTH.lerp(Color.WHITE, _hit * 0.6)
|
||||
for i in top:
|
||||
var at := BAR_ORIGIN + Vector2(i * step, 0.0)
|
||||
var pts := _segment(at, seg, 20.0 + i)
|
||||
draw_colored_polygon(pts, full if i < hp else EMPTY)
|
||||
if i >= hp and i < hp + healing:
|
||||
draw_colored_polygon(_segment(at, Vector2(seg.x * heal_frac, seg.y), 40.0 + i), Color(HEALTH.lightened(0.35), 0.85))
|
||||
if i < hp: # a darker stroke along the bottom, like paint pooling
|
||||
Sketch.line(self, at + Vector2(3.0, seg.y - 4.0), at + Vector2(seg.x - 3.0, seg.y - 4.0), full.darkened(0.3), 3.0, 60.0 + i, 0.6)
|
||||
Sketch.outline(self, pts, Color(Sketch.INK, 0.55), 1.5, 80.0 + i, 0.8, 1)
|
||||
if not stamina_shown():
|
||||
return
|
||||
# The stamina bar, as wide as the health bar.
|
||||
var bar := Rect2(BAR_ORIGIN + Vector2(0.0, SEGMENT.y + 12.0), Vector2(maxf(width, 120.0), STAMINA_HEIGHT))
|
||||
var y := bar.get_center().y
|
||||
Sketch.line(self, Vector2(bar.position.x, y), Vector2(bar.end.x, y), Color(Sketch.INK, 0.6), STAMINA_HEIGHT + 3.0, 101.0, 0.6)
|
||||
Sketch.line(self, Vector2(bar.position.x, y), Vector2(bar.end.x, y), Color(0.16, 0.3, 0.14, 0.9), STAMINA_HEIGHT, 101.0, 0.6)
|
||||
var fill := stamina()
|
||||
if fill > 0.0:
|
||||
Sketch.line(self, Vector2(bar.position.x, y), Vector2(bar.position.x + bar.size.x * fill, y), STAMINA, STAMINA_HEIGHT, 102.0, 0.6)
|
||||
|
||||
|
||||
## The marked row of the weapon panel w, top pixels down.
|
||||
func _draw_lit_row(w: Rect2, top: float) -> void:
|
||||
var row := Rect2(w.position + Vector2(6.0, top), Vector2(w.size.x - 12.0, WEAPON_ROW - 2.0))
|
||||
draw_rect(row, Color(1.0, 0.85, 0.3, 0.18))
|
||||
draw_rect(Rect2(row.position, Vector2(4.0, row.size.y)), Color(1.0, 0.85, 0.3))
|
||||
## A health segment: a slanted brush stroke.
|
||||
func _segment(at: Vector2, seg: Vector2, seed: float) -> PackedVector2Array:
|
||||
var w := 1.2
|
||||
return PackedVector2Array([at + Vector2(SEGMENT_SKEW, 0.0) + Sketch.jitter(seed, w),
|
||||
at + Vector2(SEGMENT_SKEW + seg.x, 1.5) + Sketch.jitter(seed + 1.0, w),
|
||||
at + Vector2(seg.x, seg.y) + Sketch.jitter(seed + 2.0, w), at + Vector2(0.0, seg.y - 1.0) + Sketch.jitter(seed + 3.0, w)])
|
||||
|
||||
|
||||
func _base() -> Vector2:
|
||||
return Vector2(36.0, size.y - 126.0 - (SPRINT_ROW if _sprint_shown() else 0.0))
|
||||
|
||||
|
||||
func _sprint_shown() -> bool:
|
||||
return kit != null and kit.player != null and kit.player.can_sprint()
|
||||
|
||||
|
||||
func _label(font_size: int) -> Label:
|
||||
var l := Label.new()
|
||||
l.add_theme_font_size_override("font_size", font_size)
|
||||
l.add_theme_color_override("font_outline_color", Color.BLACK)
|
||||
l.add_theme_constant_override("outline_size", 6)
|
||||
l.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
add_child(l)
|
||||
return l
|
||||
func _draw_hotbar() -> void:
|
||||
var list := slots()
|
||||
if list.is_empty():
|
||||
return
|
||||
var mains := 0
|
||||
for s in list:
|
||||
if not s["offhand"]:
|
||||
mains += 1
|
||||
var width := list.size() * SLOT.x + (list.size() - 1) * SLOT_GAP + (DIVIDER_GAP * 2.0 - SLOT_GAP if mains < list.size() else 0.0)
|
||||
var x := (size.x - width) * 0.5
|
||||
var y := size.y - HOTBAR_BOTTOM - SLOT.y
|
||||
for i in list.size():
|
||||
var s: Dictionary = list[i]
|
||||
var w: int = s["weapon"]
|
||||
if i == mains and i > 0:
|
||||
var div := x - SLOT_GAP + DIVIDER_GAP
|
||||
Sketch.line(self, Vector2(div, y - 10.0), Vector2(div, y + SLOT.y + 12.0), Sketch.INK, 3.0, 200.0, 1.5)
|
||||
x += DIVIDER_GAP * 2.0 - SLOT_GAP
|
||||
var r := Rect2(Vector2(x, y), SLOT)
|
||||
var lit: bool = s["selected"] and not s["offhand"] # the off-hand's ready shows by not being darkened
|
||||
if lit:
|
||||
r = r.grow(3.0)
|
||||
r.position.y -= 4.0
|
||||
Sketch.box(self, r, Sketch.SLOT, Sketch.INK, 4.5 if s["offhand"] else 2.5, 210.0 + i * 3.0)
|
||||
Sketch.icon(self, ScarecrowCombat.WEAPON_IDS[w], Rect2(r.get_center() - Vector2(38.0, 36.0), Vector2(76.0, 76.0)))
|
||||
var cooldown := campaign.config.bomb_cooldown if campaign != null else 0.0
|
||||
if w == ScarecrowCombat.Weapon.PUMPKIN_BOMB and combat.bomb_left > 0.0 and cooldown > 0.0:
|
||||
var left := clampf(combat.bomb_left / cooldown, 0.0, 1.0)
|
||||
draw_colored_polygon(Sketch.corners(Rect2(r.position, Vector2(r.size.x, r.size.y * left)).grow(-2.0), 230.0 + i),
|
||||
Color(0.04, 0.05, 0.04, 0.6))
|
||||
if lit:
|
||||
Sketch.box(self, r.grow(2.0), Color(0, 0, 0, 0), Sketch.GOLD, 3.5, 240.0 + i)
|
||||
if int(s["key"]) > 0:
|
||||
Sketch.text(self, r.position + Vector2(7.0, 1.0), str(s["key"]), 20, Sketch.TEXT, HORIZONTAL_ALIGNMENT_LEFT, 6)
|
||||
x += SLOT.x + SLOT_GAP
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue