Example #1
0
 public void WithType(ELocationType type)
 {
     if (type.GetValue().IsNotZero())
     {
         Query = Query.Where(location => location.Type == type);
     }
 }
Example #2
0
        public void Set(Body body)
        {
            _isSet = true;

            _type = ELocationType.Body;

            _position  = new Vector2();
            _transform = null;
            _body      = body;
        }
Example #3
0
        public void Set(Transform transform)
        {
            _isSet = true;

            _type = ELocationType.Transform;

            _position  = new Vector2();
            _transform = transform;
            _body      = null;
        }
Example #4
0
        public void Set(Vector2 position)
        {
            _isSet = true;

            _type = ELocationType.Position;

            _position  = position;
            _transform = null;
            _body      = null;
        }
Example #5
0
        public void Copy(Location otherLocation)
        {
            _isSet = otherLocation._isSet;

            _type = otherLocation._type;

            _position  = otherLocation._position;
            _transform = otherLocation._transform;
            _body      = otherLocation._body;
        }
        public ValidationFailure ReferencesValidate(Location location, ValidationContext <Location> context)
        {
            var locationType = new ELocationType().ConvertToCollection().FirstOrDefault(locationTp => locationTp.Value == location.Type.GetValue());

            if (locationType.IsNull())
            {
                return(new ValidationFailure("Location", "El tipo de ubicaciĆ³n no existe"));
            }

            var user = _userRepository.FindBy(location.UserId);

            if (user.IsNull())
            {
                return(new ValidationFailure("Location", "El usuario no existe"));
            }

            return(null);
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            // Using BeginProperty / EndProperty on the parent property means that
            // prefab override logic works on the entire property.
            EditorGUI.BeginProperty(position, label, property);


            SerializedProperty locationTypeProperty = property.FindPropertyRelative("_type");

            float propertyHeight = GetPropertyHeight(locationTypeProperty, new GUIContent());

            propertyHeight = position.height / rows;

            //Rect locationTypePosition = new Rect(position.x, position.y, position.width, propertyHeight);
            //Rect locationValuePosition = new Rect(position.x, position.y + propertyHeight, position.width, propertyHeight);

            var locationLabel = new Rect(position.x, position.y, position.width, propertyHeight);

            // Don't make child fields be indented
            var indent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;

            // Draw label
            position = EditorGUI.PrefixLabel(locationLabel, GUIUtility.GetControlID(FocusType.Passive), label, GUIStyle.none);

            //EditorGUI.indentLevel++;

            var locationTypePosition  = new Rect(position.x, position.y + propertyHeight, position.width, propertyHeight);
            var locationValuePosition = new Rect(position.x, position.y + propertyHeight * 2, position.width, propertyHeight);
            var isSetPosition         = new Rect(position.x, position.y + propertyHeight * 3, position.width, propertyHeight);

            ELocationType locationType = (ELocationType)(locationTypeProperty.intValue);

            EditorGUI.PropertyField(locationTypePosition, locationTypeProperty, GUIContent.none);

            switch (locationType)
            {
            case ELocationType.Position:
            {
                EditorGUI.PropertyField(locationValuePosition, property.FindPropertyRelative("_position"), GUIContent.none);
                break;
            }

            case ELocationType.Transform:
            {
                EditorGUI.PropertyField(locationValuePosition, property.FindPropertyRelative("_transform"), GUIContent.none);
                break;
            }

            case ELocationType.Body:
            {
                EditorGUI.PropertyField(locationValuePosition, property.FindPropertyRelative("_body"), GUIContent.none);
                break;
            }
            }

            EditorGUI.PropertyField(isSetPosition, property.FindPropertyRelative("_isSet"));

            // Set indent back to what it was
            EditorGUI.indentLevel = indent;

            EditorGUI.EndProperty();
        }