상속: IComparable
예제 #1
0
 public static string GiveMeStateFromEnum(Enum stateFromCore)
 {
     string res = "";
     switch (stateFromCore.ToString())
     {
         case "queued_for_checking":
             res = "Queued For Checking";
             break;
         case "checking_files":
             res = "Checking Files";
             break;
         case "downloading_metadata":
             res = "Downloading Metadata";
             break;
         case "downloading":
             res = "Downloading";
             break;
         case "finished":
             res = "Finished";
             break;
         case "seeding":
             res = "Seeding";
             break;
         case "allocating":
             res = "Allocating";
             break;
         case "checking_resume_data":
             res = "Checking Resume Data";
             break;
         default:
             res = "Error";
             break;
     }
     return res;
 }
예제 #2
0
 internal EventListener(Enum pEvent, Delegate pCallback)
 {
     Event = pEvent;
     ListenerType = pCallback.Target.GetType();
     ListenerHashCode = pCallback.Target.GetHashCode();
     Callback = pCallback;
 }
예제 #3
0
파일: Masks.cs 프로젝트: srndpty/VFW
 public int BunnyMask(GUIContent content, Enum enumValue)
 {
     var enumType = enumValue.GetType();
     var enumNames = Enum.GetNames(enumType);
     var enumValues = Enum.GetValues(enumType) as int[];
     return BunnyMask(content, Convert.ToInt32(enumValue), enumValues, enumNames);
 }
예제 #4
0
		public override object Serialize (IDesignerSerializationManager manager, object value)
		{
			if (manager == null)
				throw new ArgumentNullException ("manager");
			if (value == null)
				throw new ArgumentNullException ("value");

			Enum[] enums = null;
			TypeConverter converter = TypeDescriptor.GetConverter (value);
			if (converter.CanConvertTo (typeof (Enum[])))
				enums = (Enum[]) converter.ConvertTo (value, typeof (Enum[]));
			else
				enums = new Enum[] { (Enum) value };
			CodeExpression left = null;
			CodeExpression right = null;
			foreach (Enum e in enums) {
				right = GetEnumExpression (e);
				if (left == null) // just the first time
					left = right;
				else
					left = new CodeBinaryOperatorExpression (left, CodeBinaryOperatorType.BitwiseOr, right);
			}

			return left;
		}
예제 #5
0
        public static bool Contains(this Enum keys, Enum flag)
        {
            ulong keysVal = Convert.ToUInt64(keys);
            ulong flagVal = Convert.ToUInt64(flag);

            return (keysVal & flagVal) == flagVal;
        }
예제 #6
0
파일: Mediator.cs 프로젝트: silky/sledge
 public static void Publish(Enum message, params object[] parameters)
 {
     object parameter = null;
     if (parameters.Length == 1) parameter = parameters[0];
     else if (parameters.Length > 1) parameter = parameters;
     Publish(message.ToString(), parameter);
 }
예제 #7
0
        public static string GetDescription(this Type type, Enum value)
        {
            if (!EnumTypeCaches.ContainsKey(type))
            {
                EnumTypeCaches[type] = new Dictionary<Enum, string>();
            }

            if(!EnumTypeCaches[type].ContainsKey(value))
            {
                var name = Enum.GetName(type, value);
                if (!string.IsNullOrEmpty(name))
                {
                    var field = type.GetField(name);
                    if (field != null)
                    {
                        var attr = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute;
                        if (attr != null)
                        {
                            EnumTypeCaches[type][value] = attr.Description;
                            return attr.Description;
                        }
                           
                    }
                }
            }

            return EnumTypeCaches[type][value];
        }
		public IDbDataParameter Add(string paramName, Enum paramType, int paramSize, ParameterDirection paramDirection,  byte precision, byte scale, string sourceColumn, object paramValue) 
		{
			
			IDbDataParameter param = _command.CreateParameter();

			param.ParameterName = paramName;	

			if(paramType is DbType) 
			{
				param.DbType = (DbType)paramType;
			}
			
			param.Direction = paramDirection;

			if(sourceColumn != null && sourceColumn != string.Empty)
				param.SourceColumn = sourceColumn;


			if(paramSize > 0)
				param.Size = paramSize;
			if(precision > 0)
				param.Precision = precision;
			if(scale > 0)
				param.Scale = scale;

			
			if(paramValue != null && param.Value != DBNull.Value) 					
				param.Value	= paramValue;

			_parameters.Add(param);			
			

			return param;
		}
예제 #9
0
 internal static string EnumToTranslation(this ResourceManager r, Enum value)
 {
     var type = value.GetType();
     var name = Enum.GetName(type, value);
     var key = type.Name + name;
     return r.GetString(key) ?? "Key: " + key;
 }
예제 #10
0
        public Resource(ResourceManager resourceManager, Enum stringResource)
        {
            ResourceManager = resourceManager;
            StringResource = stringResource;

            LastModified = DateTime.UtcNow;
        }
        /// <summary>
        /// No type-safety check.
        /// </summary>
        public static bool HasFlag(this Enum e1, Enum e2)
        {
            ulong e = Convert.ToUInt64(e1);
            ulong f = Convert.ToUInt64(e2);

            return (e & f) == f;
        }
 public override void SelectConcept(Enum concept)
 {
     base.SelectConcept(concept);
     if(concept.GetType().Equals(typeof(DataAccessConceptsList)))
     {
         switch((DataAccessConceptsList)concept)
         {
             case DataAccessConceptsList.WorkingWithFilesExamples:
                 conceptExecutionClass = new WorkingWithFilesExamples();
                 break;
             case DataAccessConceptsList.WorkingWithStreams:
                 conceptExecutionClass = new WorkingWithStreams();
                 break;
             case DataAccessConceptsList.WorkingWithADO_DOTNET_Concepts:
                 conceptExecutionClass = new WorkingWithADO_DOTNET_Concepts();
                 break;
             case DataAccessConceptsList.WorkingWithXMLConcepts:
                 conceptExecutionClass = new WorkingWithXMLExamples();
                 break;
             case DataAccessConceptsList.LINQExamples:
                 conceptExecutionClass = new LINQExamples();
                 break;
             case DataAccessConceptsList.SerializationAndDeserializationExamples:
                 conceptExecutionClass = new SerializationAndDeserializationExamples();
                 break;
             case DataAccessConceptsList.ImplementingClassHierarchy:
                 conceptExecutionClass = new ClassHierarchyExample();
                 break;
         }
     }
 }
        public void Add(Enum id, IOBoardController ioBoard)
        {
            if (ioBoard == null) throw new ArgumentNullException(nameof(ioBoard));

            ExposeToApi(ioBoard);
            _ioBoards.Add(id, ioBoard);
        }
예제 #14
0
 private SetEnumEvent(CtorType ctorType, int position, Enum val, String name)
 {
     this.ctorType = ctorType;
     this.position = position;
     this.val = val;
     this.name = name;
 }
예제 #15
0
		/*============================================================================*/
		/* Public Functions                                                           */
		/*============================================================================*/

		public void MapListener(IEventDispatcher dispatcher, Enum type, Delegate listener, Type eventClass = null)
		{
			if (eventClass == null)
			{	
				eventClass = typeof(Event);
			}

			List<EventMapConfig> currentListeners = _suspended ? _suspendedListeners : _listeners;

			EventMapConfig config;

			int i = currentListeners.Count;

			while (i-- > 0) 
			{
				config = currentListeners [i];
				if (config.Equals (dispatcher, type, listener, eventClass))
					return;
			}

			Delegate callback = eventClass == typeof(Event) ? listener : (Action<IEvent>)delegate(IEvent evt){
				RouteEventToListener(evt, listener, eventClass);
			};

			config = new EventMapConfig (dispatcher, type, listener, eventClass, callback);

			currentListeners.Add (config);

			if (!_suspended) 
			{
				dispatcher.AddEventListener (type, callback);
			}
		}
예제 #16
0
		public void UnmapListener(IEventDispatcher dispatcher, Enum type, Delegate listener, Type eventClass = null)
		{
			if (eventClass == null)
			{	
				eventClass = typeof(Event);
			}

			List<EventMapConfig> currentListeners = _suspended ? _suspendedListeners : _listeners;

			EventMapConfig config;

			int i = currentListeners.Count;

			while (i-- > 0) 
			{
				config = currentListeners [i];
				if (config.Equals (dispatcher, type, listener, eventClass)) 
				{
					if (!_suspended) 
					{
						dispatcher.RemoveEventListener (type, config.callback);
					}
					currentListeners.RemoveAt (i);
					return;
				}
			}
		}
예제 #17
0
        public static string GetStringValue(Enum value)
        {
            string output;
            var type = value.GetType();

            if (StringValues.ContainsKey(value))
            {
                output = StringValues[value].Value;
            }
            else
            {
                var fi = type.GetField(value.ToString());
                var attrs = fi.GetCustomAttributes(typeof (StringValueAttribute), false)
                    as StringValueAttribute[];
                if (attrs != null && attrs.Length > 0)
                {
                    output = attrs[0].Value;
                    // Put it in the cache.
                    lock(StringValues)
                    {
                        // Double check
                        if (!StringValues.ContainsKey(value))
                        {
                            StringValues.Add(value, attrs[0]);
                        }
                    }
                }
                else
                {
                    return value.ToString();
                }
            }

            return output;
        }
예제 #18
0
 static string GetLocalizeCaption(Enum value)
 {
     string capture = string.Empty;
     EnumDescriptor descriptor = new EnumDescriptor(typeof(DomainComponents.Common.Gender));
     capture = descriptor.GetCaption(value);
     return capture;
 }
예제 #19
0
		public void Dispatch(Enum eventType, GameEvent gameEvent)
		{
			gameEvent.EventIndex = ++LastEventIndex;

			if (Parent != null)
			{
				Parent.Dispatch(eventType, gameEvent);
			}
			else
			{
				if (Handlers.ContainsKey(eventType))
				{
					List<EventHandler> handlersForEventType = Handlers[eventType];

					if (handlersForEventType != null && handlersForEventType.Count > 0)
					{
						handlersForEventType.ForEach(
							h =>
							{
								if (!gameEvent.StopPropagation)
								{
									h(gameEvent);
								}
							});
					}
				}
			}
		}
예제 #20
0
		static KeyInfo ValuePair(Enum token, object value)
		{
			KeyInfo k=new KeyInfo();
			k.ki_key=(int)(object)token;
			k.ki_name=token.ToString();
			return k;
		}
예제 #21
0
        public Room AddRoom(Enum id)
        {
            var room = new Room(this, id.ToString());
            _rooms.Add(id, room);

            return room;
        }
예제 #22
0
 public Car(string name, string description, double price, string carType, int yearOfProduction, Enum condition)
     : base(name, description, price)
 {
     this.CarType = carType;
     this.YearOfProduction = yearOfProduction;
     this.Condition = condition;
 }
예제 #23
0
 public FingerName getPrev(Enum current)
 {
     //set current index to last
     int currentIdx = 5;
     //initialize a Enum FingerName
     FingerName f = FingerName.UNKNOWN;
     //loop to find the current Enum index and value
     foreach (var value in Enum.GetValues(typeof(FingerName)))
     {
         if (current == value)
         {
             f = (FingerName)value;
             break;
         }
         else
         {
             currentIdx--;
         }
     }
     //minus 1 to get previous index of Enum
     int prevIdx = currentIdx - 1;
     //check if previous index is more than 0
     if (prevIdx < 0)
     {
         prevIdx = (FingerName.GetValues(typeof(FingerName)).Length) - 1;
     }
     //return the value of previous Enum
     return f;
 }
예제 #24
0
        /// <summary>
        /// Returns the string version of a http status response code
        /// </summary>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public static string getEnumHttpResponse(Enum statusCode)
        {
            string _httpResponse = "";

            switch (getEnumValue(statusCode))
            {
                case 200:
                    _httpResponse = "HTTP/1.1 200 OK";
                    break;

                case 404:
                    _httpResponse = "HTTP/1.1 404 Not Found";
                    break;

                case 423:
                    _httpResponse = "HTTP/1.1 423 Locked";
                    break;

                case 424:
                    _httpResponse = "HTTP/1.1 424 Failed Dependency";
                    break;

                case 507:
                    _httpResponse = "HTTP/1.1 507 Insufficient Storage";
                    break;

                default:
                    break;
            }

            return _httpResponse;
        }
예제 #25
0
        public static bool HasFlag(this Enum enumRef, Enum flag)
        {
            long value = Convert.ToInt64(enumRef);
            long flagVal = Convert.ToInt64(flag);

            return (value & flagVal) == flagVal;
        }
예제 #26
0
 public FingerName getNext(Enum current)
 {
     //set current index to 0
     int currentIdx = 0;
     //initialize a Enum FingerName
     FingerName f = FingerName.UNKNOWN;
     //loop to find the current Enum index and value
     foreach (var value in Enum.GetValues(typeof(FingerName)))
     {
         if (current == value)
         {
             f = (FingerName)value;
             break;
         }
         else
         {
             currentIdx++;
         }
     }
     //add 1 to get next index of Enum
     int nextIdx = currentIdx + 1;
     //check if next index value is UNKNOWN
     if (nextIdx == Enum.GetValues(typeof(FingerName)).Length)
     {
         nextIdx = 0;
     }
     //return the value of next Enum
     return f;
 }
예제 #27
0
        public static string GetStringValue(Enum value)
        {
            string output = null;
            Type type = value.GetType();

            //Check first in our cached results...
            if (_stringValues.ContainsKey(value))
                output = (_stringValues[value] as StringValueAttribute).Value;
            else
            {
                //Look for our 'StringValueAttribute' 
                //in the field's custom attributes
                FieldInfo fi = type.GetField(value.ToString());
                StringValueAttribute[] attrs =
                   fi.GetCustomAttributes(typeof(StringValueAttribute),
                                           false) as StringValueAttribute[];
                if (attrs.Length > 0)
                {
                    _stringValues.Add(value, attrs[0]);
                    output = attrs[0].Value;
                }
            }

            return output;
        }
 private static IEnumerable<Enum> GetFlags(Enum value, Enum[] values)
 {
     ulong bits = Convert.ToUInt64(value);
     List<Enum> results = new List<Enum>();
     for (int i = values.Length - 1; i >= 0; i--)
     {
         ulong mask = Convert.ToUInt64(values[i]);
         if (i == 0 && mask == 0L)
         {
             break;
         }
         if ((bits & mask) == mask)
         {
             results.Add(values[i]);
             bits -= mask;
         }
     }
     if (bits != 0L)
     {
         return Enumerable.Empty<Enum>();
     }
     if (Convert.ToUInt64(value) != 0L)
     {
         return results.Reverse<Enum>();
     }
     if (bits == Convert.ToUInt64(value) && values.Length > 0 && Convert.ToUInt64(values[0]) == 0L)
     {
         return values.Take(1);
     }
     return Enumerable.Empty<Enum>();
 }
예제 #29
0
        public static bool HasFlag(this Enum thisInstance, Enum flag)
        {
            ulong instanceVal = Convert.ToUInt64(thisInstance);
            ulong flagVal = Convert.ToUInt64(flag);

            return (instanceVal & flagVal) == flagVal;
        }
예제 #30
0
		/// <summary>
		/// Enumeration valued field.
		/// </summary>
		/// <param name="Node">Node</param>
		/// <param name="FieldName">Name of field</param>
		/// <param name="StringIds">Corresponding String IDs</param>
		/// <param name="Timepoint">Timepoint of field value.</param>
		/// <param name="Value">Value</param>
		/// <param name="Type">Type of value.</param>
		public FieldEnum(string NodeId, string FieldName, FieldLanguageStep[] StringIds, DateTime Timepoint,
			Enum Value, ReadoutType Type)
			: base(NodeId, FieldName, StringIds, Timepoint, Type)
		{
			this.value = Value.ToString();
			this.dataType = Value.GetType ().FullName;
		}
예제 #31
0
 public void UnbindBool(System.Enum id, BoolMPCallbackObj _cb)
 {
     if (!boolMessageObj.ContainsKey(id))
     {
         boolMessageObj.Add(id, _cb);
     }
     else
     {
         boolMessageObj [id] += _cb;
     }
 }
예제 #32
0
 public void UnbindInt(System.Enum id, IntMPCallbackObj _cb)
 {
     if (!intMessageObj.ContainsKey(id))
     {
         intMessageObj.Add(id, _cb);
     }
     else
     {
         intMessageObj [id] += _cb;
     }
 }
예제 #33
0
 public void BindFloat(System.Enum id, FloatMPCallbackFloat _cb)
 {
     if (!flaotMessageFloat.ContainsKey(id))
     {
         flaotMessageFloat.Add(id, _cb);
     }
     else
     {
         flaotMessageFloat [id] += _cb;
     }
 }
예제 #34
0
 public void UnbindFloat(System.Enum id, FloatMPCallbackObj _cb)
 {
     if (!flaotMessageObj.ContainsKey(id))
     {
         flaotMessageObj.Add(id, _cb);
     }
     else
     {
         flaotMessageObj [id] += _cb;
     }
 }
예제 #35
0
 public void UnbindString(System.Enum id, StringMPCallbackObj _cb)
 {
     if (!stringMessageObj.ContainsKey(id))
     {
         stringMessageObj.Add(id, _cb);
     }
     else
     {
         stringMessageObj [id] += _cb;
     }
 }
    public static System.Enum EnumField(string handle, string tooltip, System.Enum field, bool isField = true)
    {
        if (CanDraw == true)
        {
            var fieldRect = ReserveField(handle, tooltip);

            field = DrawEditableEnum(fieldRect, field, isField);
        }

        return(field);
    }
예제 #37
0
    internal override void DoStart()
    {
        fabrikatNames = new string[Fabrikat.Count + 1];


        for (int i = 0; i < Fabrikat.Count; i++)
        {
            fabrikatNames[i] = Fabrikat[i].name;
        }
        fabrikatNames[Fabrikat.Count] = "StopProduction";
        UnitState = unitState = OPTIONS.StopProduction;
    }
예제 #38
0
    public static System.Enum ShowEnumField(string fieldName, System.Enum value, GUISkin skin)
    {
        GUILayout.BeginVertical();
        GUILayout.BeginHorizontal();
        EditorGUILayout.LabelField(fieldName, skin.label, FieldLabelGUIOption, FieldDefaultHeightGUIOption);
        var output = EditorGUILayout.EnumPopup(value, skin.GetStyle("Dropdown"), FieldMaxWidthGUIOption);

        GUILayout.EndHorizontal();
        GUILayout.EndVertical();

        return(output);
    }
예제 #39
0
    public static System.Enum EnumSelection(string label, string toolTip, System.Enum selectedEnum, SerializedProperty selected, ref bool changed)
    {
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label(new GUIContent(label, toolTip), GUILayout.MaxWidth(150));
        var newValue = EditorGUILayout.EnumPopup(selectedEnum);

        EditorGUILayout.EndHorizontal();
        changed |= newValue != selectedEnum;
        selected.enumValueIndex = System.Convert.ToInt32(newValue);

        return(newValue);
    }
예제 #40
0
 public static bool EnumTryParse(string value, ref System.Enum e)
 {
     foreach (string name in System.Enum.GetNames(e.GetType()))
     {
         if (name == value)
         {
             e = (System.Enum)System.Enum.Parse(e.GetType(), value);
             return(true);
         }
     }
     return(false);
 }
예제 #41
0
    static public System.Enum DrawEnumField(System.Enum value, string title, string tooltip, bool enabled, params GUILayoutOption[] options)
    {
        if (enabled)
        {
            return(EditorGUILayout.EnumPopup(new GUIContent(title, tooltip), value, options));
        }
        Color saveColor = GUI.color;

        GUI.color = new Color(1f, 1f, 1f, 0.25f);
        EditorGUILayout.EnumPopup(new GUIContent(title, tooltip), value, options);
        GUI.color = saveColor;
        return(value);
    }
예제 #42
0
    static public System.Enum DrawEnumField(System.Enum value, string title, bool enabled = true)
    {
        if (enabled)
        {
            return(EditorGUILayout.EnumPopup(title, value));
        }
        Color saveColor = GUI.color;

        GUI.color = new Color(1f, 1f, 1f, 0.25f);
        EditorGUILayout.EnumPopup(title, value);
        GUI.color = saveColor;
        return(value);
    }
예제 #43
0
 public static IEnumerable <SelectListItem> ToSelectList <T>(this System.Enum enumValue)
 {
     return
         (System.Enum.GetValues(enumValue.GetType()).Cast <T>()
          .Select(
              x =>
              new SelectListItem
     {
         Text = ((System.Enum)(object) x).ToDescription(),
         Value = x.ToString(),
         Selected = (enumValue.Equals(x))
     }));
 }
예제 #44
0
    //Same reaction mechanic, but no volume calculations
    public void MakepHIndicators(SelectionObjectData object1, SelectionObjectData object2)
    {
        //Two objects react to get a resultant object
        System.Enum result = Reactions.React(object1.item, object2.item);

        //pH papers doesn't have volume. So, volume calculations is not needed

        //pH calculations is also needed.

        //TODO: Check if the item is present in the inventory
        //If present, compare it with it's slot's item description
        //If not, add it to a new slot along with the item description information to the slot.
    }
예제 #45
0
 public static System.Enum ToEnum(this int value, System.Type enumTypeOf, bool caseSensitive = true)
 {
     try
     {
         System.Enum result = (System.Enum)System.Enum.Parse(enumTypeOf, value.ToString(), !caseSensitive);
         return(result);
     }
     catch (System.ArgumentException)
     {
         Debug.Log("string.ToEnum() '" + value + "' is not a enum(" + enumTypeOf + ") value!");
     }
     return(default(System.Enum));
 }
예제 #46
0
    public static System.Enum FieldEnum(string label, System.Enum target, bool large)
    {
        GUILayout.BeginHorizontal();
        {
            GUILayout.Label(label, (large ? LARGE_LABEL_WIDTH : LABEL_WIDTH));
            GUILayout.Label(":", LABEL_SEPARATOR_WIDTH);

            target = EditorGUILayout.EnumPopup(target);
        }
        GUILayout.EndHorizontal();

        return(target);
    }
예제 #47
0
    void Hide(bool result, System.Enum value)
    {
        foreach (var ui in tokens)
        {
            DestroyEnumToken(ui);
        }
        tokens.Clear();

        gameObject.SetActive(false);
        var closeActionCopy = closeAction;

        closeAction = null;
        closeActionCopy?.Invoke(result, value);
    }
예제 #48
0
    public static void StopListening(System.Enum eventType, UnityAction listener)
    {
        if (instance == null)
        {
            return;
        }

        UnityEvent thisEvent = null;

        if (instance.eventDictionary.TryGetValue(eventType, out thisEvent))
        {
            thisEvent.RemoveListener(listener);
        }
    }
예제 #49
0
    void SetLanguage(System.Enum type)
    {
        var language = (Language)type;
        int index    = (int)language;

        for (int i = 0; i < settings.Length; i++)
        {
            if (language == settings[i].Type)
            {
                text.text = settings[i].Value;
                break;
            }
        }
    }
예제 #50
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        currentProperty = property;
        ExtendEnumAttribute source = (ExtendEnumAttribute)attribute;

        System.Enum enumVal = GetBaseProperty <System.Enum>(property);

        enumNames = (property.enumDisplayNames).OfType <string>().ToList();
        if (source.display)
        {
            int[] enumValues = (int[])(System.Enum.GetValues(enumVal.GetType()));
            for (int i = 0; i < enumNames.Count; i++)
            {
                enumNames[i] += " | " + enumValues[i];
            }
        }

        EditorGUI.BeginProperty(position, label, property);
        if (!showWindow)
        {
            if (enumNames.Count != 0)
            {
                enumNames.Add("Add New...");
                int newValue = EditorGUI.Popup(position, property.displayName, property.intValue, enumNames.ToArray());

                if (newValue == enumNames.Count - 1)
                {
                    NewValuePopup popup = new NewValuePopup();
                    PopupWindow.Show(new Rect(Screen.width / 2 - popupWidth / 2, position.y - popupHeight / 2, 0, 0), popup);

                    newValueText = "";
                }
                else
                {
                    property.intValue = newValue;
                }
            }
            else
            {
                EditorGUI.LabelField(position, "Extendable Enums needs at least one value in your declared enum.");
            }
        }
        else
        {
            EditorGUI.LabelField(position, "Waiting for new value input.");
        }

        EditorGUI.EndProperty();
    }
예제 #51
0
    void DrawInspector()
    {
        if (inspected == null)
        {
            return;
        }

        foreach (string key in inspectorFields.Keys)
        {
            System.Type fieldType = inspectorFields[key].FieldType;
            if (fieldType == typeof(string))
            {
                string editorText = EditorGUILayout.TextField(CleanName(key), (string)inspectorFields[key].GetValue(inspected));
                UpdateProperty <string>(key, editorText);
            }
            else if (fieldType == typeof(int))
            {
                int editorInt = EditorGUILayout.IntField(CleanName(key), (int)inspectorFields[key].GetValue(inspected));
                UpdateProperty <int>(key, editorInt);
            }
            else if (fieldType == typeof(float))
            {
                float editorFloat = EditorGUILayout.FloatField(CleanName(key), (float)inspectorFields[key].GetValue(inspected));
                UpdateProperty <float>(key, editorFloat);
            }
            else if (fieldType == typeof(bool))
            {
                bool editorBool = EditorGUILayout.Toggle(CleanName(key), (bool)inspectorFields[key].GetValue(inspected));
                UpdateProperty <bool>(key, editorBool);
            }
            else if (fieldType == typeof(Vector3))
            {
                Vector3 editorVec3 = EditorGUILayout.Vector3Field(CleanName(key), (Vector3)inspectorFields[key].GetValue(inspected));
                UpdateProperty <Vector3>(key, editorVec3);
            }
            else if (fieldType.IsEnum)
            {
                System.Enum editorEnum = EditorGUILayout.EnumPopup(CleanName(key), (System.Enum)inspectorFields[key].GetValue(inspected));
                UpdateProperty <System.Enum>(key, editorEnum);
            }
            else if (fieldType == typeof(GameObject))
            {
                GameObject editorObj = EditorGUILayout.ObjectField(CleanName(key), (GameObject)inspectorFields[key].GetValue(inspected),
                                                                   typeof(GameObject), true) as GameObject;

                UpdateProperty <GameObject>(key, editorObj);
            }
        }
    }
예제 #52
0
    public static void StartListening(System.Enum eventType, UnityAction listener)
    {
        UnityEvent thisEvent = null;

        if (instance.eventDictionary.TryGetValue(eventType, out thisEvent))
        {
            thisEvent.AddListener(listener);
        }
        else
        {
            thisEvent = new UnityEvent();
            thisEvent.AddListener(listener);
            instance.eventDictionary.Add(eventType, thisEvent);
        }
    }
예제 #53
0
    private void MaterialsGUI()
    {
        EditorGUILayout.BeginVertical();
        {
            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Label("Import Materials", GUILayout.Width(LABEL_WIDTH));
                PostprocessorSetting.Instance.ImportMaterials = EditorGUILayout.Toggle(PostprocessorSetting.Instance.ImportMaterials);
            }
            EditorGUILayout.EndHorizontal();
            if (PostprocessorSetting.Instance.ImportMaterials)
            {
                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Material Naming", GUILayout.Width(LABEL_WIDTH));
                    System.Enum selected =
                        PostprocessorSetting.Instance.MaterialNaming = (ModelImporterMaterialName)EditorGUILayout.EnumPopup(PostprocessorSetting.Instance.MaterialNaming);
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Material Search", GUILayout.Width(LABEL_WIDTH));
                    System.Enum selected =
                        PostprocessorSetting.Instance.MaterialSearch = (ModelImporterMaterialSearch)EditorGUILayout.EnumPopup(PostprocessorSetting.Instance.MaterialSearch);
                }
                EditorGUILayout.EndHorizontal();
            }

            GUILayout.Space(10);
            GUI.enabled = PostprocessorSetting.Instance.IsChanged;
            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Label("");
                if (GUILayout.Button("Revert", GUILayout.Width(60)))
                {
                    PostprocessorSetting.Instance.Revert();
                }
                if (GUILayout.Button("Apply", GUILayout.Width(60)))
                {
                    PostprocessorSetting.Instance.Save();
                }
            }
            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;
        }
        EditorGUILayout.EndVertical();
    }
예제 #54
0
    internal override void FocussedLeftOnGround(Vector3 worldPoint)
    {
        standardOrder = true;
        //   IsMovingAsGroup = true;
        movement.SetKinematic();

        movement.MoveToPoint     = worldPoint;
        movement.MovingDirection = worldPoint;
        //     gameObject.transform.position += (Movement.MovingDirection * Movement.Speed);
        IsAttacking = false;
        Target      = null;

        movement.IsMoving = true;
        UnitState         = OPTIONS.MoveTo;
        standardOrder     = false;
    }
예제 #55
0
    internal override void FocussedLeftOnEnemy(GameObject enemy)
    {
        if (GetComponent <Attackability>())
        {
            UNIT.Options.Target = enemy;
            GetComponent <Attackability>().AttackPoint = enemy.transform.position;
            standardOrder = true;
            UnitState     = EnumProvider.ORDERSLIST.Attack;

            standardOrder = false;
        }
        else
        {
            base.FocussedLeftOnEnemy(enemy);
        }
    }
예제 #56
0
    public static string GetPrettyName(System.Enum e)
    {
        var nm     = e.ToString();
        var tp     = e.GetType();
        var field  = tp.GetField(nm);
        var attrib = System.Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute;

        if (attrib != null)
        {
            return(attrib.Description);
        }
        else
        {
            return(nm);
        }
    }
예제 #57
0
    public static string get(System.Enum en)
    {
        System.Type  type    = en.GetType();
        MemberInfo[] memInfo = type.GetMember(en.ToString());

        if (memInfo != null && memInfo.Length > 0)
        {
            object[] attrs = memInfo[0].GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false);

            if (attrs != null && attrs.Length > 0)
            {
                return(((DescriptionAttribute)attrs[0]).Description);
            }
        }
        return(en.ToString());
    }
예제 #58
0
    public static string ToString_GarbageSafe(this System.Enum eEnum)
    {
        System.Type pType = eEnum.GetType();
        if (g_mapEnumToString.ContainsKey(pType) == false)
        {
            g_mapEnumToString.Add(pType, new CDictionary_ForEnumKey <System.Enum, string>());
        }

        CDictionary_ForEnumKey <System.Enum, string> mapEnumToString = g_mapEnumToString[pType];

        if (mapEnumToString.ContainsKey(eEnum) == false)
        {
            mapEnumToString.Add(eEnum, System.Enum.GetName(pType, eEnum));
        }

        return(mapEnumToString[eEnum]);
    }
예제 #59
0
    public void RenderDynamicEnum(string Label, System.Enum Enum, ref string Val)
    {
        List <string> Names = System.Enum.GetNames(Enum.GetType()).ToList();

        if (!Names.Contains(Val) && Names.Count > 0)
        {
            Val = Names [0];
        }

        var Value = (System.Enum)System.Enum.Parse(Enum.GetType(), Val);

        Value = EditorGUILayout.EnumPopup(Label, Value);

        var ParseValue = System.Enum.Parse(Value.GetType(), Value.ToString());

        Val = (string)ParseValue.ToString();
    }
예제 #60
0
    public void AddLiquidToPlayer(SelectionObjectData item)
    {
        //Add the selected object to the player

        //Add the item only if it is acid or base.
        if (item.item.GetType() == typeof(AcidsList) || item.item.GetType() == typeof(BasesList))
        {
            //If player already has a liquid in him, react
            System.Enum result = player.React(item);
            //If the result is not null, place it in the inventory
            if (result != null)
            {
                //      if(player.GetComponent<PlayerMechanics>().volume == result)
            }
            //If the player doesn't have liquid in him, then change the liquid type, volume and pH of player appropriately
        }
    }