using Entitas; using System.Collections.Generic; public enum EProperty { None, StunCount, Speed, BasicAttack, BasicStun, StaggerDefLevel, ShieldStaggerDefLevel, Max, } public enum EPropertyChangeType { Value, Percent, } public class Property { public int Value; public int Percent; } [Game] public class PropertyComponent : IComponent { public Dictionary Property = new Dictionary(); } namespace Game { public abstract partial class Util { public static void ClearProperty(GameEntity entity) { var property = entity.property.Property; if (property.Count == 0) { for (int i = 0; i < (int)EProperty.Max; i++) { property[(EProperty)i] = new Property(); } } else { for (int i = 0; i < (int)EProperty.Max; i++) { var p = property[(EProperty)i]; p.Value = 0; p.Percent = 0; } } } public static void SetProperty(GameEntity entity, EProperty propertyType, int value) { var property = entity.property.Property[propertyType]; property.Value = value; } public static int GetProperty(GameEntity entity, EProperty propertyType) { var property = entity.property.Property[propertyType]; return (int)(property.Value * (100f + property.Percent) / 100); } public static float GetPropertyRate(GameEntity entity, EProperty propertyType) { var property = entity.property.Property[propertyType]; return (100f + property.Percent) / 100f; } public static bool EntityIsStagger(GameEntity entity) { if (!entity.hasProperty) { return false; } var property = entity.property; return property.Property[EProperty.StunCount].Value > 0; } public static void AddStunCount(int entity, int count) { var e = Util.GetEntity(entity); if (e != null && e.hasProperty) { var p = e.property.Property[EProperty.StunCount]; p.Value += 1; } } } }