mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-10 23:35:54 +00:00
working spder bomb
This commit is contained in:
parent
6125565d8c
commit
f1f40a91dd
17 changed files with 400 additions and 105 deletions
|
|
@ -9,7 +9,7 @@ using Cirno.Scripts.Utils;
|
|||
|
||||
public partial class GameManager : Node2D
|
||||
{
|
||||
public static GameManager Instance { get; private set;}
|
||||
public static GameManager Instance { get; private set; }
|
||||
private Hud _hud;
|
||||
|
||||
private PlayerMovement _player;
|
||||
|
|
@ -25,7 +25,7 @@ public partial class GameManager : Node2D
|
|||
[Export] public PackedScene PlayerTemplate { get; set; }
|
||||
|
||||
[Export] public Dictionary<int, NodePath> SpawnMarkers { get; private set; } = new();
|
||||
|
||||
|
||||
//[Export] public Marker2D PlayerSpawnMarker { get; set; }
|
||||
|
||||
[Export] public PackedScene WeaponTemplate { get; private set; }
|
||||
|
|
@ -51,12 +51,12 @@ public partial class GameManager : Node2D
|
|||
|
||||
[Signal]
|
||||
public delegate void PlayerRespawnedEventHandler();
|
||||
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
Instance = this;
|
||||
|
||||
_hud = GetNodeOrNull<Hud>("HUD");
|
||||
if (_hud == null) GD.Print("No HUD in scene.");
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ public partial class GameManager : Node2D
|
|||
{
|
||||
this.GameStateChange += _hud.OnGameStateChanged;
|
||||
}
|
||||
|
||||
|
||||
if (_inventoryManager != null && _hud != null)
|
||||
{
|
||||
_inventoryManager.ItemAdded += (item, currentAmount) => _hud.AddInventoryItem(item, currentAmount);
|
||||
|
|
@ -82,7 +82,7 @@ public partial class GameManager : Node2D
|
|||
}
|
||||
|
||||
PlayerRespawned += OnPlayerRespawned;
|
||||
|
||||
|
||||
GameState = GameState.Playing;
|
||||
|
||||
//_ = DelayPlayerSpawn();
|
||||
|
|
@ -102,9 +102,9 @@ public partial class GameManager : Node2D
|
|||
StartingEquipment.AddRange(mapStartData.StartingEquipment);
|
||||
}
|
||||
|
||||
public void ApplySessionState(SessionSettings settings)
|
||||
public void ApplySessionState(SessionSettings settings)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
|
|
@ -137,7 +137,7 @@ public partial class GameManager : Node2D
|
|||
_player.ShieldChanged += (newShield, maxShield) => _hud.UpdateShield(newShield, maxShield);
|
||||
|
||||
_player.InteractableAreaEntered += (interactable) => _hud.UpdateInteractable(interactable);
|
||||
|
||||
|
||||
_player.Death += () =>
|
||||
{
|
||||
// Show Game Over
|
||||
|
|
@ -149,7 +149,7 @@ public partial class GameManager : Node2D
|
|||
GD.Print("No player and hud in scene");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (_inventoryManager is not null)
|
||||
{
|
||||
_inventoryManager.ItemAdded += (LootItem item, int amount) =>
|
||||
|
|
@ -161,23 +161,25 @@ public partial class GameManager : Node2D
|
|||
};
|
||||
|
||||
_inventoryManager.WeaponEquip += _player.EquipWeapon;
|
||||
|
||||
_inventoryManager.ItemUsed += _player.UseItem;
|
||||
}
|
||||
|
||||
|
||||
SpawnWeapons();
|
||||
}
|
||||
|
||||
public void SpawnPlayer()
|
||||
{
|
||||
if (_player != null) return;
|
||||
|
||||
|
||||
//_player = this.CreateChild<PlayerMovement>(PlayerTemplate, PlayerSpawnMarker.Position );
|
||||
_player = PlayerTemplate.Instantiate<PlayerMovement>();
|
||||
|
||||
this.CallDeferred("add_child", _player);
|
||||
_player.Transform = this.GlobalTransform;
|
||||
|
||||
|
||||
_player.GlobalPosition = GetStartPosition();
|
||||
|
||||
|
||||
//_player.GlobalPosition = PlayerSpawnMarker.Position;
|
||||
|
||||
CameraTargetPlayer();
|
||||
|
|
@ -197,11 +199,11 @@ public partial class GameManager : Node2D
|
|||
if (SpawnMarkers.TryGetValue(MapStartData.EggIndex, out var spawnMarker))
|
||||
{
|
||||
var marker = GetNode<Node2D>(spawnMarker);
|
||||
|
||||
|
||||
return marker.Position; // Why position and not globalposition? I have no idea
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var m = GetNode<Node2D>(SpawnMarkers.First().Value);
|
||||
return m.GlobalPosition;
|
||||
}
|
||||
|
|
@ -222,7 +224,7 @@ public partial class GameManager : Node2D
|
|||
{
|
||||
_cameraTarget.Position += offset.Value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void SpawnWeapons()
|
||||
|
|
@ -305,12 +307,13 @@ public partial class GameManager : Node2D
|
|||
}
|
||||
}
|
||||
|
||||
public GameState ToggleControlMode() {
|
||||
if (GameState is GameState.Playing)
|
||||
public GameState ToggleControlMode()
|
||||
{
|
||||
if (GameState is GameState.Playing)
|
||||
{
|
||||
ChangeState(GameState.Controlling);
|
||||
}
|
||||
else if (GameState is GameState.Controlling)
|
||||
else if (GameState is GameState.Controlling)
|
||||
{
|
||||
ChangeState(GameState.Playing);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue