Fix game over
This commit is contained in:
@@ -6,7 +6,7 @@ using System.Linq;
|
||||
public partial class GameManager : Node
|
||||
{
|
||||
[Signal]
|
||||
public delegate void OnGameOverEventHandler();
|
||||
public delegate void OnPlayerGameOverEventHandler();
|
||||
[Signal]
|
||||
public delegate void ReselectCharacterEventHandler(Player player);
|
||||
|
||||
@@ -17,6 +17,8 @@ public partial class GameManager : Node
|
||||
|
||||
private int _levelIndex;
|
||||
|
||||
public bool IsGameOverScreenOn = false;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
var main = GetTree().Root.GetNode<Main>("/root/Main");
|
||||
@@ -84,6 +86,9 @@ public partial class GameManager : Node
|
||||
|
||||
if (!player.CharactersExited.Any() && !player.CharactersLeftOnStage.Any())
|
||||
SetGameOver(player, true);
|
||||
|
||||
if (Players.All(x => !x.CharactersLeftOnStage.Any()) && Players.Any(x => x.CharactersExited.Any()))
|
||||
OnLevelClear();
|
||||
}
|
||||
|
||||
public void RemoveCharacterAndAddToExit(Player player)
|
||||
@@ -103,10 +108,22 @@ public partial class GameManager : Node
|
||||
{
|
||||
player.GameOver = isGameOver;
|
||||
if (isGameOver)
|
||||
EmitSignal(SignalName.OnGameOver);
|
||||
EmitSignal(SignalName.OnPlayerGameOver);
|
||||
GD.Print($"Game over for {player.Name}");
|
||||
}
|
||||
|
||||
public void ReloadGameScene()
|
||||
{
|
||||
GD.Print("Reloading scene");
|
||||
var players = GetTree().Root.GetChildren().OfType<Player>();
|
||||
foreach (var player in players)
|
||||
player.QueueFree();
|
||||
var levels = GetTree().Root.GetChildren().OfType<Level>();
|
||||
foreach (var level in levels)
|
||||
level.QueueFree();
|
||||
GetTree().ReloadCurrentScene();
|
||||
}
|
||||
|
||||
public void OnLevelClear()
|
||||
{
|
||||
foreach (var player in Players)
|
||||
@@ -114,9 +131,12 @@ public partial class GameManager : Node
|
||||
player.CharactersLeftOnStage.AddRange(player.CharactersExited);
|
||||
player.CharactersExited.Clear();
|
||||
player.CharacterIndex = 0;
|
||||
GetTree().Root.RemoveChild(player.SelectedCharacter);
|
||||
}
|
||||
|
||||
var playerCharacters = GetTree().GetNodesInGroup("Player");
|
||||
foreach (var character in playerCharacters)
|
||||
character.GetParent().RemoveChild(character);
|
||||
|
||||
var projectiles = GetTree().Root.GetChildren().OfType<Projectile>();
|
||||
foreach (var projectile in projectiles)
|
||||
projectile.QueueFree();
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://cxj6yeddshy16"]
|
||||
[gd_scene load_steps=13 format=3 uid="uid://cxj6yeddshy16"]
|
||||
|
||||
[ext_resource type="Script" path="res://GameLogic/GameManager.cs" id="1_ya2kt"]
|
||||
[ext_resource type="PackedScene" uid="uid://b57xus5rqasy8" path="res://Player/Base/Player2.tscn" id="3_y1wkr"]
|
||||
[ext_resource type="PackedScene" uid="uid://xcmspevaqcrc" path="res://Player/Base/Player1.tscn" id="4_3fl70"]
|
||||
[ext_resource type="PackedScene" uid="uid://dq1gtd55p04do" path="res://UI/StageGUI.tscn" id="4_xi0i5"]
|
||||
[ext_resource type="Script" path="res://UI/StageGUI.cs" id="4_8bo7m"]
|
||||
[ext_resource type="Script" path="res://UI/GameOverService.cs" id="5_3te1o"]
|
||||
[ext_resource type="Texture2D" uid="uid://d18xmfbg47qpi" path="res://Textures/Portraits/blank-background.png" id="5_ecqoa"]
|
||||
[ext_resource type="Script" path="res://UI/CharacterSelectUpdateService.cs" id="6_8tbm6"]
|
||||
[ext_resource type="Texture2D" uid="uid://dveeywi80ux2l" path="res://UI/Game_Over.jpg" id="6_hq16y"]
|
||||
[ext_resource type="Texture2D" uid="uid://c3eubpygfvc3l" path="res://Textures/Portraits/cap-bg-char.png" id="7_jroqd"]
|
||||
[ext_resource type="Texture2D" uid="uid://1pgw8he4k5va" path="res://Textures/Portraits/pisces-bg-char.png" id="8_pvs36"]
|
||||
[ext_resource type="Texture2D" uid="uid://bacwvejc4hcou" path="res://Textures/Portraits/sag-bg-char.png" id="9_1jise"]
|
||||
[ext_resource type="Texture2D" uid="uid://o7uu4efxf36e" path="res://Textures/Portraits/scorpio-bg-char.png" id="10_mqkvb"]
|
||||
|
||||
[node name="GameManager" type="Node3D"]
|
||||
script = ExtResource("1_ya2kt")
|
||||
@@ -24,8 +32,6 @@ shadow_normal_bias = 0.0
|
||||
directional_shadow_mode = 0
|
||||
sky_mode = 1
|
||||
|
||||
[node name="StageGUI" parent="." instance=ExtResource("4_xi0i5")]
|
||||
|
||||
[node name="DirectionalLight3D2" type="DirectionalLight3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.993572, 0.113203, 0, -0.113203, 0.993572, 0, 6.22805, 0)
|
||||
shadow_enabled = true
|
||||
@@ -34,5 +40,207 @@ shadow_normal_bias = 0.0
|
||||
directional_shadow_mode = 0
|
||||
sky_mode = 1
|
||||
|
||||
[node name="StageGUI" type="Control" parent="."]
|
||||
process_mode = 3
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("4_8bo7m")
|
||||
metadata/_edit_horizontal_guides_ = [-342.0]
|
||||
|
||||
[node name="SidebarLeft" type="TextureRect" parent="StageGUI"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 4
|
||||
anchor_top = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_top = -540.0
|
||||
offset_right = 420.0
|
||||
offset_bottom = 540.0
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("5_ecqoa")
|
||||
|
||||
[node name="SidebarRight" type="TextureRect" parent="StageGUI"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 6
|
||||
anchor_left = 1.0
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -420.0
|
||||
offset_top = -540.0
|
||||
offset_bottom = 540.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("5_ecqoa")
|
||||
|
||||
[node name="CharacterSelect" type="Control" parent="StageGUI"]
|
||||
process_mode = 3
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("6_8tbm6")
|
||||
|
||||
[node name="P1" type="Control" parent="StageGUI/CharacterSelect"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 4
|
||||
anchor_top = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_top = -20.0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 20.0
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="CapBG" type="TextureRect" parent="StageGUI/CharacterSelect/P1"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 4
|
||||
anchor_top = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_top = -540.0
|
||||
offset_right = 420.0
|
||||
offset_bottom = 540.0
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("7_jroqd")
|
||||
stretch_mode = 2
|
||||
|
||||
[node name="PiscesBG" type="TextureRect" parent="StageGUI/CharacterSelect/P1"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 4
|
||||
anchor_top = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_top = -540.0
|
||||
offset_right = 420.0
|
||||
offset_bottom = 540.0
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("8_pvs36")
|
||||
stretch_mode = 2
|
||||
|
||||
[node name="SagBG" type="TextureRect" parent="StageGUI/CharacterSelect/P1"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 4
|
||||
anchor_top = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_top = -540.0
|
||||
offset_right = 420.0
|
||||
offset_bottom = 540.0
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("9_1jise")
|
||||
stretch_mode = 2
|
||||
|
||||
[node name="ScorpioBG" type="TextureRect" parent="StageGUI/CharacterSelect/P1"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 4
|
||||
anchor_top = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_top = -540.0
|
||||
offset_right = 420.0
|
||||
offset_bottom = 540.0
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("10_mqkvb")
|
||||
stretch_mode = 2
|
||||
|
||||
[node name="P2" type="Control" parent="StageGUI/CharacterSelect"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 6
|
||||
anchor_left = 1.0
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -40.0
|
||||
offset_top = -20.0
|
||||
offset_bottom = 20.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="CapBG" type="TextureRect" parent="StageGUI/CharacterSelect/P2"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 6
|
||||
anchor_left = 1.0
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -420.0
|
||||
offset_top = -540.0
|
||||
offset_bottom = 540.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("7_jroqd")
|
||||
|
||||
[node name="PiscesBG" type="TextureRect" parent="StageGUI/CharacterSelect/P2"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 6
|
||||
anchor_left = 1.0
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -420.0
|
||||
offset_top = -540.0
|
||||
offset_bottom = 540.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("8_pvs36")
|
||||
|
||||
[node name="SagBG" type="TextureRect" parent="StageGUI/CharacterSelect/P2"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 6
|
||||
anchor_left = 1.0
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -420.0
|
||||
offset_top = -540.0
|
||||
offset_bottom = 540.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("9_1jise")
|
||||
|
||||
[node name="ScorpioBG" type="TextureRect" parent="StageGUI/CharacterSelect/P2"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 6
|
||||
anchor_left = 1.0
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -420.0
|
||||
offset_top = -540.0
|
||||
offset_bottom = 540.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("10_mqkvb")
|
||||
|
||||
[node name="GameOver" type="Control" parent="."]
|
||||
visible = false
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
script = ExtResource("5_3te1o")
|
||||
|
||||
[node name="GameOverScreen" type="TextureRect" parent="GameOver"]
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
texture = ExtResource("6_hq16y")
|
||||
|
||||
[connection signal="ReselectCharacter" from="." to="StageGUI" method="OnCharacterSelect"]
|
||||
[connection signal="CapricornSelected" from="StageGUI" to="StageGUI/CharacterSelect" method="OnCapricornSelected"]
|
||||
[connection signal="OnCharacterSelectionMade" from="StageGUI" to="." method="OnCharacterSelected"]
|
||||
[connection signal="OnGameOver" from="StageGUI" to="GameOver" method="OnGameOver"]
|
||||
[connection signal="OnPlayerGameOver" from="StageGUI" to="StageGUI/CharacterSelect" method="OnPlayerGameOver"]
|
||||
[connection signal="PiscesSelected" from="StageGUI" to="StageGUI/CharacterSelect" method="OnPiscesSelected"]
|
||||
[connection signal="SagittariusSelected" from="StageGUI" to="StageGUI/CharacterSelect" method="OnSagittariusSelected"]
|
||||
[connection signal="ScorpioSelected" from="StageGUI" to="StageGUI/CharacterSelect" method="OnScorpioSelected"]
|
||||
[connection signal="ReloadGame" from="GameOver" to="." method="ReloadGameScene"]
|
||||
|
||||
@@ -94,7 +94,6 @@ radius = 1.79103
|
||||
|
||||
[node name="Exit Portal" instance=ExtResource("1_jebs8")]
|
||||
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0)
|
||||
script = ExtResource("2_4y188")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="." index="3"]
|
||||
autoplay = "Spin"
|
||||
@@ -104,9 +103,10 @@ libraries = {
|
||||
|
||||
[node name="Area3D" type="Area3D" parent="." index="4"]
|
||||
disable_mode = 2
|
||||
script = ExtResource("2_4y188")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D" index="0"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.11619)
|
||||
shape = SubResource("CylinderShape3D_v7qe0")
|
||||
|
||||
[connection signal="body_entered" from="Area3D" to="." method="OnExitEntered"]
|
||||
[connection signal="body_entered" from="Area3D" to="Area3D" method="OnExitEntered"]
|
||||
|
||||
@@ -60,4 +60,4 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.08228, 0, -0.694794)
|
||||
[node name="RangedEnemy6" parent="Enemies" instance=ExtResource("2_fyxib")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.78224, 0, -0.525299)
|
||||
|
||||
[connection signal="body_entered" from="Area3D2" to="." method="OnExitEntered"]
|
||||
[connection signal="body_entered" from="Area3D2" to="Area3D2/Exit Portal" method="OnExitEntered"]
|
||||
|
||||
@@ -26,50 +26,45 @@ _levelIndex = 1
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D2"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -2.51823)
|
||||
shape = SubResource("CylinderShape3D_tux5n")
|
||||
disabled = true
|
||||
|
||||
[node name="Collisions" type="Node3D" parent="."]
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="Collisions"]
|
||||
|
||||
[node name="STAGE 2" parent="." instance=ExtResource("2_gsn0b")]
|
||||
|
||||
[node name="Enemies" type="Node3D" parent="."]
|
||||
|
||||
[node name="RangedEnemy" parent="Enemies" instance=ExtResource("3_hfsy3")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.3199, 0.732413, -5.12032)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.3199, 0.25446, -5.12032)
|
||||
|
||||
[node name="RangedEnemy2" parent="Enemies" instance=ExtResource("3_hfsy3")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.35919, 0.732413, -3.66653)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.35919, 0.25446, -3.66653)
|
||||
|
||||
[node name="RangedEnemy3" parent="Enemies" instance=ExtResource("3_hfsy3")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.333, 0.732413, -1.64955)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.333, 0.25446, -1.64955)
|
||||
|
||||
[node name="RangedEnemy4" parent="Enemies" instance=ExtResource("3_hfsy3")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.47707, 0.732413, 0.275753)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.47707, 0.25446, 0.275753)
|
||||
|
||||
[node name="RangedEnemy5" parent="Enemies" instance=ExtResource("3_hfsy3")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.49938, 0, 0.0400016)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.49938, -0.477953, 0.0400016)
|
||||
|
||||
[node name="RangedEnemy6" parent="Enemies" instance=ExtResource("3_hfsy3")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.11107, 0, -0.798224)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.11107, -0.486121, -0.798224)
|
||||
|
||||
[node name="MeleeEnemyOrb" parent="Enemies" instance=ExtResource("4_3lkwt")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.34221, 0, -2.23892)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.34221, -0.75971, -2.23892)
|
||||
|
||||
[node name="MeleeEnemyOrb2" parent="Enemies" instance=ExtResource("4_3lkwt")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.967, 0, -2.26512)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.967, -0.75971, -2.26512)
|
||||
|
||||
[node name="MeleeEnemyOrb3" parent="Enemies" instance=ExtResource("4_3lkwt")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.27673, 0, -3.50936)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.27673, -0.75971, -3.50936)
|
||||
|
||||
[node name="MeleeEnemyOrb4" parent="Enemies" instance=ExtResource("4_3lkwt")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.00629, 0, -3.50936)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.00629, -0.75971, -3.50936)
|
||||
|
||||
[node name="RangedEnemy7" parent="Enemies" instance=ExtResource("3_hfsy3")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.12321, 0, -1.78045)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.12321, -0.521506, -1.78045)
|
||||
|
||||
[node name="RangedEnemy8" parent="Enemies" instance=ExtResource("3_hfsy3")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.2018, 0, -0.0385171)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.2018, -0.521506, -0.0385171)
|
||||
|
||||
[connection signal="body_entered" from="Area3D2" to="." method="OnExitEntered"]
|
||||
|
||||
@@ -16,11 +16,11 @@ public partial class AreaExit : Node3D
|
||||
|
||||
private void OnExitEntered(Node3D node)
|
||||
{
|
||||
if (node.GetParent() is Player player)
|
||||
if (node is Character character)
|
||||
{
|
||||
_gameManager.RemoveCharacterAndAddToExit(player);
|
||||
_gameManager.RemoveCharacterAndAddToExit(character.OwnerPlayer);
|
||||
|
||||
GD.Print($"Exit reached by {player.Name}");
|
||||
GD.Print($"Exit reached by {character.Name}");
|
||||
|
||||
if (!_gameManager.Players.Any(x => x.CharactersLeftOnStage.Any()))
|
||||
_gameManager.OnLevelClear();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
public partial class GameOverService : Node
|
||||
public partial class GameOverService : Control
|
||||
{
|
||||
[Signal]
|
||||
public delegate void ReloadGameEventHandler();
|
||||
|
||||
private GameManager _gameManager;
|
||||
|
||||
public override void _EnterTree()
|
||||
@@ -9,9 +13,9 @@ public partial class GameOverService : Node
|
||||
_gameManager = GetTree().Root.GetNode<GameManager>("Main/GameManager");
|
||||
}
|
||||
|
||||
public void OnGameOver(Player[] players)
|
||||
public void OnGameOver(Array<Player> players)
|
||||
{
|
||||
GetNode<Control>("GameOver").Show();
|
||||
Show();
|
||||
var bgmPlayer = GetTree().Root.GetNode<BGMPlayer>("BgmPlayer");
|
||||
bgmPlayer.SetBGMFromFilepath("Audio/BGM/GameOverTheme.wav");
|
||||
bgmPlayer.PlayBGM();
|
||||
@@ -19,7 +23,9 @@ public partial class GameOverService : Node
|
||||
{
|
||||
if (Input.IsActionJustPressed(player.PlayerInput.Fire()))
|
||||
{
|
||||
GetNode<Control>("GameOver").Hide(); GetTree().ReloadCurrentScene();
|
||||
Hide();
|
||||
_gameManager.IsGameOverScreenOn = false;
|
||||
EmitSignal(SignalName.ReloadGame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System.Linq;
|
||||
|
||||
public partial class StageGUI : Control
|
||||
@@ -16,7 +17,7 @@ public partial class StageGUI : Control
|
||||
[Signal]
|
||||
public delegate void OnPlayerGameOverEventHandler(Player player);
|
||||
[Signal]
|
||||
public delegate void OnGameOverEventHandler();
|
||||
public delegate void OnGameOverEventHandler(Array<Player> players);
|
||||
|
||||
private GameManager _gameManager;
|
||||
|
||||
@@ -65,9 +66,9 @@ public partial class StageGUI : Control
|
||||
EmitSignal(SignalName.OnPlayerGameOver, player);
|
||||
}
|
||||
|
||||
if (_gameManager.Players.All(x => x.GameOver))
|
||||
if (!_gameManager.IsGameOverScreenOn && _gameManager.Players.All(x => x.GameOver))
|
||||
{
|
||||
EmitSignal(SignalName.OnGameOver);
|
||||
EmitSignal(SignalName.OnGameOver, new Array<Player>(_gameManager.Players));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=9 format=3 uid="uid://dq1gtd55p04do"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://dq1gtd55p04do"]
|
||||
|
||||
[ext_resource type="Script" path="res://UI/StageGUI.cs" id="1_wr2m0"]
|
||||
[ext_resource type="Texture2D" uid="uid://d18xmfbg47qpi" path="res://Textures/Portraits/blank-background.png" id="2_rh3al"]
|
||||
@@ -7,7 +7,6 @@
|
||||
[ext_resource type="Texture2D" uid="uid://1pgw8he4k5va" path="res://Textures/Portraits/pisces-bg-char.png" id="5_y2ln6"]
|
||||
[ext_resource type="Texture2D" uid="uid://bacwvejc4hcou" path="res://Textures/Portraits/sag-bg-char.png" id="6_iltal"]
|
||||
[ext_resource type="Texture2D" uid="uid://o7uu4efxf36e" path="res://Textures/Portraits/scorpio-bg-char.png" id="7_tgrf5"]
|
||||
[ext_resource type="Texture2D" uid="uid://dveeywi80ux2l" path="res://UI/Game_Over.jpg" id="8_o0pnh"]
|
||||
|
||||
[node name="StageGUI" type="Control"]
|
||||
process_mode = 3
|
||||
@@ -189,21 +188,3 @@ offset_bottom = 540.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("7_tgrf5")
|
||||
|
||||
[node name="GameOver" type="Control" parent="."]
|
||||
visible = false
|
||||
anchors_preset = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="GameOverScreen" type="TextureRect" parent="GameOver"]
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
texture = ExtResource("8_o0pnh")
|
||||
|
||||
[connection signal="CapricornSelected" from="." to="CharacterSelect" method="OnCapricornSelected"]
|
||||
[connection signal="OnPlayerGameOver" from="." to="CharacterSelect" method="OnPlayerGameOver"]
|
||||
[connection signal="PiscesSelected" from="." to="CharacterSelect" method="OnPiscesSelected"]
|
||||
[connection signal="SagittariusSelected" from="." to="CharacterSelect" method="OnSagittariusSelected"]
|
||||
[connection signal="ScorpioSelected" from="." to="CharacterSelect" method="OnScorpioSelected"]
|
||||
|
||||
Reference in New Issue
Block a user