Ejemplo n.º 1
0
 // TODO: can this be replaced with a new text RSC entry?
 private static TextFile.Token[] GetPotionRecipeTokens()
 {
     TextFile.Token[] tokens = new TextFile.Token[4];
     tokens[0] = TextFile.CreateTextToken(HardStrings.potionRecipeFor);
     tokens[1] = TextFile.CreateFormatToken(TextFile.Formatting.JustifyCenter);
     tokens[2] = TextFile.CreateTextToken("Weight: %kg kilograms");
     tokens[3] = TextFile.CreateFormatToken(TextFile.Formatting.JustifyCenter);
     return(tokens);
 }
Ejemplo n.º 2
0
        private static List <TextFile.Token> CreateMessage(string text)
        {
            List <TextFile.Token> message = new List <TextFile.Token>
            {
                TextFile.CreateFormatToken(TextFile.Formatting.JustifyCenter),
                TextFile.CreateTextToken(text),
            };

            return(message);
        }
            public override TextFile.Token[] PotionRecipeIngredients(TextFile.Formatting format)
            {
                List <TextFile.Token> ingredientsTokens = new List <TextFile.Token>();
                PotionRecipe          potionRecipe      = GameManager.Instance.EntityEffectBroker.GetPotionRecipe(parent.potionRecipeKey);

                if (potionRecipe != null)
                {
                    foreach (PotionRecipe.Ingredient ingredient in potionRecipe.Ingredients)
                    {
                        ItemTemplate ingredientTemplate = DaggerfallUnity.Instance.ItemHelper.GetItemTemplate(ingredient.id);
                        ingredientsTokens.Add(TextFile.CreateTextToken(ingredientTemplate.name));
                        ingredientsTokens.Add(TextFile.CreateFormatToken(format));
                    }
                }
                return(ingredientsTokens.ToArray());
            }
Ejemplo n.º 4
0
            public override TextFile.Token[] PotionRecipeIngredients(TextFile.Formatting format)
            {
                // InconsolableCellist:
                // Potions can have multiple recipes, and it's unclear how this variation is stored
                // The actual variation could be stored in the currentVariation field, but I haven't been able find any recipes
                // in the game that aren't just the first recipe in the list; for now we'll just pick the first one here
                List <TextFile.Token> ingredientsTokens = new List <TextFile.Token>();

                Ingredient[] ingredients = parent.recipeArray[0].ingredients;
                for (int i = 0; i < ingredients.Length; ++i)
                {
                    ingredientsTokens.Add(TextFile.CreateTextToken(ingredients[i].name));
                    ingredientsTokens.Add(TextFile.CreateFormatToken(format));
                }
                return(ingredientsTokens.ToArray());
            }
Ejemplo n.º 5
0
        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;
                }
            }
        }
Ejemplo n.º 6
0
 public override TextFile.Token[] MagicPowers(TextFile.Formatting format)
 {   // %mpw
     if (parent.IsArtifact)
     {
         // Use appropriate artifact description message. (8700-8721)
         try {
             ArtifactsSubTypes artifactType = ItemHelper.GetArtifactSubType(parent.shortName);
             return(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(8700 + (int)artifactType));
         } catch (KeyNotFoundException e) {
             Debug.Log(e.Message);
             return(null);
         }
     }
     else if (!parent.IsIdentified)
     {
         // Powers unknown.
         TextFile.Token nopowersToken = TextFile.CreateTextToken(HardStrings.powersUnknown);
         return(new TextFile.Token[] { nopowersToken });
     }
     else
     {
         // List item powers.
         // TODO: Update once magic effects have been implemented. (just puts "Power number N" for now)
         // Pretty sure low numbers are type of application, and higher ones are effects.
         // e.g. shield of fortitude is [1, 87] which maps to "Cast when held: Fortitude" in classic.
         List <TextFile.Token> magicPowersTokens = new List <TextFile.Token>();
         for (int i = 0; i < parent.legacyMagic.Length; i++)
         {
             if (parent.legacyMagic[i] == 0xffff)
             {
                 break;
             }
             magicPowersTokens.Add(TextFile.CreateTextToken("Power number " + parent.legacyMagic[i]));
             magicPowersTokens.Add(TextFile.CreateFormatToken(format));
         }
         return(magicPowersTokens.ToArray());
     }
 }
Ejemplo n.º 7
0
        protected virtual DaggerfallMessageBox CreateDialogBox(string entryStr, string baseKey)
        {
            string heading     = TextManager.Instance.GetLocalizedText(baseKey + "Head");
            string action      = TextManager.Instance.GetLocalizedText(baseKey);
            string explanation = TextManager.Instance.GetLocalizedText(baseKey + "2");

            TextFile.Token[] tokens = new TextFile.Token[] {
                TextFile.CreateTextToken(heading), TextFile.CreateFormatToken(TextFile.Formatting.JustifyCenter), TextFile.NewLineToken,
                TextFile.CreateTextToken(action), TextFile.NewLineToken, TextFile.NewLineToken,
                new TextFile.Token()
                {
                    text = entryStr, formatting = TextFile.Formatting.TextHighlight
                }, TextFile.CreateFormatToken(TextFile.Formatting.JustifyCenter), TextFile.NewLineToken,
                TextFile.CreateTextToken(explanation), TextFile.CreateFormatToken(TextFile.Formatting.EndOfRecord)
            };

            DaggerfallMessageBox dialogBox = new DaggerfallMessageBox(uiManager, this);

            dialogBox.SetHighlightColor(Color.white);
            dialogBox.SetTextTokens(tokens);
            dialogBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
            dialogBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
            return(dialogBox);
        }
            public override TextFile.Token[] MagicPowers(TextFile.Formatting format)
            {   // %mpw
                if (parent.IsArtifact)
                {
                    // Use appropriate artifact description message. (8700-8721)
                    try {
                        ArtifactsSubTypes artifactType = ItemHelper.GetArtifactSubType(parent.shortName);
                        return(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(8700 + (int)artifactType));
                    } catch (KeyNotFoundException e) {
                        Debug.Log(e.Message);
                        return(null);
                    }
                }
                else if (!parent.IsIdentified)
                {
                    // Powers unknown.
                    TextFile.Token nopowersToken = TextFile.CreateTextToken(HardStrings.powersUnknown);
                    return(new TextFile.Token[] { nopowersToken });
                }
                else
                {
                    // List item powers.
                    List <TextFile.Token> magicPowersTokens = new List <TextFile.Token>();
                    for (int i = 0; i < parent.legacyMagic.Length; i++)
                    {
                        // Also 65535 to handle saves from when the type was read as an unsigned value
                        if (parent.legacyMagic[i].type == EnchantmentTypes.None || (int)parent.legacyMagic[i].type == 65535)
                        {
                            break;
                        }

                        string firstPart = HardStrings.itemPowers[(int)parent.legacyMagic[i].type] + " ";

                        if (parent.legacyMagic[i].type == EnchantmentTypes.SoulBound && parent.legacyMagic[i].param != -1)
                        {
                            magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.enemyNames[parent.legacyMagic[i].param]));
                        }
                        else if (parent.legacyMagic[i].type == EnchantmentTypes.ExtraSpellPts)
                        {
                            magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.extraSpellPtsTimes[parent.legacyMagic[i].param]));
                        }
                        else if (parent.legacyMagic[i].type == EnchantmentTypes.PotentVs || parent.legacyMagic[i].type == EnchantmentTypes.LowDamageVs)
                        {
                            magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.enemyGroupNames[parent.legacyMagic[i].param]));
                        }
                        else if (parent.legacyMagic[i].type == EnchantmentTypes.RegensHealth)
                        {
                            magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.regensHealthTimes[parent.legacyMagic[i].param]));
                        }
                        else if (parent.legacyMagic[i].type == EnchantmentTypes.VampiricEffect)
                        {
                            magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.vampiricEffectRanges[parent.legacyMagic[i].param]));
                        }
                        else if (parent.legacyMagic[i].type == EnchantmentTypes.IncreasedWeightAllowance)
                        {
                            magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.increasedWeightAllowances[parent.legacyMagic[i].param]));
                        }
                        else if (parent.legacyMagic[i].type == EnchantmentTypes.EnhancesSkill)
                        {
                            magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + DaggerfallUnity.Instance.TextProvider.GetSkillName((DaggerfallConnect.DFCareer.Skills)parent.legacyMagic[i].param)));
                        }
                        else if (parent.legacyMagic[i].type == EnchantmentTypes.ImprovesTalents)
                        {
                            magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.improvedTalents[parent.legacyMagic[i].param]));
                        }
                        else if (parent.legacyMagic[i].type == EnchantmentTypes.GoodRepWith || parent.legacyMagic[i].type == EnchantmentTypes.BadRepWith)
                        {
                            magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.repWithGroups[parent.legacyMagic[i].param]));
                        }
                        else if (parent.legacyMagic[i].type == EnchantmentTypes.ItemDeteriorates)
                        {
                            magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.itemDeteriorateLocations[parent.legacyMagic[i].param]));
                        }
                        else if (parent.legacyMagic[i].type == EnchantmentTypes.UserTakesDamage)
                        {
                            magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.userTakesDamageLocations[parent.legacyMagic[i].param]));
                        }
                        else if (parent.legacyMagic[i].type == EnchantmentTypes.HealthLeech)
                        {
                            magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.healthLeechStopConditions[parent.legacyMagic[i].param]));
                        }
                        else if (parent.legacyMagic[i].type == EnchantmentTypes.BadReactionsFrom)
                        {
                            magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.badReactionFromEnemyGroups[parent.legacyMagic[i].param]));
                        }
                        else if (parent.legacyMagic[i].type <= EnchantmentTypes.CastWhenStrikes)
                        {
                            List <DaggerfallConnect.Save.SpellRecord.SpellRecordData> spells = DaggerfallSpellReader.ReadSpellsFile();
                            bool found = false;

                            foreach (DaggerfallConnect.Save.SpellRecord.SpellRecordData spell in spells)
                            {
                                if (spell.index == parent.legacyMagic[i].param)
                                {
                                    magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + spell.spellName));
                                    found = true;
                                    break;
                                }
                            }

                            if (!found)
                            {
                                magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + "ERROR"));
                            }
                        }
                        else
                        {
                            magicPowersTokens.Add(TextFile.CreateTextToken(firstPart));
                        }

                        magicPowersTokens.Add(TextFile.CreateFormatToken(format));
                    }
                    return(magicPowersTokens.ToArray());
                }
            }