Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void initFactions()
- {
- ///<summary>
- /// ==== DEEP EXPLAINATION ================================================================
- ///
- /// I'VE USED A DATATABLE !
- ///
- /// To avoid redundant datas, we will avoid to have
- /// TownA - TownB 30
- /// TownB - TownA 40
- /// do to so, indeed we need that the value from A and B still the same,
- /// At each cycle we will move the pointer forward so:
- /// Pesaro, will check Fano and Gabicce.
- /// next cycle, Fano will check just Gabicce, 'cause Pesaro already have a relation with Fano.
- /// On the next Gabicce, will check nothing 'cause Gabicce already have a relation with Pesaro and Fano!
- /// </summary>
- int counter = Towns.Count;
- int x = 0;
- foreach (var faction in FactionsNames)
- {
- if (faction == Towns[counter-1].name)
- break;
- for (int t = x; t < counter; t++)
- {
- // We didn't set the last town because all relationship are alreayd set.
- if (faction == Towns[t].GetComponent<TownAI>().TownName)
- continue;
- FactionRow fr;
- fr.IdFactionA = FactionsNames.IndexOf(faction);
- fr.IdFactionB = t;
- fr.RelationValue = Random.Range(0, 100);
- FactionTable.Add(fr);
- // Debug.Log(faction + "("+ fr.IdFactionA + ") : " + Towns[t].GetComponent<TownAI>().TownName +"("+ fr.IdFactionB + ") = " + fr.RelationValue);
- }
- x++; // increasing the cursor so next step we will skip the check of the early town!
- }
- for (int i = 0; i < FactionTable.Count; i++)
- {
- TownAI townAAi = Towns[FactionTable[i].IdFactionA].GetComponent<TownAI>();
- TownAI townBAi = Towns[FactionTable[i].IdFactionB].GetComponent<TownAI>();
- townAAi.AddEnemyOrAllied(townBAi.gameObject, FactionTable[i].RelationValue);
- townBAi.AddEnemyOrAllied(townAAi.gameObject, FactionTable[i].RelationValue);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment