private void SetCharacteristic(CharacteristicType type, int statValue) { characterHolder.GetCharacteristicInput(type).text = statValue.ToString(); int modificator = CharacterValuesUtility.GetCharacteristicModificator(statValue); characterHolder.GetCharacteristicModificatorText(type).text = TextUtility.GetSignedValueString(modificator); }
private void SetInitiative() { var sheet = characterSheetController.Character; int initiativeModificator = CharacterValuesUtility.GetCharacteristicModificator(sheet[CharacteristicType.Dexterity]); characterHolder.initiativeValueText.text = TextUtility.GetSignedValueString(initiativeModificator); }
private void SetHits() { var sheet = characterSheetController.Character; int level = CharacterValuesUtility.CalculateLevel(sheet.ExpiriencePoints); int constitutionModificator = CharacterValuesUtility.GetCharacteristicModificator(sheet[CharacteristicType.Constitution]); int wholeMaxHits = sheet.MaxHits + level * constitutionModificator; characterHolder.hitsValueText.text = TextUtility.GetValueAndMaxString(sheet.CurrentHits, wholeMaxHits); }
private void SetPassivePerception() { var sheet = characterSheetController.Character; int result = 10 + CharacterValuesUtility.GetCharacteristicModificator(sheet[CharacteristicType.Wisdom]); if ((sheet.PersonalSkills & SkillType.Perception) == SkillType.Perception) { int level = CharacterValuesUtility.CalculateLevel(sheet.ExpiriencePoints); result += CharacterValuesUtility.GetMasteryBonus(level); } characterHolder.passivePerceptionValueText.text = result.ToString(); }
private void SetSkillModificator(SkillHolder skillHolder) { var sheet = characterSheetController.Character; var skillCharacteristic = CharacterUtility.GetCharacteristicBySkill(skillHolder.type); int characteristicValue = sheet[skillCharacteristic]; bool isOwned = (sheet.PersonalSkills & skillHolder.type) == skillHolder.type; int modificator = CharacterValuesUtility.GetCharacteristicModificator(characteristicValue); if (isOwned) { int level = CharacterValuesUtility.CalculateLevel(sheet.ExpiriencePoints); modificator += CharacterValuesUtility.GetMasteryBonus(level); } skillHolder.valueText.text = TextUtility.GetSignedValueString(modificator); skillHolder.toggleButton.isOn = isOwned; }
private void SetSavingThrowModificator(SavingThrowHolder savingThrow) { var sheet = characterSheetController.Character; int characteristicValue = sheet[savingThrow.characteristic]; int modificator = CharacterValuesUtility.GetCharacteristicModificator(characteristicValue); var baseSavingThrows = CharacterUtility.GetSavingThrowsByClass(sheet.Type); bool isOwned = baseSavingThrows.Contains(savingThrow.characteristic); if (isOwned) { int level = CharacterValuesUtility.CalculateLevel(sheet.ExpiriencePoints); modificator += CharacterValuesUtility.GetMasteryBonus(level); } savingThrow.valueText.text = TextUtility.GetSignedValueString(modificator); savingThrow.toggle.isOn = isOwned; }
public void Show(CharacterSheet sheet, OnValidateInput onValidate) { currentHitsInputField.text = sheet.CurrentHits.ToString(); maxHitsInputField.text = sheet.MaxHits.ToString(); int level = CharacterValuesUtility.CalculateLevel(sheet.ExpiriencePoints); int constitutionModificator = CharacterValuesUtility.GetCharacteristicModificator(sheet[CharacteristicType.Constitution]); bonusHitsText.text = TextUtility.GetSignedValueString(level * constitutionModificator); okButton.onClick.AddListener(() => { OnOkPressed?.Invoke(currentHitsInputField.text, maxHitsInputField.text); Destroy(this.gameObject); }); cancelButton.onClick.AddListener(() => { OnCancelPressed?.Invoke(currentHitsInputField.text, maxHitsInputField.text); Destroy(this.gameObject); }); }
private void HandleHitsInputs(string currentHitsText, string maxHitsText) { var sheet = characterSheetController.Character; if (!Int32.TryParse(currentHitsText, out int currentHits)) { currentHits = sheet.CurrentHits; } if (!Int32.TryParse(maxHitsText, out int maxHits)) { maxHits = sheet.MaxHits; } int level = CharacterValuesUtility.CalculateLevel(sheet.ExpiriencePoints); int constitutionModificator = CharacterValuesUtility.GetCharacteristicModificator(sheet[CharacteristicType.Constitution]); int wholeMaxHits = maxHits + level * constitutionModificator; currentHits = Mathf.Min(currentHits, wholeMaxHits); sheet.CurrentHits = currentHits; sheet.MaxHits = maxHits; // update new value on UI characterHolder.hitsValueText.text = TextUtility.GetValueAndMaxString(currentHits, wholeMaxHits); }