コード例 #1
0
        private void SavePersonBasicData(Person p)
        {
            try
            {
                p.SurName = this.tbSurName.Text;
                p.GivenName = this.tbGivenName.Text;
                p.CalledName = this.tbCalledName.Text;
                p.PictureIndex = int.Parse(this.tbPic.Text);
                p.Ideal = int.Parse(this.tbIdeal.Text);
                p.IdealTendency = this.cbIdealTendency.SelectedItem as IdealTendencyKind;
                p.BornRegion = (PersonBornRegion) this.cbBornRegion.SelectedIndex;
                p.AvailableLocation = int.Parse(this.tbAvailableLocation.Text);
                p.YearAvailable = int.Parse(this.tbAvailableYear.Text);
                p.YearBorn = int.Parse(this.tbBornYear.Text);
                p.YearDead = int.Parse(this.tbDeadYear.Text);
                p.DeadReason = (PersonDeadReason) this.cbDeadReason.SelectedIndex;
                p.Strength = int.Parse(this.tbStrength.Text);
                p.Command = int.Parse(this.tbCommand.Text);
                p.Intelligence = int.Parse(this.tbIntelligence.Text);
                p.Politics = int.Parse(this.tbPolitics.Text);
                p.Glamour = int.Parse(this.tbGlamour.Text);
                p.StrengthExperience = int.Parse(this.tbStrengthExperience.Text);
                p.CommandExperience = int.Parse(this.tbCommandExperience.Text);
                p.IntelligenceExperience = int.Parse(this.tbIntelligenceExperience.Text);
                p.PoliticsExperience = int.Parse(this.tbPoliticsExperience.Text);
                p.GlamourExperience = int.Parse(this.tbGlamourExperience.Text);
                p.Braveness = int.Parse(this.tbBraveness.Text);
                p.Calmness = int.Parse(this.tbCalmness.Text);
                p.Loyalty = int.Parse(this.tbLoyalty.Text);
                p.Character = p.Scenario.GameCommonData.AllCharacterKinds[this.cbCharacter.SelectedIndex];
                p.Strain = int.Parse(this.tbStrain.Text);
                int t;
                int.TryParse(this.tbFather.Text, out t);
                p.Father = p.Scenario.Persons.GetGameObject(t) as Person;
                int.TryParse(this.tbMother.Text, out t);
                p.Mother = p.Scenario.Persons.GetGameObject(t) as Person;
                int.TryParse(this.tbSpouse.Text, out t);
                p.Spouse = p.Scenario.Persons.GetGameObject(t) as Person;

                p.Brothers.Clear();
                char[] separator = new char[] { ' ', '\n', '\r', '\t' };
                string[] strArray = this.tbBrother.Text.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                foreach (String s in strArray)
                {
                    int.TryParse(s, out t);
                    Person q = this.Persons.GetGameObject(t) as Person;
                    p.Brothers.Add(q);
                }

                p.Generation = int.Parse(this.tbGeneration.Text);
                p.PersonalLoyalty = (int) this.cbPersonalLoyalty.SelectedIndex;
                p.Ambition = (int) this.cbAmbition.SelectedIndex;
                p.Qualification = (PersonQualification) this.cbQualification.SelectedIndex;
                p.ValuationOnGovernment = (PersonValuationOnGovernment) this.cbValuationOnGovernment.SelectedIndex;
                p.StrategyTendency = (PersonStrategyTendency) this.cbStrategyTendency.SelectedIndex;
                try
                {
                    StaticMethods.LoadFromString(p.JoinFactionID, this.tbOldFactionID.Text);
                }
                catch
                {
                }

                PersonList pl = p.GetClosePersons();
                foreach (Person q in pl)
                {
                    p.RemoveClose(q);
                }
                pl = p.GetHatedPersons();
                foreach (Person q in pl)
                {
                    p.RemoveHated(q);
                }

                foreach (string str in this.lbClosePersons.Items)
                {
                    int id = int.Parse(str.Substring(0, str.IndexOf(" ")));
                    p.AddClose(p.Scenario.Persons.GetGameObject(id) as Person);
                }

                foreach (string str in this.lbHatedPersons.Items)
                {
                    int id = int.Parse(str.Substring(0, str.IndexOf(" ")));
                    p.AddHated(p.Scenario.Persons.GetGameObject(id) as Person);
                }
            }
            catch
            {
                MessageBox.Show("请输入正确的数据格式。");
            }
        }