More work on maps and multiplayer
This commit is contained in:
3044
experimental/map.tscn
Normal file
3044
experimental/map.tscn
Normal file
File diff suppressed because it is too large
Load Diff
1
external/grills.crocotile
vendored
Normal file
1
external/grills.crocotile
vendored
Normal file
File diff suppressed because one or more lines are too long
109
minimap.tres
Normal file
109
minimap.tres
Normal file
File diff suppressed because one or more lines are too long
Binary file not shown.
139
models/test_minimap_meshes.tscn
Normal file
139
models/test_minimap_meshes.tscn
Normal file
@@ -0,0 +1,139 @@
|
||||
[gd_scene load_steps=5 format=4 uid="uid://bkps6dwdynirj"]
|
||||
|
||||
[ext_resource type="Material" uid="uid://dljweksgxvqv6" path="res://visuals/materials/maptile.tres" id="1_68tke"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://dpltfkrswbxnf" path="res://models/default_mesh.res" id="1_0823e"]
|
||||
|
||||
[sub_resource type="ArrayMesh" id="ArrayMesh_5s8vg"]
|
||||
_surfaces = [{
|
||||
"aabb": AABB(-0.5, 0.0023012161, -0.5, 1, 1, 1),
|
||||
"format": 34896613377,
|
||||
"index_count": 36,
|
||||
"index_data": PackedByteArray("AAABAAIAAwACAAEAAAACAAQAAwABAAUABQABAAAABgACAAMABQAGAAMABgAEAAIABQAAAAcABQAHAAYABwAAAAQABwAEAAYA"),
|
||||
"name": "texture_0",
|
||||
"primitive": 3,
|
||||
"uv_scale": Vector4(0, 0, 0, 0),
|
||||
"vertex_count": 8,
|
||||
"vertex_data": PackedByteArray("AAD/////AAAAAP//AAAAAP////8AAAAA//8AAAAAAAD///////8AAAAAAAAAAAAA//8AAP//AAAAAAAA//8AAA==")
|
||||
}]
|
||||
blend_shape_mode = 0
|
||||
|
||||
[sub_resource type="ArrayMesh" id="ArrayMesh_6o4ed"]
|
||||
resource_name = "default_mesh"
|
||||
_surfaces = [{
|
||||
"aabb": AABB(-0.5, 0.0023012161, -0.5, 1, 1, 1),
|
||||
"attribute_data": PackedByteArray("AAD/DwAAAAD/DwAAAAD/D/8PAAD/D/8PAAD/DwAAAAD/DwAAAAD/D/8PAAD/D/8PAAD/DwAAAAD/DwAAAAD/D/8PAAD/D/8PAAD/DwAAAAD/DwAAAAD/D/8PAAD/D/8PAAD/DwAAAAD/DwAAAAD/D/8PAAD/D/8PAAD/DwAAAAD/DwAAAAD/D/8PAAD/D/8P"),
|
||||
"format": 34896613399,
|
||||
"index_count": 36,
|
||||
"index_data": PackedByteArray("AAABAAIAAwAEAAUABgAHAAgACQAKAAsADAANAA4ADwAQABEAEgATABQAFQAWABcAGAAZABoAGwAcAB0AHgAfACAAIQAiACMA"),
|
||||
"material": ExtResource("1_68tke"),
|
||||
"name": "texture_0",
|
||||
"primitive": 3,
|
||||
"uv_scale": Vector4(0, 0, 0, 0),
|
||||
"vertex_count": 36,
|
||||
"vertex_data": PackedByteArray("AAD//////78AAP//AAD/v/////8AAP+/AAD//////7//////AAD/v/////////+/AAAAAAAA/78AAP//AAD/vwAA//////+/AAAAAAAA/78AAP//////vwAAAAD///+/AAAAAP//AIAAAP////8AgP///////wCAAAAAAP//AID///////8AgP//AAD//wCA//8AAP///7//////////v/////8AAP+///8AAP///7//////AAD/v///AAAAAP+///8AAAAA////////AAD//wAA//8AAP////8AAAAA//8AAP//AAD//wAAAAAAAP//AAAAAAAA/78AAAAA////v///AAD///+/AAAAAAAA/7///wAA////v///AAAAAP+/////f////3////9/////f////3////9//3////9/////f////3////9/////f////3////9/////f////3////9/////f////38AAP9/AAD/fwAA/38AAP9/AAD/fwAA/3////9/////f////3////9/////f///AAD/fwAA/38AAP9/AAD/fwAA/38AAP9/")
|
||||
}]
|
||||
blend_shape_mode = 0
|
||||
shadow_mesh = SubResource("ArrayMesh_5s8vg")
|
||||
|
||||
[node name="Node3D" type="Node3D"]
|
||||
|
||||
[node name="Ramp" type="MeshInstance3D" parent="."]
|
||||
cast_shadow = 0
|
||||
mesh = ExtResource("1_0823e")
|
||||
skeleton = NodePath("")
|
||||
metadata/extras = {
|
||||
"data": {
|
||||
"billboard": {
|
||||
"enabled": false,
|
||||
"y": false
|
||||
},
|
||||
"custom": [],
|
||||
"directional": {
|
||||
"angles": [],
|
||||
"enabled": false,
|
||||
"mode": "cameraAngle"
|
||||
},
|
||||
"instances": [{
|
||||
"custom": [],
|
||||
"name": "Ramp",
|
||||
"parent": null,
|
||||
"pos": {
|
||||
"x": 0.5,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"rot": {
|
||||
"order": "XYZ",
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"sca": {
|
||||
"x": 1.0,
|
||||
"y": 1.0,
|
||||
"z": 1.0
|
||||
},
|
||||
"uuid": "E237E1EF-6E12-406F-A5A8-F16232ED7E31"
|
||||
}],
|
||||
"name": "Ramp",
|
||||
"points": [{
|
||||
"name": "Origin",
|
||||
"pos": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
[node name="Cube" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, 0)
|
||||
cast_shadow = 0
|
||||
mesh = SubResource("ArrayMesh_6o4ed")
|
||||
skeleton = NodePath("")
|
||||
metadata/extras = {
|
||||
"data": {
|
||||
"billboard": {
|
||||
"enabled": false,
|
||||
"y": false
|
||||
},
|
||||
"custom": [],
|
||||
"directional": {
|
||||
"angles": [],
|
||||
"enabled": false,
|
||||
"mode": "cameraAngle"
|
||||
},
|
||||
"instances": [{
|
||||
"custom": [],
|
||||
"name": "Cube",
|
||||
"parent": null,
|
||||
"pos": {
|
||||
"x": 2.0,
|
||||
"y": 1.0,
|
||||
"z": 0.5
|
||||
},
|
||||
"rot": {
|
||||
"order": "XYZ",
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
},
|
||||
"sca": {
|
||||
"x": 1.0,
|
||||
"y": 1.0,
|
||||
"z": 1.0
|
||||
},
|
||||
"uuid": "7D3B65D3-B14B-4022-AEF3-7E23133D62C6"
|
||||
}],
|
||||
"name": "Cube",
|
||||
"points": [{
|
||||
"name": "Origin",
|
||||
"pos": {
|
||||
"x": 0.0,
|
||||
"y": 0.0,
|
||||
"z": 0.0
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ colors = PackedColorArray(1, 1, 1, 1)
|
||||
gradient = SubResource("Gradient_w1hxv")
|
||||
width = 1
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
[node name="Control" type="Control" groups=["scenes"]]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
[ext_resource type="Script" uid="uid://dep7nr2nkdmga" path="res://scripts/multiplayer_setup.gd" id="1_lckj3"]
|
||||
|
||||
[node name="MultiplayerSetup" type="MultiplayerSpawner" groups=["level_spawner"]]
|
||||
_spawnable_scenes = PackedStringArray("uid://ti65jukt8gvs", "uid://ck4x56txf676a")
|
||||
_spawnable_scenes = PackedStringArray("uid://ti65jukt8gvs", "uid://ck4x56txf676a", "uid://by6suwmds7xq2")
|
||||
spawn_path = NodePath(".")
|
||||
script = ExtResource("1_lckj3")
|
||||
|
||||
@@ -160,6 +160,7 @@ text = "JOIN"
|
||||
layout_mode = 2
|
||||
text = "Back"
|
||||
|
||||
[connection signal="spawned" from="." to="." method="_on_level_spawned"]
|
||||
[connection signal="pressed" from="Setup/Panel/Menu/HostButton" to="." method="_on_host_game_button_pressed"]
|
||||
[connection signal="pressed" from="Setup/Panel/Menu/JoinButton" to="." method="_on_join_game_button_pressed"]
|
||||
[connection signal="pressed" from="Setup/Panel/Menu/BackButton" to="." method="_on_menu_back_button_pressed"]
|
||||
|
||||
9
scenes/test/input_test.tscn
Normal file
9
scenes/test/input_test.tscn
Normal file
@@ -0,0 +1,9 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dr200o3iarrkk"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://6qk4ejmk8nch" path="res://scripts/test/input_test.gd" id="1_0ii2u"]
|
||||
[ext_resource type="PackedScene" uid="uid://by6suwmds7xq2" path="res://scenes/test_level.tscn" id="2_yja7f"]
|
||||
|
||||
[node name="InputTest" type="Node3D"]
|
||||
script = ExtResource("1_0ii2u")
|
||||
|
||||
[node name="Level" parent="." instance=ExtResource("2_yja7f")]
|
||||
File diff suppressed because one or more lines are too long
@@ -90,7 +90,7 @@ shader = ExtResource("13_4qe4i")
|
||||
shader_parameter/chars = ExtResource("14_p07av")
|
||||
shader_parameter/noise_tex = ExtResource("15_khjys")
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
[node name="Control" type="Control" groups=["scenes"]]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
||||
@@ -57,7 +57,11 @@ func switch_scene(packed_scene : PackedScene, spawn : bool = true) -> void:
|
||||
tween.tween_property(blinder, "self_modulate:a", 1, .15)
|
||||
if spawn:
|
||||
var spawner = get_tree().get_first_node_in_group("level_spawner") as MultiplayerSpawner
|
||||
tween.tween_callback(spawner.add_child.bind(packed_scene.instantiate(),true))
|
||||
tween.tween_callback(spawner.add_child.bind(packed_scene.instantiate(), true))
|
||||
var current_scene = get_tree().get_first_node_in_group("scenes")
|
||||
if current_scene:
|
||||
tween.tween_callback(current_scene.queue_free)
|
||||
current_scene.process_mode=Node.PROCESS_MODE_DISABLED
|
||||
else:
|
||||
tween.tween_callback(get_tree().change_scene_to_packed.bind(packed_scene))
|
||||
tween.tween_property(blinder, "self_modulate:a", 0, .15)
|
||||
|
||||
@@ -79,10 +79,10 @@ func add_trap(trap : Trap, crd : Vector3i) -> void:
|
||||
trap.square = crd
|
||||
traps[crd] = trap
|
||||
trap.position = Vector3(crd) + Vector3(.5, 0, .5)
|
||||
add_child(trap)
|
||||
add_child(trap, true)
|
||||
|
||||
func add_projectile(shot : Projectile) -> void:
|
||||
add_child(shot)
|
||||
add_child(shot, true)
|
||||
|
||||
func remove_trap_square(crd : Vector3i) -> void:
|
||||
traps.erase(crd)
|
||||
@@ -104,7 +104,7 @@ func is_valid_trap_square(crd : Vector3i) -> bool:
|
||||
|
||||
func add_vfx(vfx, crd : Vector3i) -> void:
|
||||
vfx.position = Vector3(crd) #+ Vector3(0.5, 0, 0.5)
|
||||
add_child(vfx)
|
||||
add_child(vfx, true)
|
||||
|
||||
func activate_trap(crd : Vector3i) -> void:
|
||||
if traps.has(crd):
|
||||
|
||||
@@ -73,3 +73,7 @@ func _on_joining_back_button_pressed() -> void:
|
||||
func _on_client_added(peer_handle : String, peer_id : int) -> void:
|
||||
%ParticipantsText.text = "[color=FFFF00][b]*%s[/b][/color]\n[color=FFFFFF]*%s[/color]" % [handle, peer_handle]
|
||||
%StartButton.disabled = false
|
||||
|
||||
func _on_level_spawned(node: Node) -> void:
|
||||
if node is Level:
|
||||
Game.level_spawned.rpc_id(1, Multiplayer.id)
|
||||
|
||||
@@ -8,9 +8,11 @@ class_name PawnBody extends Node3D
|
||||
@onready var struggle_ui : Sprite3D = %StruggleUI
|
||||
@onready var struggle_bar : ProgressBar = %StruggleBar
|
||||
|
||||
@rpc("call_local")
|
||||
func play_animation(anim_name : String) -> void:
|
||||
anim_player.play(anim_name)
|
||||
|
||||
@rpc("call_local")
|
||||
func show_struggle() -> void:
|
||||
struggle_ui.visible = true
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ const disarm_trap_modal = preload("res://templates/disarm_trap_modal.tscn")
|
||||
|
||||
@export var speed : float = 10
|
||||
@onready var body : PawnBody = $PawnBody
|
||||
@onready var input : PawnInput = $PawnInput
|
||||
@onready var data : PawnLevelData = $Data
|
||||
@onready var trap_sound : AudioStreamPlayer3D = $TrapSound
|
||||
@onready var detonate_sound : AudioStreamPlayer3D = $DetonateSound
|
||||
@@ -26,11 +27,11 @@ const disarm_trap_modal = preload("res://templates/disarm_trap_modal.tscn")
|
||||
|
||||
var id : int = 1
|
||||
|
||||
var state : State
|
||||
@export var state : State
|
||||
var button_actions : Dictionary[int, String]
|
||||
var current_square : Vector3i
|
||||
var facing : Vector3
|
||||
var detecting : bool = false
|
||||
@export var detecting : bool = false
|
||||
var detect_squares : Dictionary[Vector3i, bool] = {}
|
||||
var detect_tween : Tween = null
|
||||
var fling_direction : Vector3
|
||||
@@ -77,32 +78,14 @@ func _physics_process(delta: float) -> void:
|
||||
if attack_timer > 0:
|
||||
attack_timer -= delta
|
||||
check_attack_target()
|
||||
if is_poisoned():
|
||||
poison_time_remaining -= delta
|
||||
poison_pulse_timer += delta
|
||||
if poison_pulse_timer >= 1.0:
|
||||
poison_pulse_timer -= 1.0
|
||||
hurt(poison_strength)
|
||||
if poison_time_remaining <= 0:
|
||||
var pshader : ShaderMaterial = body.material.next_pass
|
||||
pshader.set_shader_parameter("strength", 0)
|
||||
poison_status_changed.emit(false)
|
||||
|
||||
var dir = Input.get_vector("west", "east", "north", "south")
|
||||
dir = Vector3(dir.x, 0, dir.y)
|
||||
if struggle_timer > 0:
|
||||
struggle_timer -= delta
|
||||
var snapped_angle = round(dir.angle_to(Vector3(1,0,0)) * 4 / PI) * PI * .25
|
||||
if abs(snapped_angle - struggle_angle) >= PI * .25:
|
||||
struggle_angle = snapped_angle
|
||||
struggle_timer -= 2 * delta
|
||||
struggling.emit(struggle_timer)
|
||||
if struggle_timer <= 0:
|
||||
hurt(1)
|
||||
knockdown(facing)
|
||||
else:
|
||||
update_poison(delta)
|
||||
|
||||
if !update_struggle(delta):
|
||||
return
|
||||
|
||||
var dir = input.dir
|
||||
|
||||
if input_locked or modal != null:
|
||||
dir = Vector3.ZERO
|
||||
|
||||
@@ -163,12 +146,11 @@ func _physics_process(delta: float) -> void:
|
||||
move_and_slide()
|
||||
|
||||
if detecting:
|
||||
update_detecting()
|
||||
update_detect_region.rpc(true)
|
||||
|
||||
#Deal with the rest of the buttons
|
||||
if !input_locked:
|
||||
if modal:
|
||||
var evt = InputEventAction.new()
|
||||
var buttons = [
|
||||
"lay trap",
|
||||
"detect",
|
||||
@@ -176,31 +158,16 @@ func _physics_process(delta: float) -> void:
|
||||
"detonate"
|
||||
]
|
||||
for button in buttons:
|
||||
if Input.is_action_just_pressed(button):
|
||||
evt.action = button
|
||||
evt.pressed = true
|
||||
modal.button_pressed(evt)
|
||||
if input.is_action_just_pressed(button):
|
||||
modal.button_pressed(button)
|
||||
elif state == State.NORMAL:
|
||||
if Input.is_action_just_pressed("left cycle trap"):
|
||||
cycle_active_trap(-1)
|
||||
if Input.is_action_just_pressed("right cycle trap"):
|
||||
cycle_active_trap(1)
|
||||
if Input.is_action_just_pressed("detonate"):
|
||||
detonate()
|
||||
elif Input.is_action_just_pressed("detect"):
|
||||
start_detecting()
|
||||
elif Input.is_action_just_released("detect"):
|
||||
stop_detecting()
|
||||
elif !detecting and Input.is_action_just_pressed("lay trap"):
|
||||
try_lay_trap()
|
||||
elif Input.is_action_pressed("attack"):
|
||||
attack()
|
||||
update_actions()
|
||||
|
||||
func attack() -> void:
|
||||
if attack_timer > 0:
|
||||
return
|
||||
if meleeing:
|
||||
body.play_animation("melee")
|
||||
body.play_animation.rpc("melee")
|
||||
attack_timer = melee_recovery_time
|
||||
else:
|
||||
if ammo <= 0:
|
||||
@@ -219,6 +186,50 @@ func attack() -> void:
|
||||
v.y = 0
|
||||
body.look_at(body.global_position - v)
|
||||
|
||||
|
||||
func update_actions() -> void:
|
||||
if input.is_action_just_pressed("left cycle trap"):
|
||||
cycle_active_trap(-1)
|
||||
if input.is_action_just_pressed("right cycle trap"):
|
||||
cycle_active_trap(1)
|
||||
if input.is_action_just_pressed("detonate"):
|
||||
detonate()
|
||||
elif input.is_action_just_pressed("detect"):
|
||||
start_detecting()
|
||||
elif input.is_action_just_released("detect"):
|
||||
stop_detecting()
|
||||
elif !detecting and input.is_action_just_pressed("lay trap"):
|
||||
try_lay_trap()
|
||||
elif input.is_action_pressed("attack"):
|
||||
attack()
|
||||
|
||||
func update_struggle(delta : float) -> bool:
|
||||
if struggle_timer > 0:
|
||||
struggle_timer -= delta
|
||||
var snapped_angle = round(input.dir.angle_to(Vector3(1,0,0)) * 4 / PI) * PI * .25
|
||||
if abs(snapped_angle - struggle_angle) >= PI * .25:
|
||||
struggle_angle = snapped_angle
|
||||
struggle_timer -= 2 * delta
|
||||
struggling.emit(struggle_timer)
|
||||
if struggle_timer <= 0:
|
||||
hurt(1)
|
||||
knockdown(facing)
|
||||
else:
|
||||
return false
|
||||
return true
|
||||
|
||||
func update_poison(delta : float) -> void:
|
||||
if is_poisoned():
|
||||
poison_time_remaining -= delta
|
||||
poison_pulse_timer += delta
|
||||
if poison_pulse_timer >= 1.0:
|
||||
poison_pulse_timer -= 1.0
|
||||
hurt(poison_strength)
|
||||
if poison_time_remaining <= 0:
|
||||
var pshader : ShaderMaterial = body.material.next_pass
|
||||
pshader.set_shader_parameter("strength", 0)
|
||||
poison_status_changed.emit(false)
|
||||
|
||||
func fire_ranged() -> void:
|
||||
var shot = body.projectile_template.instantiate()
|
||||
var tdir : Vector3 = Vector3.ZERO
|
||||
@@ -308,52 +319,6 @@ func clear_action() -> void:
|
||||
input_locked = false
|
||||
action_tween = null
|
||||
|
||||
func update_detecting() -> void:
|
||||
var new_square : Vector3i = (global_position - Vector3.ONE * .5).round()
|
||||
if new_square == current_square:
|
||||
return
|
||||
current_square = new_square
|
||||
var new_squares : Dictionary[Vector3i, bool] = {}
|
||||
for i in range(-2, 3):
|
||||
for j in range(-2, 3):
|
||||
for k in range(-2, 2):
|
||||
if abs(i) + abs(j) < 3:
|
||||
var sq = current_square + Vector3i(i, k, j)
|
||||
new_squares[sq] = true
|
||||
|
||||
|
||||
for sq in detect_squares.keys():
|
||||
if !new_squares.has(sq):
|
||||
Game.level.detect_square(sq, false)
|
||||
|
||||
|
||||
|
||||
var remove_list = []
|
||||
var trap_detected : bool = false
|
||||
for sq in new_squares.keys():
|
||||
if detect_squares.has(sq):
|
||||
continue
|
||||
if !Game.level.detect_square(sq, true):
|
||||
remove_list.append(sq)
|
||||
else:
|
||||
var trap = Game.level.get_square_trap(sq + Vector3i(0,1,0))
|
||||
if trap and trap.is_just_revealed():
|
||||
trap_detected = true
|
||||
if trap_detected:
|
||||
detect_alert()
|
||||
|
||||
detect_squares = new_squares
|
||||
for key in remove_list:
|
||||
detect_squares.erase(key)
|
||||
|
||||
var trap : Trap = Game.level.get_square_trap(current_square)
|
||||
if trap != null:
|
||||
if trap.trap_owner == Multiplayer.id:
|
||||
show_remove_trap_modal()
|
||||
else:
|
||||
trap.disarming = true
|
||||
show_disarm_trap_modal()
|
||||
|
||||
|
||||
func detect_alert() -> void:
|
||||
detect_sound.play()
|
||||
@@ -392,26 +357,44 @@ func show_disarm_trap_modal() -> void:
|
||||
|
||||
func start_detecting() -> void:
|
||||
detecting = true
|
||||
current_square = (global_position - Vector3.ONE * .5).round()
|
||||
detect_squares = {}
|
||||
update_detect_region.rpc(false)
|
||||
|
||||
@rpc("authority")
|
||||
func update_detect_region(update : bool) -> void:
|
||||
var new_square : Vector3i = (global_position - Vector3.ONE * .5).round()
|
||||
if update and new_square == current_square:
|
||||
return
|
||||
current_square = new_square
|
||||
var new_squares : Dictionary[Vector3i, bool] = {}
|
||||
for i in range(-2, 3):
|
||||
for j in range(-2, 3):
|
||||
for k in range(-2, 2):
|
||||
if abs(i) + abs(j) < 3:
|
||||
var sq = current_square + Vector3i(i, k, j)
|
||||
detect_squares[sq] = true
|
||||
new_squares[sq] = true
|
||||
|
||||
if update:
|
||||
for sq in detect_squares.keys():
|
||||
if !new_squares.has(sq):
|
||||
Game.level.detect_square(sq, false)
|
||||
|
||||
var remove_list = []
|
||||
var trap_detected : bool = false
|
||||
for sq in detect_squares.keys():
|
||||
for sq in new_squares.keys():
|
||||
if update and detect_squares.has(sq):
|
||||
continue
|
||||
if !Game.level.detect_square(sq, true):
|
||||
remove_list.append(sq)
|
||||
else:
|
||||
var trap = Game.level.get_square_trap(sq + Vector3i(0,1,0))
|
||||
if trap and trap.is_just_revealed():
|
||||
trap_detected = true
|
||||
|
||||
if trap_detected:
|
||||
detect_alert()
|
||||
|
||||
detect_squares = new_squares
|
||||
|
||||
for key in remove_list:
|
||||
detect_squares.erase(key)
|
||||
|
||||
@@ -419,9 +402,16 @@ func start_detecting() -> void:
|
||||
if trap != null:
|
||||
if trap.trap_owner == Multiplayer.id:
|
||||
show_remove_trap_modal()
|
||||
else:
|
||||
trap.disarming = true
|
||||
show_disarm_trap_modal()
|
||||
|
||||
func stop_detecting() -> void:
|
||||
detecting = false
|
||||
clear_detect_region()
|
||||
|
||||
@rpc("authority")
|
||||
func clear_detect_region() -> void:
|
||||
for sq in detect_squares.keys():
|
||||
Game.level.detect_square(sq, false)
|
||||
detect_squares = {}
|
||||
@@ -434,7 +424,7 @@ func setup(id : int, traps : Array, pos : Vector3) -> void:
|
||||
for trap in traps:
|
||||
traplist.append(PawnLevelData.TrapData.new(trap.type, trap.qty, trap.qty))
|
||||
$Data.traps = traplist
|
||||
set_multiplayer_authority(id)
|
||||
input.set_multiplayer_authority(id)
|
||||
struggling.connect(body._on_struggle_changed)
|
||||
Game.setup_player(self)
|
||||
|
||||
|
||||
55
scripts/pawn_input.gd
Normal file
55
scripts/pawn_input.gd
Normal file
@@ -0,0 +1,55 @@
|
||||
class_name PawnInput extends Node
|
||||
|
||||
|
||||
@export var dir : Vector3
|
||||
@export var pressed : Dictionary[String, bool]
|
||||
@export var just_pressed : Dictionary[String, bool]
|
||||
@export var just_released : Dictionary[String, bool]
|
||||
|
||||
func _ready() -> void:
|
||||
pressed = {
|
||||
"left cycle trap":false,
|
||||
"right cycle trap":false,
|
||||
"detonate":false,
|
||||
"detect":false,
|
||||
"lay trap":false,
|
||||
"attack":false
|
||||
}
|
||||
just_pressed = {
|
||||
"left cycle trap":false,
|
||||
"right cycle trap":false,
|
||||
"detonate":false,
|
||||
"detect":false,
|
||||
"lay trap":false,
|
||||
"attack":false
|
||||
}
|
||||
just_released = {
|
||||
"left cycle trap":false,
|
||||
"right cycle trap":false,
|
||||
"detonate":false,
|
||||
"detect":false,
|
||||
"lay trap":false,
|
||||
"attack":false
|
||||
}
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var d = Input.get_vector("west", "east", "north", "south")
|
||||
dir = Vector3(d.x, 0, d.y)
|
||||
for key : String in pressed:
|
||||
if Input.is_action_pressed(key):
|
||||
just_pressed[key] = !pressed[key]
|
||||
just_released[key] = false
|
||||
pressed[key] = true
|
||||
else:
|
||||
just_released[key] = pressed[key]
|
||||
just_pressed[key] = false
|
||||
pressed[key] = false
|
||||
|
||||
func is_action_pressed(action : String) -> bool:
|
||||
return pressed.has(action) && pressed[action]
|
||||
|
||||
func is_action_just_pressed(action : String) -> bool:
|
||||
return just_pressed.has(action) && just_pressed[action]
|
||||
|
||||
func is_action_just_released(action : String) -> bool:
|
||||
return just_released.has(action) && just_released[action]
|
||||
1
scripts/pawn_input.gd.uid
Normal file
1
scripts/pawn_input.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cvuoq81ipid2o
|
||||
8
scripts/test/input_test.gd
Normal file
8
scripts/test/input_test.gd
Normal file
@@ -0,0 +1,8 @@
|
||||
extends Node3D
|
||||
|
||||
@onready var level : Level = $Level
|
||||
|
||||
func _ready() -> void:
|
||||
Game.pawns_selected[1] = load("res://data/pawns/van_reily.tres")
|
||||
level.setup()
|
||||
|
||||
1
scripts/test/input_test.gd.uid
Normal file
1
scripts/test/input_test.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://6qk4ejmk8nch
|
||||
@@ -252,18 +252,6 @@ horizontal_alignment = 1
|
||||
custom_minimum_size = Vector2(150, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="SubViewportContainer" type="SubViewportContainer" parent="Control/PanelContainer/HBoxContainer/OppnentView"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="Control/PanelContainer/HBoxContainer/OppnentView/SubViewportContainer"]
|
||||
handle_input_locally = false
|
||||
gui_disable_input = true
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="Control/PanelContainer/HBoxContainer/OppnentView/SubViewportContainer/SubViewport"]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="VBoxContainer3" type="VBoxContainer" parent="Control/PanelContainer/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(250, 0)
|
||||
layout_mode = 2
|
||||
@@ -272,6 +260,24 @@ layout_mode = 2
|
||||
custom_minimum_size = Vector2(250, 130)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="SubViewportContainer" type="SubViewportContainer" parent="Control/PanelContainer/HBoxContainer/VBoxContainer3/PanelContainer3"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="Control/PanelContainer/HBoxContainer/VBoxContainer3/PanelContainer3/SubViewportContainer"]
|
||||
handle_input_locally = false
|
||||
scaling_3d_mode = 1
|
||||
fsr_sharpness = 2.0
|
||||
canvas_item_default_texture_filter = 0
|
||||
gui_disable_input = true
|
||||
size = Vector2i(250, 130)
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="Control/PanelContainer/HBoxContainer/VBoxContainer3/PanelContainer3/SubViewportContainer/SubViewport"]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 11000, 0)
|
||||
keep_aspect = 0
|
||||
projection = 1
|
||||
size = 25.0
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Control/PanelContainer/HBoxContainer/VBoxContainer3"]
|
||||
custom_minimum_size = Vector2(0, 70)
|
||||
layout_mode = 2
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=35 format=3 uid="uid://c8xf3qawk5c6u"]
|
||||
[gd_scene load_steps=37 format=3 uid="uid://c8xf3qawk5c6u"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bcs7ygh6s3l35" path="res://scripts/pawn_controller.gd" id="1_h27ep"]
|
||||
[ext_resource type="Script" uid="uid://wye3mat5y5yg" path="res://scripts/pawn_body.gd" id="2_dn5ph"]
|
||||
@@ -21,6 +21,7 @@
|
||||
[ext_resource type="Texture2D" uid="uid://dmnwtwu5v4voh" path="res://visuals/images/icons/detect mark.png" id="19_5822g"]
|
||||
[ext_resource type="AudioStream" uid="uid://cmnibhyxpag0a" path="res://audio/sounds/BeepBeep_high.wav" id="20_v7o58"]
|
||||
[ext_resource type="PackedScene" uid="uid://bqwpra5d1faxw" path="res://models/pawns/van_reily.gltf" id="21_dn5ph"]
|
||||
[ext_resource type="Script" uid="uid://cvuoq81ipid2o" path="res://scripts/pawn_input.gd" id="22_pnc3q"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_y646j"]
|
||||
next_pass = ExtResource("4_8twd3")
|
||||
@@ -220,6 +221,26 @@ height = 1.0
|
||||
properties/0/path = NodePath(".:position")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 1
|
||||
properties/1/path = NodePath(".:detecting")
|
||||
properties/1/spawn = true
|
||||
properties/1/replication_mode = 1
|
||||
properties/2/path = NodePath(".:state")
|
||||
properties/2/spawn = true
|
||||
properties/2/replication_mode = 1
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_pnc3q"]
|
||||
properties/0/path = NodePath("PawnInput:dir")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 1
|
||||
properties/1/path = NodePath("PawnInput:pressed")
|
||||
properties/1/spawn = true
|
||||
properties/1/replication_mode = 1
|
||||
properties/2/path = NodePath("PawnInput:just_pressed")
|
||||
properties/2/spawn = true
|
||||
properties/2/replication_mode = 1
|
||||
properties/3/path = NodePath("PawnInput:just_released")
|
||||
properties/3/spawn = true
|
||||
properties/3/replication_mode = 1
|
||||
|
||||
[node name="Player" type="CharacterBody3D" groups=["combat"]]
|
||||
physics_interpolation_mode = 1
|
||||
@@ -356,3 +377,8 @@ max_db = -7.0
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_h27ep")
|
||||
|
||||
[node name="PawnInput" type="MultiplayerSynchronizer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
replication_config = SubResource("SceneReplicationConfig_pnc3q")
|
||||
script = ExtResource("22_pnc3q")
|
||||
|
||||
114
test minimap.tres
Normal file
114
test minimap.tres
Normal file
File diff suppressed because one or more lines are too long
18
visuals/materials/maptile.tres
Normal file
18
visuals/materials/maptile.tres
Normal file
@@ -0,0 +1,18 @@
|
||||
[gd_resource type="ShaderMaterial" load_steps=4 format=3 uid="uid://dljweksgxvqv6"]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://dtq021j73hhht" path="res://visuals/shaders/maptile.gdshader" id="1_o0obt"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_2ho3f"]
|
||||
offsets = PackedFloat32Array(0, 0.245, 0.56, 0.8025, 1)
|
||||
colors = PackedColorArray(0, 0, 0.003921569, 1, 1.6845763e-06, 0, 0.54036456, 1, 0.0007814509, 0.22053, 0.7667125, 1, 0.00022246034, 0.29345024, 0.68059045, 1, 0, 0.49560964, 0.86397636, 1)
|
||||
|
||||
[sub_resource type="GradientTexture1D" id="GradientTexture1D_lvjv7"]
|
||||
gradient = SubResource("Gradient_2ho3f")
|
||||
width = 1024
|
||||
|
||||
[resource]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_o0obt")
|
||||
shader_parameter/height_gradient = SubResource("GradientTexture1D_lvjv7")
|
||||
shader_parameter/vertical_offset = 9999.0
|
||||
shader_parameter/vertical_range = 6.0
|
||||
24
visuals/shaders/maptile.gdshader
Normal file
24
visuals/shaders/maptile.gdshader
Normal file
@@ -0,0 +1,24 @@
|
||||
shader_type spatial;
|
||||
|
||||
uniform sampler2D height_gradient;
|
||||
uniform float vertical_offset;
|
||||
uniform float vertical_range : hint_range(1.0, 12.0, 1.0);
|
||||
varying vec3 world_position;
|
||||
|
||||
void vertex() {
|
||||
// Called for every vertex the material is visible on.
|
||||
world_position = (MODEL_MATRIX * vec4(VERTEX, 1)).xyz;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
float h = (world_position.y - vertical_offset)/vertical_range;
|
||||
vec2 uv = vec2(clamp(h, 0.001, 1.0),0.5);
|
||||
vec4 color = texture(height_gradient, uv);
|
||||
ALBEDO = color.rgb;
|
||||
// Called for every pixel the material is visible on.
|
||||
}
|
||||
|
||||
//void light() {
|
||||
// // Called for every pixel for every light affecting the material.
|
||||
// // Uncomment to replace the default light processing function with this one.
|
||||
//}
|
||||
1
visuals/shaders/maptile.gdshader.uid
Normal file
1
visuals/shaders/maptile.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dtq021j73hhht
|
||||
Reference in New Issue
Block a user