feat: implement core game scene, player logic, and modular manager architecture for Tekton Dash
This commit is contained in:
@@ -95,7 +95,7 @@ func simple_move_to(grid_position: Vector2i) -> bool:
|
||||
if is_wall_passable:
|
||||
var impenetrable_coords = [
|
||||
Vector2i(0,0), Vector2i(1,0), Vector2i(2,0), Vector2i(3,0), Vector2i(4,0), Vector2i(5,0), Vector2i(6,0), Vector2i(7,0), Vector2i(8,0), Vector2i(9,0), Vector2i(10,0), Vector2i(13,0), Vector2i(19,0), Vector2i(20,0), Vector2i(21,0), Vector2i(22,0),
|
||||
Vector2i(0,1), Vector2i(1,1), Vector2i(2,1), Vector2i(3,1), Vector2i(6,1),
|
||||
Vector2i(0,1), Vector2i(2,1), Vector2i(3,1), Vector2i(6,1),
|
||||
Vector2i(0,2), Vector2i(1,2), Vector2i(2,2), Vector2i(3,2),
|
||||
Vector2i(17,9), Vector2i(18,9), Vector2i(19,9), Vector2i(20,9), Vector2i(21,9), Vector2i(22,9),
|
||||
Vector2i(11,10), Vector2i(12,10), Vector2i(13,10), Vector2i(15,10), Vector2i(16,10), Vector2i(17,10), Vector2i(18,10), Vector2i(19,10), Vector2i(20,10), Vector2i(21,10), Vector2i(22,10),
|
||||
|
||||
@@ -13,48 +13,38 @@ const STATIC_CONTROLLER_SCRIPT = "res://scripts/static_tekton_controller.gd"
|
||||
# Mid-Left, Mid-Mid, Mid-Right
|
||||
# Bot-Left, Bot-Mid, Bot-Right
|
||||
|
||||
func calculate_spawn_points(count: int, gridmap: Node) -> Array[Vector2i]:
|
||||
func calculate_spawn_points(_count: int, gridmap: Node) -> Array[Vector2i]:
|
||||
"""
|
||||
Calculates random spawn positions for static tektons.
|
||||
Returns an Array of Vector2i positions.
|
||||
Calculates the 5 fixed potential spawn positions for static tektons.
|
||||
Corners: (1,1), (W-2,1), (1,H-2), (W-2,H-2)
|
||||
Center: (W/2, H/2)
|
||||
Returns exactly 5 spots if possible.
|
||||
"""
|
||||
if count <= 0 or not gridmap: return []
|
||||
if not gridmap: return []
|
||||
|
||||
print("[StaticTektonManager] Calculating static tekton positions (Fixed 5-Zone + Center)...")
|
||||
|
||||
# 1. Define Zones (3x3 Grid)
|
||||
var width = gridmap.columns
|
||||
var depth = gridmap.rows
|
||||
var zone_w = width / 3
|
||||
var zone_d = depth / 3
|
||||
var height = gridmap.rows
|
||||
|
||||
var zones = []
|
||||
for z in range(3):
|
||||
for x in range(3):
|
||||
zones.append(Rect2i(x * zone_w, z * zone_d, zone_w, zone_d))
|
||||
print("[StaticTektonManager] Calculating static tekton positions (Fixed 5-Spots)...")
|
||||
|
||||
# Fixed Spots
|
||||
var spots: Array[Vector2i] = [
|
||||
Vector2i(1, 1), # Top-Left
|
||||
Vector2i(width - 2, 1), # Top-Right
|
||||
Vector2i(1, height - 2), # Bottom-Left
|
||||
Vector2i(width - 2, height - 2), # Bottom-Right
|
||||
Vector2i(width / 2, height / 2) # Center
|
||||
]
|
||||
|
||||
# Validate spots (ensure they are walkable and have room)
|
||||
var valid_spots: Array[Vector2i] = []
|
||||
for spot in spots:
|
||||
if _is_valid_3x3(spot, gridmap):
|
||||
valid_spots.append(spot)
|
||||
else:
|
||||
print("[StaticTektonManager] Warning: Spot %s is not a valid 3x3 walkable area!" % str(spot))
|
||||
|
||||
# 2. Select Fixed Targets: TL(0), TR(2), Center(4), BL(6), BR(8)
|
||||
# This ensures they are never adjacent (always separated by a middle zone)
|
||||
var target_indices = [0, 2, 6, 8, 4]
|
||||
target_indices.shuffle() # Randomize which of the 5 zones we pick
|
||||
|
||||
# If count < 5, we prioritize corners then center
|
||||
# If count > 5, we only return 5 because that's the max safe non-adjacent set in 3x3
|
||||
var spawn_points: Array[Vector2i] = []
|
||||
|
||||
for zone_idx in target_indices:
|
||||
if spawn_points.size() >= count:
|
||||
break
|
||||
var zone = zones[zone_idx]
|
||||
|
||||
# Determine Position Type for Bias
|
||||
# 0:TL, 1:TR, 2:BL, 3:BR, 4:Center
|
||||
# We pass zone_idx to _pick_spot_in_zone to snap corners
|
||||
var pos = _pick_spot_in_zone(zone, gridmap, zone_idx)
|
||||
if pos != Vector2i(-1, -1):
|
||||
spawn_points.append(pos)
|
||||
|
||||
return spawn_points
|
||||
return valid_spots
|
||||
|
||||
func _pick_spot_in_zone_biased(zone: Rect2i, gridmap: Node, type: int) -> Vector2i:
|
||||
# type: 0=TL, 1=TR, 2=BL, 3=BR, 4=Center
|
||||
|
||||
Reference in New Issue
Block a user