public string PrintRelationships() { string rels = GetName() + "\n"; rels += "Spouse: "; if (null == spouse) { rels += "null"; } else { rels += spouse.GetName(); } rels += "\nSiblings: " + PrintListPeeps(siblings) + "\n"; rels += "Children: " + PrintListPeeps(children) + "\n"; return(rels); }
void OnGUI() { GUI.skin = controller.GetUISkin(); Vector3 pos = Camera.main.WorldToScreenPoint(transform.position + new Vector3(-0.35f, -0.15f, 0.0f)); pos.y = Screen.height - pos.y; string labelText; if (null != liege) { float height = fontStyle.lineHeight - 7f; labelText = liege.GetName() + "\n"; GUI.Label(new Rect(pos.x, pos.y, 300, 300), labelText, fontStyle); labelText = troops + "/" + max_troops + " troops"; GUI.Label(new Rect(pos.x, pos.y + height, 300, 300), labelText, fontStyle); labelText = (int)(Morale() * 100f) + "% morale"; GUI.Label(new Rect(pos.x, pos.y + 2f * height, 300, 300), labelText, fontStyle); } else { labelText = "Abandoned"; GUI.Label(new Rect(pos.x, pos.y, 300, 300), labelText, fontStyle); } }
void StartGame() { currentState = GameStates.PLAYING; ResetCameraPos(); int CASTLES_ACROSS = 5; int CASTLES_DOWN = 4; dg = new DynastyGen(BannerSprites.GetUpperBound(0) + 1); ai_dynasties = dg.GenerateIntertwinedDynasties(3); player_dynasty = dg.GenerateIntertwinedDynasties(1)[0]; string dynDebug = ""; foreach (KeyValuePair <int, List <Person> > dynPair in dg.dynastiesGenerated) { foreach (Person p in dynPair.Value) { dynDebug += p.PrintRelationships() + "\n"; } } Debug.Log(dynDebug); for (int x = 0; x < CASTLES_ACROSS; x++) { for (int y = 0; y < CASTLES_DOWN; y++) { const float PIXEL_SIZE = 1f / 16f; Vector2 uc = Random.insideUnitCircle * 0.2f; Vector3 pos = new Vector3(x - (float)(CASTLES_ACROSS - 1) / 2f + uc.x, y - (float)(CASTLES_DOWN - 1) / 2f + uc.y, 0); pos.x = pos.x * 1.6f - 0.15f; pos.y *= 1.4f; pos.x -= pos.x % PIXEL_SIZE; pos.y -= pos.y % PIXEL_SIZE; GameObject gOb = (GameObject)Instantiate(Resources.Load("Prefabs/Castle_prefab"), pos, Quaternion.identity); gOb.name = "Castle ( " + x + ", " + y + ")"; Castle newCastle = gOb.GetComponent <Castle>(); newCastle.controller = this; if (x == CASTLES_ACROSS - 1 && y == CASTLES_DOWN - 1) { //Player castle Person p = dg.GetUnlandedMember(player_dynasty); Debug.Assert(p != null); p.holding = newCastle; newCastle.liege = p; } else { int dynasty = Random.Range(0, ai_dynasties.GetUpperBound(0) + 1); int count = 0; Person p = null; while (null == p && count <= ai_dynasties.GetUpperBound(0)) { int dynIndex = (dynasty + count) % (ai_dynasties.GetUpperBound(0) + 1); p = dg.GetUnlandedMember(ai_dynasties[dynIndex]); if (null != p) { newCastle.max_troops = Random.Range(7 - p.GetRank(), 18 - 2 * p.GetRank()); newCastle.troops = newCastle.max_troops; newCastle.liege = p; p.holding = newCastle; Debug.Log("Adding castle(" + x + ", " + y + ") to person " + p.GetName()); } else { Debug.Log("Dynasty " + dynIndex + " has ran out of unlanded members."); } count++; } if (null == p) { Destroy(gOb); } } } } }