private DialogCriteria GetPersonalityCriteria(PersonalityTraitData inTrait, string inString)
    {
        DialogCriteria dialogCriteria = (DialogCriteria)null;

        DialogCriteria.CriteriaOperator criteriaOperator = !inString.Contains(">=") ? (!inString.Contains("<=") ? (!inString.Contains("<") ? (!inString.Contains(">") ? DialogCriteria.CriteriaOperator.Equals : DialogCriteria.CriteriaOperator.Greater) : DialogCriteria.CriteriaOperator.Smaller) : DialogCriteria.CriteriaOperator.SmallerOrEquals) : DialogCriteria.CriteriaOperator.GreaterOrEquals;
        string[] separator = new string[5] {
            "=", ">", ">=", "<", "<="
        };
        string[] strArray = inString.Split(separator, StringSplitOptions.RemoveEmptyEntries);
        if (strArray.Length == 1)
        {
            if (!string.IsNullOrEmpty(strArray[0]) && strArray[0] != "0")
            {
                dialogCriteria = new DialogCriteria(strArray[0].Trim(), string.Empty);
                dialogCriteria.criteriaOperator = criteriaOperator;
            }
        }
        else if (strArray.Length == 2)
        {
            dialogCriteria = new DialogCriteria(strArray[0].Trim(), strArray[1].Trim());
            dialogCriteria.criteriaOperator = criteriaOperator;
        }
        else
        {
            throw new Exception(string.Format("Personality Trait with ID {0} has bad formatted requirements! Check database Personality Traits", (object)inTrait.ID));
        }
        return(dialogCriteria);
    }
    private void LoadTraitSpecialCaseData(PersonalityTraitData inTrait, DatabaseEntry inEntry)
    {
        inTrait.specialCases.Clear();
        string stringValue1 = inEntry.GetStringValue("Special Case");

        if (!string.IsNullOrEmpty(stringValue1) && stringValue1 != "0")
        {
            string str1    = stringValue1;
            char[] chArray = new char[1] {
                ';'
            };
            foreach (string str2 in str1.Split(chArray))
            {
                string inSpecialCaseString = str2.Trim();
                if (!string.IsNullOrEmpty(inSpecialCaseString) && inSpecialCaseString != "0")
                {
                    inTrait.specialCases.Add(this.GetSpecialCaseType(inSpecialCaseString));
                }
            }
        }
        string stringValue2 = inEntry.GetStringValue("Special Case Description");

        if (string.IsNullOrEmpty(stringValue2) || !(stringValue2 != "0"))
        {
            return;
        }
        inTrait.specialCaseDescriptionID = stringValue2;
    }
示例#3
0
 public PersonalityTrait(PersonalityTraitData inPersonalityTraitData, Driver inDriver)
 {
     this.data    = inPersonalityTraitData;
     this.mDriver = inDriver;
     this.specialCaseBehaviour.driver       = this.mDriver;
     this.specialCaseBehaviour.specialCases = this.data.specialCases;
     this.mTraitStartDate = Game.instance.time.now;
 }
 private void LoadIsRepeatableFlag(PersonalityTraitData inTrait, DatabaseEntry inEntry)
 {
     if (inEntry.GetStringValue("Repeatable") == "Yes")
     {
         inTrait.isRepeatable = true;
     }
     else
     {
         inTrait.isRepeatable = false;
     }
 }
 private void LoadTriatShownType(PersonalityTraitData inTrait, DatabaseEntry inEntry)
 {
     if (inEntry.GetStringValue("Shown") == "PlayerDriverOnly")
     {
         inTrait.shownType = PersonalityTraitData.TriggerShownType.PlayerDriverOnly;
     }
     else
     {
         inTrait.shownType = PersonalityTraitData.TriggerShownType.AllDrivers;
     }
 }
示例#6
0
 public bool IsTraitOpposite(PersonalityTraitData inTraitData)
 {
     for (int index = 0; index < this.opposites.Length; ++index)
     {
         if (this.opposites[index] == inTraitData.ID)
         {
             return(true);
         }
     }
     return(false);
 }
示例#7
0
    public PersonalityTrait AddPersonalityTrait(PersonalityTraitData inPersonalityTraitData, bool inActivatePersonalityTraitTrigger)
    {
        PersonalityTrait inPersonalityTrait = new PersonalityTrait(inPersonalityTraitData, this.mDriver);

        if (inPersonalityTrait.Data.removesTraits != null)
        {
            for (int index1 = 0; index1 < inPersonalityTrait.Data.removesTraits.Length; ++index1)
            {
                int removesTrait = inPersonalityTrait.Data.removesTraits[index1];
                for (int index2 = 0; index2 < this.permanentPersonalityTraits.Count; ++index2)
                {
                    if (removesTrait == this.permanentPersonalityTraits[index2].Data.ID)
                    {
                        this.RemovePersonalityTrait(this.permanentPersonalityTraits[index2]);
                        --index2;
                    }
                }
                for (int index2 = 0; index2 < this.temporaryPersonalityTraits.Count; ++index2)
                {
                    if (removesTrait == this.temporaryPersonalityTraits[index2].Data.ID)
                    {
                        this.RemovePersonalityTrait(this.temporaryPersonalityTraits[index2]);
                        --index2;
                    }
                }
            }
        }
        if (inPersonalityTraitData.type == PersonalityTraitData.TraitType.Permanent)
        {
            this.permanentPersonalityTraits.Add(inPersonalityTrait);
        }
        else if (inPersonalityTraitData.type == PersonalityTraitData.TraitType.Temporary)
        {
            inPersonalityTrait.SetupTraitEndTime();
            this.temporaryPersonalityTraits.Add(inPersonalityTrait);
        }
        this.allTraits.Add(inPersonalityTrait);
        if (!inPersonalityTraitData.isRepeatable)
        {
            this.mTraitHistory.Add(inPersonalityTraitData.ID);
        }
        this.CheckTraitAppliesModifierPotential(inPersonalityTrait);
        inPersonalityTrait.OnTraitStart();
        if (inActivatePersonalityTraitTrigger)
        {
            this.ActivatePersonalityTraitTrigger(inPersonalityTrait);
        }
        return(inPersonalityTrait);
    }
    private void LoadEventTriggerType(PersonalityTraitData inTrait, DatabaseEntry inEntry)
    {
        string stringValue = inEntry.GetStringValue("EventTrigger");

        if (string.IsNullOrEmpty(stringValue))
        {
            return;
        }
        if (stringValue == "PostRace")
        {
            inTrait.eventTriggerType = PersonalityTraitData.EventTriggerType.PostRace;
        }
        else
        {
            inTrait.eventTriggerType = PersonalityTraitData.EventTriggerType.None;
        }
    }
    private void LoadTraitType(PersonalityTraitData inTrait, DatabaseEntry inEntry)
    {
        string stringValue = inEntry.GetStringValue("Type");

        if (stringValue == "Permanent")
        {
            inTrait.type = PersonalityTraitData.TraitType.Permanent;
        }
        else
        {
            if (!(stringValue == "Temp"))
            {
                return;
            }
            inTrait.type = PersonalityTraitData.TraitType.Temporary;
        }
    }
 public void LoadPersonalityTraitsFromDatabase(List <DatabaseEntry> personalityTraitsData)
 {
     for (int index = 0; index < personalityTraitsData.Count; ++index)
     {
         bool                 flag     = false;
         DatabaseEntry        inEntry  = personalityTraitsData[index];
         int                  intValue = inEntry.GetIntValue("ID");
         PersonalityTraitData inTrait;
         if (this.personalityTraits.ContainsKey(intValue))
         {
             inTrait = this.personalityTraits[intValue];
         }
         else
         {
             inTrait = new PersonalityTraitData();
             flag    = true;
         }
         inTrait.ID = intValue;
         inTrait.SetNameID(inEntry.GetStringValue("Trait Name ID"));
         inTrait.SetDescriptionID(inEntry.GetStringValue("Description ID"));
         inTrait.customTraitName        = inEntry.GetStringValue("Trait Name");
         inTrait.customTraitDescription = inEntry.GetStringValue("Trait Description");
         this.LoadTraitType(inTrait, inEntry);
         inTrait.possibleLength = this.ParseStringToIntegerArray(inEntry, "Length");
         this.LoadTraitRequirements(inTrait, inEntry);
         inTrait.probability   = (float)(1.0 - (double)inEntry.GetFloatValue("Probability") / 100.0);
         inTrait.evolvesInto   = this.ParseStringToIntegerArray(inEntry, "Evolves Into");
         inTrait.opposites     = this.ParseStringToIntegerArray(inEntry, "Opposites");
         inTrait.removesTraits = this.ParseStringToIntegerArray(inEntry, "Removes Traits");
         this.LoadTraitTriggerSource(inTrait, inEntry);
         this.LoadTriatShownType(inTrait, inEntry);
         this.LoadTraitModifiers(inTrait, inEntry);
         this.LoadTraitSpecialCaseData(inTrait, inEntry);
         this.LoadEventTriggerType(inTrait, inEntry);
         this.LoadIsRepeatableFlag(inTrait, inEntry);
         if (flag)
         {
             this.personalityTraits.Add(inTrait.ID, inTrait);
         }
     }
 }
 private void LoadTraitModifiers(PersonalityTraitData inTrait, DatabaseEntry inEntry)
 {
     inTrait.allStats = inEntry.GetIntValue("All Stats");
     inTrait.driverStatsModifier.Braking       = (float)inEntry.GetIntValue("Braking");
     inTrait.driverStatsModifier.Cornering     = (float)inEntry.GetIntValue("Cornering");
     inTrait.driverStatsModifier.Smoothness    = (float)inEntry.GetIntValue("Smoothness");
     inTrait.driverStatsModifier.Overtaking    = (float)inEntry.GetIntValue("Overtaking");
     inTrait.driverStatsModifier.Consistency   = (float)inEntry.GetIntValue("Consistency");
     inTrait.driverStatsModifier.Adaptability  = (float)inEntry.GetIntValue("Adaptability");
     inTrait.driverStatsModifier.Fitness       = (float)inEntry.GetIntValue("Fitness");
     inTrait.driverStatsModifier.Feedback      = (float)inEntry.GetIntValue("Feedback");
     inTrait.driverStatsModifier.Focus         = (float)inEntry.GetIntValue("Focus");
     inTrait.driverStatsModifier.Marketability = (float)inEntry.GetIntValue("Marketability") / 100f;
     inTrait.moraleModifier          = (float)inEntry.GetIntValue("Morale") / 100f;
     inTrait.mechanicModifier        = inEntry.GetIntValue("Mechanic");
     inTrait.teammateModifier        = (float)inEntry.GetIntValue("Teammate") / 100f;
     inTrait.chairmanModifier        = inEntry.GetIntValue("Chairman");
     inTrait.improveabilityModifier  = (float)inEntry.GetIntValue("Improveability") / 100f;
     inTrait.potentialModifier       = inEntry.GetIntValue("Potential");
     inTrait.desiredWinsModifier     = inEntry.GetIntValue("Desired Wins");
     inTrait.desiredEarningsModifier = (long)inEntry.GetIntValue("Desired Earnings") * 1000L;
 }
    private void LoadTraitRequirements(PersonalityTraitData inTrait, DatabaseEntry inEntry)
    {
        List <DialogCriteria> dialogCriteriaList = new List <DialogCriteria>();
        string stringValue = inEntry.GetStringValue("Requirement");

        if (!string.IsNullOrEmpty(stringValue))
        {
            string str     = stringValue;
            char[] chArray = new char[1] {
                ';'
            };
            foreach (string inString in str.Split(chArray))
            {
                DialogCriteria personalityCriteria = this.GetPersonalityCriteria(inTrait, inString);
                if (personalityCriteria != null)
                {
                    dialogCriteriaList.Add(personalityCriteria);
                }
            }
        }
        inTrait.requirements = dialogCriteriaList;
    }
    private void LoadTraitTriggerSource(PersonalityTraitData inTrait, DatabaseEntry inEntry)
    {
        inTrait.triggerCriteria.Clear();
        string stringValue = inEntry.GetStringValue("Triggers");

        if (string.IsNullOrEmpty(stringValue))
        {
            return;
        }
        string[] strArray1 = stringValue.Split(';');
        for (int index = 0; index < strArray1.Length; ++index)
        {
            if (!string.IsNullOrEmpty(strArray1[index]) && !(strArray1[index] == "0"))
            {
                string[] strArray2 = strArray1[index].Split('=');
                if (strArray2.Length == 2)
                {
                    inTrait.triggerCriteria.Add(new DialogCriteria("Type", "Header"));
                    inTrait.triggerCriteria.Add(new DialogCriteria(strArray2[0].Trim(), strArray2[1].Trim()));
                }
            }
        }
    }
示例#14
0
 private void addButton_Click(object sender, RoutedEventArgs e)
 {
     SelectedData = traitList.SelectedItem as PersonalityTraitData;
     this.Close();
 }