update obstacles

This commit is contained in:
2025-03-21 11:44:12 +08:00
parent 50e5298009
commit 679961aa77
6 changed files with 323 additions and 327 deletions
+13 -44
View File
@@ -67,8 +67,8 @@ enum ActionState {
}
# Obstacle
# Add these properties to track the current obstacle direction
var current_obstacle_orientation = ObstacleOrientation.NORTH # Default to NORTH
# Add these properties to track current obstacle settings
var current_obstacle_orientation = ObstacleOrientation.NORTH
var current_obstacle_item = 12 # Starting with first obstacle item (12)
enum ObstacleDirection {
@@ -77,10 +77,10 @@ enum ObstacleDirection {
}
enum ObstacleOrientation {
NORTH = 0,
EAST = 1,
SOUTH = 2,
WEST = 3
NORTH = 0, # Blocks movement to the north (top)
EAST = 1, # Blocks movement to the east (right)
SOUTH = 2, # Blocks movement to the south (bottom)
WEST = 3 # Blocks movement to the west (left)
}
var current_action_state = ActionState.NONE
@@ -229,43 +229,6 @@ func set_action_state(new_state):
ActionState.PLACING_OBSTACLE:
local_player_character.highlight_valid_obstacle_cells()
# Update the place_obstacle function for floor 3
#func place_obstacle(grid_position: Vector2i):
#if not local_player_character or local_player_character.action_points < 1:
#return false
#
#var floor_index = 3 # Always place on floor 3
#var direction = EnhancedGridMap.Direction.BLOCKED_NORTH
#
#match current_obstacle_direction:
#ObstacleDirection.VERTICAL:
#direction = EnhancedGridMap.Direction.BLOCKED_NORTH # Block movement along east-west axis
#ObstacleDirection.HORIZONTAL:
#direction = EnhancedGridMap.Direction.BLOCKED_EAST # Block movement along north-south axis
#
#var success = $EnhancedGridMap.place_obstacle(
#Vector3i(grid_position.x, floor_index, grid_position.y),
#current_obstacle_item,
#direction
#)
#
#if success:
#local_player_character.action_points -= 1
#local_player_character.clear_highlights()
#
## Don't exit the obstacle placement mode to allow multiple placements
#local_player_character.highlight_valid_obstacle_cells()
#
## Exit obstacle placement mode and return to default state
#set_action_state(ActionState.NONE)
#
## Sync the obstacle with other clients
#if is_multiplayer_authority():
#rpc("sync_place_obstacle", grid_position.x, grid_position.y, floor_index, current_obstacle_item, direction)
#
#return true
#return false
func place_obstacle(grid_position: Vector2i):
if not local_player_character or local_player_character.action_points < 1:
return false
@@ -294,9 +257,15 @@ func place_obstacle(grid_position: Vector2i):
return true
return false
# Updated function to cycle through the four orientations
# Updated function to cycle through the four orientations
func cycle_obstacle_orientation():
var orientations = [ObstacleOrientation.NORTH, ObstacleOrientation.EAST, ObstacleOrientation.SOUTH, ObstacleOrientation.WEST]
var orientations = [
ObstacleOrientation.NORTH,
ObstacleOrientation.EAST,
ObstacleOrientation.SOUTH,
ObstacleOrientation.WEST
]
var current_index = orientations.find(current_obstacle_orientation)
current_index = (current_index + 1) % orientations.size()
current_obstacle_orientation = orientations[current_index]