Changed targeting system to use cone
parent
88c7a0c504
commit
508c90f611
Binary file not shown.
Binary file not shown.
BIN
Models/Material_001.material (Stored with Git LFS)
BIN
Models/Material_001.material (Stored with Git LFS)
Binary file not shown.
BIN
Models/Material_002.material (Stored with Git LFS)
BIN
Models/Material_002.material (Stored with Git LFS)
Binary file not shown.
Binary file not shown.
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=17 format=2]
|
||||
[gd_scene load_steps=18 format=2]
|
||||
|
||||
[ext_resource path="res://Scripts/Player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Models/Arrow.obj" type="ArrayMesh" id=2]
|
||||
|
@ -13,6 +13,7 @@
|
|||
[ext_resource path="res://Images/BatteryBolt.png" type="Texture" id=11]
|
||||
[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://Models/cone-collision.tres" type="Shape" id=14]
|
||||
|
||||
[sub_resource type="CapsuleShape" id=1]
|
||||
radius = 0.15
|
||||
|
@ -465,18 +466,29 @@ anims/ShowEndTurnBanner = ExtResource( 9 )
|
|||
|
||||
[node name="GunContainer" type="Spatial" parent="."]
|
||||
transform = Transform( -4.37114e-09, 4.37114e-09, 0.1, 0.1, -4.37114e-09, 4.37114e-09, 4.37114e-09, 0.1, -4.37114e-09, 0, -0.0222926, 0.382747 )
|
||||
visible = false
|
||||
|
||||
[node name="Cone" type="Area" parent="GunContainer"]
|
||||
transform = Transform( 1, -1.77636e-14, 1.91069e-15, 1.77636e-14, 1, -1.77636e-14, -1.91069e-15, 1.77636e-14, 1, 1.19209e-07, 2.66684, -1.16571e-07 )
|
||||
input_ray_pickable = false
|
||||
gravity = 0.0
|
||||
linear_damp = 0.0
|
||||
angular_damp = 0.0
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="GunContainer/Cone"]
|
||||
transform = Transform( 25, 0, 0, 0, -4.07302e-06, -100, 0, 25, -1.62921e-05, 0, 1000, 0 )
|
||||
shape = ExtResource( 14 )
|
||||
|
||||
[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 )
|
||||
|
||||
[node name="RayCast" type="RayCast" parent="GunContainer"]
|
||||
transform = Transform( 1, 0, 1.64203e-15, 0, 1, 0, 1.64203e-15, 0, 1, 7.45058e-08, 1.76881, -7.73171e-08 )
|
||||
visible = false
|
||||
enabled = true
|
||||
cast_to = Vector3( 0, 500, 0 )
|
||||
cast_to = Vector3( 0, 0, -500 )
|
||||
|
||||
[node name="CSGCylinder" type="CSGCylinder" parent="GunContainer/RayCast"]
|
||||
transform = Transform( 1, 0, 1.64203e-15, 0, 1, 0, 1.64203e-15, 0, 1, 0, 30, 0 )
|
||||
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 30, 0 )
|
||||
material_override = SubResource( 3 )
|
||||
radius = 0.09
|
||||
height = 60.0
|
||||
|
@ -614,6 +626,7 @@ margin_left = 10.0
|
|||
margin_top = 10.0
|
||||
margin_right = -10.0
|
||||
margin_bottom = -10.0
|
||||
|
||||
[connection signal="mouse_entered" from="." to="." method="_on_Player_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="." to="." method="_on_Player_mouse_exited"]
|
||||
[connection signal="value_changed" from="MainPanel/TimeBar" to="." method="_on_TimeBar_value_changed"]
|
||||
|
@ -630,3 +643,5 @@ margin_bottom = -10.0
|
|||
[connection signal="value_changed" from="ThrustPanel/ZLin" to="." method="_on_ZLin_value_changed"]
|
||||
[connection signal="value_changed" from="ThrustPanel/ZRot" to="." method="_on_ZRot_value_changed"]
|
||||
[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_exited" from="GunContainer/Cone" to="." method="_on_player_exit_firing_arc"]
|
||||
|
|
|
@ -8,6 +8,7 @@ var thrust_plan : Plan = Plan.new()
|
|||
var weapons_plan : Plan = Plan.new()
|
||||
var is_local : bool = false
|
||||
var running_plan : bool = false
|
||||
var using_full_plan : bool = false
|
||||
var was_running_plan : bool = false
|
||||
var plan_time : float = 0.0
|
||||
var last_translation : Vector3 = get_translation()
|
||||
|
@ -35,6 +36,8 @@ var end_health : float = 100.0
|
|||
var energy : float = 100.0
|
||||
var end_energy : float = 100.0
|
||||
|
||||
var players_in_firing_arc = []
|
||||
|
||||
onready var arrow_obj : Spatial = $ArrowContainer
|
||||
onready var arrow_scale_obj : Spatial = $ArrowContainer/ArrowScaleContainer
|
||||
onready var rotate_arrow_obj : Spatial = $RotateArrowContainer
|
||||
|
@ -288,7 +291,7 @@ func _physics_process(delta : float) -> void:
|
|||
if !running_plan:
|
||||
if is_local and was_running_plan:
|
||||
get_parent().show_winner()
|
||||
$GunContainer.visible = false
|
||||
$GunContainer/RayCast.visible = false
|
||||
arrow_obj.visible = true
|
||||
rotate_arrow_obj.visible = true
|
||||
disable_all_engine_particles()
|
||||
|
@ -297,6 +300,19 @@ func _physics_process(delta : float) -> void:
|
|||
was_running_plan = false
|
||||
return
|
||||
|
||||
if !was_running_plan:
|
||||
players_in_firing_arc = $GunContainer/Cone.get_overlapping_bodies()
|
||||
if using_full_plan:
|
||||
set_linear_velocity(initial_velocity)
|
||||
set_angular_velocity(initial_rotational_velocity)
|
||||
set_translation(initial_translation)
|
||||
set_rotation(initial_rotation)
|
||||
else:
|
||||
set_linear_velocity(end_linear_velocity)
|
||||
set_angular_velocity(end_rotational_velocity)
|
||||
set_translation(end_translation)
|
||||
set_rotation(end_rotation)
|
||||
|
||||
was_running_plan = true
|
||||
if time_of_death > 0 and plan_time > time_of_death:
|
||||
self.visible = false
|
||||
|
@ -312,6 +328,7 @@ func _physics_process(delta : float) -> void:
|
|||
last_translation = get_translation()
|
||||
last_rotation = get_rotation()
|
||||
running_plan = false
|
||||
print("thrust plan set running plan to false")
|
||||
return
|
||||
arrow_obj.visible = false
|
||||
rotate_arrow_obj.visible = false
|
||||
|
@ -322,16 +339,16 @@ func _physics_process(delta : float) -> void:
|
|||
var all_weapons_elements = _get_all_weapons_elements()
|
||||
var current_weapons_element : WeaponsElement = _get_current_plan_element(all_weapons_elements)
|
||||
if current_weapons_element == null:
|
||||
$GunContainer.visible = false
|
||||
$GunContainer/RayCast.visible = false
|
||||
running_plan = false
|
||||
return
|
||||
if current_weapons_element.firing and is_alive:
|
||||
_fire_gun(delta)
|
||||
elif energy < 100:
|
||||
$GunContainer.visible = false
|
||||
$GunContainer/RayCast.visible = false
|
||||
energy += BASE_ENERGY_REGEN * delta
|
||||
else:
|
||||
$GunContainer.visible = false
|
||||
$GunContainer/RayCast.visible = false
|
||||
|
||||
calculate_other_damage(delta)
|
||||
plan_time += delta
|
||||
|
@ -462,13 +479,10 @@ func update_engine_particles(linear_thrust : Vector3, rotational_thrust : Vector
|
|||
engine_particles2.emitting = false
|
||||
|
||||
func play_current_plan() -> void:
|
||||
set_linear_velocity(end_linear_velocity)
|
||||
set_angular_velocity(end_rotational_velocity)
|
||||
set_translation(end_translation)
|
||||
set_rotation(end_rotation)
|
||||
|
||||
health = end_health
|
||||
energy = end_energy
|
||||
|
||||
using_full_plan = false
|
||||
running_plan = true
|
||||
plan_time = 5 * turn_counter
|
||||
|
||||
|
@ -476,11 +490,8 @@ func play_all_plans() -> void:
|
|||
get_parent().play_full_plans()
|
||||
|
||||
func play_full_plan() -> void:
|
||||
set_linear_velocity(initial_velocity)
|
||||
set_angular_velocity(initial_rotational_velocity)
|
||||
set_translation(initial_translation)
|
||||
set_rotation(initial_rotation)
|
||||
running_plan = true
|
||||
using_full_plan = true
|
||||
plan_time = 0.0
|
||||
health = 100.0
|
||||
energy = 100.0
|
||||
|
@ -493,20 +504,34 @@ func _update_battery_visuals(value : float) -> void:
|
|||
|
||||
func _update_laser(length : float) -> void:
|
||||
$GunContainer/RayCast/CSGCylinder.height = length*10
|
||||
$GunContainer/RayCast/CSGCylinder.translation = Vector3(0, length*5, 0)
|
||||
$GunContainer/RayCast/CSGCylinder.translation = Vector3(0, 0, -length*5)
|
||||
|
||||
func _fire_gun(delta : float) -> void:
|
||||
$GunContainer.visible = true
|
||||
if $GunContainer/RayCast.is_colliding():
|
||||
$GunContainer/RayCast.visible = true
|
||||
|
||||
var closest_enemy = null
|
||||
var distance_of_closest = -1
|
||||
for player in players_in_firing_arc:
|
||||
if player.player_id == player_id or !player.is_alive:
|
||||
continue
|
||||
var player_distance : float = (player.translation - translation).length()
|
||||
if distance_of_closest == -1 or player_distance < distance_of_closest:
|
||||
closest_enemy = player
|
||||
distance_of_closest = player_distance
|
||||
|
||||
|
||||
if closest_enemy != null:
|
||||
$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 target_pos : Vector3 = $GunContainer/RayCast.get_collision_point()
|
||||
_update_laser(raycast_pos.distance_to(target_pos))
|
||||
else:
|
||||
_update_laser($GunContainer/RayCast.cast_to.y)
|
||||
$GunContainer/RayCast.rotation = Vector3.ZERO
|
||||
_update_laser(-$GunContainer/RayCast.cast_to.z)
|
||||
energy -= delta * BASE_ENERGY_USAGE
|
||||
if $GunContainer/RayCast.is_colliding():
|
||||
var target : RigidBody = $GunContainer/RayCast.get_collider()
|
||||
target.take_damage(BASE_DPS * delta)
|
||||
if closest_enemy != null:
|
||||
closest_enemy.take_damage(BASE_DPS * delta)
|
||||
|
||||
func get_display_name() -> String:
|
||||
return get_parent().get_parent().name_dict[player_id]
|
||||
|
@ -583,3 +608,11 @@ func fix_plans() -> void:
|
|||
var new_weapons_element : WeaponsElement = WeaponsElement.new()
|
||||
new_weapons_element.firing = false
|
||||
new_weapons_element.time = 5.0 - weapons_plan.current_time()
|
||||
|
||||
func _on_player_enter_firing_arc(body):
|
||||
players_in_firing_arc.append(body)
|
||||
print(body.name)
|
||||
|
||||
func _on_player_exit_firing_arc(body):
|
||||
players_in_firing_arc.erase(body)
|
||||
print(body.name)
|
||||
|
|
Binary file not shown.
|
@ -8,21 +8,20 @@ export_filter="all_resources"
|
|||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="../Builds/Client.x86_64"
|
||||
patch_list=PoolStringArray( )
|
||||
script_export_mode=1
|
||||
script_encryption_key=""
|
||||
|
||||
[preset.0.options]
|
||||
|
||||
custom_template/debug=""
|
||||
custom_template/release=""
|
||||
binary_format/64_bits=true
|
||||
binary_format/embed_pck=false
|
||||
texture_format/bptc=false
|
||||
texture_format/s3tc=true
|
||||
texture_format/etc=false
|
||||
texture_format/etc2=false
|
||||
texture_format/no_bptc_fallbacks=true
|
||||
binary_format/64_bits=true
|
||||
binary_format/embed_pck=false
|
||||
custom_template/release=""
|
||||
custom_template/debug=""
|
||||
|
||||
[preset.1]
|
||||
|
||||
|
@ -34,21 +33,20 @@ export_filter="all_resources"
|
|||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="../Builds/Windows/Client.exe"
|
||||
patch_list=PoolStringArray( )
|
||||
script_export_mode=1
|
||||
script_encryption_key=""
|
||||
|
||||
[preset.1.options]
|
||||
|
||||
custom_template/debug=""
|
||||
custom_template/release=""
|
||||
binary_format/64_bits=true
|
||||
binary_format/embed_pck=false
|
||||
texture_format/bptc=false
|
||||
texture_format/s3tc=true
|
||||
texture_format/etc=false
|
||||
texture_format/etc2=false
|
||||
texture_format/no_bptc_fallbacks=true
|
||||
binary_format/64_bits=true
|
||||
binary_format/embed_pck=false
|
||||
custom_template/release=""
|
||||
custom_template/debug=""
|
||||
codesign/enable=false
|
||||
codesign/identity=""
|
||||
codesign/password=""
|
||||
|
|
|
@ -179,6 +179,7 @@ fallback="en_GB"
|
|||
|
||||
[physics]
|
||||
|
||||
3d/physics_engine="GodotPhysics"
|
||||
3d/default_gravity=0.0
|
||||
|
||||
[rendering]
|
||||
|
|
Loading…
Reference in New Issue