46 lines
No EOL
1.8 KiB
GDScript
46 lines
No EOL
1.8 KiB
GDScript
class_name FireWallTile
|
|
extends Tile
|
|
|
|
func _init(button: Button, is_white: bool, d: int, owner: TileOwner = TileOwner.GAME) -> void:
|
|
super._init(button, is_white, d)
|
|
tile_name = "Fire Wall"
|
|
description = "Captures any piece that moves through"
|
|
type = TileType.GENERAL
|
|
duration = d
|
|
|
|
func apply_effect(piece: Pawn = null) -> void:
|
|
if piece && is_effect_active():
|
|
# Only affect enemy pieces based on tile owner
|
|
var is_enemy = false
|
|
match tile_owner:
|
|
TileOwner.PLAYER: # White
|
|
is_enemy = piece.Item_Color == 1 # Black pieces are enemy
|
|
TileOwner.ENEMY: # Black
|
|
is_enemy = piece.Item_Color == 0 # White pieces are enemy
|
|
TileOwner.GAME:
|
|
is_enemy = true # Game-owned fire affects all
|
|
|
|
if is_enemy:
|
|
var container = piece.get_parent() as PieceContainer
|
|
if container:
|
|
var board = container.get_parent().get_parent() as ChessGame
|
|
board.updatePoints(piece)
|
|
container.remove_piece()
|
|
|
|
func update_appearance() -> void:
|
|
if is_effect_active() && base_button:
|
|
var style = StyleBoxFlat.new()
|
|
var tile_color = Color(1, 0.4, 0) # Default orange-ish color for effects
|
|
var base_color = Color(0.8, 0.8, 0.8) if base_is_white else Color(0.2, 0.2, 0.2)
|
|
|
|
# Blend the tile effect color with the base chess board color
|
|
style.bg_color = Color(
|
|
(base_color.r + tile_color.r) / 2,
|
|
(base_color.g + tile_color.g) / 2,
|
|
(base_color.b + tile_color.b) / 2
|
|
)
|
|
|
|
# Apply the style using theme override
|
|
base_button.add_theme_stylebox_override("normal", style)
|
|
else:
|
|
restore_base_appearance() |