Repository navigation
Replies: 1 comment
구현추상 메서드를 통해 간접적으로 사용 UStat 제네릭 클래스using System;
public abstract class UStat<T> where T : IComparable<T>
{
T _value;
public abstract T GetMaxValue();
public abstract T GetMinValue();
// 연산에 사용되는 수치
public T Value
{
get
{
if (_value.CompareTo(GetMaxValue()) > 0)
return GetMaxValue();
if (_value.CompareTo(GetMinValue()) < 0)
return GetMinValue();
return _value;
}
set => _value = value;
}
// UI에 표시할 실제 수치
public T RawValue => _value;
}자손 클래스public class UIntStat : UStat<int>
{
public const int MaxValue = 999;
public const int MinValue = 0;
public override int GetMaxValue() => MaxValue;
public override int GetMinValue() => MinValue;
}
public class UFloatStat : UStat<float>
{
public const float MaxValue = 1.4f;
public const float MinValue = 1f;
public override float GetMaxValue() => MaxValue;
public override float GetMinValue() => MinValue;
}
public class UHealth : UIntStat { }
public class UAttackPower : UIntStat { }
public class USkillPower : UIntStat { }
public class UAttackSpeed : UFloatStat { }
public class UMoveSpeed : UFloatStat { } |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
요구 사항
All reactions