riversong code showcase

This commit is contained in:
Daniele Marotta
2026-05-21 15:52:18 +02:00
commit 4c9eea1c02
462 changed files with 23406 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
using Unity.Properties;
using UnityEngine;
namespace DanieleMarotta.RiversongCodeShowcase
{
public class HousePanelNeedModel : UIModel
{
private int _value;
private int _max;
public int RowIndex { get; set; }
[CreateProperty] public string Name { get; set; }
[CreateProperty] public Sprite Icon { get; set; }
[CreateProperty] public int Value { get; set; }
[CreateProperty] public int Max { get; set; }
[CreateProperty] public string ValueString => $"{Mathf.RoundToInt(100 * Mathf.Clamp01(Value / (float)Max))}%";
public void Initialize(int rowIndex, string name, Sprite icon, int value, int max)
{
RowIndex = rowIndex;
Name = name;
Icon = icon;
Value = value;
Max = max;
}
public void UpdateValue(int value)
{
if (Value == value) return;
Value = value;
NotifyPropertyChanged(nameof(Value));
NotifyPropertyChanged(nameof(ValueString));
}
}
}