123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- using CommonLang;
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace CommonAI.Zone.Attributes
- {
- //-----------------------------------------------------------
- [AttributeUsage(AttributeTargets.Field)]
- public class ColorValueAttribute : System.Attribute
- {
- public static readonly int COLOR_GREEN = FromARGB(0xff, 0x00, 0xff, 0x00);
- public static readonly int COLOR_LIGHT_GREEN = FromARGB(0xff, 0x80, 0xff, 0x80);
- public static readonly int COLOR_DARK_GRAY = FromARGB(0xff, 0x40, 0x40, 0x40);
- public static readonly int COLOR_RED = FromARGB(0xff, 0xff, 0x00, 0x00);
- public static readonly int COLOR_LIGHT_BLUE = FromARGB(0xff, 0x80, 0x80, 0xff);
- public static int FromARGB(float a, float r, float g, float b)
- {
- int ARGB = 0;
- ARGB |= ((int)CMath.getInRange(a * 255, 0, 255)) << 24;
- ARGB |= ((int)CMath.getInRange(r * 255, 0, 255)) << 16;
- ARGB |= ((int)CMath.getInRange(g * 255, 0, 255)) << 8;
- ARGB |= ((int)CMath.getInRange(b * 255, 0, 255));
- return ARGB;
- }
- public static int FromARGB(int a, int r, int g, int b)
- {
- int ARGB = 0;
- ARGB |= ((int)CMath.getInRange(a, 0, 255)) << 24;
- ARGB |= ((int)CMath.getInRange(r, 0, 255)) << 16;
- ARGB |= ((int)CMath.getInRange(g, 0, 255)) << 8;
- ARGB |= ((int)CMath.getInRange(b, 0, 255));
- return ARGB;
- }
- }
- //-----------------------------------------------------------
- /// <summary>
- /// 标识 Field Int32 字段为 类型的模板ID
- /// </summary>
- [AttributeUsage(AttributeTargets.Field)]
- public class TemplateIDAttribute : System.Attribute
- {
- private Type templateType;
- public TemplateIDAttribute(Type templateType)
- {
- this.templateType = templateType;
- }
- public Type TemplateType
- {
- get { return templateType; }
- }
- }
- //-----------------------------------------------------------
- /// <summary>
- /// 标识 Field Int32 字段为 UnitInfo 模板ID的等级
- /// </summary>
- [AttributeUsage(AttributeTargets.Field)]
- public class TemplateLevelAttribute : System.Attribute
- {
- public TemplateLevelAttribute()
- {
- }
- }
- //-----------------------------------------------------------
- /// <summary>
- /// 标识 Field 数组或List字段为 Int32 类型的模板ID
- /// </summary>
- [AttributeUsage(AttributeTargets.Field)]
- public class TemplatesIDAttribute : System.Attribute
- {
- private Type templateType;
- public TemplatesIDAttribute(Type templateType)
- {
- this.templateType = templateType;
- }
- public Type TemplateType
- {
- get { return templateType; }
- }
- }
- //-----------------------------------------------------------
- /// <summary>
- /// 标识 Field 字段为资源文件
- /// </summary>
- [AttributeUsage(AttributeTargets.Field)]
- public class ResourceIDAttribute : System.Attribute
- {
- }
- //-----------------------------------------------------------
- /// <summary>
- /// 标识 Field 字段为场景单位 Name
- /// </summary>
- [AttributeUsage(AttributeTargets.Field)]
- public class SceneObjectIDAttribute : System.Attribute
- {
- private Type objectType;
- public SceneObjectIDAttribute(Type objectType)
- {
- this.objectType = objectType;
- }
- public Type ObjectType
- {
- get { return objectType; }
- }
- }
- //-----------------------------------------------------------
- /// <summary>
- /// 标识 Field 字段为场景事件触发 Name
- /// </summary>
- [AttributeUsage(AttributeTargets.Field)]
- public class SceneEventIDAttribute : System.Attribute
- {
- }
- //-----------------------------------------------------------
- /// <summary>
- /// 标识 Field 字段为场景环境变量 Key
- /// </summary>
- [AttributeUsage(AttributeTargets.Field)]
- public class SceneVarIDAttribute : System.Attribute
- {
- public readonly Type VarType;
- public SceneVarIDAttribute(Type varType)
- {
- this.VarType = varType;
- }
- }
- /// <summary>
- /// 标识 Field 字段为临时变量 Key
- /// </summary>
- [AttributeUsage(AttributeTargets.Field)]
- public class LocalVarIDAttribute : System.Attribute
- {
- public readonly Type VarType;
- public LocalVarIDAttribute(Type varType)
- {
- this.VarType = varType;
- }
- }
- //-----------------------------------------------------------
- /// <summary>
- /// 标识 Field 字段为 脚本文件
- /// </summary>
- [AttributeUsage(AttributeTargets.Field)]
- public class SceneScriptIDAttribute : System.Attribute
- {
- }
- //-----------------------------------------------------------
- /// <summary>
- /// 标识 UnitTrigger (单位被动系) 触发类型。
- /// </summary>
- [AttributeUsage(AttributeTargets.Class)]
- public class UnitTriggerEventTypeAttribute : System.Attribute
- {
- private Type[] delegateTypes;
- public UnitTriggerEventTypeAttribute(params Type[] delegateTypes)
- {
- this.delegateTypes = delegateTypes;
- }
- public Type[] DelegateTypes
- {
- get { return delegateTypes; }
- }
- }
- //-----------------------------------------------------------
- //-----------------------------------------------------------
- /// <summary>
- /// 标识 Field 字段为单位事件触发 Name
- /// </summary>
- [AttributeUsage(AttributeTargets.Field)]
- public class UnitEventIDAttribute : System.Attribute
- {
- }
- //-----------------------------------------------------------
- /// <summary>
- /// 标记对象字段名字,用于AbstractValue取Field
- /// </summary>
- [AttributeUsage(AttributeTargets.Field)]
- public class ObjectMemberNameAttribute : System.Attribute
- {
- public readonly Type ObjectType;
- public readonly Type FieldType;
- public ObjectMemberNameAttribute(Type fieldType)
- {
- this.ObjectType = null;
- this.FieldType = fieldType;
- }
- public ObjectMemberNameAttribute(Type objType, Type fieldType)
- {
- this.ObjectType = objType;
- this.FieldType = fieldType;
- }
- }
- //-----------------------------------------------------------
- /// <summary>
- /// 标记对象字段名字,用于生成Language.csv
- /// </summary>
- [AttributeUsage(AttributeTargets.Field)]
- public class LocalizationTextAttribute : System.Attribute
- {
- public LocalizationTextAttribute()
- {
- }
- }
- //-----------------------------------------------------------
- /// <summary>
- /// 标记对象字段名字,用于AbstractValue取QuestID
- /// </summary>
- [AttributeUsage(AttributeTargets.Field)]
- public class QuestIDAttribute : System.Attribute
- {
- public QuestIDAttribute()
- {
- }
- }
- //-----------------------------------------------------------
- /// <summary>
- /// 标记 event 是否可以在编辑时反射成事件触发器
- /// </summary>
- [AttributeUsage(AttributeTargets.Event | AttributeTargets.Property | AttributeTargets.Field)]
- public class EventTriggerDescAttribute : System.Attribute
- {
- public string Description { get; private set; }
- public EventTriggerDescAttribute(string desc)
- {
- this.Description = desc;
- }
- }
- //-----------------------------------------------------------
-
- //-----------------------------------------------------------
- }
|