Exemple #1
0
        public void Start()
        {
            if (IsPlaying)
            {
                return;
            }

            IsPlaying = true;

            Elapsed = 0.0f;

            bool valid = Validate();

            if (!valid)
            {
                Kill();

                return;
            }

            if (firstTime)
            {
                firstTime = false;

                initialValue = currValueGetter.Invoke();
                finalValue   = finalValueGetter.Invoke();

                firstTimeInitialValue = initialValue;
                firstTimeFinalValue   = finalValue;
            }

            CompleteIfInstant();
        }
        public virtual void SetValue(object value)
        {
            if (!CheckInstanceIsValid())
            {
                return;
            }
            CheckValueType(value);
            object obj = Getter.Invoke(GetInternalStrongInstance(), null);

            value = CheckRange((T)value);
            if (obj == value)
            {
                return;
            }
            try
            {
                Setter.Invoke(GetInternalStrongInstance(), new object[1] {
                    value
                });
                if (this.ValueChanged != null)
                {
                    this.ValueChanged(obj, value);
                }
            }
            catch (Exception inner)
            {
                throw new TweakableSetException(base.Name, value.ToString(), inner);
            }
        }
Exemple #3
0
        public override void Get(object source, BinaryWriter writer)
        {
            List <T> list = Getter.Invoke(source);

            if (list == null)
            {
                if (!defaultNull)
                {
                    writer.Write((byte)0);
                }
                return;
            }
            if (list.Count == 0)
            {
                if (defaultNull)
                {
                    writer.Write((byte)1);
                }
                return;
            }
            for (int i = 0; i < list.Count; i++)
            {
                DatabaseManager.SaveSubobject(list[i], writer);
            }
        }
Exemple #4
0
        public override void Get(object source, BinaryWriter writer)
        {
            int currentValue = Getter.Invoke(source);

            if (!hasDefault || defaultInt != currentValue)
            {
                writer.Write(Getter.Invoke(source));
            }
        }
Exemple #5
0
        public override void Get(object source, BinaryWriter writer)
        {
            T value = Getter.Invoke(source);

            if (!hasDefault || !defaultValue.Equals(value))
            {
                writer.Write(value.ToInt32(null));
            }
        }
Exemple #6
0
        public override void Get(object source, BinaryWriter writer)
        {
            bool currentValue = Getter.Invoke(source);

            if (currentValue != defaultValue)
            {
                writer.Write(currentValue);
            }
        }
Exemple #7
0
        public override void Get(object source, BinaryWriter writer)
        {
            string str = Getter.Invoke(source);

            if (str != null && str != defaultValue)
            {
                writer.Write(str);
            }
        }
Exemple #8
0
        public override void Get(object source, BinaryWriter writer)
        {
            ISubobject child = Getter.Invoke(source);

            if (child == null)
            {
                return;
            }
            DatabaseManager.SaveSubobject(child, writer);
        }
Exemple #9
0
        public override void Get(object source, BinaryWriter writer)
        {
            T list = Getter.Invoke(source);

            int[] saveIDs = list.GetIDs();
            foreach (int i in saveIDs)
            {
                writer.Write(i);
            }
        }
Exemple #10
0
        /// <summary>
        /// Gets the value of the property. Null if the property cannot be read.
        /// </summary>
        /// <param name="viewModel">Instance of <see cref="BaseViewModel" /> from which to read data from.</param>
        /// <returns>Instance of the value.</returns>
        public object GetValue(BaseViewModel viewModel)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            var value = Getter.Invoke(viewModel);

            return(value);
        }
Exemple #11
0
 public override void Get(object source, BinaryWriter writer)
 {
     int[] array = Getter.Invoke(source);
     if (array != null)
     {
         foreach (int i in array)
         {
             writer.Write(i);
         }
     }
 }
Exemple #12
0
    private static IEnumerator To(Getter <float> getter, Setter <float> setter, float endValue, float duration)
    {
        float f = getter.Invoke();

        while (f != endValue)
        {
            yield return(null);

            f = Mathf.MoveTowards(f, endValue, Time.deltaTime / duration);
            setter.Invoke(f);
        }
    }
Exemple #13
0
        public override void Get(object source, BinaryWriter writer)
        {
            T reference = Getter.Invoke(source);

            if (reference == null)
            {
                return;
            }
            int saveID = reference.GetSaveID();

            writer.Write(saveID);
        }
 public virtual object GetValue()
 {
     if (CheckInstanceIsValid())
     {
         try
         {
             return(Getter.Invoke(GetInternalStrongInstance(), null));
         }
         catch (Exception inner)
         {
             throw new TweakableGetException(base.Name, inner);
         }
     }
     return(null);
 }
Exemple #15
0
 public override Object GetValue(Object obj)
 {
     if (Getter == null)
     {
         return(null);
     }
     try
     {
         return(Getter.Invoke(obj, EMPTY_ARGS));
     }
     catch (Exception e)
     {
         throw RuntimeExceptionUtil.Mask(e, "Error occured while calling '" + Getter + "' on object '" + obj + "' of type '" + obj.GetType().ToString()
                                         + "'");
     }
 }
        public override GameObject GetGui(GameObject prefab)
        {
            var current = GameObject.Instantiate(prefab);

            current.name = Name;

            current.transform.Find("Title").GetComponent <Text>().text = Name;

            Slider currentSlider = current.GetComponentInChildren <Slider>();

            currentSlider.minValue = Minimum;
            currentSlider.maxValue = Maximum;

            currentSlider.value = Getter.Invoke();

            Text currentValue = current.transform.Find("CurrentValue").GetComponent <Text>();

            currentValue.text = String.Format(DisplayFormat, Getter.Invoke());

            currentSlider.onValueChanged.AddListener(delegate
            {
                Slider localSlider     = currentSlider;
                Text localCurrentValue = currentValue;

                Setter.Invoke(localSlider.value);
                localCurrentValue.text = String.Format(DisplayFormat, Getter.Invoke());
            });

            Button resetButton = current.transform.Find("ResetButton").GetComponent <Button>();

            resetButton.onClick.AddListener(delegate
            {
                Slider localSlider     = currentSlider;
                Text localCurrentValue = currentValue;

                localSlider.value      = Default;
                localCurrentValue.text = Default.ToString();
                Setter.Invoke(Default);
            });

            return(current);
        }
Exemple #17
0
 public virtual object GetValue(object target, IContainer container)
 {
     return(Getter.Invoke(target, container));
 }
 // --------------------------------------------------------------------------------------------------------------------------
 public override object GetPropData()
 {
     return(Getter.Invoke(Source, null));
 }
 public object Get(T context) => Getter.Invoke(context);
Exemple #20
0
 /// <summary>
 /// Gets the value of this property, for a given target object
 /// </summary>
 public dynamic GetValue(object target) => Getter?.Invoke(target);
 public TValue GetValue <TValue>(MethodParameterValue[] parameters)
 {
     return((TValue)Getter?.Invoke(parameters));
 }
        public override GameObject GetGui(GameObject prefab)
        {
            var current = GameObject.Instantiate(prefab);

            current.name = Name;

            current.transform.Find("Title").GetComponent <Text>().text = Name;

            Slider redSlider   = current.transform.Find("Colors/Red/RedSlider").GetComponent <Slider>();
            Slider greenSlider = current.transform.Find("Colors/Green/GreenSlider").GetComponent <Slider>();
            Slider blueSlider  = current.transform.Find("Colors/Blue/BlueSlider").GetComponent <Slider>();

            Text redValue   = current.transform.Find("Colors/Red/RedValue").GetComponent <Text>();
            Text greenValue = current.transform.Find("Colors/Green/GreenValue").GetComponent <Text>();
            Text blueValue  = current.transform.Find("Colors/Blue/BlueValue").GetComponent <Text>();

            Image colorPreview = current.transform.Find("ColorPreview").GetComponent <Image>();

            UnityAction <float> sliderUpdate = delegate
            {
                Color toSet = new Color(redSlider.value, greenSlider.value, blueSlider.value);

                Setter.Invoke(toSet);

                redValue.text   = Mathf.FloorToInt(redSlider.value * 255).ToString();
                greenValue.text = Mathf.FloorToInt(greenSlider.value * 255).ToString();
                blueValue.text  = Mathf.FloorToInt(blueSlider.value * 255).ToString();

                colorPreview.color = toSet;
            };

            redSlider.onValueChanged.AddListener(sliderUpdate);
            greenSlider.onValueChanged.AddListener(sliderUpdate);
            blueSlider.onValueChanged.AddListener(sliderUpdate);

            redSlider.value   = Getter.Invoke().r;
            greenSlider.value = Getter.Invoke().g;
            blueSlider.value  = Getter.Invoke().b;

            redValue.text   = Mathf.FloorToInt(redSlider.value * 255).ToString();
            greenValue.text = Mathf.FloorToInt(greenSlider.value * 255).ToString();
            blueValue.text  = Mathf.FloorToInt(blueSlider.value * 255).ToString();

            colorPreview.color = Getter.Invoke();

            Button resetButton = current.transform.Find("ResetButton").GetComponent <Button>();

            resetButton.onClick.AddListener(delegate
            {
                redSlider.value   = Default.r;
                greenSlider.value = Default.g;
                blueSlider.value  = Default.b;

                redValue.text   = Default.r.ToString();
                greenValue.text = Default.g.ToString();
                blueValue.text  = Default.b.ToString();

                colorPreview.color = Default;

                Setter.Invoke(Default);
            });

            return(current);
        }
Exemple #23
0
 public override void Get(object source, BinaryWriter writer)
 {
     writer.Write(Getter.Invoke(source));
 }
Exemple #24
0
 public object GetValue(object source)
 {
     return(Getter.Invoke(source, null));
 }
Exemple #25
0
 protected override void GetInitialValueFromSubject()
 {
     OriginValue = Getter?.Invoke() ?? Color.black;
 }
Exemple #26
0
 /// <summary>
 /// Gets the value of this property, for a given target object
 /// </summary>
 public virtual object GetValue(object target) => Getter?.Invoke(target);
 protected override void GetInitialValueFromSubject()
 {
     OriginValue = Getter?.Invoke() ?? Quaternion.identity;
 }
Exemple #28
0
 protected override void GetInitialValueFromSubject()
 {
     OriginValue = Getter?.Invoke() ?? Vector2.zero;
 }
Exemple #29
0
 public object GetValue(object parent)
 {
     return(Getter.Invoke(parent, null));
 }
        public object GetValue(object target)
        {
            object value = Getter.Invoke(target, null);

            return(value);
        }