Esempio n. 1
0
 public void LoadDialogFromString(Dictionary <int, Person> persons, string data)
 {
     if (data == null)
     {
         return;
     }
     char[]   separator = new char[] { ' ', '\n', '\r', '\t' };
     string[] strArray  = data.Split(separator, StringSplitOptions.RemoveEmptyEntries);
     this.Dialogs.Clear();
     for (int i = 0; i < strArray.Length; i += 2)
     {
         PersonDialog item = new PersonDialog();
         int          num2 = int.Parse(strArray[i]);
         if (num2 >= 0 && !persons.ContainsKey(num2))
         {
             continue;
         }
         if (num2 >= 0)
         {
             item.SpeakingPerson   = persons[num2];
             item.SpeakingPersonID = num2;
         }
         else
         {
             item.SpeakingPerson   = null;
             item.SpeakingPersonID = -1;
         }
         item.Text = strArray[i + 1];
         this.Dialogs.Add(item);
     }
 }
 private void btnAddAnyDialog_Click(object sender, EventArgs e)
 {
     PersonDialog item = new PersonDialog();
     item.SpeakingPerson = null;
     item.Text = "非空话语";
     this.EditingEvent.Dialogs.Add(item);
     this.RefreshDialogs();
 }
Esempio n. 3
0
        public bool matchEventPersons(Architecture a)
        {
            GameObjectList allPersons = a.AllPersonAndChildren.GetList();

            HashSet <int> haveCond = new HashSet <int>();

            foreach (KeyValuePair <int, List <Condition> > i in this.personCond)
            {
                haveCond.Add(i.Key);
            }

            HashSet <int> noCond = new HashSet <int>();

            foreach (KeyValuePair <int, List <Person> > i in this.person)
            {
                if (!haveCond.Contains(i.Key) && i.Value.Count == 0)
                {
                    noCond.Add(i.Key);
                }
            }

            Dictionary <int, List <Person> > candidates = new Dictionary <int, List <Person> >();

            foreach (int i in this.person.Keys)
            {
                candidates[i] = new List <Person>();
                if (noCond.Contains(i))
                {
                    foreach (Person p in allPersons.GetList())
                    {
                        candidates[i].Add(p);
                    }
                }
            }

            // check person in the architecture
            foreach (KeyValuePair <int, List <Condition> > i in this.personCond)
            {
                foreach (Person p in allPersons)
                {
                    bool ok = Condition.CheckConditionList(i.Value, p, this);
                    if (ok)
                    {
                        if (this.person[i.Key].Contains(null) || this.person[i.Key].Contains(p))
                        {
                            candidates[i.Key].Add(p);
                        }
                    }
                }
            }
            // check 7000 - 8000 persons which can be in anywhere
            foreach (KeyValuePair <int, List <Person> > i in this.person)
            {
                foreach (Person p in i.Value)
                {
                    if (p != null /*&& p.ID >= 7000 && p.ID < 8000*/)
                    {
                        bool ok;
                        if (this.personCond.ContainsKey(i.Key))
                        {
                            ok = Condition.CheckConditionList(this.personCond[i.Key], p, this);
                        }
                        else
                        {
                            ok = true;
                        }
                        if (ok)
                        {
                            if (this.person[i.Key].Contains(null) || this.person[i.Key].Contains(p))
                            {
                                candidates[i.Key].Add(p);
                            }
                        }
                    }
                }
            }

            foreach (List <Person> i in candidates.Values)
            {
                if (i.Count == 0)
                {
                    return(false);
                }
            }

            Dictionary <int, Person> matchedPersons = new Dictionary <int, Person>();

            foreach (KeyValuePair <int, List <Person> > i in candidates)
            {
                if (i.Value.Count <= 0)
                {
                    return(false);
                }
                Person selected = i.Value[GameObject.Random(i.Value.Count)];
                matchedPersons[i.Key] = selected;
                foreach (List <Person> j in candidates.Values)
                {
                    j.Remove(selected);
                }
            }

            matchedDialog = new List <PersonDialog>();
            foreach (PersonIdDialog i in this.dialog)
            {
                if (!matchedPersons.ContainsKey(i.id))
                {
                    return(false);
                }

                PersonDialog pd = new PersonDialog();
                pd.SpeakingPerson = matchedPersons[i.id];
                pd.Text           = i.dialog;
                for (int j = 0; j < matchedPersons.Count; ++j)
                {
                    pd.Text = pd.Text.Replace("%" + j, matchedPersons[j].Name);
                }
                matchedDialog.Add(pd);
            }

            matchedyesDialog = new List <PersonDialog>();
            foreach (PersonIdDialog i in this.yesdialog)
            {
                if (!matchedPersons.ContainsKey(i.id))
                {
                    return(false);
                }

                PersonDialog pd = new PersonDialog();
                pd.SpeakingPerson = matchedPersons[i.id];
                pd.Text           = i.yesdialog;
                for (int j = 0; j < matchedPersons.Count; ++j)
                {
                    pd.Text = pd.Text.Replace("%" + j, ' ' + matchedPersons[j].Name + ' ');
                }
                matchedyesDialog.Add(pd);
            }

            matchednoDialog = new List <PersonDialog>();
            foreach (PersonIdDialog i in this.nodialog)
            {
                if (!matchedPersons.ContainsKey(i.id))
                {
                    return(false);
                }

                PersonDialog pd = new PersonDialog();
                pd.SpeakingPerson = matchedPersons[i.id];
                pd.Text           = i.nodialog;
                for (int j = 0; j < matchedPersons.Count; ++j)
                {
                    pd.Text = pd.Text.Replace("%" + j, ' ' + matchedPersons[j].Name + ' ');
                }
                matchednoDialog.Add(pd);
            }

            matchedScenBiography = new List <PersonDialog>();
            foreach (PersonIdDialog i in this.scenBiography)
            {
                if (!matchedPersons.ContainsKey(i.id))
                {
                    return(false);
                }

                PersonDialog pd = new PersonDialog();
                pd.SpeakingPerson = matchedPersons[i.id];
                pd.Text           = i.dialog;
                for (int j = 0; j < matchedPersons.Count; ++j)
                {
                    pd.Text = pd.Text.Replace("%" + j, matchedPersons[j].Name);
                }
                matchedScenBiography.Add(pd);
            }

            matchedEffect = new Dictionary <Person, List <EventEffect> >();
            foreach (KeyValuePair <int, List <EventEffect> > i in this.effect)
            {
                matchedEffect.Add(matchedPersons[i.Key], i.Value);
            }
            matchedYesEffect = new Dictionary <Person, List <EventEffect> >();
            foreach (KeyValuePair <int, List <EventEffect> > i in this.yesEffect)
            {
                matchedYesEffect.Add(matchedPersons[i.Key], i.Value);
            }
            matchedNoEffect = new Dictionary <Person, List <EventEffect> >();
            foreach (KeyValuePair <int, List <EventEffect> > i in this.noEffect)
            {
                matchedNoEffect.Add(matchedPersons[i.Key], i.Value);
            }

            if (a.BelongedFaction != null)
            {
                foreach (Person p in matchedPersons.Values)
                {
                    if (p == a.BelongedFaction.Leader && Session.Current.Scenario.IsPlayer(a.BelongedFaction))
                    {
                        involveLeader = true;
                    }
                }
            }

            return(true);
        }
Esempio n. 4
0
        public bool checkConditions(Architecture a)
        {
            if (this.happened && !this.repeatable) return false;
            if (GameObject.Random(this.happenChance) != 0)
            {
                return false;
            }

            if (this.AfterEventHappened >= 0)
            {
                if (!(base.Scenario.AllEvents.GetGameObject(this.AfterEventHappened) as Event).happened)
                {
                    return false;
                }
            }

            foreach (Condition i in this.architectureCond)
            {
                if (!i.CheckCondition(a, this))
                {
                    return false;
                }
            }

            foreach (Condition i in this.factionCond)
            {
                if (!i.CheckCondition(a.BelongedFaction, this))
                {
                    return false;
                }
            }

            Dictionary<int, List<Person>> candidates = new Dictionary<int, List<Person>>();
            foreach (int i in this.personCond.Keys)
            {
                candidates[i] = new List<Person>();
            }
            foreach (KeyValuePair<int, List<Condition>> i in this.personCond)
            {
                foreach (Person p in a.Persons)
                {
                    bool ok = true;
                    foreach (Condition c in i.Value)
                    {
                        if (!c.CheckCondition(p, this))
                        {
                            ok = false;
                            break;
                        }
                    }
                    if (ok)
                    {
                        if (this.person[i.Key].Contains(null) || this.person[i.Key].Contains(p))
                        {
                            candidates[i.Key].Add(p);
                        }
                    }
                }
            }

            foreach (List<Person> i in candidates.Values)
            {
                if (i.Count == 0) return false;
            }

            Dictionary<int, Person> matchedPersons = new Dictionary<int, Person>();
            foreach (KeyValuePair<int, List<Person>> i in candidates)
            {
                if (i.Value.Count <= 0) return false;
                Person selected = i.Value[GameObject.Random(i.Value.Count)];
                matchedPersons[i.Key] = selected;
                foreach (List<Person> j in candidates.Values)
                {
                    j.Remove(selected);
                }
            }

            matchedDialog = new List<PersonDialog>();
            foreach (PersonIdDialog i in this.dialog)
            {
                if (!matchedPersons.ContainsKey(i.id)) return false;

                PersonDialog pd = new PersonDialog();
                pd.SpeakingPerson = matchedPersons[i.id];
                pd.Text = i.dialog;
                for (int j = 0; j < matchedPersons.Count; ++j)
                {
                    pd.Text = pd.Text.Replace("%" + j, matchedPersons[i.id].Name);
                }
                matchedDialog.Add(pd);
            }

            matchedEffect = new Dictionary<Person, List<EventEffect>>();
            foreach (KeyValuePair<int, List<EventEffect>> i in this.effect)
            {
                matchedEffect.Add(matchedPersons[i.Key], i.Value);
            }

            return true;
        }
Esempio n. 5
0
        public bool matchEventPersons(Architecture a)
        {
            Dictionary <int, List <Person> > candidates = new Dictionary <int, List <Person> >();

            foreach (int i in this.person.Keys)
            {
                candidates[i] = new List <Person>();
            }
            foreach (KeyValuePair <int, List <Condition> > i in this.personCond)
            {
                foreach (Person p in a.Persons)
                {
                    bool ok = true;
                    foreach (Condition c in i.Value)
                    {
                        if (!c.CheckCondition(p, this))
                        {
                            ok = false;
                            break;
                        }
                    }
                    if (ok)
                    {
                        if (this.person[i.Key].Contains(null) || this.person[i.Key].Contains(p))
                        {
                            candidates[i.Key].Add(p);
                        }
                    }
                }
            }
            foreach (KeyValuePair <int, List <Person> > i in this.person)
            {
                foreach (Person p in i.Value)
                {
                    if (p != null && p.ID >= 7000 && p.ID < 8000)
                    {
                        bool ok = true;
                        if (this.personCond.ContainsKey(i.Key))
                        {
                            foreach (Condition c in this.personCond[i.Key])
                            {
                                if (!c.CheckCondition(p, this))
                                {
                                    ok = false;
                                    break;
                                }
                            }
                        }
                        if (ok)
                        {
                            if (this.person[i.Key].Contains(null) || this.person[i.Key].Contains(p))
                            {
                                candidates[i.Key].Add(p);
                            }
                        }
                    }
                }
            }

            foreach (List <Person> i in candidates.Values)
            {
                if (i.Count == 0)
                {
                    return(false);
                }
            }

            Dictionary <int, Person> matchedPersons = new Dictionary <int, Person>();

            foreach (KeyValuePair <int, List <Person> > i in candidates)
            {
                if (i.Value.Count <= 0)
                {
                    return(false);
                }
                Person selected = i.Value[GameObject.Random(i.Value.Count)];
                matchedPersons[i.Key] = selected;
                foreach (List <Person> j in candidates.Values)
                {
                    j.Remove(selected);
                }
            }

            matchedDialog = new List <PersonDialog>();
            foreach (PersonIdDialog i in this.dialog)
            {
                if (!matchedPersons.ContainsKey(i.id))
                {
                    return(false);
                }

                PersonDialog pd = new PersonDialog();
                pd.SpeakingPerson = matchedPersons[i.id];
                pd.Text           = i.dialog;
                for (int j = 0; j < matchedPersons.Count; ++j)
                {
                    pd.Text = pd.Text.Replace("%" + j, matchedPersons[j].Name);
                }
                matchedDialog.Add(pd);
            }

            matchedEffect = new Dictionary <Person, List <EventEffect> >();
            foreach (KeyValuePair <int, List <EventEffect> > i in this.effect)
            {
                matchedEffect.Add(matchedPersons[i.Key], i.Value);
            }

            return(true);
        }
Esempio n. 6
0
        public bool matchEventPersons(Architecture a)
        {
            HashSet<int> haveCond = new HashSet<int>();
            foreach (KeyValuePair<int, List<Condition>> i in this.personCond)
            {
                haveCond.Add(i.Key);
            }

            HashSet<int> noCond = new HashSet<int>();
            foreach (int i in this.person.Keys)
            {
                if (!haveCond.Contains(i))
                {
                    noCond.Add(i);
                }
            }

            Dictionary<int, List<Person>> candidates = new Dictionary<int, List<Person>>();
            foreach (int i in this.person.Keys)
            {
                candidates[i] = new List<Person>();
                if (noCond.Contains(i))
                {
                    foreach (Person p in a.Persons.GetList())
                    {
                        candidates[i].Add(p);
                    }
                }
            }

            foreach (KeyValuePair<int, List<Condition>> i in this.personCond)
            {
                foreach (Person p in a.Persons)
                {
                    bool ok = true;
                    foreach (Condition c in i.Value)
                    {
                        if (!c.CheckCondition(p, this))
                        {
                            ok = false;
                            break;
                        }
                    }
                    if (ok)
                    {
                        if (this.person[i.Key].Contains(null) || this.person[i.Key].Contains(p))
                        {
                            candidates[i.Key].Add(p);
                        }
                    }
                }
            }
            foreach (KeyValuePair<int, List<Person>> i in this.person)
            {
                foreach (Person p in i.Value)
                {
                    if (p != null && p.ID >= 7000 && p.ID < 8000)
                    {
                        bool ok = true;
                        if (this.personCond.ContainsKey(i.Key))
                        {
                            foreach (Condition c in this.personCond[i.Key])
                            {
                                if (!c.CheckCondition(p, this))
                                {
                                    ok = false;
                                    break;
                                }
                            }
                        }
                        if (ok)
                        {
                            if (this.person[i.Key].Contains(null) || this.person[i.Key].Contains(p))
                            {
                                candidates[i.Key].Add(p);
                            }
                        }
                    }
                }
            }

            foreach (List<Person> i in candidates.Values)
            {
                if (i.Count == 0) return false;
            }

            Dictionary<int, Person> matchedPersons = new Dictionary<int, Person>();
            foreach (KeyValuePair<int, List<Person>> i in candidates)
            {
                if (i.Value.Count <= 0) return false;
                Person selected = i.Value[GameObject.Random(i.Value.Count)];
                matchedPersons[i.Key] = selected;
                foreach (List<Person> j in candidates.Values)
                {
                    j.Remove(selected);
                }
            }

            matchedDialog = new List<PersonDialog>();
            foreach (PersonIdDialog i in this.dialog)
            {
                if (!matchedPersons.ContainsKey(i.id)) return false;

                PersonDialog pd = new PersonDialog();
                pd.SpeakingPerson = matchedPersons[i.id];
                pd.Text = i.dialog;
                for (int j = 0; j < matchedPersons.Count; ++j)
                {
                    pd.Text = pd.Text.Replace("%" + j, matchedPersons[j].Name);
                }
                matchedDialog.Add(pd);
            }

            matchedEffect = new Dictionary<Person, List<EventEffect>>();
            foreach (KeyValuePair<int, List<EventEffect>> i in this.effect)
            {
                matchedEffect.Add(matchedPersons[i.Key], i.Value);
            }

            return true;
        }
Esempio n. 7
0
        public bool matchEventPersons(Architecture a)
        {
            GameObjectList allPersons = a.Persons.GetList();

            foreach (Person p in a.NoFactionPersons)
            {
                allPersons.Add(p);
            }
            foreach (Captive p in a.Captives)
            {
                allPersons.Add(p.CaptivePerson);
            }
            foreach (Person p in a.Feiziliebiao)
            {
                allPersons.Add(p);
            }

            HashSet <int> haveCond = new HashSet <int>();

            foreach (KeyValuePair <int, List <Condition> > i in this.personCond)
            {
                haveCond.Add(i.Key);
            }

            HashSet <int> noCond = new HashSet <int>();

            foreach (KeyValuePair <int, List <Person> > i in this.person)
            {
                if (!haveCond.Contains(i.Key) && i.Value.Count == 0)
                {
                    noCond.Add(i.Key);
                }
            }

            Dictionary <int, List <Person> > candidates = new Dictionary <int, List <Person> >();

            foreach (int i in this.person.Keys)
            {
                candidates[i] = new List <Person>();
                if (noCond.Contains(i))
                {
                    foreach (Person p in allPersons.GetList())
                    {
                        candidates[i].Add(p);
                    }
                }
            }

            // check person in the architecture
            foreach (KeyValuePair <int, List <Condition> > i in this.personCond)
            {
                foreach (Person p in allPersons)
                {
                    bool ok = true;
                    foreach (Condition c in i.Value)
                    {
                        if (!c.CheckCondition(p, this))
                        {
                            ok = false;
                            break;
                        }
                    }
                    if (ok)
                    {
                        if (this.person[i.Key].Contains(null) || this.person[i.Key].Contains(p))
                        {
                            candidates[i.Key].Add(p);
                        }
                    }
                }
            }
            // check 7000 - 8000 persons which can be in anywhere
            foreach (KeyValuePair <int, List <Person> > i in this.person)
            {
                foreach (Person p in i.Value)
                {
                    if (p != null /*&& p.ID >= 7000 && p.ID < 8000*/)
                    {
                        bool ok = true;
                        if (this.personCond.ContainsKey(i.Key))
                        {
                            foreach (Condition c in this.personCond[i.Key])
                            {
                                if (!c.CheckCondition(p, this))
                                {
                                    ok = false;
                                    break;
                                }
                            }
                        }
                        if (ok)
                        {
                            if (this.person[i.Key].Contains(null) || this.person[i.Key].Contains(p))
                            {
                                candidates[i.Key].Add(p);
                            }
                        }
                    }
                }
            }

            foreach (List <Person> i in candidates.Values)
            {
                if (i.Count == 0)
                {
                    return(false);
                }
            }

            //Dictionary<int, Person> matchedPersons = new Dictionary<int, Person>();
            foreach (KeyValuePair <int, List <Person> > i in candidates)
            {
                if (i.Value.Count <= 0)
                {
                    return(false);
                }
                Person selected = i.Value[GameObject.Random(i.Value.Count)];
                matchedPersons[i.Key] = selected;
                foreach (List <Person> j in candidates.Values)
                {
                    j.Remove(selected);
                }
            }

            matchedDialog = new List <PersonDialog>();
            foreach (PersonIdDialog i in this.dialog)
            {
                if (!matchedPersons.ContainsKey(i.id))
                {
                    return(false);
                }

                PersonDialog pd = new PersonDialog();
                pd.SpeakingPerson = matchedPersons[i.id];
                pd.Text           = i.dialog;
                for (int j = 0; j < matchedPersons.Count; ++j)
                {
                    pd.Text = pd.Text.Replace("%" + j, matchedPersons[j].Name);
                }
                matchedDialog.Add(pd);
            }

            matchedScenBiography = new List <PersonDialog>();
            foreach (PersonIdDialog i in this.scenBiography)
            {
                if (!matchedPersons.ContainsKey(i.id))
                {
                    return(false);
                }

                PersonDialog pd = new PersonDialog();
                pd.SpeakingPerson = matchedPersons[i.id];
                pd.Text           = i.dialog;
                for (int j = 0; j < matchedPersons.Count; ++j)
                {
                    pd.Text = pd.Text.Replace("%" + j, matchedPersons[j].Name);
                }
                matchedScenBiography.Add(pd);
            }

            matchedEffect = new Dictionary <Person, List <EventEffect> >();
            foreach (KeyValuePair <int, List <EventEffect> > i in this.effect)
            {
                matchedEffect.Add(matchedPersons[i.Key], i.Value);
            }
            matchedYesEffect = new Dictionary <Person, List <EventEffect> >();
            foreach (KeyValuePair <int, List <EventEffect> > i in this.yesEffect)
            {
                matchedYesEffect.Add(matchedPersons[i.Key], i.Value);
            }
            matchedNoEffect = new Dictionary <Person, List <EventEffect> >();
            foreach (KeyValuePair <int, List <EventEffect> > i in this.noEffect)
            {
                matchedNoEffect.Add(matchedPersons[i.Key], i.Value);
            }

            return(true);
        }
Esempio n. 8
0
        public bool checkConditions(Architecture a)
        {
            if (this.happened && !this.repeatable)
            {
                return(false);
            }
            if (GameObject.Random(this.happenChance) != 0)
            {
                return(false);
            }

            if (this.AfterEventHappened >= 0)
            {
                if (!(base.Scenario.AllEvents.GetGameObject(this.AfterEventHappened) as Event).happened)
                {
                    return(false);
                }
            }

            foreach (Condition i in this.architectureCond)
            {
                if (!i.CheckCondition(a, this))
                {
                    return(false);
                }
            }

            foreach (Condition i in this.factionCond)
            {
                if (!i.CheckCondition(a.BelongedFaction, this))
                {
                    return(false);
                }
            }

            Dictionary <int, List <Person> > candidates = new Dictionary <int, List <Person> >();

            foreach (int i in this.personCond.Keys)
            {
                candidates[i] = new List <Person>();
            }
            foreach (KeyValuePair <int, List <Condition> > i in this.personCond)
            {
                foreach (Person p in a.Persons)
                {
                    bool ok = true;
                    foreach (Condition c in i.Value)
                    {
                        if (!c.CheckCondition(p, this))
                        {
                            ok = false;
                            break;
                        }
                    }
                    if (ok)
                    {
                        if (this.person[i.Key].Contains(null) || this.person[i.Key].Contains(p))
                        {
                            candidates[i.Key].Add(p);
                        }
                    }
                }
            }

            foreach (List <Person> i in candidates.Values)
            {
                if (i.Count == 0)
                {
                    return(false);
                }
            }

            Dictionary <int, Person> matchedPersons = new Dictionary <int, Person>();

            foreach (KeyValuePair <int, List <Person> > i in candidates)
            {
                if (i.Value.Count <= 0)
                {
                    return(false);
                }
                Person selected = i.Value[GameObject.Random(i.Value.Count)];
                matchedPersons[i.Key] = selected;
                foreach (List <Person> j in candidates.Values)
                {
                    j.Remove(selected);
                }
            }

            matchedDialog = new List <PersonDialog>();
            foreach (PersonIdDialog i in this.dialog)
            {
                if (!matchedPersons.ContainsKey(i.id))
                {
                    return(false);
                }

                PersonDialog pd = new PersonDialog();
                pd.SpeakingPerson = matchedPersons[i.id];
                pd.Text           = i.dialog;
                for (int j = 0; j < matchedPersons.Count; ++j)
                {
                    pd.Text = pd.Text.Replace("%" + j, matchedPersons[i.id].Name);
                }
                matchedDialog.Add(pd);
            }

            matchedEffect = new Dictionary <Person, List <EventEffect> >();
            foreach (KeyValuePair <int, List <EventEffect> > i in this.effect)
            {
                matchedEffect.Add(matchedPersons[i.Key], i.Value);
            }

            return(true);
        }
Esempio n. 9
0
 public void LoadDialogFromString(Dictionary<int, Person> persons, string data)
 {
     char[] separator = new char[] { ' ', '\n', '\r', '\t' };
     string[] strArray = data.Split(separator, StringSplitOptions.RemoveEmptyEntries);
     this.Dialogs.Clear();
     for (int i = 0; i < strArray.Length; i += 2)
     {
         PersonDialog item = new PersonDialog();
         int num2 = int.Parse(strArray[i]);
         if (num2 >= 0 && !persons.ContainsKey(num2)) continue;
         if (num2 >= 0)
         {
             item.SpeakingPerson = persons[num2];
         }
         item.Text = strArray[i + 1];
         this.Dialogs.Add(item);
     }
 }
 private void btnAddDialogFromAll_Click(object sender, EventArgs e)
 {
     frmSelectPersonList list = new frmSelectPersonList();
     list.Persons = this.Scenario.Persons;
     list.SelectOne = true;
     list.ShowDialog();
     if (list.IDList.Count == 1)
     {
         PersonDialog item = new PersonDialog();
         item.SpeakingPerson = this.Scenario.Persons.GetGameObject(list.IDList[0]) as Person;
         item.Text = "非空话语";
         this.EditingEvent.Dialogs.Add(item);
         this.RefreshDialogs();
     }
 }
 private void btnAddDialogFromRelated_Click(object sender, EventArgs e)
 {
     PersonList list = new PersonList();
     if (this.EditingEvent.LaunchPerson != null)
     {
         list.Add(this.EditingEvent.LaunchPerson);
     }
     if (this.EditingEvent.TargetPersons.Count > 0)
     {
         foreach (PersonRelation relation in this.EditingEvent.TargetPersons)
         {
             list.Add(relation.SpeakingPerson);
         }
     }
     frmSelectPersonList list2 = new frmSelectPersonList();
     list2.Persons = list;
     list2.SelectOne = true;
     list2.ShowDialog();
     if (list2.IDList.Count == 1)
     {
         PersonDialog item = new PersonDialog();
         item.SpeakingPerson = list.GetGameObject(list2.IDList[0]) as Person;
         item.Text = "非空话语";
         this.EditingEvent.Dialogs.Add(item);
         this.RefreshDialogs();
     }
 }
Esempio n. 12
0
        public bool matchEventPersons(Architecture a)
        {
            GameObjectList allPersons = a.Persons.GetList();
            foreach (Person p in a.NoFactionPersons)
            {
                allPersons.Add(p);
            }
            foreach (Captive p in a.Captives)
            {
                allPersons.Add(p.CaptivePerson);
            }
            foreach (Person p in a.Feiziliebiao)
            {
                allPersons.Add(p);
            }

            HashSet<int> haveCond = new HashSet<int>();
            foreach (KeyValuePair<int, List<Condition>> i in this.personCond)
            {
                haveCond.Add(i.Key);
            }

            HashSet<int> noCond = new HashSet<int>();
            foreach (KeyValuePair<int, List<Person>> i in this.person)
            {
                if (!haveCond.Contains(i.Key) && i.Value.Count == 0)
                {
                    noCond.Add(i.Key);
                }
            }

            Dictionary<int, List<Person>> candidates = new Dictionary<int, List<Person>>();
            foreach (int i in this.person.Keys)
            {
                candidates[i] = new List<Person>();
                if (noCond.Contains(i))
                {
                    foreach (Person p in allPersons.GetList())
                    {
                        candidates[i].Add(p);
                    }
                }
            }

            // check person in the architecture
            foreach (KeyValuePair<int, List<Condition>> i in this.personCond)
            {
                foreach (Person p in allPersons)
                {
                    bool ok = true;
                    foreach (Condition c in i.Value)
                    {
                        if (!c.CheckCondition(p, this))
                        {
                            ok = false;
                            break;
                        }
                    }
                    if (ok)
                    {
                        if (this.person[i.Key].Contains(null) || this.person[i.Key].Contains(p))
                        {
                            candidates[i.Key].Add(p);
                        }
                    }
                }
            }
            // check 7000 - 8000 persons which can be in anywhere
            foreach (KeyValuePair<int, List<Person>> i in this.person)
            {
                foreach (Person p in i.Value)
                {
                    if (p != null /*&& p.ID >= 7000 && p.ID < 8000*/)
                    {
                        bool ok = true;
                        if (this.personCond.ContainsKey(i.Key))
                        {
                            foreach (Condition c in this.personCond[i.Key])
                            {
                                if (!c.CheckCondition(p, this))
                                {
                                    ok = false;
                                    break;
                                }
                            }
                        }
                        if (ok)
                        {
                            if (this.person[i.Key].Contains(null) || this.person[i.Key].Contains(p))
                            {
                                candidates[i.Key].Add(p);
                            }
                        }
                    }
                }
            }

            foreach (List<Person> i in candidates.Values)
            {
                if (i.Count == 0) return false;
            }

            //Dictionary<int, Person> matchedPersons = new Dictionary<int, Person>();
            foreach (KeyValuePair<int, List<Person>> i in candidates)
            {
                if (i.Value.Count <= 0) return false;
                Person selected = i.Value[GameObject.Random(i.Value.Count)];
                matchedPersons[i.Key] = selected;
                foreach (List<Person> j in candidates.Values)
                {
                    j.Remove(selected);
                }
            }

            matchedDialog = new List<PersonDialog>();
            foreach (PersonIdDialog i in this.dialog)
            {
                if (!matchedPersons.ContainsKey(i.id)) return false;

                PersonDialog pd = new PersonDialog();
                pd.SpeakingPerson = matchedPersons[i.id];
                pd.Text = i.dialog;
                for (int j = 0; j < matchedPersons.Count; ++j)
                {
                    pd.Text = pd.Text.Replace("%" + j, matchedPersons[j].Name);
                }
                matchedDialog.Add(pd);
            }

            matchedScenBiography = new List<PersonDialog>();
            foreach (PersonIdDialog i in this.scenBiography)
            {
                if (!matchedPersons.ContainsKey(i.id)) return false;

                PersonDialog pd = new PersonDialog();
                pd.SpeakingPerson = matchedPersons[i.id];
                pd.Text = i.dialog;
                for (int j = 0; j < matchedPersons.Count; ++j)
                {
                    pd.Text = pd.Text.Replace("%" + j, matchedPersons[j].Name);
                }
                matchedScenBiography.Add(pd);
            }

            matchedEffect = new Dictionary<Person, List<EventEffect>>();
            foreach (KeyValuePair<int, List<EventEffect>> i in this.effect)
            {
                matchedEffect.Add(matchedPersons[i.Key], i.Value);
            }
            matchedYesEffect = new Dictionary<Person, List<EventEffect>>();
            foreach (KeyValuePair<int, List<EventEffect>> i in this.yesEffect)
            {
                matchedYesEffect.Add(matchedPersons[i.Key], i.Value);
            }
            matchedNoEffect = new Dictionary<Person, List<EventEffect>>();
            foreach (KeyValuePair<int, List<EventEffect>> i in this.noEffect)
            {
                matchedNoEffect.Add(matchedPersons[i.Key], i.Value);
            }

            return true;
        }