Fix issues
This commit is contained in:
@@ -5,11 +5,19 @@ public partial class AreaExit : Node3D
|
||||
[Export]
|
||||
private int _levelIndex;
|
||||
|
||||
private GameManager _gameManager;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_gameManager = GetTree().Root.GetNode<GameManager>("Main/GameManager");
|
||||
}
|
||||
|
||||
|
||||
private void OnExitEntered(Node3D node)
|
||||
{
|
||||
GD.Print("Exit reached");
|
||||
var main = GetTree().Root.GetNode<Main>("/root/Main");
|
||||
main.LoadNextLevel(_levelIndex);
|
||||
GD.Print("Exit reached");
|
||||
var main = GetTree().Root.GetNode<Main>("/root/Main");
|
||||
main.LoadNextLevel(_levelIndex);
|
||||
_gameManager.ResetPlayerPosition();
|
||||
}
|
||||
}
|
||||
|
||||
10
Scripts/FinalLevel.cs
Normal file
10
Scripts/FinalLevel.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Godot;
|
||||
|
||||
public partial class FinalLevel : Node3D
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
var finalBossGUI = GetTree().GetFirstNodeInGroup("BossGUI") as Control;
|
||||
finalBossGUI.Show();
|
||||
}
|
||||
}
|
||||
@@ -38,14 +38,19 @@ public partial class GameManager : Node
|
||||
|
||||
public void SetP1ToPreviousCharacter() => _p1CharacterIndex = _p1CharacterIndex == 0 ? _p1Characters.Count() : --_p1CharacterIndex;
|
||||
|
||||
public void ResetPlayerPosition()
|
||||
{
|
||||
var playerSpawnPoint = GetNode<SpawnPoint>("P1SpawnPoint");
|
||||
playerSpawnPoint.SetPlayerPosition(_p1SelectedCharacter);
|
||||
}
|
||||
|
||||
public void OnP1CharacterSelected()
|
||||
{
|
||||
GD.Print("Instancing...");
|
||||
var selectedPlayer = _p1Characters[_p1CharacterIndex].Instantiate();
|
||||
_p1SelectedCharacter = selectedPlayer as Character;
|
||||
GetTree().Root.AddChild(_p1SelectedCharacter);
|
||||
var playerSpawnPoint = GetNode<SpawnPoint>("P1SpawnPoint");
|
||||
playerSpawnPoint.SetPlayerPosition(_p1SelectedCharacter);
|
||||
ResetPlayerPosition();
|
||||
}
|
||||
|
||||
public void RemoveP1Character()
|
||||
|
||||
@@ -30,7 +30,7 @@ public partial class MainMenu : Node2D
|
||||
if (animationName == "FirstLevel")
|
||||
{
|
||||
var main = GetTree().Root.GetNode<Main>("/root/Main");
|
||||
main.LoadLevel(8);
|
||||
main.LoadLevel(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,12 @@ public partial class MeleeEnemy : BasicEnemy
|
||||
var convertedPlayers = players.Select(x => (Node3D)x);
|
||||
var target = convertedPlayers.OrderBy(x => Position.DistanceTo(x.Position)).FirstOrDefault();
|
||||
Position = Position.MoveToward(target.Position, _speed * (float)delta);
|
||||
MoveAndSlide();
|
||||
//MoveAndSlide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class BasicEnemy : CharacterBody3D
|
||||
public partial class BasicEnemy : Node3D
|
||||
{
|
||||
public void OnHit(Node3D node)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ public partial class Player1 : Character
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
if (!_gameManager.IsP1SelectingCharacter)
|
||||
{
|
||||
{
|
||||
Velocity = CalculateCharacterMovement(delta);
|
||||
MoveAndSlide();
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public partial class Player1 : Character
|
||||
private async void Fire()
|
||||
{
|
||||
var projectile = _fireProjectile.Instantiate<Projectile>();
|
||||
projectile.Position = Position;
|
||||
projectile.Position = Position + new Vector3(0f, 1f, 0f);
|
||||
GetParent().AddChild(projectile);
|
||||
CanShoot = false;
|
||||
await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout");
|
||||
@@ -76,7 +76,7 @@ public partial class Player1 : Character
|
||||
private async void AltFire()
|
||||
{
|
||||
var projectile = _altFireProjectile.Instantiate<Projectile>();
|
||||
projectile.Position = Position;
|
||||
projectile.Position = Position + new Vector3(0f, 1f, 0f);
|
||||
GetParent().AddChild(projectile);
|
||||
CanShoot = false;
|
||||
await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout");
|
||||
|
||||
3
Scripts/RangedEnemy.cs
Normal file
3
Scripts/RangedEnemy.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
public partial class RangedEnemy : BasicEnemy
|
||||
{
|
||||
}
|
||||
16
Scripts/SingleShot.cs
Normal file
16
Scripts/SingleShot.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Godot;
|
||||
using System.Linq;
|
||||
|
||||
public partial class SingleShot : Projectile
|
||||
{
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
var pellet = GetChildren().OfType<RigidBody3D>().Single();
|
||||
pellet.Translate(new Vector3(0, 0, Speed * -(float)delta));
|
||||
}
|
||||
|
||||
private void OnBulletHitObject(Node node)
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using Godot;
|
||||
|
||||
public partial class TestBullet : Projectile
|
||||
{
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
Translate(new Vector3(0, 0, Speed * -(float)delta));
|
||||
}
|
||||
|
||||
private void OnBulletHitObject(Node node)
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user