Skip to content

Instantly share code, notes, and snippets.

@saitocastel1900
Created November 10, 2022 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saitocastel1900/136722a8cf47a5d8202db310ec180aa6 to your computer and use it in GitHub Desktop.
Save saitocastel1900/136722a8cf47a5d8202db310ec180aa6 to your computer and use it in GitHub Desktop.
using System;
using UniRx;
using UnityEngine;
namespace Gauge
{
public class Model
{
public IReadOnlyReactiveProperty<int> Value => _value;
private IntReactiveProperty _value { set; get; }
public event Action OnCallback;
/// <summary>
/// コンストラクタ
/// </summary>
/// <param name="value"></param>
public Model(int value=0)
{
_value=new IntReactiveProperty(value);
}
/// <summary>
/// スコアを更新(加算)
/// </summary>
/// <param name="value"></param>
public void UpdateCount(int value)
{
_value.Value = Mathf.Clamp(value, 0, 10);
if (_value.Value >= 10) OnCallback?.Invoke();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment