42 lines
977 B
C#
42 lines
977 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using BITKit;
|
|
using Cysharp.Threading.Tasks;
|
|
using UnityEngine;
|
|
|
|
namespace BITFALL.Player.Survival
|
|
{
|
|
public interface IPlayerSurvivalService
|
|
{
|
|
IPlayerSurvivalElement[] Elements { get; }
|
|
}
|
|
/// <summary>
|
|
/// 玩家生存接口
|
|
/// </summary>
|
|
public interface IPlayerSurvivalElement
|
|
{
|
|
string Name { get; }
|
|
public int Value { get; set; }
|
|
event Action<int> OnValueChanged;
|
|
}
|
|
public abstract class PlayerSurvivalElement:IPlayerSurvivalElement{
|
|
public virtual string Name=>GetType().Name;
|
|
private int _value = 100;
|
|
public int Value {
|
|
get => _value;
|
|
set
|
|
{
|
|
_value = Mathf.Clamp(value, 0, 100);
|
|
OnValueChanged?.Invoke(value);
|
|
}
|
|
}
|
|
public event Action<int> OnValueChanged;
|
|
}
|
|
[Serializable]
|
|
public sealed class PlayerSurvivalHunger:PlayerSurvivalElement{}
|
|
[Serializable]
|
|
public sealed class PlayerSurvivalThirst:PlayerSurvivalElement{}
|
|
}
|