Set game over for character condition
This commit is contained in:
@@ -5,12 +5,10 @@
|
||||
[ext_resource type="PackedScene" uid="uid://dq1gtd55p04do" path="res://Scenes/StageGUI.tscn" id="5_gsh7q"]
|
||||
[ext_resource type="Script" path="res://Scripts/SpawnPoint.cs" id="7_4n1rc"]
|
||||
|
||||
[node name="GameManager" type="Node" node_paths=PackedStringArray("_p1SelectedCharacter", "_p2SelectedCharacter")]
|
||||
[node name="GameManager" type="Node"]
|
||||
script = ExtResource("1_ya2kt")
|
||||
_p1Characters = [ExtResource("1_6lmun"), ExtResource("1_6lmun")]
|
||||
_p2Characters = [ExtResource("1_6lmun"), ExtResource("1_6lmun")]
|
||||
_p1SelectedCharacter = NodePath("Pisces")
|
||||
_p2SelectedCharacter = NodePath("Pisces2")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||
transform = Transform3D(-0.929007, 0.136193, 0.34409, 0.369825, 0.375014, 0.850055, -0.0132668, 0.91696, -0.398758, -3.58319, 11.9025, 0.163277)
|
||||
@@ -37,11 +35,4 @@ script = ExtResource("7_4n1rc")
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.651031, 0, 0)
|
||||
script = ExtResource("7_4n1rc")
|
||||
|
||||
[node name="Pisces" parent="." instance=ExtResource("1_6lmun")]
|
||||
visible = false
|
||||
|
||||
[node name="Pisces2" parent="." instance=ExtResource("1_6lmun")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.67345, 0, 0)
|
||||
visible = false
|
||||
|
||||
[connection signal="OnCharacterSelectionMade" from="StageGUI" to="." method="OnP1CharacterSelected"]
|
||||
|
||||
@@ -35,4 +35,12 @@ shape = SubResource("CapsuleShape3D_ayco3")
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.06805, -0.211049)
|
||||
shape = SubResource("CapsuleShape3D_fqik1")
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
offset_left = 1602.0
|
||||
offset_top = 40.0
|
||||
offset_right = 1872.0
|
||||
offset_bottom = 178.0
|
||||
text = "Hit"
|
||||
|
||||
[connection signal="body_entered" from="Pivot/Area3D" to="." method="OnHit"]
|
||||
[connection signal="pressed" from="Button" to="." method="HitDebug"]
|
||||
|
||||
@@ -8,9 +8,9 @@ public partial class GameManager : Node
|
||||
public bool IsP2SelectingCharacter = true;
|
||||
|
||||
[Export]
|
||||
private Array<PackedScene> _p1Characters;
|
||||
public Array<PackedScene> _p1Characters;
|
||||
[Export]
|
||||
private Array<PackedScene> _p2Characters;
|
||||
public Array<PackedScene> _p2Characters;
|
||||
|
||||
[Export]
|
||||
public Character _p1SelectedCharacter;
|
||||
@@ -18,6 +18,8 @@ public partial class GameManager : Node
|
||||
[Export]
|
||||
public Character _p2SelectedCharacter;
|
||||
|
||||
public bool P1GameOver = false;
|
||||
|
||||
private int _p1CharacterIndex = 0;
|
||||
private int _p2CharacterIndex = 0;
|
||||
|
||||
@@ -27,15 +29,19 @@ public partial class GameManager : Node
|
||||
|
||||
public void OnP1CharacterSelected()
|
||||
{
|
||||
if (_p1SelectedCharacter != null)
|
||||
_p1SelectedCharacter.QueueFree();
|
||||
|
||||
var selectedPlayer = _p1Characters[_p1CharacterIndex].Instantiate();
|
||||
_p1SelectedCharacter = selectedPlayer as Character;
|
||||
GetTree().Root.AddChild(_p1SelectedCharacter);
|
||||
var playerSpawnPoint = GetNode<SpawnPoint>("P1SpawnPoint");
|
||||
playerSpawnPoint.SetPlayerPosition(_p1SelectedCharacter);
|
||||
}
|
||||
|
||||
public void RemoveP1Character()
|
||||
{
|
||||
_p1Characters.Remove(_p1Characters.ElementAt(_p1CharacterIndex));
|
||||
_p1SelectedCharacter?.QueueFree();
|
||||
_p1CharacterIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Character : CharacterBody3D
|
||||
|
||||
@@ -82,8 +82,19 @@ public partial class Player1 : Character
|
||||
CanShoot = true;
|
||||
}
|
||||
|
||||
private void HitDebug()
|
||||
{
|
||||
var node = new Node3D();
|
||||
OnHit(node);
|
||||
}
|
||||
|
||||
private void OnHit(Node3D node)
|
||||
{
|
||||
QueueFree();
|
||||
_gameManager.RemoveP1Character();
|
||||
if (_gameManager._p1Characters.Count == 0)
|
||||
{
|
||||
GD.Print("Game over for P1");
|
||||
_gameManager.P1GameOver = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ public partial class StageGUI : Control
|
||||
|
||||
public void OnCharacterSelect()
|
||||
{
|
||||
if (_gameManager.P1GameOver)
|
||||
return;
|
||||
|
||||
var wheel1 = GetNode<TextureRect>("CharacterSelect/Wheel");
|
||||
var wheel2 = GetNode<TextureRect>("CharacterSelect/Wheel2");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user