FINAL JAM COMMIT

This commit is contained in:
2026-02-01 14:06:04 +02:00
parent d910018b7b
commit 4dcca0d08a
42 changed files with 1652 additions and 55 deletions
+15 -4
View File
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using Godot;
using Godot.Collections;
public enum TurretType
{
@@ -11,10 +11,17 @@ public enum TurretType
public partial class TurretController : Node2D
{
[Export] private Dictionary<TurretType, PackedScene> _typeToPrefab;
[Export] private Dictionary<TurretType, PackedScene> _typeToPlaceholder;
public static TurretController Instance;
[Export] private Godot.Collections.Dictionary<TurretType, PackedScene> _typeToPrefab;
[Export] private Godot.Collections.Dictionary<TurretType, PackedScene> _typeToPlaceholder;
[Export] private Node2D _turretParent;
[Export] public int BasePrice;
public int TurretAmount => _allTurrets.Count;
public int TurretPrice => BasePrice + (int)Math.Round(30f * Math.Pow(TurretAmount, 1.5f));
[Signal]
public delegate void PlaceTurretEventHandler(TurretType t);
@@ -23,8 +30,11 @@ public partial class TurretController : Node2D
private TurretPlaceholder _turretPlaceholder;
private TurretType _currentlyPlacingType;
private HashSet<Node2D> _allTurrets = new();
public override void _Ready()
{
Instance = this;
PlaceTurret += StartPlaceingTurret;
}
@@ -40,8 +50,9 @@ public partial class TurretController : Node2D
{
case MouseButton.Left:
if (!_turretPlaceholder.CanPlace) return;
if (!GameController.Instance.TryRemoveCurrency(_turretPlaceholder.Cost)) return;
if (!GameController.Instance.TryRemoveCurrency(TurretPrice)) return;
var newT = _typeToPrefab[_currentlyPlacingType].Instantiate() as Node2D;
_allTurrets.Add(newT);
_turretParent.AddChild(newT);
newT.GlobalPosition = mpos;
break;