You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			92 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			C#
		
	
		
		
			
		
	
	
			92 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			C#
		
	
| 
											2 years ago
										 | 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<EProperty, Property> Property = new Dictionary<EProperty, Property>(); | ||
|  | } | ||
|  | 
 | ||
|  | 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; | ||
|  |             } | ||
|  |         } | ||
|  | 
 | ||
|  |     } | ||
|  | } |