Пример #1
0
 public void UpdateBinding(IVariableStore store, string group, BindingAnimationStatus status)
 {
     if (string.IsNullOrEmpty(group) || BindingGroup == group)
     {
         UpdateBinding(store, status);
     }
 }
Пример #2
0
 public void UpdateBinding(string group, BindingAnimationStatus status)
 {
     if (string.IsNullOrEmpty(group) || BindingGroup == group)
     {
         UpdateBinding(Variables, status ?? _ignoredStatus);
     }
 }
Пример #3
0
        public static void UpdateBinding(GameObject obj, string group, BindingAnimationStatus status, List <VariableBinding> bindings)
        {
            GetBindings(obj, true, bindings);

            foreach (var binding in bindings)
            {
                binding.UpdateBinding(group, status);
            }
        }
Пример #4
0
        public virtual void UpdateBindings(IVariableStore variables, string group, BindingAnimationStatus status)
        {
            Variables = variables;

            InterfaceBinding.UpdateBindings(gameObject, variables, group, status);

            foreach (var obj in DependentObjects)
            {
                InterfaceBinding.UpdateBindings(obj, variables, group, status);
            }
        }
Пример #5
0
        protected override void UpdateBinding(IVariableStore variables, BindingAnimationStatus status)
        {
            if (Graph.Instruction && !Graph.IsRunning)
            {
                Resolve(variables, Variable, out VariableValue value);

                if (!VariableHandler.IsEqual(_value, value).GetValueOrDefault(false))
                {
                    StartCoroutine(VariableChanged(value, status));
                }
            }
        }
Пример #6
0
        protected override void UpdateBinding(IVariableStore variables, BindingAnimationStatus status)
        {
            if (Object)
            {
                var enabled = false;

                try
                {
                    var value = Condition.Evaluate(variables);

                    if (value.Type == VariableType.Bool)
                    {
                        enabled = value.Bool;
                    }
                    else if (!SuppressErrors)
                    {
                        if (value.IsEmpty)
                        {
                            Debug.LogWarningFormat(this, _missingExpressionWarning, this);
                        }
                        else
                        {
                            Debug.LogWarningFormat(this, _invalidExpressionWarning, this, Condition.LastOperation);
                        }
                    }
                }
                catch (ExpressionEvaluationException exception)
                {
                    Debug.LogWarningFormat(this, _failedExpressionWarning, this, Condition.LastOperation, exception.Message);
                }
                catch (CommandEvaluationException exception)
                {
                    Debug.LogWarningFormat(this, _failedCommandWarning, this, exception.Command, exception.Message);
                }

                if (Object is GameObject gameObject)
                {
                    gameObject.SetActive(enabled);
                }
                else if (Object is Behaviour behaviour)
                {
                    behaviour.enabled = enabled;
                }
                else if (Object is Renderer renderer)
                {
                    renderer.enabled = enabled;
                }
                else
                {
                    Debug.LogWarningFormat(this, _invalidObjectWarning, this, Object);
                }
            }
        }
Пример #7
0
        public override void UpdateBinding(IVariableStore variables, BindingAnimationStatus status)
        {
            var active = false;

            try
            {
                Condition.Evaluate(variables).TryGetBoolean(out active);
            }
            catch
            {
            }

            gameObject.SetActive(active);
        }
Пример #8
0
        private IEnumerator AnimateFill(float target, BindingAnimationStatus status)
        {
            while (_image.fillAmount != target)
            {
                var speed = Speed * Time.deltaTime;
                var fill  = Mathf.MoveTowards(_image.fillAmount, target, speed);

                SetFill(fill);

                yield return(null);
            }

            status?.Decrement();
        }
Пример #9
0
        private IEnumerator VariableChanged(VariableValue value, BindingAnimationStatus status)
        {
            status.Increment();

            _value = value;

            CompositionManager.Instance.RunInstruction(Graph, Variables, VariableValue.Create(gameObject));

            while (Graph.IsRunning)
            {
                yield return(null);
            }

            status.Decrement();
        }
Пример #10
0
        public override void UpdateBinding(IVariableStore variables, BindingAnimationStatus status)
        {
            status?.Increment();

            var fill = GetFill(variables);

            if (Speed <= 0.0f)
            {
                SetFill(fill);
                status?.Decrement();
            }
            else
            {
                StartCoroutine(AnimateFill(fill, status));
            }
        }
Пример #11
0
        public override void UpdateBindings(IVariableStore variables, string group, BindingAnimationStatus status)
        {
            Variables = variables;

            InterfaceBinding.UpdateSelfBindings(gameObject, variables, group, status);

            foreach (var obj in DependentObjects)
            {
                InterfaceBinding.UpdateBindings(obj, variables, group, status);
            }

            foreach (var item in _items)
            {
                InterfaceBinding.UpdateBindings(item.Object, item.Variables, group, status);
            }
        }
Пример #12
0
        public override void UpdateBinding(IVariableStore variables, BindingAnimationStatus status)
        {
            status?.Increment();

            var value = GetValue(variables);

            if (Speed <= 0)
            {
                SetValue(value);
                status?.Decrement();
            }
            else
            {
                StartCoroutine(AnimateValue(value, status));
            }
        }
Пример #13
0
        public override void UpdateBinding(IVariableStore variables, BindingAnimationStatus status)
        {
            var value = Variable.GetValue(variables);

            if (value.TryGetObject(out Sprite sprite))
            {
                _image.sprite = sprite;
            }
            else if (value.Type == VariableType.Empty)
            {
                Debug.LogErrorFormat(this, _missingVariableError, Variable);
            }
            else
            {
                Debug.LogErrorFormat(this, _invalidVariableError, Variable);
            }
        }
Пример #14
0
        private IEnumerator AnimateFill(float target, BindingAnimationStatus status)
        {
            status.Increment();

            while (_image.fillAmount != target)
            {
                var delta = UseScaledTime ? Time.deltaTime : Time.unscaledDeltaTime;
                var speed = Speed * delta;
                var fill  = Mathf.MoveTowards(_image.fillAmount, target, speed);

                SetFill(fill);

                yield return(null);
            }

            status.Decrement();
        }
Пример #15
0
        protected override void UpdateBinding(IVariableStore variables, BindingAnimationStatus status)
        {
            if (Resolve(variables, Variable, out VariableValue value))
            {
                var equal = VariableHandler.IsEqual(value, _previousValue);

                if (!equal.HasValue || !equal.Value)
                {
                    SetText(value.ToString(), true);
                    _previousValue = value;
                }
            }
            else
            {
                _previousValue = VariableValue.Empty;
                SetText(string.Empty, false);
            }
        }
Пример #16
0
        public override void UpdateBindings(IVariableStore variables, string group, BindingAnimationStatus status)
        {
            Variables = variables;

            var binding = Binding.GetValue(variables);

            if (binding.TryGetStore(out IVariableStore store))
            {
                InterfaceBinding.UpdateBindings(gameObject, store, group, status);
            }
            else if (binding.Type == VariableType.Empty)
            {
                Debug.LogWarningFormat(this, _missingBindingError, Binding);
            }
            else
            {
                Debug.LogWarningFormat(this, _invalidBindingError, Binding);
            }
        }
Пример #17
0
        protected override void UpdateBinding(IVariableStore variables, BindingAnimationStatus status)
        {
            var hasAmount = Resolve(variables, AmountVariable, out float amount);
            var hasTotal  = Resolve(variables, TotalVariable, out float total);

            _image.enabled = hasAmount && hasTotal;

            if (_image.enabled)
            {
                var fill = amount / total;

                if (Speed <= 0.0f)
                {
                    SetFill(fill);
                }
                else
                {
                    StopAllCoroutines();
                    StartCoroutine(AnimateFill(fill, status));
                }
            }
        }
Пример #18
0
        protected override void UpdateBinding(IVariableStore variables, BindingAnimationStatus status)
        {
            if (Resolve(variables, Variable, out VariableValue value))
            {
                var equal = VariableHandler.IsEqual(value, _previousValue);

                if (!equal.HasValue || !equal.Value)
                {
                    if (value.TryGetInt(out int i))
                    {
                        var text = Format.GetFormattedString(i);
                        SetText(text, true);
                        _previousValue = value;
                    }
                    else if (value.TryGetFloat(out float f))
                    {
                        var text = Format.GetFormattedString(f);
                        SetText(text, true);
                        _previousValue = value;
                    }
                    else
                    {
                        if (!SuppressErrors)
                        {
                            Debug.LogWarningFormat(this, _invalidVariableWarning, Variable, name, value.Type);
                        }

                        SetText(string.Empty, false);
                        _previousValue = VariableValue.Empty;
                    }
                }
            }
            else
            {
                _previousValue = VariableValue.Empty;
                SetText(string.Empty, false);
            }
        }
Пример #19
0
        private IEnumerator AnimateValue(int target, BindingAnimationStatus status)
        {
            if (int.TryParse(_text.text, out var current))
            {
                var value = (float)current;
                while (current != target)
                {
                    var speed = Speed * Time.deltaTime;
                    value   = Mathf.MoveTowards(value, (float)target, speed);
                    current = Mathf.RoundToInt(value);

                    SetValue(current);

                    yield return(null);
                }
            }
            else
            {
                Debug.LogWarningFormat(this, _invalidTextWarning, name);
            }

            status?.Decrement();
        }
Пример #20
0
        protected override void UpdateBinding(IVariableStore variables, BindingAnimationStatus status)
        {
            if (Template != null)
            {
                if (Resolve(variables, Variable, out IVariableList list))
                {
                    SyncItems(list.Count);

                    for (var i = 0; i < list.Count; i++)
                    {
                        var item = list.GetVariable(i);
                        SetItem(i, item);
                    }
                }
                else if (Resolve(variables, Variable, out IVariableStore store))
                {
                    var names = store.GetVariableNames();

                    SyncItems(names.Count);

                    for (var i = 0; i < names.Count; i++)
                    {
                        var item = store.GetVariable(names[i]);
                        SetItem(i, item);
                    }
                }
            }
            else
            {
                Debug.LogWarningFormat(this, _missingTemplateWarning, name);
            }

            foreach (var item in _items)
            {
                UpdateBinding(item.gameObject, string.Empty, status, _bindings);
            }
        }
Пример #21
0
        protected override void UpdateBinding(IVariableStore variables, BindingAnimationStatus status)
        {
            var enabled = false;
            var text    = string.Empty;

            try
            {
                var result = Expression.Evaluate(variables);
                var equal  = VariableHandler.IsEqual(result, _resultValue);

                if (_resultState != ResultState.Value || !equal.HasValue || !equal.Value)
                {
                    if (result.IsEmpty)
                    {
                        if (!SuppressErrors)
                        {
                            Debug.LogWarningFormat(this, _missingExpressionWarning, this);
                        }
                    }
                    else
                    {
                        enabled = true;

                        if (result.TryGetInt(out var intValue))
                        {
                            text = Formatting.GetFormattedString(intValue);
                        }
                        if (result.TryGetFloat(out var floatValue))
                        {
                            text = Formatting.GetFormattedString(floatValue);
                        }
                        else
                        {
                            text = result.ToString();
                        }
                    }
                }

                _resultValue = result;
            }
            catch (ExpressionEvaluationException exception)
            {
                if (_resultState != ResultState.Error)
                {
                    Debug.LogWarningFormat(this, _failedExpressionWarning, this, Expression.LastOperation, exception.Message);
                }

                _resultState = ResultState.Error;
            }
            catch (CommandEvaluationException exception)
            {
                if (_resultState != ResultState.Error)
                {
                    Debug.LogWarningFormat(this, _failedCommandWarning, this, exception.Command, exception.Message);
                }

                _resultState = ResultState.Error;
            }

            SetText(text, enabled);
        }
Пример #22
0
 protected override void UpdateBinding(IVariableStore variables, BindingAnimationStatus status)
 {
     Sprite.enabled = ResolveObject(variables, Variable, out Sprite sprite);
     Sprite.sprite  = sprite;
 }
Пример #23
0
 protected override void UpdateBinding(IVariableStore variables, BindingAnimationStatus status)
 {
     Text.enabled = Resolve(variables, Variable, out Color color);
     Text.color   = color;
 }
Пример #24
0
        protected override void UpdateBinding(IVariableStore variables, BindingAnimationStatus status)
        {
            var text = Message.GetText(variables, SuppressErrors);

            SetText(text, true);
        }
Пример #25
0
        public static void UpdateSelfBindings(GameObject obj, IVariableStore variables, string group, BindingAnimationStatus status)
        {
            _bindings.Clear();

            obj.GetComponents(_bindings);

            foreach (var binding in _bindings)
            {
                binding.UpdateBinding(variables, group, status);
            }
        }
Пример #26
0
 public override void UpdateBinding(IVariableStore variables, BindingAnimationStatus status)
 {
     _variables = variables;
     _text.textComponent.text = Variable.GetValue(_variables).ToString();
 }
Пример #27
0
        public static void UpdateBindings(GameObject obj, IVariableStore variables, string group, BindingAnimationStatus status)
        {
            _bindings.Clear();

            obj.GetComponentsInChildren(true, _bindings);             // this includes components directly on obj

            foreach (var binding in _bindings)
            {
                binding.UpdateBinding(variables, group, status);
            }
        }
Пример #28
0
 public override void UpdateBinding(IVariableStore variables, BindingAnimationStatus status)
 {
     Text.text = Message.GetText(variables);
 }
Пример #29
0
 protected abstract void UpdateBinding(IVariableStore variables, BindingAnimationStatus status);
Пример #30
0
 public static void UpdateBinding(GameObject obj, string group, BindingAnimationStatus status)
 {
     UpdateBinding(obj, group, status, _bindings);
 }