// TODO Check which ones are up to date and which arent, then cut it down to a single one. //Only for use at game start public Character(int rnk, OfficerRoles r, Empire e, Theme t = null) { empire = e; Role = r; Rank = rnk; ID = GetNextID(); Age = (int)(rnd.Next(24, 29) + Rank * rnd.Next(1.65f, 2.5f)); BiologicalAge = Age; sex = (Sex)rnd.Next(0, 2); Noble = RollNoble(Role); int TraitCount = rnd.Next(2, 6); while (TraitCount > 0) { int ind = rnd.Next(0, Trait.Traits.Count); TraitCount--; AddTrait(Trait.Traits [ind]); } if (t != null) { ThemeManager.GenerateCharName(this, t); //todo } else { ThemeManager.GenerateCharName(this); //todo } Register(this); if ((int)Role < 5) { JoinsUp(); } }
public List <Character> GetCharactersByTypeAndRank(OfficerRoles r, int rank) { List <Character> ch = new List <Character> (); List <Character> imthenulls = new List <Character> (); foreach (Character c in Character.CharactersByEmpire[this]) { if (c != null) { try { if (c.Role == r && c.Rank == rank) { ch.Add(c); } } catch { if (c.CharName == null) { Debug.LogError("Name has failed to process"); } } } else { imthenulls.Add(c); Debug.LogError("A null character was removed from the list"); } } foreach (Character c in imthenulls) { Character.CharactersByEmpire[this].Remove(c); } ch = ch.OrderByDescending(x => x.Rank).ThenByDescending(x => x.Noble).ThenByDescending(x => x.NobleRank).ToList(); return(ch); }
public static List <Character> GetCharactersByTypeAndRank(OfficerRoles r, List <Character> Set, int rank = -1) { List <Character> ch = new List <Character> (); List <Character> imthenulls = new List <Character> (); foreach (Character c in Set) { if (c != null) { if (c.Role == r && (c.Rank == rank || rank == -1)) { ch.Add(c); } } else { imthenulls.Add(c); } } foreach (Character c in imthenulls) { //Do Nothing } ch = ch.OrderByDescending(x => x.Rank).ThenByDescending(x => x.Noble).ThenByDescending(x => x.NobleRank).ToList(); return(ch); }
void UpdateOfficerScroll(int i = 0) { if (!Initialized) { Initialize(); } OfficerRoles r = (OfficerRoles)i; int yOff = -45; int interval = 1; foreach (GameObject g in OfficerButtons) { Destroy(g); } List <Character> ToScreen = new List <Character>(); OfficerButtons.Clear(); foreach (Character d in ActiveEmpire.GetCharactersByType(r)) { if (string.IsNullOrEmpty(NameFilter.text) || d.GetNameString().IndexOf(NameFilter.text.Trim(), System.StringComparison.InvariantCultureIgnoreCase) > -1 || (d.Location != null && d.Location.GetLocationName().IndexOf(NameFilter.text.Trim(), System.StringComparison.InvariantCultureIgnoreCase) > -1)) { if (!NoblesOnly() || (NoblesOnly() && d.Noble)) { if (!UnassignedOnly() || r != OfficerRoles.Navy || (UnassignedOnly() && d.NavalRole == NavalCommanderRole.NONE)) { ToScreen.AddExclusive(d); } } } } ToScreen.ForEach(x => { GameObject g = Instantiate <GameObject> (ButtonPrefab) as GameObject; OfficerButtons.Add(g); RectTransform h = g.GetComponent <RectTransform> (); OfficerButtonManager manager = g.AddComponent <OfficerButtonManager> (); manager.Manager = this; manager.Assign(x); h.SetParent(OfficersParent.transform); // h.rotation = Camera.main.transform.rotation; h.anchoredPosition3D = new Vector3(0f, yOff * interval, 0f); h.sizeDelta = new Vector2(800f, 35f); h.localScale = new Vector3(1f, 1f, 1f); interval++; }); }
static IEnumerator LoadTitles() { while (String.IsNullOrEmpty(ThemeManager.StreamingPath)) { Console.WriteLine("Characters Waiting..."); yield return(null); } Console.WriteLine("Characters Proceeding."); List <string> paths = new List <string> (); paths.AddRange(Directory.GetDirectories(System.IO.Path.Combine(ThemeManager.StreamingPath, "Roles"))); char splitter = ':'; paths.ForEach(p => { //For each file int index = -1; List <string> Lines = new List <string>(); Lines.AddRange(File.ReadAllLines(p)); OfficerRoles target = OfficerRoles.Army; Debug.LogWarning(Lines.Count + " Linecount in " + p); Lines.ForEach(l => { //For each line in that file //Should look Like// //Rank:TitleAbbrev:Title Debug.LogAssertion(l); if (index == -1) { target = (OfficerRoles)Enum.Parse(typeof(OfficerRoles), l); index++; } else { List <string> rankTitle = l.Split(splitter).ToList(); KeyValuePair <OfficerRoles, int> key = new KeyValuePair <OfficerRoles, int>(target, int.Parse(rankTitle[0])); KeyValuePair <string, string> value = new KeyValuePair <string, string>(rankTitle[1], rankTitle[2]); RoleTitlesDict.Add(key, value); Debug.LogWarning(value.Key + " " + value.Value); index++; } }); MaxRanks.Add(target, index - 1); }); TitlesLoaded = true; }
static IEnumerator GenerateCharactersCoroutine(Empire e, OfficerRoles r, List <float> dist, int MaxNumber) { while (!TitlesLoaded) { Debug.LogError("Waiting"); yield return(null); } int rankIndex = 0; foreach (var f in dist) { int i = (int)(MaxNumber * f); while (i >= 0) { i--; Character c = new Character(rankIndex, r, e); } rankIndex++; } yield return(null); }
public void Retire(bool Forced) { string st = ""; SetAssigned(true); if (Forced) { st = string.Format("{0}: <color=navy>{1}</color> was <color=red>dishonorably discharged</color> from the service.", StrategicClock.GetDate(), GetNameString()); } else { st = string.Format("{0}: <color=navy>{1}</color> {2} has <color=green>retired honorably</color> from the service.", StrategicClock.GetDate(), GetNobleTitle(), GetNameString()); } EmpireLogEntry E = new EmpireLogEntry(LogCategories.MILITARY, 3, empire, "OFFICER RETIRES", st, new List <Character> { this }); AddHistory(st); // shipPosting = null Role = OfficerRoles.Retired; }
public List <Character> GetCharactersByType(OfficerRoles r, List <Character> CharSet) { List <Character> ch = new List <Character> (); List <Character> imthenulls = new List <Character> (); if (CharSet.Count < 1) { CharSet.AddRange(Character.CharactersByEmpire[this]); } foreach (Character c in CharSet) { if (c != null) { try { if (c.Role == r) { ch.Add(c); } } catch { if (string.IsNullOrEmpty(c.CharName)) { //c.CharName = "Null"; Debug.LogError("Name has failed to process"); } } } else { imthenulls.Add(c); Debug.LogError("A null character was removed from the list"); } } foreach (Character c in imthenulls) { Character.CharactersByEmpire[this].Remove(c); } ch = ch.OrderByDescending(x => x.Rank).ThenByDescending(x => x.Noble).ThenByDescending(x => x.NobleRank).ToList(); return(ch); }
static List <Character> GetCharactersAtLocation(ILocation loc, Dictionary <OfficerRoles, List <Character> > dict, OfficerRoles?rNullable = null, bool softReq = false) { List <Character> Output = new List <Character> (); foreach (Character c in AllCharacters.Values) { if (c.Location == loc) { if (dict.ContainsKey(c.Role)) { dict[c.Role].Add(c); } else { dict.Add(c.Role, new List <Character> { c }); } Output.Add(c); } } if (rNullable != null && Output.Count > 0) { OfficerRoles r = rNullable.Value; Output = GetCharactersByTypeAndRank(r, Output); } if (rNullable == null) { Output = Output.OrderByDescending(x => x.Rank).ThenByDescending(x => x.Noble).ThenByDescending(x => x.NobleRank).ToList(); } else { Output = Output.OrderBy(x => x.Role).ThenByDescending(x => x.Rank).ThenByDescending(x => x.Noble).ThenByDescending(x => x.NobleRank).ToList(); } return(Output); }
public List <Character> GetCharactersAtLocation(ILocation loc, OfficerRoles?rNullable = null, bool softReq = true) { List <Character> Output = new List <Character> (); foreach (Character c in Character.CharactersByEmpire[this]) { if (c.Location == loc) { Output.Add(c); } } if (rNullable != null && Output.Count > 0) { OfficerRoles r = rNullable.Value; Output = GetCharactersByType(r, Output); if (Output.Count < 1 && softReq) { foreach (Character c in Character.CharactersByEmpire[this]) { if (c.Location == loc) { Output.Add(c); } } } } if (rNullable == null) { Output = Output.OrderByDescending(x => x.Rank).ThenByDescending(x => x.Noble).ThenByDescending(x => x.NobleRank).ToList(); } else { Output = Output.OrderBy(x => x.Role).ThenByDescending(x => x.Rank).ThenByDescending(x => x.Noble).ThenByDescending(x => x.NobleRank).ToList(); } return(Output); }
// Update is called once per frame void Update() { if (gameObject.active) { if (LocationsParentRect.localPosition.y < 0) { LocationsParentRect.transform.localPosition = new Vector3(0f, 0f, 0f); } if (OfficersParentRect.localPosition.y < 0) { OfficersParentRect.transform.localPosition = new Vector3(0f, 0f, 0f); } if (HistoryRect.localPosition.y < 0) { HistoryRect.transform.localPosition = new Vector3(0f, 0f, 0f); } if (Input.GetKeyDown(KeyCode.Space) && SelectedChar != null) { OfficerRoles original = SelectedChar.Role; SelectedChar.Role = SystemRandomExtensions.RandomEnum <OfficerRoles>(); Debug.LogError(original.ToString() + "=>" + SelectedChar.Role.ToString()); } } }
bool RollNoble(OfficerRoles r) { float odds = .015f; switch (r) { case OfficerRoles.Navy: odds = .1f; break; case OfficerRoles.Army: odds = .03f; break; case OfficerRoles.Government: odds = .4f; break; case OfficerRoles.Research: odds = .02f; break; case OfficerRoles.Intelligence: odds = 0f; break; case OfficerRoles.Police: odds = 0f; break; case OfficerRoles.Child: break; case OfficerRoles.Corporate: odds = .025f; break; case OfficerRoles.Social: odds = .75f; break; case OfficerRoles.Merchant: odds = 0f; break; case OfficerRoles.Scientist: odds = .02f; break; case OfficerRoles.Politician: odds = .6f; break; case OfficerRoles.Media: odds = .05f; break; case OfficerRoles.Engineer: odds = .02f; break; case OfficerRoles.Noble: odds = 1f; break; case OfficerRoles.Retired: break; case OfficerRoles.Terrorist: odds = .01f; break; case OfficerRoles.Rebel: odds = .01f; break; case OfficerRoles.Spy: odds = .01f; break; case OfficerRoles.Criminal: odds = .01f; break; default: throw new ArgumentOutOfRangeException("r", r, null); } return(rnd.NextFloat(0, 1f) < odds); }
public static int GetMaxRank(OfficerRoles r) { return(MaxRanks[r]); }
//////////////////////////////////////////////////////////////////////////////////////////////////// //CHARACTERS //////////////////////////////////////////////////////////////////////////////////////////////////// #region Characters //How many of each type of character an empire starts with. static KeyValuePair <int, List <float> > StartingByRole(OfficerRoles r) { int num = 100; //Default Rank distribution. List <float> dist = new List <float>() { .40f, .2f, .15f, .1f, .075f, .05f, .035f, .025f }; switch (r) { case OfficerRoles.Navy: num = 50; break; case OfficerRoles.Army: num = 30; break; case OfficerRoles.Government: num = 20; break; case OfficerRoles.Research: num = 15; break; case OfficerRoles.Intelligence: dist = new List <float>() { .50f, 4f, .1f }; num = 5; break; case OfficerRoles.Police: dist = new List <float>() { .50f, 4f, .1f }; num = 12; break; case OfficerRoles.Child: num = 0; break; case OfficerRoles.Corporate: dist = new List <float>() { .50f, .3f, .2f }; num = 5; break; case OfficerRoles.Social: num = 40; break; case OfficerRoles.Merchant: num = 40; break; case OfficerRoles.Scientist: num = 15; break; case OfficerRoles.Politician: num = 30; break; case OfficerRoles.Media: num = 7; break; case OfficerRoles.Engineer: num = 10; break; case OfficerRoles.Noble: dist = new List <float>() { 1f }; num = 30; break; case OfficerRoles.Retired: num = 15; break; case OfficerRoles.Terrorist: num = 5; break; case OfficerRoles.Rebel: num = 10; break; case OfficerRoles.Spy: dist = new List <float>() { .50f, .3f, .2f, .1f }; num = 3; break; case OfficerRoles.Criminal: num = 40; break; default: throw new ArgumentOutOfRangeException("r", r, null); } KeyValuePair <int, List <float> > result = new KeyValuePair <int, List <float> >(num, dist); return(result); }