diff --git a/Models/Cone.obj b/Models/Cone.obj new file mode 100644 index 0000000..f46d05c --- /dev/null +++ b/Models/Cone.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:37a1fdfb98f374944c10bb40a3af9b4566917e4353f6fd9da52802da33d92633 +size 2032 diff --git a/Models/Cone.obj.import b/Models/Cone.obj.import new file mode 100644 index 0000000..d3f8daa --- /dev/null +++ b/Models/Cone.obj.import @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a48eeb5e6b11a251d372273f860addc8e0523ba9e15eda830d141de844e0e31d +size 489 diff --git a/Models/Material_001.material b/Models/Material_001.material index 7cd74ce..0cc83be 100644 --- a/Models/Material_001.material +++ b/Models/Material_001.material @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:339e75ee79c98e0c6ab55c76c747a9f14afc0954f8ffbdc0552dca374556ba1f -size 728 +oid sha256:20f19baac0a048991d3e988ee29775afbd2a5f05581de13cc7d3e64fddfd28e3 +size 729 diff --git a/Models/Material_002.material b/Models/Material_002.material index dcec47c..7dc28af 100644 --- a/Models/Material_002.material +++ b/Models/Material_002.material @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f468728890627c07ab6f93b29c3cfc670b179b54c39de5c33bd9f5e6530e1be6 -size 829 +oid sha256:063b630bfbbe43e689fd6f9e5871eae2196b1bf8c8c4b24f427d19585602610b +size 831 diff --git a/Models/cone-collision.tres b/Models/cone-collision.tres new file mode 100644 index 0000000..ba7efee --- /dev/null +++ b/Models/cone-collision.tres @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c358d4b73112aa33450e7f9d7713679fcfe8ae95e32386188e53fb0397e6a562 +size 1922 diff --git a/Scenes/Player.tscn b/Scenes/Player.tscn index e15364d..4e80e91 100644 --- a/Scenes/Player.tscn +++ b/Scenes/Player.tscn @@ -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"] diff --git a/Scripts/Player.gd b/Scripts/Player.gd index 975278a..ff78da0 100644 --- a/Scripts/Player.gd +++ b/Scripts/Player.gd @@ -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() @@ -296,6 +299,19 @@ func _physics_process(delta : float) -> void: set_rotation(last_rotation) 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: @@ -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) diff --git a/Shaders/OutsideSpaceship.material b/Shaders/OutsideSpaceship.material index 6b2caaa..7365bff 100644 Binary files a/Shaders/OutsideSpaceship.material and b/Shaders/OutsideSpaceship.material differ diff --git a/export_presets.cfg b/export_presets.cfg index fc2c02b..f88c2a7 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -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="" diff --git a/project.godot b/project.godot index 918db97..86463ba 100644 --- a/project.godot +++ b/project.godot @@ -179,6 +179,7 @@ fallback="en_GB" [physics] +3d/physics_engine="GodotPhysics" 3d/default_gravity=0.0 [rendering]