Exemplo n.º 1
0
    public CharacterRecord(EB.Sparx.CharacterData data)
    {
        _characterRecordEntries = new List <ICharacterRecordEntry>();

        CustomizationRecord = new CharacterRecordEntryCustomization();
        _characterRecordEntries.Add(CustomizationRecord);

        AbilitiesRecord = new CharacterRecordEntryAbilities();
        _characterRecordEntries.Add(AbilitiesRecord);

        StatisticsRecord = new CharacterRecordEntryStatistics();
        _characterRecordEntries.Add(StatisticsRecord);

        //ToDo:
        //QuestsRecord = new CharacterRecordEntryQuests();
        //_characterRecordEntries.Add(QuestsRecord);

        ProgressFlagsRecord = new CharacterRecordEntryProgressFlags();
        _characterRecordEntries.Add(ProgressFlagsRecord);

        EquipmentRecord = new SecureCharacterRecordEntryEquipment(this);
        GeneralRecord   = new SecureCharacterRecordEntryGeneral(this);

        foreach (ICharacterRecordEntry entry in _characterRecordEntries)
        {
            entry.Initialize();
        }
        EquipmentRecord.Initialize();
        GeneralRecord.Initialize();

        if (null == data)
        {
            return;
        }

        int characterId = data.Id;

        if (characterId < 0)
        {
            LoadState = LoadStateType.Failed;
            return;
        }

        PortraitId = data.PortraitId;

#if DEBUG
        //DebugSystem.RegisterInstance("Character " + characterId, this, "Character");
#endif

        LoadState = LoadStateType.Loading;
        Load(data);

#if DEBUG
        if (LoadStateType.Failed == LoadState)
        {
            //DebugSystem.UnregisterSystem(this);
        }
#endif
    }
Exemplo n.º 2
0
    public static string ReplaceTokens(string inStr)
    {
        CharacterRecord character = CharacterManager.Instance.CurrentCharacter;

        if (character == null)
        {
            EB.Debug.LogWarning("StringUtils::ReplaceTokens character was null");
            return(inStr);
        }

        SecureCharacterRecordEntryGeneral record = character.GeneralRecord;

        if (record == null)
        {
            EB.Debug.LogWarning("StringUtils::ReplaceTokens could not obtain CharacterRecordGeneral from character");
            return(inStr);
        }

        System.Text.StringBuilder sb = new System.Text.StringBuilder(inStr);

        try
        {
            sb.Replace(TOKEN_CHAR_GENDER_LOWER, character.GeneralRecord.gender.ToString().ToLower());
            sb.Replace(TOKEN_CHAR_GENDER_UPPER, Capitalize(character.GeneralRecord.gender.ToString()));
            sb.Replace(TOKEN_CHAR_NAME, Capitalize(character.GeneralRecord.name));
            sb.Replace(TOKEN_CHAR_NAME_ALLCAPS, character.GeneralRecord.name.ToUpper());
            //sb.Replace(TOKEN_CHAR_CLASS_LOWER, record.characterClass.ToString().ToLower());
            //sb.Replace(TOKEN_CHAR_CLASS_UPPER, Capitalize(record.characterClass.ToString()));
            sb.Replace(TOKEN_CHAR_CLASS_HISHER_LOWER, (record.gender == eGender.Male ? GetLocalized("his") : GetLocalized("her")).ToLower());
            sb.Replace(TOKEN_CHAR_CLASS_HISHER_UPPER, Capitalize(record.gender == eGender.Male ? GetLocalized("his") : GetLocalized("her")));
            sb.Replace(TOKEN_CHAR_CLASS_HESHE_LOWER, (record.gender == eGender.Male ? GetLocalized("he") : GetLocalized("she")).ToLower());
            sb.Replace(TOKEN_CHAR_CLASS_HESHE_UPPER, Capitalize(record.gender == eGender.Male ? GetLocalized("he") : GetLocalized("she")));
        } catch (System.Exception e)
        {
            EB.Debug.LogWarning(e.Message);
            return(inStr);
        }

        // testing prms

        return(sb.ToString());
    }