Skip to content
This repository has been archived by the owner on Oct 19, 2018. It is now read-only.

Commit

Permalink
Merge pull request #7 from luiges90/patch-7
Browse files Browse the repository at this point in the history
事件新增寫入武將年表
  • Loading branch information
kpxp committed Jan 22, 2016
2 parents fc1e88a + d17d211 commit 1119e61
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
47 changes: 46 additions & 1 deletion GameObjects/GameObjects/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class Event : GameObject
public Dictionary<Person, List<EventEffect>> matchedEffect;
public List<EventEffect> architectureEffect;
public List<EventEffect> factionEffect;
public List<PersonIdDialog> scenBiography = new List<>();
public List<PersonDialog> matchedScenBiography = new List<>();
public String Image = "";
public String Sound = "";
public bool GloballyDisplayed = false;
Expand All @@ -48,6 +50,9 @@ public void ApplyEventDialogs(Architecture a)
{
this.OnApplyEvent(this, a);
}
for (PersonDialog i : matchedScenBiography) {
this.Scenario.YearTable.addPersonInGameBiography(i.SpeakingPerson, this.Scenario.Date, i.Text);
}
if (nextScenario.Length > 0)
{
base.Scenario.EnableLoadAndSave = false;
Expand Down Expand Up @@ -220,6 +225,21 @@ public bool matchEventPersons(Architecture a)
}
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)
Expand Down Expand Up @@ -445,6 +465,21 @@ public void LoadDialogFromString(string data)
this.dialog.Add(d);
}
}

public void LoadScenBiographyFromString(string data)
{
char[] separator = new char[] { ' ', '\n', '\r', '\t' };
string[] strArray = data.Split(separator, StringSplitOptions.RemoveEmptyEntries);

this.scenBiography = new List<PersonIdDialog>();
for (int i = 0; i < strArray.Length; i += 2)
{
PersonIdDialog d = new PersonIdDialog();
d.id = int.Parse(strArray[i]);
d.dialog = strArray[i + 1];
this.scenBiography.Add(d);
}
}

public string SaveDialogToString()
{
Expand All @@ -455,6 +490,16 @@ public string SaveDialogToString()
}
return result;
}

public string SaveScenBiographyToString()
{
string result = "";
foreach (PersonIdDialog i in this.scenBiography)
{
result += i.id + " " + i.scenBiography + " ";
}
return result;
}

public void LoadEffectFromString(EventEffectTable allEffect, string data)
{
Expand Down Expand Up @@ -546,4 +591,4 @@ public bool CheckFactionEvent(Architecture a)
public delegate void ApplyEvent(Event te, Architecture a);

}
}
}
6 changes: 6 additions & 0 deletions GameObjects/GameObjects/GameScenario.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4539,6 +4539,11 @@ private List<string> LoadGameDataFromDataBase(OleDbConnection DbConnection, stri
te.CheckArea = (EventCheckAreaKind)((short)reader["CheckAreaKind"]);
te.LoadTargetPersonFromString(this.AllPersons, reader["TargetPersons"].ToString());
te.LoadDialogFromString(this.AllPersons, reader["Dialogs"].ToString());
try {
te.LoadScenBiographyFromString(this.AllPersons, reader["ScenBiography"].ToString());
} catch {

}
te.LoadSelfEffectFromString(this.GameCommonData.AllTroopEventEffects, reader["EffectSelf"].ToString());
te.LoadEffectPersonFromString(this.AllPersons, this.GameCommonData.AllTroopEventEffects, reader["EffectPersons"].ToString());
te.LoadEffectAreaFromString(this.GameCommonData.AllTroopEventEffects, reader["EffectAreas"].ToString());
Expand Down Expand Up @@ -5580,6 +5585,7 @@ public bool SaveGameScenarioToDatabase(string connectionString, bool saveMap, bo
row["CheckAreaKind"] = event2.CheckArea;
row["TargetPersons"] = event2.SaveTargetPersonToString();
row["Dialogs"] = event2.SaveDialogToString();
row["ScenBiography"] = event2.SaveScenBiographyToString();
row["EffectSelf"] = event2.SaveSelfEffectToString();
row["EffectPersons"] = event2.SaveEffectPersonToString();
row["EffectAreas"] = event2.SaveEffectAreaToString();
Expand Down

0 comments on commit 1119e61

Please sign in to comment.