// Update is called once per frame void Update() { if (model.target.Model.identityType == IdentityType.Government) { GovernmentModel gov = (GovernmentModel)model.target.Model; Button button = mainInfo[mainInfo.Count - 1]; double totalInfluence = 0; foreach (SolarModel star in gov.stars) { totalInfluence += star.governmentInfluence; } button.GetComponentInChildren <Text>().text = "Total Influence:" + totalInfluence; } }
/// <summary> /// Finds a space in the galazy for a new government,and then sets the stars as that government's space /// </summary> /// <param name="model">The government model to set</param> /// <returns></returns> private int FindGovernmentStar(GovernmentModel model) { int outTime = 0; while (true) { int index = UnityEngine.Random.Range(0, game.data.stars.Count); if (game.data.stars[index].government.Model == null) { bool freeSpace = true; foreach (SolarModel star in game.data.stars[index].nearStars) { if (star.government.Model != null) { freeSpace = false; } } if (freeSpace) //Found spot { game.data.stars[index].government.Model = model; model.stars.Add(game.data.stars[index]); game.data.stars[index].isCapital = true; foreach (SolarModel star in game.data.stars[index].nearStars) { star.government.Model = model; model.stars.Add(star); } return(index); } } outTime++; if (outTime > 1000) { print("Find Star timed out"); return(-1); } } }
public CompanyModel(string _name, GovernmentModel gov, CreatureModel _ceo) { name = _name; ceo.Model = _ceo; governmentAccess.Add(gov); }
protected override void OnInitialize() { if (model.target.Model.identityType == IdentityType.Government) { GovernmentModel gov = (GovernmentModel)model.target.Model; Button name = Instantiate(uiButtonInstance, contentPosition.transform); name.GetComponent <Image>().color = gov.spriteColor; mainInfo.Add(name); name.onClick.AddListener(() => GameManager.instance.GoToTarget(model.target.Model)); name.GetComponentInChildren <Text>().text = gov.name; Button button = Instantiate(uiButtonInstance, contentPosition.transform); mainInfo.Add(button); button.GetComponentInChildren <Text>().text = "Leader: " + gov.leaders[0]; button = Instantiate(uiButtonInstance, contentPosition.transform); mainInfo.Add(button); button.GetComponentInChildren <Text>().text = "Capital: " + gov.location.Model.name; button.onClick.AddListener(() => GameManager.instance.OpenInfoPanel(gov.location.Model)); button.GetComponent <Image>().color = gov.location.Model.spriteColor; button = Instantiate(uiButtonInstance, contentPosition.transform); mainInfo.Add(button); button.GetComponentInChildren <Text>().text = "Money: " + gov.money; button = Instantiate(uiButtonInstance, contentPosition.transform); mainInfo.Add(button); button.GetComponentInChildren <Text>().text = "Star Count:" + gov.stars.Count; double totalInfluence = 0; foreach (SolarModel star in gov.stars) { totalInfluence += star.governmentInfluence; } button = Instantiate(uiButtonInstance, contentPosition.transform); mainInfo.Add(button); button.GetComponentInChildren <Text>().text = "Total Influence:" + totalInfluence; } else if (model.target.Model.identityType == IdentityType.Station) { StationModel station = (StationModel)model.target.Model; Button name = Instantiate(uiButtonInstance, contentPosition.transform); name.GetComponent <Image>().color = station.spriteColor; mainInfo.Add(name); name.onClick.AddListener(() => GameManager.instance.GoToTarget(model.target.Model)); name.GetComponentInChildren <Text>().text = station.name; Button button = Instantiate(uiButtonInstance, contentPosition.transform); mainInfo.Add(button); button.GetComponentInChildren <Text>().text = "Owner: " + station.owner.Model.name; button = Instantiate(uiButtonInstance, contentPosition.transform); mainInfo.Add(button); button.GetComponentInChildren <Text>().text = "Manager: " + station.manager.Model.name; button = Instantiate(uiButtonInstance, contentPosition.transform); mainInfo.Add(button); button.GetComponentInChildren <Text>().text = "Money: " + station.money; button = Instantiate(uiButtonInstance, contentPosition.transform); mainInfo.Add(button); button.GetComponentInChildren <Text>().text = "Input Goods:"; foreach (Items item in station.factory.inputItems) { button = Instantiate(uiButtonInstance, contentPosition.transform); mainInfo.Add(button); button.GetComponentInChildren <Text>().text = item.name + ": " + item.amount + " (" + item.pendingAmount + ")"; button.GetComponent <Image>().color = item.color; } button.GetComponentInChildren <Text>().text = "Output Goods:"; foreach (Items item in station.factory.outputItems) { button = Instantiate(uiButtonInstance, contentPosition.transform); mainInfo.Add(button); button.GetComponentInChildren <Text>().text = item.name + ": " + item.amount + " (" + item.pendingAmount + ")"; button.GetComponent <Image>().color = item.color; } } }
/// <summary> /// Updates all the government bodies per frame /// </summary> /// <returns></returns> IEnumerator UpdateGovernments() { int govIndex = 0; while (true) { GovernmentModel model = data.governments[govIndex]; foreach (SolarModel star in model.stars) { double deltaTime = data.date.time - model.age.time - model.dateCreated.time; model.age.AddTime(deltaTime); double totalPop = 0; //foreach (SolarBody body in star.solar.satelites) //{ // totalPop += body.population; // foreach (SolarBody moon in body.satelites) // { // totalPop += moon.population; // } //} //foreach (StationModel station in star.stations) //{ // totalPop += station.population; //} //star.governmentInfluence += (totalPop * .001f * (float) data.date.deltaTime) - (star.governmentInfluence * .1f * (float)data.date.deltaTime); foreach (SolarModel nearStar in star.nearStars) { nearStar.governmentInfluence += star.governmentInfluence * .1f * (float)data.date.deltaTime; star.governmentInfluence -= star.governmentInfluence * .1f * (float)data.date.deltaTime; if (galaxy.mapButtonCanvases.Count > 0 && galaxyView) { nearStar.localScale = Mathf.Pow(nearStar.governmentInfluence, .6f) + 1f; } if (nearStar.governmentInfluence > 250 && nearStar.government.Model == null) { nearStar.government.Model = star.government.Model; model.stars.Add(nearStar); if (galaxy.mapButtonCanvases.Count > 0) { nearStar.color = star.government.Model.spriteColor; } } nearStar.NotifyChange(); } star.NotifyChange(); //if (star.governmentInfluence < 250) //{ // star.government.Model = null; // star.color = Color.grey; // model.stars.Remove(star); // //} yield return(null); } govIndex++; if (govIndex >= data.governments.Count) { govIndex = 0; } } }