public GameObjectList GetAnimationList() { GameObjectList list = new GameObjectList(); foreach (Animation animation in this.Animations.Values) { list.Add(animation); } return list; }
public GameObjectList GetInfluenceKindList() { GameObjectList list = new GameObjectList(); foreach (InfluenceKind kind in this.InfluenceKinds.Values) { list.Add(kind); } return list; }
public GameObjectList GetSkillList() { GameObjectList list = new GameObjectList(); foreach (Skill skill in this.Skills.Values) { list.Add(skill); } return list; }
public GameObjectList GetSectionAIDetailList() { GameObjectList list = new GameObjectList(); foreach (SectionAIDetail detail in this.SectionAIDetails.Values) { list.Add(detail); } return list; }
public GameObjectList GetTextMessageList() { GameObjectList list = new GameObjectList(); foreach (TextMessage message in this.TextMessages.Values) { list.Add(message); } return list; }
public GameObjectList GetConditionList() { GameObjectList list = new GameObjectList(); foreach (Condition condition in this.Conditions.Values) { list.Add(condition); } return list; }
public GameObjectList GetTitleList() { GameObjectList list = new GameObjectList(); foreach (Title title in this.Titles.Values) { list.Add(title); } return list; }
public GameObjectList GetConditionKindList() { GameObjectList list = new GameObjectList(); foreach (ConditionKind kind in this.ConditionKinds.Values) { list.Add(kind); } return list; }
public GameObjectList GetStratagemList() { GameObjectList list = new GameObjectList(); foreach (Stratagem stratagem in this.Stratagems.Values) { list.Add(stratagem); } return list; }
public GameObjectList GetCombatMethodList() { GameObjectList list = new GameObjectList(); foreach (CombatMethod method in this.CombatMethods.Values) { list.Add(method); } return list; }
public GameObjectList Getguanjuedezhongleiliebiao() { GameObjectList list = new GameObjectList(); foreach (guanjuezhongleilei kind in this.guanjuedezhongleizidian.Values) { list.Add(kind); } return list; }
public GameObjectList GetAllDiplomaticRelationDisplayList() { GameObjectList list = new GameObjectList(); foreach (DiplomaticRelation relation in this.DiplomaticRelations.Values) { list.Add(new DiplomaticRelationDisplay(relation, relation.RelationFaction1String)); } return list; }
public GameObjectList GetTechniqueList() { GameObjectList list = new GameObjectList(); foreach (Technique technique in this.Techniques.Values) { list.Add(technique); } return list; }
public GameObjectList GetEventEffectList() { GameObjectList list = new GameObjectList(); foreach (EventEffect effect in this.EventEffects.Values) { list.Add(effect); } return list; }
public GameObjectList GetEventEffectKindList() { GameObjectList list = new GameObjectList(); foreach (EventEffectKind kind in this.EventEffectKinds.Values) { list.Add(kind); } return list; }
public GameObjectList GetStuntList() { GameObjectList list = new GameObjectList(); foreach (Stunt stunt in this.Stunts.Values) { list.Add(stunt); } return list; }
public GameObjectList GetBiographyList() { GameObjectList list = new GameObjectList(); foreach (Biography biography in this.Biographys.Values) { list.Add(biography); } return list; }
public GameObjectList GetFacilityKindList() { GameObjectList list = new GameObjectList(); foreach (FacilityKind kind in this.FacilityKinds.Values) { list.Add(kind); } return list; }
public GameObjectList GetArchitectureKindList() { GameObjectList list = new GameObjectList(); foreach (ArchitectureKind kind in this.ArchitectureKinds.Values) { list.Add(kind); } return list; }
public GameObjectList Getzainanzhongleiliebiao() { GameObjectList list = new GameObjectList(); foreach (zainanzhongleilei kind in this.zainanzhongleizidian.Values) { list.Add(kind); } return list; }
public GameObjectList GetTerrainDetailList() { GameObjectList list = new GameObjectList(); foreach (TerrainDetail detail in this.TerrainDetails.Values) { list.Add(detail); } return list; }
public GameObjectList GetDiplomaticRelationListByFactionID(int factionID) { GameObjectList list = new GameObjectList(); foreach (DiplomaticRelation relation in this.DiplomaticRelations.Values) { if ((relation.RelationFaction1ID == factionID) || (relation.RelationFaction2ID == factionID)) { list.Add(relation); } } return list; }
public GameObjectList GetSectionNoOrientationAutoAIDetailsByConditions(bool allowOffensiveCampaign, bool valueRecruitment) { GameObjectList list = new GameObjectList(); foreach (SectionAIDetail detail in this.SectionAIDetails.Values) { if ((((detail.OrientationKind == SectionOrientationKind.无) && detail.AutoRun) && (detail.AllowOffensiveCampaign == allowOffensiveCampaign)) && (detail.ValueRecruitment == valueRecruitment)) { list.Add(detail); } } return list; }
public GameObjectList GetSectionAIDetailsByConditions(SectionOrientationKind orientationKind, bool autoRun, bool valueOffensiveCampaign, bool allowOffensiveCampaign, bool allowMilitaryTransfer, bool valueRecruitment) { GameObjectList list = new GameObjectList(); foreach (SectionAIDetail detail in this.SectionAIDetails.Values) { if (((((detail.OrientationKind == orientationKind) && (detail.AutoRun == autoRun)) && ((detail.ValueOffensiveCampaign == valueOffensiveCampaign) && (detail.AllowOffensiveCampaign == allowOffensiveCampaign))) && (detail.AllowMilitaryTransfer == allowMilitaryTransfer)) && (detail.ValueRecruitment == valueRecruitment)) { list.Add(detail); } } return list; }
public GameObjectList GetSelectedList() { GameObjectList list = new GameObjectList(); foreach (GameObject obj2 in this.gameObjects) { if (obj2.Selected) { list.Add(obj2); } } return(list); }
public void BuildQueue(bool preUserControlFinished) { GameObjectList list = base.GetList(); list.PropertyName = "Power"; list.IsNumber = true; list.SmallToBig = true; list.ReSort(); foreach (Faction faction in list) { this.SetFactionInQueue(faction, preUserControlFinished); } }
public Screen(Game game) : base(game) { this.PluginList = new GameObjectList(); this.EnableUpdate = true; this.EnableMouseEvent = true; this.EnableScroll = true; this.EnableLaterMouseEvent = true; this.EnableSelecting = true; this.ScrollDisableRects = new List <Rectangle>(); this.LaterMouseEventDisableRects = new List <Rectangle>(); this.SelectingDisableRects = new List <Rectangle>(); this.UndoneWorks = new Stack <UndoneWorkItem>(); this.UndoneWorks.Push(new UndoneWorkItem(UndoneWorkKind.None, UndoneWorkSubKind.None)); }
public Screen(Game game) : base(game) { this.PluginList = new GameObjectList(); this.EnableUpdate = true; this.EnableMouseEvent = true; this.EnableScroll = true; this.EnableLaterMouseEvent = true; this.EnableSelecting = true; this.ScrollDisableRects = new List<Rectangle>(); this.LaterMouseEventDisableRects = new List<Rectangle>(); this.SelectingDisableRects = new List<Rectangle>(); this.UndoneWorks = new Stack<UndoneWorkItem>(); this.UndoneWorks.Push(new UndoneWorkItem(UndoneWorkKind.None, UndoneWorkSubKind.None)); }
public void LoadFromString(GameObjectList list, string dataString) { char[] separator = new char[] { ' ', '\n', '\r', '\t' }; string[] strArray = dataString.Split(separator, StringSplitOptions.RemoveEmptyEntries); this.Clear(); foreach (string str in strArray) { GameObject gameObject = list.GetGameObject(int.Parse(str)); if (gameObject != null) { this.Add(gameObject); } } }
public GameObjectList GetDiplomaticRelationDisplayListByFactionID(int factionID) { GameObjectList list = new GameObjectList(); foreach (DiplomaticRelation relation in this.DiplomaticRelations.Values) { if (relation.RelationFaction1ID == factionID) { list.Add(new DiplomaticRelationDisplay(relation, relation.RelationFaction2String)); } else if (relation.RelationFaction2ID == factionID) { list.Add(new DiplomaticRelationDisplay(relation, relation.RelationFaction1String)); } } return list; }
public void BuildQueue() { this.queueEnded = false; if (this.troopQueue.Count != 0) { throw new Exception("troopQueue is not empty before building"); } this.AmbushList.Clear(); GameObjectList randomList = base.GetRandomList(); if (Session.GlobalVariables.MilitaryKindSpeedValid && (randomList.Count > 1)) { randomList.PropertyName = "Speed"; randomList.IsNumber = true; randomList.SmallToBig = false; randomList.ReSort(); } foreach (Troop troop in randomList) { if (troop.CanMoveAnyway()) { if (troop.Status == TroopStatus.伪报) { int z = 0; z++; } troop.InitializeInQueue(); if (troop.Status == TroopStatus.埋伏) { this.AmbushList.Add(troop); } else { this.troopQueue.Enqueue(troop); } } troop.Operated = false; troop.Controllable = true; } }
public GameObjectList GetList(params GameObjectCondition[] conditions) { GameObjectList list = new GameObjectList(); foreach (GameObject obj2 in this.gameObjects) { bool flag = true; for (int i = 0; i < conditions.Length; i++) { if (conditions[i].LEG == 0) { if (!StaticMethods.GetPropertyValue(obj2, conditions[i].PropertyName).Equals(conditions[i].PropertyValue)) { flag = false; break; } } else if (conditions[i].LEG > 0) { if (((int)StaticMethods.GetPropertyValue(obj2, conditions[i].PropertyName)) <= ((int)conditions[i].PropertyValue)) { flag = false; break; } } else if ((conditions[i].LEG < 0) && (((int)StaticMethods.GetPropertyValue(obj2, conditions[i].PropertyName)) >= ((int)conditions[i].PropertyValue))) { flag = false; break; } } if (flag) { list.Add(obj2); } } return(list); }
public GameObjectList GetMinObjects(int count) { int num; if (count > this.Count) { count = this.Count; } GameObjectList list = new GameObjectList(); if (this.SmallToBig) { for (num = 0; num < count; num++) { list.Add(this[num]); } return(list); } for (num = count - 1; num >= 0; num--) { list.Add(this[num]); } return(list); }
private void screen_OnMouseMove(Point position, bool leftDown) { if (!this.xianshiyoucelan) return; if ((this.screen.PeekUndoneWork().Kind == UndoneWorkKind.None) && (this.oldMousePosition != position)) { if (leftDown) { if (this.ShowCheckBox && ((this.MultiSelecting && !this.MovingHorizontalScrollBar) && !this.MovingVerticalScrollBar)) { GameObject gameObjectByPosition = this.GetGameObjectByPosition(position); if (gameObjectByPosition != null) { if (!this.SelectingRows) { this.SelectingRows = true; this.SelectingBool = gameObjectByPosition.Selected; } if (this.SelectingRows) { if (this.SelectingBool) { if ((this.SelectedItemMaxCount <= 0) || (this.gameObjectList.GetSelectedList().Count < this.SelectedItemMaxCount)) { gameObjectByPosition.Selected = this.SelectingBool; this.ResetEditableTextures(); } } else { gameObjectByPosition.Selected = this.SelectingBool; this.ResetEditableTextures(); } } this.OKButtonEnabled = this.gameObjectList.HasSelectedItem(); this.SelectedItemList = this.gameObjectList.GetSelectedList(); } } if (this.ShowHorizontalScrollBar && (this.MovingHorizontalScrollBar || StaticMethods.PointInRectangle(position, this.listKindToDisplay.HorizontalScrollBar))) { this.listKindToDisplay.MoveHorizontal(position.X - this.oldMousePosition.X); this.MovingHorizontalScrollBar = true; } if (this.ShowVerticalScrollBar && (this.MovingVerticalScrollBar || StaticMethods.PointInRectangle(position, this.listKindToDisplay.VerticalScrollBar))) { this.listKindToDisplay.MoveVertical(position.Y - this.oldMousePosition.Y); this.MovingVerticalScrollBar = true; } } else { int rowTopByPosition = this.GetRowTopByPosition(position); if (rowTopByPosition >= 0) { this.Focused = rowTopByPosition; this.FocusedObject = this.GetGameObjectByPosition(position); this.DrawFocused = true; } else { this.DrawFocused = false; } } this.oldMousePosition = position; } }
private void screen_OnMouseLeftDown(Point position) { if (StaticMethods.PointInRectangle(position, this.ToolDisplayPosition)) { this.xianshiyoucelan = !this.xianshiyoucelan ; if (true) //base.Enabled) { if (this.xianshiyoucelan) { this.ToolDisplayTexture = this.ToolSelectedTexture; } else { this.ToolDisplayTexture = this.ToolTexture; } } } if (this.xianshiyoucelan && (this.screen.PeekUndoneWork().Kind == UndoneWorkKind.None) && StaticMethods.PointInRectangle(position, this.RealClient)) { if (position.Y < this.listKindToDisplay.ColumnsTop) { Tab tab = this.FindTabByPosition(position); if (tab != null) { tab.Selected = true; } } else if (position.Y < (this.listKindToDisplay.ColumnsTop + this.columnheaderHeight)) { Column columnByPosition = this.GetColumnByPosition(position); if (columnByPosition != null) { PropertyComparer comparer = new PropertyComparer(columnByPosition.Name, columnByPosition.IsNumber, columnByPosition.SmallToBig); this.gameObjectList.Sort(comparer); this.listKindToDisplay.ResetAllTextures(); columnByPosition.SmallToBig = !columnByPosition.SmallToBig; } } else { GameObject gameObjectByPosition; if (this.ShowCheckBox) { gameObjectByPosition = this.GetGameObjectByPosition(position); if (gameObjectByPosition != null) { if (this.listKindToDisplay.IsInEditableColumn(position)) { if ((gameObjectByPosition.Selected || (this.SelectedItemMaxCount <= 0)) || (this.gameObjectList.GetSelectedList().Count < this.SelectedItemMaxCount)) { gameObjectByPosition.Selected = !gameObjectByPosition.Selected; if (this.MultiSelecting) { this.SelectingRows = true; this.SelectingBool = gameObjectByPosition.Selected; this.SelectedItemList = this.gameObjectList.GetSelectedList(); } else { this.gameObjectList.SetOtherUnSelected(gameObjectByPosition); } this.OKButtonEnabled = this.gameObjectList.HasSelectedItem() || (gameObjectByPosition is Faction); this.ResetEditableTextures(); if (gameObjectByPosition.Selected) { this.SelectedItem = gameObjectByPosition; if (!(this.MultiSelecting || !GlobalVariables.SingleSelectionOneClick)) { this.iGameFrame.OK(); } else { this.screen.PlayNormalSound(this.SelectSoundFile); } } else { this.SelectedItem = null; } } } else { if (gameObjectByPosition is Troop) { if ((this.iTroopDetail != null) && (this.Function != FrameFunction.Jump)) { this.iTroopDetail.SetPosition(ShowPosition.Center); this.iTroopDetail.SetTroop(gameObjectByPosition); this.iTroopDetail.IsShowing = true; } this.screen.JumpTo((gameObjectByPosition as Troop).Position); } else if (gameObjectByPosition is Person) { if ((this.iPersonDetail != null) && (this.Function != FrameFunction.Jump)) { this.iPersonDetail.SetPosition(ShowPosition.Center); this.iPersonDetail.SetPerson(gameObjectByPosition); this.iPersonDetail.IsShowing = true; } if (!(gameObjectByPosition as Person).IsCaptive) { this.screen.JumpTo((gameObjectByPosition as Person).Position); } } else if (gameObjectByPosition is Architecture) { if ((this.iArchitectureDetail != null) && (this.Function != FrameFunction.Jump)) { this.iArchitectureDetail.SetPosition(ShowPosition.Center); this.iArchitectureDetail.SetArchitecture(gameObjectByPosition); this.iArchitectureDetail.IsShowing = true; } this.screen.JumpTo((gameObjectByPosition as Architecture).Position); } else if (gameObjectByPosition is Military) { this.screen.JumpTo((gameObjectByPosition as Military).Position); } else if (gameObjectByPosition is Faction) { if ((this.iFactionTechniques != null) && (this.Function != FrameFunction.Jump)) { this.iFactionTechniques.SetArchitecture(null); this.iFactionTechniques.SetFaction(gameObjectByPosition, false); this.iFactionTechniques.SetPosition(ShowPosition.Center); this.iFactionTechniques.IsShowing = true; } this.screen.JumpTo((gameObjectByPosition as Faction).Leader.Position); } else if (gameObjectByPosition is Captive) { if ((this.iPersonDetail != null) && (this.Function != FrameFunction.Jump)) { this.iPersonDetail.SetPosition(ShowPosition.Center); this.iPersonDetail.SetPerson((gameObjectByPosition as Captive).CaptivePerson); this.iPersonDetail.IsShowing = true; } } else if (gameObjectByPosition is Treasure) { if ((this.iTreasureDetail != null) && (this.Function != FrameFunction.Jump)) { this.iTreasureDetail.SetPosition(ShowPosition.Center); this.iTreasureDetail.SetTreasure(gameObjectByPosition); this.iTreasureDetail.IsShowing = true; } if ((gameObjectByPosition as Treasure).BelongedPerson != null) { this.screen.JumpTo((gameObjectByPosition as Treasure).BelongedPerson.Position); } } if (gameObjectByPosition != null) { this.TriggerItemClick(); } } } } else { gameObjectByPosition = this.GetGameObjectByPosition(position); if (gameObjectByPosition != null) { if (this.listKindToDisplay.SelectedTab.ListMethod != null) { this.PushSubKindByName(this.listKindToDisplay.SelectedTab.ListKind, StaticMethods.GetListMethodValue(gameObjectByPosition, this.listKindToDisplay.SelectedTab.ListMethod) as GameObjectList); } else { if (gameObjectByPosition is Troop) { if ((this.iTroopDetail != null) && (this.Function != FrameFunction.Jump)) { this.iTroopDetail.SetPosition(ShowPosition.Center); this.iTroopDetail.SetTroop(gameObjectByPosition); this.iTroopDetail.IsShowing = true; } this.screen.JumpTo((gameObjectByPosition as Troop).Position); } else if (gameObjectByPosition is Person) { if ((this.iPersonDetail != null) && (this.Function != FrameFunction.Jump)) { this.iPersonDetail.SetPosition(ShowPosition.Center); this.iPersonDetail.SetPerson(gameObjectByPosition); this.iPersonDetail.IsShowing = true; } if (!(gameObjectByPosition as Person).IsCaptive) { this.screen.JumpTo((gameObjectByPosition as Person).Position); } } else if (gameObjectByPosition is Architecture) { if ((this.iArchitectureDetail != null) && (this.Function != FrameFunction.Jump)) { this.iArchitectureDetail.SetPosition(ShowPosition.Center); this.iArchitectureDetail.SetArchitecture(gameObjectByPosition); this.iArchitectureDetail.IsShowing = true; } this.screen.JumpTo((gameObjectByPosition as Architecture).Position); } else if (gameObjectByPosition is Military) { this.screen.JumpTo((gameObjectByPosition as Military).Position); } else if (gameObjectByPosition is Faction) { if ((this.iFactionTechniques != null) && (this.Function != FrameFunction.Jump)) { this.iFactionTechniques.SetArchitecture(null); this.iFactionTechniques.SetFaction(gameObjectByPosition, false); this.iFactionTechniques.SetPosition(ShowPosition.Center); this.iFactionTechniques.IsShowing = true; } this.screen.JumpTo((gameObjectByPosition as Faction).Leader.Position); } else if (gameObjectByPosition is Captive) { if ((this.iPersonDetail != null) && (this.Function != FrameFunction.Jump)) { this.iPersonDetail.SetPosition(ShowPosition.Center); this.iPersonDetail.SetPerson((gameObjectByPosition as Captive).CaptivePerson); this.iPersonDetail.IsShowing = true; } } else if (gameObjectByPosition is Treasure) { if ((this.iTreasureDetail != null) && (this.Function != FrameFunction.Jump)) { this.iTreasureDetail.SetPosition(ShowPosition.Center); this.iTreasureDetail.SetTreasure(gameObjectByPosition); this.iTreasureDetail.IsShowing = true; } if ((gameObjectByPosition as Treasure).BelongedPerson != null) { this.screen.JumpTo((gameObjectByPosition as Treasure).BelongedPerson.Position); } } if (gameObjectByPosition != null) { this.TriggerItemClick(); } } } } } } }
internal void RefreshEditable() { this.ResetEditableTextures(); this.OKButtonEnabled = this.gameObjectList.HasSelectedItem(); if (this.MultiSelecting) { this.SelectedItemList = this.gameObjectList.GetSelectedList(); } else if (this.OKButtonEnabled) { this.SelectedItem = this.gameObjectList.GetSelectedList()[0]; } }
internal void PushSubKindByName(string name, GameObjectList list) { if ((list != null) && (list.Count != 0)) { if (this.SubKinds.Count == 0) { this.RightClickClose = false; this.RootListKind.Kind = this.listKindToDisplay; this.RootListKind.List = this.gameObjectList; } this.SetObjectList(list); this.listKindToDisplay = this.GetListKindByName(name); if (this.listKindToDisplay != null) { this.ReCalculate(); SubKind item = new SubKind { Kind = this.listKindToDisplay, List = list }; this.SubKinds.Push(item); } } }
private void architecture_OnRewardPersons(Architecture architecture, GameObjectList personlist) { architecture.Scenario.GameScreen.ArchitectureRewardPersons(architecture, personlist); }
public virtual void ArchitectureRewardPersons(Architecture architecture, GameObjectList personlist) { }
private void architecture_OnRewardPersons(Architecture architecture, GameObjectList personlist) { Session.MainGame.mainGameScreen.ArchitectureRewardPersons(architecture, personlist); }
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); }
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); }