Fix spawn location and on hit

This commit is contained in:
2023-09-04 11:36:31 -07:00
parent c2239d240e
commit e27fe40420
10 changed files with 79 additions and 54 deletions

View File

@@ -1,9 +1,8 @@
[gd_scene load_steps=6 format=3 uid="uid://cxj6yeddshy16"]
[gd_scene load_steps=5 format=3 uid="uid://cxj6yeddshy16"]
[ext_resource type="Script" path="res://Scripts/GameManager.cs" id="1_ya2kt"]
[ext_resource type="PackedScene" uid="uid://xcmspevaqcrc" path="res://Scenes/Player1.tscn" id="4_3fl70"]
[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"]
[ext_resource type="PackedScene" uid="uid://jircpua5fl80" path="res://Scenes/Player2.tscn" id="8_sixv3"]
[node name="GameManager" type="Node3D"]
@@ -24,14 +23,6 @@ offset_bottom = 0.0
size_flags_horizontal = 4
size_flags_vertical = 4
[node name="P1SpawnPoint" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.30792, 0, 5.60868)
script = ExtResource("7_4n1rc")
[node name="P2SpawnPoint" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.910204, 0, 5.60868)
script = ExtResource("7_4n1rc")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -0.504317, 0.863519, 0, -0.863519, -0.504317, 0, 19.9508, 0)

View File

@@ -1,11 +1,10 @@
[gd_scene load_steps=8 format=3 uid="uid://dqv03pua4j8ga"]
[gd_scene load_steps=7 format=3 uid="uid://dqv03pua4j8ga"]
[ext_resource type="Script" path="res://Scripts/AreaExit.cs" id="1_owv8t"]
[ext_resource type="PackedScene" uid="uid://bt5rolsyjmx55" path="res://Scenes/MeleeEnemyOrb.tscn" id="5_dqbra"]
[ext_resource type="PackedScene" uid="uid://bnn68u04ktmas" path="res://Levels/Final Levels/Stage1/Stage1Fix.tscn" id="6_60jd6"]
[ext_resource type="PackedScene" uid="uid://jgf7k1r35km1" path="res://Scenes/ExitPortal.tscn" id="6_gegi6"]
[ext_resource type="PackedScene" uid="uid://dahp73fwld24h" path="res://Scenes/RangedEnemy.tscn" id="6_jck5a"]
[ext_resource type="Script" path="res://Scripts/SpawnPoint.cs" id="9_8v1uu"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_kv6vl"]
radius = 0.957319
@@ -25,14 +24,6 @@ transform = Transform3D(0.7, 0, 0, 0, 0.7, 0, 0, 0, 0.7, 0, 0, -2.53252)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -2.51823)
shape = SubResource("CylinderShape3D_kv6vl")
[node name="P1_SpawnPoint" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.28216, 0.123258, 5.51333)
script = ExtResource("9_8v1uu")
[node name="P2_SpawnPoint" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.78123, 0.123258, 5.51333)
script = ExtResource("9_8v1uu")
[node name="MeleeEnemyOrb" parent="." instance=ExtResource("5_dqbra")]
[node name="Node3D" parent="." instance=ExtResource("6_jck5a")]

View File

@@ -7,26 +7,9 @@
[node name="MainMenu" type="Node2D"]
script = ExtResource("1_6aikc")
[node name="NewGame" type="Control" parent="."]
z_index = 10
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="UIAnimations" parent="." instance=ExtResource("2_erh7e")]
[node name="Button" type="Button" parent="NewGame"]
top_level = true
layout_mode = 0
offset_left = 583.0
offset_top = 441.0
offset_right = 1155.0
offset_bottom = 645.0
text = "Play"
[node name="TextureRect" type="TextureRect" parent="NewGame"]
layout_mode = 1
[node name="TextureRect" type="TextureRect" parent="."]
anchors_preset = 14
anchor_top = 0.5
anchor_right = 1.0
@@ -41,6 +24,33 @@ size_flags_horizontal = 4
texture = ExtResource("3_7s65g")
expand_mode = 1
[node name="UIAnimations" parent="." instance=ExtResource("2_erh7e")]
[node name="NewGame" type="Control" parent="."]
z_index = 10
z_as_relative = false
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[connection signal="pressed" from="NewGame/Button" to="." method="OnStartButtonPressed"]
[node name="Button" type="Button" parent="NewGame"]
top_level = true
layout_mode = 0
offset_left = 654.0
offset_top = 170.0
offset_right = 1226.0
offset_bottom = 374.0
text = "One Player"
[node name="Button2" type="Button" parent="NewGame"]
top_level = true
layout_mode = 0
offset_left = 647.0
offset_top = 608.0
offset_right = 1219.0
offset_bottom = 812.0
text = "Two Player"
[connection signal="pressed" from="NewGame/Button" to="." method="OnSinglePlayerPressed"]
[connection signal="pressed" from="NewGame/Button2" to="." method="OnTwoPlayerPressed"]

View File

@@ -12,4 +12,6 @@ SpawnPoint = NodePath("Marker3D")
PlayableCharacters = Array[PackedScene]([ExtResource("2_7c6mk"), ExtResource("3_mtqa2"), ExtResource("4_1xs5f")])
[node name="Marker3D" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.5, 0.123, 5.513)
gizmo_extents = 1.0
script = ExtResource("2_mkhuu")

View File

@@ -12,4 +12,6 @@ SpawnPoint = NodePath("Marker3D")
PlayableCharacters = Array[PackedScene]([ExtResource("2_w2id2"), ExtResource("3_8owb2"), ExtResource("4_w8v7n")])
[node name="Marker3D" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.5, 0, 5.609)
gizmo_extents = 1.0
script = ExtResource("1_xs6nn")

View File

@@ -2,4 +2,8 @@ using Godot;
public partial class Character : CharacterBody3D
{
public void OnHit(Node3D node)
{
QueueFree();
}
}

View File

@@ -24,10 +24,14 @@ public partial class GameManager : Node
{
var player = playerScene.Instantiate();
Players = Players.Append((Player)player);
GD.Print("Players added");
}
}
public void OnHandleCharacterSelectUI(Player player)
{
EmitSignal(SignalName.ReselectCharacter, player);
}
public void SetToNextCharacter(Player player) => _characterIndex = (++_characterIndex) % player.PlayableCharacters.Count();
public void SetToPreviousCharacter(Player player) => _characterIndex = _characterIndex == 0 ? player.PlayableCharacters.Count() - 1 : --_characterIndex;

View File

@@ -9,12 +9,18 @@ public partial class Main : Node
[Export]
public PackedScene GameManager;
public void LoadLevel(int indexToLoad)
public void LoadLevel(int indexToLoad, int numberOfPlayers)
{
var sceneToLoad = Levels.ElementAt(indexToLoad);
CallDeferred(nameof(DeferredGoToScene), sceneToLoad);
var gameManager = GameManager.Instantiate();
AddChild(gameManager);
var gameManagerInstance = (GameManager)gameManager;
gameManagerInstance.OnHandleCharacterSelectUI(gameManagerInstance.Players.ElementAt(0));
if (numberOfPlayers == 2)
gameManagerInstance.OnHandleCharacterSelectUI(gameManagerInstance.Players.ElementAt(1));
}
public void LoadNextLevel(int currentSceneIndex)

View File

@@ -3,7 +3,7 @@ using System.Linq;
public partial class MainMenu : Node2D
{
private AnimationPlayer _player;
private AnimationPlayer _animationPlayer;
[Signal]
public delegate void IntroAnimationsCompletedEventHandler();
@@ -11,26 +11,42 @@ public partial class MainMenu : Node2D
public override void _Ready()
{
GetParent().GetNode<TextureRect>("MainMenu/UIAnimations/LoreSplash").Show();
_player = GetTree().Root.GetNode<AnimationPlayer>("/root/Main/MainMenu/UIAnimations/AnimationPlayer");
_player.Queue("IntroLore");
_animationPlayer = GetTree().Root.GetNode<AnimationPlayer>("/root/Main/MainMenu/UIAnimations/AnimationPlayer");
_animationPlayer.Queue("IntroLore");
var bgmPlayer = GetTree().Root.GetNode<BGMPlayer>("BgmPlayer");
bgmPlayer.SetBGMFromFilepath("Audio/BGM/titlemusic.wav");
bgmPlayer.PlayBGM();
}
private void OnStartButtonPressed()
private void OnSinglePlayerPressed()
{
_player.Play("FirstLevel");
_animationPlayer.Play("FirstLevel");
Hide();
_player.AnimationFinished += OnAnimationFinished;
_animationPlayer.AnimationFinished += OnAnimationFinishedCallSinglePlayerStart;
}
private void OnAnimationFinished(StringName animationName)
private void OnAnimationFinishedCallSinglePlayerStart(StringName animationName)
{
if (animationName == "FirstLevel")
{
var main = GetTree().Root.GetNode<Main>("/root/Main");
main.LoadLevel(7);
main.LoadLevel(0, 1);
}
}
private void OnTwoPlayerPressed()
{
_animationPlayer.Play("FirstLevel");
Hide();
_animationPlayer.AnimationFinished += OnAnimationFinishedCallTwoPlayerStart;
}
private void OnAnimationFinishedCallTwoPlayerStart(StringName animationName)
{
if (animationName == "FirstLevel")
{
var main = GetTree().Root.GetNode<Main>("/root/Main");
main.LoadLevel(0, 2);
}
}
}

View File

@@ -18,17 +18,16 @@ public partial class StageGUI : Control
if (_gameManager.IsGameOver)
return;
var wheel1 = GetNode<TextureRect>("CharacterSelect/Wheel");
var wheel2 = GetNode<TextureRect>("CharacterSelect/Wheel2");
if (player == _gameManager.Players.ElementAt(0))
{
var wheel1 = GetNode<TextureRect>("CharacterSelect/Wheel");
wheel1.FocusMode = FocusModeEnum.All;
wheel1.GrabFocus();
wheel1.Visible = true;
}
else if (player == _gameManager.Players.ElementAt(1))
{
var wheel2 = GetNode<TextureRect>("CharacterSelect/Wheel2");
wheel2.FocusMode = FocusModeEnum.All;
wheel2.GrabFocus();
wheel2.Visible = true;