コード例 #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();
        }
コード例 #2
0
        public void RemoveAdjustment()
        {
            _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);
            _adjustment.RemoveAdjustment(_data);

            Assert.AreEqual(10, _data.GetStatInt(_health));
        }