private void DisplayQuestion(int questionIndex) { questionLabel.Clear(); questionLabel = new MultiFormatTextLabel { Position = new Vector2(leftTextOffset, topTextOffset), Size = new Vector2(320f, 0f), // make sure it has enough space - allow it to run off the screen TextColor = Color.black, ShadowPosition = new Vector2(0f, 0f), Parent = questionScroll, RestrictedRenderAreaCoordinateType = BaseScreenComponent.RestrictedRenderArea_CoordinateType.CustomParent }; string[] lines = questionLibrary[questionIndex].Split("\r\n".ToCharArray()).Where(x => x != string.Empty).ToArray(); List <TextFile.Token> tokens = new List <TextFile.Token>(); foreach (string line in lines) { tokens.Add(TextFile.CreateTextToken(line)); tokens.Add(TextFile.CreateFormatToken(TextFile.Formatting.NewLine)); } questionLabel.RestrictedRenderAreaCustomParent = textArea; questionLabel.SetText(tokens.ToArray()); questionScroll.Components.Add(questionLabel); scrollFrame = 0; questionScroll.BackgroundTexture = scrollTextures[0]; for (int i = 0; i < questionLabel.TextLabels.Count; i++) { TextLabel label = questionLabel.TextLabels[i]; if (label.Text.Contains("a)")) { aIndex = i; } else if (label.Text.Contains("b)")) { bIndex = i; } else if (label.Text.Contains("c)")) { cIndex = i; } } }
public override void OnPop() { base.OnPop(); questMessages = null; questLogLabel.Clear(); }
protected void SetAttackInfo(MultiFormatTextLabel label, bool rightHand = true) { var weapon = playerEntity.ItemEquipTable.GetItem(rightHand ? EquipSlots.RightHand : EquipSlots.LeftHand); short weaponSkill = 0; int chanceToHitMod = 0; int damageMod = 0; int minDamage = 0; int maxDamage = 0; // Note from Numidium: I copied snippets from FormulaHelper.cs to calculate the values used here if (weapon != null) { weaponSkill = weapon.GetWeaponSkillIDAsShort(); short skillValue = PlayerEntity.Skills.GetLiveSkillValue(weaponSkill); chanceToHitMod = skillValue; // Apply weapon proficiency if (((int)playerEntity.Career.ExpertProficiencies & weapon.GetWeaponSkillUsed()) != 0) { damageMod += (playerEntity.Level / 3) + 1; chanceToHitMod += playerEntity.Level; } // Apply weapon material modifier chanceToHitMod += FormulaHelper.CalculateWeaponToHit(weapon); // Apply racial bonuses FormulaHelper.ToHitAndDamageMods racialMods = FormulaHelper.CalculateRacialModifiers(PlayerEntity, weapon, PlayerEntity); damageMod += racialMods.damageMod; chanceToHitMod += racialMods.toHitMod; // Apply stat to-hit bonuses chanceToHitMod += (playerEntity.Stats.LiveAgility + playerEntity.Stats.LiveLuck) / 10; // Apply adrenaline rush const int adrenalineRushModifier = 5; const int improvedAdrenalineRushModifier = 8; if (playerEntity.Career.AdrenalineRush && playerEntity.CurrentHealth < playerEntity.MaxHealth / 8) { chanceToHitMod += (playerEntity.ImprovedAdrenalineRush) ? improvedAdrenalineRushModifier : adrenalineRushModifier; } // Apply enchantment modifier chanceToHitMod += playerEntity.ChanceToHitModifier; // Calculate min and max damage player can do with their current weapon damageMod += weapon.GetWeaponMaterialModifier() + FormulaHelper.DamageModifier(playerEntity.Stats.LiveStrength); minDamage = weapon.GetBaseDamageMin() + damageMod; maxDamage = weapon.GetBaseDamageMax() + damageMod; } // Apply hand-to-hand proficiency. Hand-to-hand proficiency is not applied in classic. else { var handToHandSkill = playerEntity.Skills.GetLiveSkillValue((short)DFCareer.Skills.HandToHand); chanceToHitMod += handToHandSkill; if (((int)playerEntity.Career.ExpertProficiencies & (int)DFCareer.ProficiencyFlags.HandToHand) != 0) { damageMod += (playerEntity.Level / 3) + 1; chanceToHitMod += playerEntity.Level; } minDamage = FormulaHelper.CalculateHandToHandMinDamage(handToHandSkill); maxDamage = FormulaHelper.CalculateHandToHandMaxDamage(handToHandSkill); } label.Clear(); var handText = rightHand ? "Right" : "Left"; label.SetText(new TextAsset(handText + "\nAtk:\n" + chanceToHitMod.ToString() + "\nDmg:\n" + minDamage.ToString() + "-" + maxDamage.ToString())); }