counter +1

This commit is contained in:
Rendo 2025-07-19 19:29:45 +05:00
commit 92ebb2868d
11 changed files with 50 additions and 39 deletions

View file

@ -59,7 +59,7 @@ public partial class PlantField : Node2D
bool canPlace = _resource != null
&& inBoundary
&& PoolContainer.Instance.EntityField[_resource.Layer].ContainsKey(expected_pos) == false
&& RuntimeLevelData.Instance.CheckSpendSun(_resource.Cost);
&& RuntimeLevelData.Instance.CheckSpendSun((int)_resource.Cost);
// Setting visuals
if (_previousCanPlace != canPlace)
@ -97,7 +97,7 @@ public partial class PlantField : Node2D
PoolContainer.Instance.EntityField[_resource.Layer].Add(plant.GlobalPosition, plant);
RuntimeLevelData.Instance.SpendSun(_resource.Cost);
RuntimeLevelData.Instance.SpendSun((int)_resource.Cost);
PoolContainer.Instance.SpawnParticles(particles, plant.GlobalPosition + Vector2.Down * FieldParams.TileHeight/2.0f);

View file

@ -1,5 +1,6 @@
using System;
using Godot;
using Newlon.Components.GUI;
namespace Newlon.Components.Level;
@ -14,8 +15,7 @@ public partial class RuntimeLevelData : Node
Loose
}
[Export]
public float SunCount { get; private set; } = 0;
public int SunCount { get; private set; } = 0;
[Export]
private LevelRunner levelRunner;
[Export]
@ -37,20 +37,24 @@ public partial class RuntimeLevelData : Node
public override void _Ready()
{
Engine.TimeScale = 1.0;
SunCount = LevelResource.startSun;
SunCounter.UpdateInstantly();
SetLevelState(LevelStates.ChooseYourSeeds);
}
#region Sun
public void AddSun(float amount)
public void AddSun(int amount)
{
SunCount += amount;
SunCounter.Update();
}
public void SpendSun(float amount)
public void SpendSun(int amount)
{
SunCount -= amount;
SunCounter.Update();
}
public bool CheckSpendSun(float amount)
public bool CheckSpendSun(int amount)
{
if (SunCount - amount < 0) return false;