started player handling on map
This commit is contained in:
parent
72ea3b861a
commit
10eaf40c64
@ -55,20 +55,6 @@ texture_region_size = Vector2i(32, 32)
|
||||
5:1/0/texture_origin = Vector2i(0, -8)
|
||||
6:1/0 = 0
|
||||
6:1/0/texture_origin = Vector2i(0, -8)
|
||||
0:2/0 = 0
|
||||
1:2/0 = 0
|
||||
2:2/0 = 0
|
||||
3:2/0 = 0
|
||||
4:2/0 = 0
|
||||
5:2/0 = 0
|
||||
6:2/0 = 0
|
||||
0:3/0 = 0
|
||||
1:3/0 = 0
|
||||
2:3/0 = 0
|
||||
3:3/0 = 0
|
||||
4:3/0 = 0
|
||||
5:3/0 = 0
|
||||
6:3/0 = 0
|
||||
|
||||
[sub_resource type="TileSet" id="TileSet_s16iq"]
|
||||
tile_shape = 1
|
||||
@ -104,68 +90,57 @@ size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
text = "Reset"
|
||||
|
||||
[node name="Z_CW" type="Button" parent="CanvasLayer"]
|
||||
anchors_preset = 6
|
||||
anchor_left = 1.0
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -34.0
|
||||
offset_top = -15.5
|
||||
offset_bottom = 15.5
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 2
|
||||
[node name="RotationVBoxContainer" type="VBoxContainer" parent="CanvasLayer"]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="Z_CW" type="Button" parent="CanvasLayer/RotationVBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Rotate CW Z-Axis"
|
||||
|
||||
[node name="Z_CCW" type="Button" parent="CanvasLayer"]
|
||||
anchors_preset = 4
|
||||
anchor_top = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_top = -15.5
|
||||
offset_right = 44.0
|
||||
offset_bottom = 15.5
|
||||
grow_vertical = 2
|
||||
[node name="Z_CCW" type="Button" parent="CanvasLayer/RotationVBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Rotate CCW Z-Axis"
|
||||
|
||||
[node name="X_CW" type="Button" parent="CanvasLayer"]
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -140.0
|
||||
offset_top = -31.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
[node name="X_CW" type="Button" parent="CanvasLayer/RotationVBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Rotate CW X-Axis"
|
||||
|
||||
[node name="X_CCW" type="Button" parent="CanvasLayer"]
|
||||
offset_right = 150.0
|
||||
offset_bottom = 31.0
|
||||
[node name="X_CCW" type="Button" parent="CanvasLayer/RotationVBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Rotate CCW X-Axis"
|
||||
|
||||
[node name="Y_CW" type="Button" parent="CanvasLayer"]
|
||||
anchors_preset = 2
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -31.0
|
||||
offset_right = 139.0
|
||||
grow_vertical = 0
|
||||
[node name="Y_CW" type="Button" parent="CanvasLayer/RotationVBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Rotate CW Y-Axis"
|
||||
|
||||
[node name="Y_CCW" type="Button" parent="CanvasLayer"]
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -150.0
|
||||
offset_bottom = 31.0
|
||||
grow_horizontal = 0
|
||||
[node name="Y_CCW" type="Button" parent="CanvasLayer/RotationVBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Rotate CCW Y-Axis"
|
||||
|
||||
[node name="DebugPlayerStuff" type="VBoxContainer" parent="CanvasLayer"]
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -37.5
|
||||
offset_right = 37.5
|
||||
offset_bottom = 70.0
|
||||
grow_horizontal = 2
|
||||
|
||||
[node name="PlayerZLayerChangeUp" type="Button" parent="CanvasLayer/DebugPlayerStuff"]
|
||||
layout_mode = 2
|
||||
text = "Z-layer +"
|
||||
|
||||
[node name="PlayerZLayerChangeDown" type="Button" parent="CanvasLayer/DebugPlayerStuff"]
|
||||
layout_mode = 2
|
||||
text = "Z-layer -"
|
||||
|
||||
[connection signal="pressed" from="CanvasLayer/ResetButton" to="." method="_on_reset_button_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/Z_CW" to="." method="_on_cw_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/Z_CCW" to="." method="_on_ccw_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/X_CW" to="." method="_on_x_cw_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/X_CCW" to="." method="_on_x_ccw_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/Y_CW" to="." method="_on_y_cw_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/Y_CCW" to="." method="_on_y_ccw_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/RotationVBoxContainer/Z_CW" to="." method="_on_cw_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/RotationVBoxContainer/Z_CCW" to="." method="_on_ccw_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/RotationVBoxContainer/X_CW" to="." method="_on_x_cw_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/RotationVBoxContainer/X_CCW" to="." method="_on_x_ccw_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/RotationVBoxContainer/Y_CW" to="." method="_on_y_cw_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/RotationVBoxContainer/Y_CCW" to="." method="_on_y_ccw_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/DebugPlayerStuff/PlayerZLayerChangeUp" to="." method="_on_player_z_layer_change_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/DebugPlayerStuff/PlayerZLayerChangeDown" to="." method="_on_player_z_layer_change_down_pressed"]
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
func _ready():
|
||||
var map = $IsometricMapLayerHolder
|
||||
var player = $Player
|
||||
map.set_player(player)
|
||||
map.init_player()
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
pass
|
||||
|
||||
@ -57,6 +57,7 @@ func _set_max_array_size():
|
||||
MAX_ARRAY_SIZE = GRID_SIZE_HEIGHT
|
||||
|
||||
|
||||
|
||||
func create_debug_map_array():
|
||||
var _debug_map = []
|
||||
|
||||
@ -90,6 +91,7 @@ func create_debug_map_array():
|
||||
"destroyable": false,
|
||||
"visibility": false,
|
||||
"unit": null,
|
||||
"unit_type": null, # PC (more options e.g. can move it) or NPC (can only view it)
|
||||
"gravity": null,
|
||||
}
|
||||
_debug_map[x][y][z] = tile_data
|
||||
@ -470,8 +472,6 @@ func isometric_grid_hover():
|
||||
# Update the highlighted tiles list
|
||||
highlighted_tiles = new_highlighted_tiles
|
||||
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# Store initial camera position
|
||||
initial_camera_position = camera.position
|
||||
@ -606,3 +606,65 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
elif event is InputEventKey and event.pressed and event.keycode == KEY_ESCAPE:
|
||||
pass
|
||||
#deselect_tile()
|
||||
|
||||
var player_node
|
||||
|
||||
func set_player(p):
|
||||
player_node = p
|
||||
|
||||
|
||||
func init_player():
|
||||
var tile = debug_map[int(INITIAL_GRID_SIZE_WIDTH/2)][INITIAL_GRID_SIZE_LENGTH/2][1]
|
||||
tile["visibility"] = true
|
||||
tile["unit"] = player_node
|
||||
tile["unit_type"] ="PC"
|
||||
player_node.set_unit_position(tile["x"], tile["y"], tile["z"])
|
||||
|
||||
|
||||
func _on_player_z_layer_change_pressed() -> void:
|
||||
var new_z = 0
|
||||
var new_y = 0
|
||||
var new_x = 0
|
||||
for z in GRID_SIZE_HEIGHT:
|
||||
for x in GRID_SIZE_WIDTH:
|
||||
for y in GRID_SIZE_LENGTH:
|
||||
var tile = debug_map[x][y][z]
|
||||
if tile["unit_type"] == "PC":
|
||||
new_z = z + 1
|
||||
new_y = y - 1
|
||||
new_x = x - 1
|
||||
tile["unit"] = null
|
||||
tile["unit_tpye"] = null
|
||||
tile["visibility"] = null
|
||||
|
||||
|
||||
var new_player_tile = debug_map[new_x][new_y][new_z]
|
||||
new_player_tile["unit"] = null
|
||||
new_player_tile["unit_tpye"] = null
|
||||
new_player_tile["visibility"] = null
|
||||
player_node.set_unit_position(new_player_tile["x"], new_player_tile["y"], new_player_tile["z"])
|
||||
|
||||
|
||||
|
||||
func _on_player_z_layer_change_down_pressed() -> void:
|
||||
var new_z = 0
|
||||
var new_y = 0
|
||||
var new_x = 0
|
||||
for z in GRID_SIZE_HEIGHT:
|
||||
for x in GRID_SIZE_WIDTH:
|
||||
for y in GRID_SIZE_LENGTH:
|
||||
var tile = debug_map[x][y][z]
|
||||
if tile["unit_type"] == "PC":
|
||||
new_z = z - 1
|
||||
new_y = y + 1
|
||||
new_x = x + 1
|
||||
tile["unit"] = null
|
||||
tile["unit_tpye"] = null
|
||||
tile["visibility"] = null
|
||||
|
||||
|
||||
var new_player_tile = debug_map[new_x][new_y][new_z]
|
||||
new_player_tile["unit"] = null
|
||||
new_player_tile["unit_tpye"] = null
|
||||
new_player_tile["visibility"] = null
|
||||
player_node.set_unit_position(new_player_tile["x"], new_player_tile["y"], new_player_tile["z"])
|
||||
|
||||
@ -3,10 +3,30 @@ extends CharacterBody2D
|
||||
@onready var collision_shape_2d: CollisionShape2D = $CollisionShape2D
|
||||
@onready var animated_sprite: AnimatedSprite2D = $AnimatedSprite2D
|
||||
|
||||
var player_data = {
|
||||
"stats": {
|
||||
"health": 100,
|
||||
"speed": 3,
|
||||
"attack": 10,
|
||||
"defense": 5
|
||||
},
|
||||
"inventory": [],
|
||||
"name": "Hero"
|
||||
}
|
||||
|
||||
|
||||
func set_unit_position(x, y, z):
|
||||
var z_layer = z
|
||||
var x_position = x
|
||||
var y_position = y
|
||||
# Update the visual z-index directly
|
||||
animated_sprite.z_index = z_layer
|
||||
animated_sprite.position = Vector2i(x_position, y_position)
|
||||
print("Palyer Z-Layer: ", z_layer)
|
||||
|
||||
|
||||
func _process(_delta: float):
|
||||
play_idle_animation()
|
||||
animated_sprite.z_index = 5
|
||||
|
||||
|
||||
func play_idle_animation():
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user