Fix game over

This commit is contained in:
2023-09-06 17:41:53 -07:00
parent 5acfb9300c
commit aac5fbd297
14 changed files with 301 additions and 72 deletions

View File

@@ -7,7 +7,7 @@ public partial class Character : CharacterBody3D
[Export]
protected PackedScene _altFireProjectile;
protected Player _ownerPlayer;
public Player OwnerPlayer;
[Export]
protected float _speed = 3.0f;
@@ -24,7 +24,7 @@ public partial class Character : CharacterBody3D
public void Initialize(Player ownerPlayer)
{
_ownerPlayer = ownerPlayer;
OwnerPlayer = ownerPlayer;
}
public override void _PhysicsProcess(double delta)
@@ -38,9 +38,9 @@ public partial class Character : CharacterBody3D
if (Input.IsActionJustPressed("exit"))
GetTree().Quit();
if (Input.IsActionJustPressed(_ownerPlayer.PlayerInput.Fire()) && CanShoot)
if (Input.IsActionJustPressed(OwnerPlayer.PlayerInput.Fire()) && CanShoot)
Fire();
if (Input.IsActionJustPressed(_ownerPlayer.PlayerInput.AltFire()) && CanShoot)
if (Input.IsActionJustPressed(OwnerPlayer.PlayerInput.AltFire()) && CanShoot)
AltFire();
}
@@ -48,7 +48,7 @@ public partial class Character : CharacterBody3D
{
var velocity = Velocity;
var inputDir = Input.GetVector(_ownerPlayer.PlayerInput.Left(), _ownerPlayer.PlayerInput.Right(), _ownerPlayer.PlayerInput.Up(), _ownerPlayer.PlayerInput.Down());
var inputDir = Input.GetVector(OwnerPlayer.PlayerInput.Left(), OwnerPlayer.PlayerInput.Right(), OwnerPlayer.PlayerInput.Up(), OwnerPlayer.PlayerInput.Down());
var direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
if (direction != Vector3.Zero)
{
@@ -89,6 +89,6 @@ public partial class Character : CharacterBody3D
public void OnHit(Node3D node)
{
if (this != null)
_gameManager.CallDeferred(GameManager.MethodName.RemoveCharacter, _ownerPlayer);
_gameManager.CallDeferred(GameManager.MethodName.RemoveCharacter, OwnerPlayer);
}
}

View File

@@ -216,6 +216,7 @@ size = Vector3(0.856928, 1.65704, 0.82877)
[node name="Capricorn" type="CharacterBody3D" groups=["Player"]]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.408962, 0)
collision_layer = 17
motion_mode = 1
script = ExtResource("1_aqn5t")
_fireProjectile = ExtResource("2_e6qos")

View File

@@ -23,9 +23,9 @@ public partial class CapricornControls : Character
if (Input.IsActionJustPressed("exit"))
GetTree().Quit();
if (Input.IsActionJustPressed(_ownerPlayer.PlayerInput.Fire()) && CanShoot)
if (Input.IsActionJustPressed(OwnerPlayer.PlayerInput.Fire()) && CanShoot)
Fire(_fireProjectile);
if (Input.IsActionJustPressed(_ownerPlayer.PlayerInput.AltFire()) && CanShoot)
if (Input.IsActionJustPressed(OwnerPlayer.PlayerInput.AltFire()) && CanShoot)
Fire(_altFireProjectile);
}
@@ -33,7 +33,7 @@ public partial class CapricornControls : Character
{
var velocity = Velocity;
var inputDir = Input.GetVector(_ownerPlayer.PlayerInput.Left(), _ownerPlayer.PlayerInput.Right(), _ownerPlayer.PlayerInput.Up(), _ownerPlayer.PlayerInput.Down());
var inputDir = Input.GetVector(OwnerPlayer.PlayerInput.Left(), OwnerPlayer.PlayerInput.Right(), OwnerPlayer.PlayerInput.Up(), OwnerPlayer.PlayerInput.Down());
var direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
if (direction != Vector3.Zero)
{
@@ -119,6 +119,6 @@ public partial class CapricornControls : Character
public new void OnHit(Node3D node)
{
if (this != null)
_gameManager.CallDeferred(GameManager.MethodName.RemoveCharacter, _ownerPlayer);
_gameManager.CallDeferred(GameManager.MethodName.RemoveCharacter, OwnerPlayer);
}
}

View File

@@ -14,6 +14,7 @@ height = 1.67894
[node name="Pisces" type="CharacterBody3D" groups=["Player"]]
transform = Transform3D(0.33, 0, 0, 0, 0.33, 0, 0, 0, 0.33, 0, 0.332056, 0)
collision_layer = 17
motion_mode = 1
script = ExtResource("1_gp8nm")
_fireProjectile = ExtResource("2_rsvhh")

View File

@@ -601,6 +601,8 @@ blend_shape_mode = 0
shadow_mesh = SubResource("ArrayMesh_htkik")
[node name="Sagittarius" type="CharacterBody3D" groups=["Player"]]
collision_layer = 0
collision_mask = 0
motion_mode = 1
slide_on_ceiling = false
floor_stop_on_slope = false
@@ -614,20 +616,34 @@ shape = SubResource("BoxShape3D_te8tc")
[node name="Pivot" type="Node3D" parent="."]
[node name="megami" type="Node3D" parent="Pivot"]
[node name="RigidBody3D" type="RigidBody3D" parent="Pivot"]
collision_layer = 17
collision_mask = 17
gravity_scale = 0.0
continuous_cd = true
max_contacts_reported = 1
contact_monitor = true
can_sleep = false
freeze = true
[node name="CollisionShape3D" type="CollisionShape3D" parent="Pivot/RigidBody3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.726881, 0.14479)
shape = SubResource("BoxShape3D_te8tc")
[node name="megami" type="Node3D" parent="Pivot/RigidBody3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0476897, 0, 0.00673294)
[node name="Plane" type="MeshInstance3D" parent="Pivot"]
[node name="Plane" type="MeshInstance3D" parent="Pivot/RigidBody3D"]
transform = Transform3D(0.00858108, 0.00109693, 0.00129912, 0, 0.00668392, -0.00564368, -0.00170029, 0.00553605, 0.00655646, 0.0457722, 1.25172, -0.0470017)
mesh = SubResource("ArrayMesh_5aftx")
skeleton = NodePath("")
[node name="Area3D" type="Area3D" parent="Pivot"]
[node name="Area3D" type="Area3D" parent="Pivot/RigidBody3D"]
collision_layer = 2
collision_mask = 4100
[node name="CollisionShape3D" type="CollisionShape3D" parent="Pivot/Area3D"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="Pivot/RigidBody3D/Area3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.726881, 0.14479)
shape = SubResource("BoxShape3D_te8tc")
[connection signal="body_entered" from="Pivot/Area3D" to="." method="OnHit"]
[connection signal="body_entered" from="Pivot/RigidBody3D/Area3D" to="." method="OnHit"]