コード例 #1
0
    private void UpdateExpiriencePoints(int expPoints)
    {
        int level = CharacterValuesUtility.CalculateLevel(expPoints);

        characterHolder.levelText.text           = level.ToString();
        characterHolder.expirienceProgress.value = CharacterValuesUtility.CalculateLevelProgress(expPoints);
        characterHolder.expirienceText.text      = String.Format("{0}/{1}", expPoints.ToString(), CharacterValuesUtility.GetPointsByLevel(level + 1).ToString());
    }
コード例 #2
0
    private void ResetHitDices()
    {
        var sheet = characterSheetController.Character;
        int level = CharacterValuesUtility.CalculateLevel(sheet.ExpiriencePoints);

        int restoredDiceCount = Mathf.CeilToInt(level / 2f);
        int diceCount         = sheet.HitDiceCount + restoredDiceCount;

        sheet.HitDiceCount = Mathf.Min(level, diceCount);
    }
コード例 #3
0
    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);
    }
コード例 #4
0
    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();
    }
コード例 #5
0
    private void SetHitDices()
    {
        var sheet = characterSheetController.Character;

        characterHolder.diceTypeText.text = TextUtility.GetDiceValueString(1, CharacterUtility.GetDiceTypeByClass(sheet.Type));

        int level = CharacterValuesUtility.CalculateLevel(sheet.ExpiriencePoints);

        if (sheet.HitDiceCount > level)
        {
            sheet.HitDiceCount = level;
        }
        characterHolder.dicesValueText.text = TextUtility.GetValueAndMaxString(sheet.HitDiceCount, level);
    }
コード例 #6
0
    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;
    }
コード例 #7
0
    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;
    }
コード例 #8
0
    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);
        });
    }
コード例 #9
0
    public CharacterSheet(Guid id)
    {
        Id          = id;
        CreatedDate = DateTime.Now;

        playerName = defaultName;

        characteristics = new Dictionary <CharacteristicType, int>();
        foreach (CharacteristicType type in Enum.GetValues(typeof(CharacteristicType)))
        {
            characteristics.Add(type, 0);
        }

        type              = CharacterType.Fighter;
        race              = RaceType.Human;
        expiriencePoints  = 0;
        personalSkills    = SkillType.None;
        armorClass        = 0;
        currentHits       = 0;
        maxHits           = 0;
        hitDiceCount      = CharacterValuesUtility.CalculateLevel(expiriencePoints);
        deathSuccessCount = 0;
        deathFailureCount = 0;
    }
コード例 #10
0
    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);
    }
コード例 #11
0
    private void SetHitDicesCount(CharacterSheet sheet)
    {
        int level = CharacterValuesUtility.CalculateLevel(sheet.ExpiriencePoints);

        diceCountValueText.text = TextUtility.GetValueAndMaxString(sheet.HitDiceCount, level);
    }
コード例 #12
0
    private void SetMasteryBonus(int expPoints)
    {
        int level = CharacterValuesUtility.CalculateLevel(expPoints);

        characterHolder.masteryBonusValueText.text = TextUtility.GetSignedValueString(CharacterValuesUtility.GetMasteryBonus(level));
    }