public void MoveSoldiers() { // Debug.LogError("Entered MS function"); try { bool enough_AP = intendant.action_points >= 1; bool enough_MP = intendant.ProtagonistState.GetComponent <stategen>().Balance >= MoveCost; bool common_border = intendant.selected_province.GetComponent <provincegen>().connections.Contains(intendant.selected_passive_province.GetComponent <provincegen>().GetId()); stategen current_stategen = intendant.ProtagonistState.GetComponent <stategen>(); bool self_ally_or_enemy = (intendant.ProtagonistState == intendant.selected_passive_province.GetComponent <provincegen>().state) || (current_stategen.Allies.Contains(intendant.selected_passive_province.GetComponent <provincegen>().state)) || (current_stategen.Enemyes.Contains(intendant.selected_passive_province.GetComponent <provincegen>().state)); // Debug.Log(String.Format("{0}, {1}, {2}, {3}", enough_AP, enough_MP, common_border, self_ally_or_enemy)); if (enough_AP && enough_MP && self_ally_or_enemy && common_border) { // Debug.LogError(String.Format(" 1 Moved {0} from {1} to {2}", PeopleToMove, intendant.selected_province, intendant.selected_passive_province)); Consequentor.MoveSoldiers(intendant.selected_province, intendant.selected_passive_province, PeopleToMove); // Debug.LogError(String.Format(" 2 Moved {0} from {1} to {2}", PeopleToMove, intendant.selected_province, intendant.selected_passive_province)); intendant.SpendMoney(MoveCost); intendant.SpendActionPoints(1); intendant.selected_province.GetComponent <provincegen>().army -= PeopleToMove; intendant.UpdateMode(); UpdateInfo(); } } catch (Exception) { } }
public static void WorsenPoliticalRelations(GameObject state1, GameObject state2) { stategen gen1 = state1.GetComponent <stategen>(); stategen gen2 = state2.GetComponent <stategen>(); Vector2 coords1 = gen1.diplomacy_coords; Vector2 coords2 = gen2.diplomacy_coords; Vector2 delta = (coords2 - coords1) * 0.25f; gen1.diplomacy_coords = coords1 - delta; gen2.diplomacy_coords = coords2 + delta; }
public void EnterPoliticalCoordsOK() { PoliticalCoordsMenuBackground.SetActive(false); ChangeMode(POLITICAL_MODE); UpdateBalance(); UpdateActions(); UpdateStep(); stategen protagonist_stategen = ProtagonistState.GetComponent <stategen>(); protagonist_stategen.Balance = initial_MP; UpdateBalance(); protagonist_stategen.GetCivilianTax(); protagonist_stategen.GetProductionTax(); protagonist_stategen.GetArmyOutcome(); }//Executor
// Update is called once per frame public void UpdateInfo() { // Debug.LogError(intendant); provincegen current_provincegen = intendant.selected_province.GetComponent <provincegen>(); stategen current_stategen = intendant.ProtagonistState.GetComponent <stategen>(); MaxPeopleToConscript = (int)((float)current_provincegen.population / 2); MaxPeopleToDemobilize = current_provincegen.army; MaxPeopleToMove = current_provincegen.army; PeopleToConscript = 0; PeopleToDemobilize = 0; PeopleToMove = 0; ConscriptSlider.value = 0; DemobilizeSlider.value = 0; MoveSlider.value = 0; }
public void SelectState(GameObject state) { try { selected_state.GetComponent <stategen>().ChangeSelection(); } catch (Exception) { } stategen current_stategen = state.GetComponent <stategen>(); selected_state = state; current_stategen.ChangeSelection(); if (mode == DIPLOMACY_MODE && state != ProtagonistState) { OpenMenu(DiplomacyMenu); diplomacyManager.UpdateInfo(); } }
void ConsoleManager(string command) // manager { Debug.LogError(command); if (command.Contains("capture")) { string[] args = command.Split('(')[1].Split(')')[0].Split(','); // intendant.CaptureProvince(Convert.ToInt32(args[0]), Convert.ToInt32(args[1])); } else if (command.Contains("changemode")) { string[] args = command.Split('(')[1].Split(')')[0].Split(','); intendant.ChangeMode(Convert.ToInt32(args[0])); } else if (command.Contains("ecinfo")) { try { stategen state = intendant.ProtagonistState.GetComponent <stategen>(); Debug.LogError("Economic info"); Debug.LogError(String.Format("Foreign Trade is {0}", state.ForeignTrade)); Debug.LogError(String.Format("Investments is {0}", state.Investments)); Debug.LogError(String.Format("Foreign Trade is {0}", state.Researches)); Debug.LogError(String.Format("Army is {0}", state.Army)); Debug.LogError(String.Format("CivTax is {0}", state.CivilianTax)); Debug.LogError(String.Format("ProdTax is {0}", state.ProductionTax)); } catch (Exception) { Debug.LogError("Error occured"); } } else if (command.Contains("givemoney")) { intendant.ProtagonistState.GetComponent <stategen>().Balance += 1000; intendant.UpdateBalance(); } }
public void setState(GameObject new_state) { state = new_state.GetComponent <stategen>(); }
// Start is called before the first frame update void Start() { state = gameObject.GetComponent <stategen>(); intendant = GameObject.Find("Intendant").GetComponent <intendant>(); Consequentor = GameObject.Find("Consequentor").GetComponent <consequentor>(); }
// блок функций для взаимодейтвия с главными параметрами public void Step() { step++; UpdateStep(); action_points = 10; UpdateActions(); // так бля пора обрабатывать детерминаторы foreach (GameObject state in list_of_states) { stategen st = state.GetComponent <stategen>(); for (int i = 0; i < st.list_of_provinces.Count; i++) { if (st.list_of_provinces[i].GetComponent <provincegen>().state != state) { Debug.LogError(st); } } if (state != ProtagonistState) { state.GetComponent <Determinator>().Determinate(); } } // так бля пока запускать консеквентор Consequentor.Simulate(); // так бля пора собирать налоги foreach (GameObject state in list_of_states) { stategen st = state.GetComponent <stategen>(); int people_growth = 0, prod_growth = 0, edu_growth = 0; if (state == ProtagonistState) { people_growth = (int)((st.GetCivilianTax() + st.GetProductionTax()) * st.ForeignTrade); prod_growth = (int)((st.GetCivilianTax() + st.GetProductionTax()) * st.Investments); edu_growth = (int)((st.GetCivilianTax() + st.GetProductionTax()) * st.Researches); } else { people_growth = (int)((float)(st.political_coords.x + 10) / 200f * st.GetPopulation()); prod_growth = (int)((float)(st.political_coords.x - 10) / -200f * st.GetProduction()); edu_growth = (int)((float)(st.political_coords.y - 10) / -200f * st.GetEducation()); } for (int i = 0; i < edu_growth; i++) { st.list_of_provinces[UnityEngine.Random.Range(0, st.list_of_provinces.Count)].GetComponent <provincegen>().education++; } for (int i = 0; i < prod_growth; i++) { st.list_of_provinces[UnityEngine.Random.Range(0, st.list_of_provinces.Count)].GetComponent <provincegen>().productions++; } for (int i = 0; i < people_growth; i++) { st.list_of_provinces[UnityEngine.Random.Range(0, st.list_of_provinces.Count)].GetComponent <provincegen>().population++; } } stategen protst = ProtagonistState.GetComponent <stategen>(); SpendMoney(-1 * protst.proficite); UpdateMode(); protst.RestructBudget(); Debug.Log(CheckDiplomacyWin()); if (CheckSquareWin() || CheckEconomicWin() || CheckDiplomacyWin() || CheckSeparatismWin()) { EndGameMenu.SetActive(true); } if (ProtagonistState.GetComponent <stategen>().list_of_provinces.Count == 0 || step > 100) { EndGameMenu.SetActive(false); EndGameText.text = "You lose"; } }