// Update is called once per frame void Update() { if (PlayerManager.Gamestate == gamestate.sea_levels_rose) { return; } if (humans) { bool p1Back = RCI.GetButton(XboxCtrlrInput.XboxButton.Back, player_data.controllers[(int)player.A]); bool p2Back = RCI.GetButton(XboxCtrlrInput.XboxButton.Back, player_data.controllers[(int)player.B]); controls_display.SetActive(p1Back || p2Back); } else { if (MultiDisplayScript.singleDisplay) { bool p1Back = RCI.GetButton(XboxCtrlrInput.XboxButton.Back, player_data.controllers[(int)player.A]); bool p2Back = RCI.GetButton(XboxCtrlrInput.XboxButton.Back, player_data.controllers[(int)player.B]); if (!(p1Back || p2Back)) { controls_display.SetActive(RCI.GetButton(XboxCtrlrInput.XboxButton.Back, player_data.controllers[(int)player.Earth])); } } else { controls_display.SetActive(RCI.GetButton(XboxCtrlrInput.XboxButton.Back, player_data.controllers[(int)player.Earth])); } } }
// Called every frame private void Update() { dummy_earthquake.gameObject.SetActive(disaster.isDisasterQueued()); if (disaster.isDisasterQueued()) { // Earthquake logic angular_velo = 0; if (RCI.GetButtonDown(XboxButton.X, Reticle.controller)) { disaster.causeDisaster(transform.position, disaster.earthquake_radius); disaster.setDisaster(false); dummy_earthquake.gameObject.SetActive(false); angular_velo = base_angular_velo; } } else if (!(PlayerManager.Gamestate == gamestate.sea_levels_rose)) { // Rainstorm logic if (RCI.GetButtonDown(XboxButton.X, Reticle.controller) && Time.time > next_rainstorm) { if (Physics2D.RaycastAll(transform.position, Vector2.zero).Length >= 2) { next_rainstorm = Time.time + rainstorm.rainstorm_time - 0.5f; Instantiate(rainstorm, transform.position, Quaternion.identity); } } // Tree-growing logic if (RCI.GetButton(XboxButton.A, Reticle.controller) || Input.GetKey(KeyCode.T)) { cell_controller.instance.growTrees(transform.position, tree_growth_radius, Time.deltaTime * tree_growth_rate); last_tree_time = Time.time; angular_velo += angular_accel * Time.deltaTime; } else { angular_velo -= angular_accel * Time.deltaTime * 1.5f; } angular_velo = Mathf.Clamp(angular_velo, base_angular_velo, max_angular_velo); // Animal-placing (deer) logic: if (RCI.GetButtonDown(XboxButton.Y, Reticle.controller) && Time.time > next_deer) { if (Physics2D.RaycastAll(transform.position, Vector2.zero).Length >= 2) { next_deer = Time.time + deer_cooldown; Instantiate(Deer, transform.position, Quaternion.identity); //int deer_total = FindObjectsOfType<deer>().Length; //if (deer_total < 3) { //} last_deer_time = Time.time; } } if (RCI.GetButtonDown(XboxButton.B, Reticle.controller)) { if (Physics2D.RaycastAll(transform.position, Vector2.zero).Length >= 2 && Time.time > next_wolf) { next_wolf = Time.time + wolf_cooldown; Instantiate(Wolf, transform.position, Quaternion.identity); //int wolf_total = FindObjectsOfType<wolf>().Length; //if (wolf_total < 3) { //} } } } // Rotate according to angular velocity angular_velo = Mathf.Clamp(angular_velo, 0, max_angular_velo); transform.Rotate(new Vector3(0, 0, angular_velo)); }
// Update is called once per frame void Update() { // START_TO_JOIN if (Gamestate == gamestate.start_to_join) { // Check for players hitting start to join if (RCI.GetButton(XboxButton.Start, XboxController.First)) { p1Reticle.SetActive(true); p1JoinText.SetActive(false); } if (RCI.GetButton(XboxButton.Start, XboxController.Second)) { p2Reticle.SetActive(true); p2JoinText.SetActive(false); } // Check if for state change if (p1Reticle.activeSelf && p2Reticle.activeSelf) { Gamestate = gamestate.playing; timer_TMP.gameObject.SetActive(true); p1StartArea.Owner = player.A; p2StartArea.Owner = player.B; update_timer_text(); } return; } // PLAYING if (Gamestate == gamestate.playing) { // Check for one player eliminated bool pA_elim = true; bool pB_elim = true; foreach (region Region in region.allRegions) { pA_elim = (pA_elim && Region.Owner != player.A); pB_elim = (pB_elim && Region.Owner != player.B); if (!pA_elim && !pB_elim) { break; } } pA_elim = pA_elim && !moving_units.pA_has_units; pB_elim = pB_elim && !moving_units.pB_has_units; if (pA_elim || pB_elim) { // Pull up win-screen Gamestate = gamestate.winscreen; timer_TMP.gameObject.SetActive(false); winner_TMP.gameObject.SetActive(true); if (pA_elim ? (policy_manager.policies[(int)player.B] == policy.industry) : (policy_manager.policies[(int)player.A] == policy.industry)) { Winstate = winstate.ind; } else { Winstate = winstate.eco; } string empire_won = pA_elim ? "Blue" : "Red"; winner_TMP.text = "The " + empire_won + " Empire is victorious"; timer = winscreen_time; return; } moving_units.pA_has_units = false; moving_units.pB_has_units = false; // Otherwise, iterate the timer timer -= Time.deltaTime; if (timer > 0) { update_timer_text(); } else { // Pull up tie screen Gamestate = gamestate.winscreen; Winstate = winstate.tie; timer_TMP.gameObject.SetActive(false); winner_TMP.gameObject.SetActive(true); winner_TMP.text = "Both empires lived on..."; timer = winscreen_time; } return; } // WINSCREEN if (Gamestate == gamestate.winscreen) { timer -= Time.deltaTime; if (timer > 0) { // This is fine. Waiting for delay to end } else if (status_controller.instance.airLevel < 0.1 || status_controller.instance.temperatureLevel < 0.1) { // Sea levels rose Gamestate = gamestate.sea_levels_rose; winner_TMP.gameObject.SetActive(false); sea_levels_rose_TMP.gameObject.SetActive(true); sea_level_timer = human_playtime; // Set TMP text based on if it's a tie, or one empire if (Winstate == winstate.tie) { sea_levels_rose_TMP.text = "But as sea levels rose, so each empire fell..."; } else { sea_levels_rose_TMP.text = "But as sea levels rose, so the empire fell..."; } } else { // Empires fall Gamestate = gamestate.empires_falling; winner_TMP.gameObject.SetActive(false); empires_fall_TMP.gameObject.SetActive(true); } return; } // EMPIRES FALLING if (Gamestate == gamestate.empires_falling) { // Wait for all regions to be neutral. foreach (region Region in region.allRegions) { if (Region.Owner != player.none) { return; } } // Once it's over: init(); return; } // SEA LEVELS ROSE if (Gamestate == gamestate.sea_levels_rose) { sea_level_timer -= Time.deltaTime; if (sea_level_timer > 0) { // This is fine if (sea_level_controller.idle) { sea_levels_rose_TMP.text = "...and there was no land left to fight for"; } } else if (Random.Range(0, 2) == 0) { // Some chance for the sea levels to stay sea_level_timer = 30; } else { // When this state ends init(); return; } } }