Ejemplo n.º 1
0
        void DebugApplyAdjustment()
        {
            // Never runtime debug the root parent. This will cause catastrophic data corruption
            if (!IsRuntimeViewable)
            {
                return;
            }

            EditorGUILayout.LabelField("Debug - Stats Adjustment", EditorStyles.boldLabel);

            _adjustment = (StatsAdjustment)EditorGUILayout.ObjectField("Adjustment", _adjustment, typeof(StatsAdjustment), false);
            if (_adjustment == null)
            {
                return;
            }

            _adjustmentIndex = EditorGUILayout.FloatField(new GUIContent("Adjustment Index", "Index of the applied adjustment"),
                                                          _adjustmentIndex);

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Apply"))
            {
                _adjustment.ApplyAdjustment(Target, _adjustmentIndex);
            }

            if (GUILayout.Button("Remove"))
            {
                _adjustment.RemoveAdjustment(Target);
            }
            EditorGUILayout.EndHorizontal();
        }
Ejemplo n.º 2
0
        public void ApplyAdjustment()
        {
            _data.Setup();

            var m = new ModifierGroup {
                definition   = _health,
                operatorType = OperatorType.Add,
                value        = new StatValueSelector {
                    type = StatValueType.Int
                }
            };

            m.value.GetValue().SetInt(3);

            _adjustment.Adjustments.Add(m);

            _adjustment.ApplyAdjustment(_data, 0);

            Assert.AreEqual(13, _data.GetStatInt(_health));
        }
Ejemplo n.º 3
0
    private void Start()
    {
        // Generate a runtime copy that's safe to interact with
        runtimeStats = originalStats.CreateRuntimeCopy();

        armor.ApplyAdjustment(runtimeStats);

        // Generate the health bar
        var health = runtimeStats.GetStatInt("health");

        healthBar.maxValue = health;
        healthBar.value    = health;

        // Bind our receive damage button
        buttonDealDamage.onClick.AddListener(ReceiveDamage);
    }