示例#1
0
 public Positioning(float speed)
 {
     Position = new Vector3ReactiveProperty(Vector3.zero);
     Rotation = new QuaternionReactiveProperty(Quaternion.identity);
     Scale    = new Vector3ReactiveProperty(Vector3.one);
     Speed    = speed;
 }
示例#2
0
    public virtual void BringIn()
    {
        if (m_bInit == false)
        {
            MovePos = new Vector3ReactiveProperty(GetPos());
            m_btn.btn.OnClickAsObservable()
            .Subscribe(_ =>
            {
                if (PuzzleManager.instance.m_pSelectPuzzleObj == null)
                {
                    m_selectObj.SetActive(true);
                    PuzzleManager.instance.m_pSelectPuzzleObj.Add(this);
                }
                else if (PuzzleManager.instance.m_pSelectPuzzleObj.Contains(this) || PuzzleManager.instance.CheckMovePuzzle(x, y) == false)
                {
                    m_selectObj.SetActive(false);
                    if (PuzzleManager.instance.m_pSelectPuzzleObj.Contains(this))
                    {
                        PuzzleManager.instance.m_pSelectPuzzleObj.Remove(this);
                    }
                }
                else if (PuzzleManager.instance.CheckMovePuzzle(x, y))
                {
                    PuzzleManager.instance.m_pSelectPuzzleObj.Add(this);
                    m_selectObj.SetActive(false);
                    PuzzleChangeAnim(PuzzleManager.instance.GetPuzzleItemObj(x, y));
                }
            }).AddTo(this);

            bDestroy.ToReadOnlyReactiveProperty().Where(_ => _).Subscribe(_ => DestroyPuzzleItem()).AddTo(this);
            MovePos.Where(_ => GetPos() != _).Subscribe(_ => PuzzleMoveAnim()).AddTo(this);
            m_bInit = true;
        }

        gameObject.SetActive(true);
    }
        public static JSONClass SerializeComponent(this object component)
        {
            var node = new JSONClass();

            foreach (var property in component.GetType().GetProperties())
            {
                if (property.CanRead && property.CanWrite)
                {
                    if (property.PropertyType == typeof(int))
                    {
                        node.Add(property.Name, new JSONData((int)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(IntReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as IntReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new IntReactiveProperty();
                        }
                        node.Add(property.Name, new JSONData((int)reactiveProperty.Value));
                        continue;
                    }
                    if (property.PropertyType == typeof(float))
                    {
                        node.Add(property.Name, new JSONData((float)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(FloatReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as FloatReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new FloatReactiveProperty();
                        }
                        node.Add(property.Name, new JSONData((float)reactiveProperty.Value));
                        continue;
                    }
                    if (property.PropertyType == typeof(bool))
                    {
                        node.Add(property.Name, new JSONData((bool)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(BoolReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as BoolReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new BoolReactiveProperty();
                        }
                        node.Add(property.Name, new JSONData((bool)reactiveProperty.Value));
                        continue;
                    }
                    if (property.PropertyType == typeof(string))
                    {
                        node.Add(property.Name, new JSONData((string)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(StringReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as StringReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new StringReactiveProperty();
                        }
                        node.Add(property.Name, new JSONData((string)reactiveProperty.Value));
                        continue;
                    }
                    if (property.PropertyType == typeof(Vector2))
                    {
                        node.Add(property.Name, new JSONData((Vector2)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(Vector2ReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as Vector2ReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new Vector2ReactiveProperty();
                        }
                        node.Add(property.Name, new JSONData((Vector2)reactiveProperty.Value));
                        continue;
                    }
                    if (property.PropertyType == typeof(Vector3))
                    {
                        node.Add(property.Name, new JSONData((Vector3)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(Vector3ReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as Vector3ReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new Vector3ReactiveProperty();
                        }
                        node.Add(property.Name, new JSONData((Vector3)reactiveProperty.Value));
                        continue;
                    }
                }
            }
            return(node);
        }
        private static void ApplyValue(object component, JSONNode node, PropertyInfo property)
        {
            if (property.CanRead && property.CanWrite)
            {
                var propertyData = node[property.Name];
                if (propertyData == null)
                {
                    return;
                }

                if (property.PropertyType == typeof(int))
                {
                    property.SetValue(component, propertyData.AsInt, null);
                    return;
                }
                if (property.PropertyType == typeof(IntReactiveProperty))
                {
                    var reactiveProperty = new IntReactiveProperty(propertyData.AsInt);
                    property.SetValue(component, reactiveProperty, null);
                    return;
                }
                if (property.PropertyType == typeof(float))
                {
                    property.SetValue(component, propertyData.AsFloat, null);
                    return;
                }
                if (property.PropertyType == typeof(FloatReactiveProperty))
                {
                    var reactiveProperty = new FloatReactiveProperty(propertyData.AsFloat);
                    property.SetValue(component, reactiveProperty, null);
                    return;
                }
                if (property.PropertyType == typeof(bool))
                {
                    property.SetValue(component, propertyData.AsBool, null);
                    return;
                }
                if (property.PropertyType == typeof(BoolReactiveProperty))
                {
                    var reactiveProperty = new BoolReactiveProperty(propertyData.AsBool);
                    property.SetValue(component, reactiveProperty, null);
                    return;
                }
                if (property.PropertyType == typeof(string))
                {
                    property.SetValue(component, propertyData.Value, null);
                    return;
                }
                if (property.PropertyType == typeof(StringReactiveProperty))
                {
                    var reactiveProperty = new StringReactiveProperty(propertyData.Value);
                    property.SetValue(component, reactiveProperty, null);
                    return;
                }
                if (property.PropertyType == typeof(Vector2))
                {
                    property.SetValue(component, propertyData.AsVector2, null);
                    return;
                }
                if (property.PropertyType == typeof(Vector2ReactiveProperty))
                {
                    var reactiveProperty = new Vector2ReactiveProperty(propertyData.AsVector2);
                    property.SetValue(component, reactiveProperty, null);
                    return;
                }
                if (property.PropertyType == typeof(Vector3))
                {
                    property.SetValue(component, propertyData.AsVector3, null);
                    return;
                }
                if (property.PropertyType == typeof(Vector3ReactiveProperty))
                {
                    var reactiveProperty = new Vector3ReactiveProperty(propertyData.AsVector3);
                    property.SetValue(component, reactiveProperty, null);
                    return;
                }
            }
        }
示例#5
0
        public static JSONObject Serialize(this object component)
        {
            var node = new JSONObject();

            foreach (var property in component.GetType().GetProperties())
            {
                if (property.CanRead && property.CanWrite)
                {
                    if (property.PropertyType == typeof(int) || property.PropertyType.IsEnum)
                    {
                        node.Add(property.Name, new JSONNumber((int)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(IntReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as IntReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new IntReactiveProperty();
                        }
                        node.Add(property.Name, new JSONNumber((int)reactiveProperty.Value));
                        continue;
                    }
                    if (property.PropertyType == typeof(float))
                    {
                        node.Add(property.Name, new JSONNumber((float)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(FloatReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as FloatReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new FloatReactiveProperty();
                        }
                        node.Add(property.Name, new JSONNumber((float)reactiveProperty.Value));
                        continue;
                    }
                    if (property.PropertyType == typeof(bool))
                    {
                        node.Add(property.Name, new JSONBool((bool)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(BoolReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as BoolReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new BoolReactiveProperty();
                        }
                        node.Add(property.Name, new JSONBool((bool)reactiveProperty.Value));
                        continue;
                    }
                    if (property.PropertyType == typeof(string))
                    {
                        node.Add(property.Name, new JSONString((string)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(StringReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as StringReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new StringReactiveProperty();
                        }
                        node.Add(property.Name, new JSONString((string)reactiveProperty.Value));
                        continue;
                    }
                    if (property.PropertyType == typeof(Vector2))
                    {
                        var jsonObject = ((Vector2)property.GetValue(component, null)).AsJSONObject();
                        node.Add(property.Name, jsonObject);
                        continue;
                    }
                    if (property.PropertyType == typeof(Vector2ReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as Vector2ReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new Vector2ReactiveProperty();
                        }

                        var jsonObject = reactiveProperty.Value.AsJSONObject();
                        node.Add(property.Name, jsonObject);
                        continue;
                    }
                    if (property.PropertyType == typeof(Vector3))
                    {
                        var jsonObject = ((Vector3)property.GetValue(component, null)).AsJSONObject();
                        node.Add(property.Name, jsonObject);
                        continue;
                    }
                    if (property.PropertyType == typeof(Vector3ReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as Vector3ReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new Vector3ReactiveProperty();
                        }

                        var jsonObject = reactiveProperty.Value.AsJSONObject();
                        node.Add(property.Name, jsonObject);
                        continue;
                    }
                    if (property.PropertyType == typeof(Color))
                    {
                        var jsonObject = ((Color)property.GetValue(component, null)).AsJSONObject();
                        node.Add(property.Name, jsonObject);
                        continue;
                    }
                    if (property.PropertyType == typeof(ColorReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as ColorReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new ColorReactiveProperty();
                        }

                        var jsonObject = reactiveProperty.Value.AsJSONObject();
                        node.Add(property.Name, jsonObject);
                        continue;
                    }
                }
            }
            return(node);
        }
示例#6
0
 public Positioning(float speed)
 {
     Position = new Vector3ReactiveProperty();
     Speed    = speed;
 }
示例#7
0
 public NullInputSource()
 {
     moveInput = new Vector3ReactiveProperty();
     targets = new ReactiveProperty<object>();
 }
示例#8
0
 public Player()
 {
     PlayerHealth   = new ReactiveProperty <int>(3);
     PlayerPosition = new Vector3ReactiveProperty();
 }
示例#9
0
 public NullInputSource()
 {
     moveInput = new Vector3ReactiveProperty();
     targets   = new ReactiveProperty <object>();
 }