Added visualisation for firing arc #3

Merged
TechieDamien merged 1 commits from weapons_visualisation into master 2021-07-10 15:36:45 +00:00
3 changed files with 35 additions and 6 deletions

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=18 format=2] [gd_scene load_steps=19 format=2]
[ext_resource path="res://Scripts/Player.gd" type="Script" id=1] [ext_resource path="res://Scripts/Player.gd" type="Script" id=1]
[ext_resource path="res://Models/Arrow.obj" type="ArrayMesh" id=2] [ext_resource path="res://Models/Arrow.obj" type="ArrayMesh" id=2]
@ -14,6 +14,7 @@
[ext_resource path="res://Images/BatteryFilling.png" type="Texture" id=12] [ext_resource path="res://Images/BatteryFilling.png" type="Texture" id=12]
[ext_resource path="res://Images/BatteryBackground.png" type="Texture" id=13] [ext_resource path="res://Images/BatteryBackground.png" type="Texture" id=13]
[ext_resource path="res://Models/cone-collision.tres" type="Shape" id=14] [ext_resource path="res://Models/cone-collision.tres" type="Shape" id=14]
[ext_resource path="res://Models/Cone.obj" type="ArrayMesh" id=15]
[sub_resource type="CapsuleShape" id=1] [sub_resource type="CapsuleShape" id=1]
radius = 0.15 radius = 0.15
@ -478,6 +479,11 @@ angular_damp = 0.0
transform = Transform( 25, 0, 0, 0, -4.07302e-06, -100, 0, 25, -1.62921e-05, 0, 1000, 0 ) transform = Transform( 25, 0, 0, 0, -4.07302e-06, -100, 0, 25, -1.62921e-05, 0, 1000, 0 )
shape = ExtResource( 14 ) shape = ExtResource( 14 )
[node name="Cone" type="MeshInstance" parent="GunContainer/Cone/CollisionShape"]
visible = false
mesh = ExtResource( 15 )
material/0 = ExtResource( 4 )
[node name="spaceship-gun" parent="GunContainer" instance=ExtResource( 10 )] [node name="spaceship-gun" parent="GunContainer" instance=ExtResource( 10 )]
transform = Transform( 1, 0, 1.64203e-15, 0, 1, 0, 1.64203e-15, 0, 1, 4.47035e-08, 0.811224, -3.54597e-08 ) transform = Transform( 1, 0, 1.64203e-15, 0, 1, 0, 1.64203e-15, 0, 1, 4.47035e-08, 0.811224, -3.54597e-08 )
@ -571,6 +577,18 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="WeaponVisualiserMenu" type="OptionButton" parent="WeaponsPanel"]
anchor_left = 0.5
anchor_top = 0.8
anchor_right = 0.5
anchor_bottom = 0.8
margin_left = -50.0
margin_right = 50.0
grow_horizontal = 2
text = "None"
items = [ "None", null, false, 0, null, "Self", null, false, 1, null, "Everyone", null, false, 2, null ]
selected = 0
[node name="StatusPanel" type="Panel" parent="."] [node name="StatusPanel" type="Panel" parent="."]
visible = false visible = false
anchor_left = 0.5 anchor_left = 0.5
@ -645,3 +663,4 @@ margin_bottom = -10.0
[connection signal="pressed" from="ThrustPanel/ResetButton" to="." method="_on_ResetButton_pressed"] [connection signal="pressed" from="ThrustPanel/ResetButton" to="." method="_on_ResetButton_pressed"]
[connection signal="body_entered" from="GunContainer/Cone" to="." method="_on_player_enter_firing_arc"] [connection signal="body_entered" from="GunContainer/Cone" to="." method="_on_player_enter_firing_arc"]
[connection signal="body_exited" from="GunContainer/Cone" to="." method="_on_player_exit_firing_arc"] [connection signal="body_exited" from="GunContainer/Cone" to="." method="_on_player_exit_firing_arc"]
[connection signal="item_selected" from="WeaponsPanel/WeaponVisualiserMenu" to="." method="_on_WeaponVisualiserMenu_item_selected"]

View File

@ -37,13 +37,11 @@ func mouse_exit(player_obj : RigidBody):
remote func declare_winner(name : String) -> void: remote func declare_winner(name : String) -> void:
winner_name = "Victor: " + name winner_name = "Victor: " + name
$WinnerPanel/WinnerLabel.text = winner_name $WinnerPanel/WinnerLabel.text = winner_name
func show_winner() -> void: func show_winner() -> void:
if winner_name != null: if winner_name != null:
$WinnerPanel.visible = true $WinnerPanel.visible = true
func _on_RematchButton_pressed(): func _on_RematchButton_pressed():
$WinnerPanel/RematchButton.disabled = true $WinnerPanel/RematchButton.disabled = true
$Camera.clear_register() $Camera.clear_register()
@ -53,9 +51,10 @@ func _on_RematchButton_pressed():
winner_name = null winner_name = null
rpc_id(1, "request_rematch", get_tree().get_network_unique_id()) rpc_id(1, "request_rematch", get_tree().get_network_unique_id())
func _on_ExitButton_pressed(): func _on_ExitButton_pressed():
get_parent().exit_button_pressed() get_parent().exit_button_pressed()
func set_all_firing_arc_visibilities(toggle : bool) -> void:
for player in players.values():
player.set_firing_arc_visibility(toggle)

View File

@ -522,7 +522,6 @@ func _fire_gun(delta : float) -> void:
if closest_enemy != null: if closest_enemy != null:
$GunContainer/RayCast.look_at($GunContainer/RayCast.global_transform.origin - translation, Vector3(0,1,0)) $GunContainer/RayCast.look_at($GunContainer/RayCast.global_transform.origin - translation, Vector3(0,1,0))
#$GunContainer/RayCast.rotate_object_local(Vector3(-1,-1,-1).normalized(), 90.0)
var raycast_pos : Vector3 = $GunContainer/RayCast.global_transform.origin var raycast_pos : Vector3 = $GunContainer/RayCast.global_transform.origin
var target_pos : Vector3 = $GunContainer/RayCast.get_collision_point() var target_pos : Vector3 = $GunContainer/RayCast.get_collision_point()
_update_laser(raycast_pos.distance_to(target_pos)) _update_laser(raycast_pos.distance_to(target_pos))
@ -616,3 +615,15 @@ func _on_player_enter_firing_arc(body):
func _on_player_exit_firing_arc(body): func _on_player_exit_firing_arc(body):
players_in_firing_arc.erase(body) players_in_firing_arc.erase(body)
print(body.name) print(body.name)
func set_firing_arc_visibility(toggle : bool) -> void:
$GunContainer/Cone/CollisionShape/Cone.visible = toggle
func _on_WeaponVisualiserMenu_item_selected(index):
if index == 0:
get_parent().set_all_firing_arc_visibilities(false)
elif index == 1:
get_parent().set_all_firing_arc_visibilities(false)
set_firing_arc_visibility(true)
elif index == 2:
get_parent().set_all_firing_arc_visibilities(true)