Beispiel #1
0
        private void statChanged(object sender, EventArgs e)
        {
            unBindEvents();

            Data.Character character = (Data.Character)unitList.SelectedItem;
            IntegerUpDown  statBox   = (IntegerUpDown)sender;             //get the control that fired the event

            Enum.Stat stat = XMLProperties.StatProperty.GetStat(statBox); //get value of attached property

            if (stat == Enum.Stat.Level || stat == Enum.Stat.Experience)
            {
                _saveFile[character.StartAddress + (int)stat] = (byte)statBox.Value; //update exp or level based on current value
            }
            else
            {
                // new value is the character base stats subtracted from current value
                // because the value in save file is just the values to be added to the base stat
                byte newVal = (byte)(statBox.Value - character.BaseStats[(int)stat]);
                _saveFile[character.StartAddress + 21 + (int)stat] = newVal;
            }

            bindEvents();
        }
 public static void SetStat(UIElement element, Enum.Stat value)
 {
     element.SetValue(MyStatProperty, value);
 }