private void Level_RemovedItem(Item item) { if (Units.ContainsKey(item)) { Units.Remove(item); } }
protected void set_animation_mode(int id1, int id2, bool fighting, Combat_Data data) { bool scene_battle = is_scene_battle(id1, id2, fighting, data); // If not using map battle mode, ensure battlers actually have sprites for scene battle mode if (scene_battle) { foreach (int id in new int[] { id1, id2 }) { if (!Units.ContainsKey(id)) { scene_battle = false; break; } Game_Unit unit = Units[id]; var battlerData = new BattlerSpriteData(unit); if (!battlerData.AnimData(Global.game_state.dance_active && id == id1).ValidAnim) { scene_battle = false; break; } } } Global.game_system.Battle_Mode = scene_battle ? Constants.Animation_Modes.Full : Constants.Animation_Modes.Map; }
public bool IsValidCity(HexCorner corner, PlayerColor color) { if (Units.ContainsKey(corner) && Units[corner].Type == UnitTypes.Settlement && Units[corner].Color == color) { return(true); } return(false); }
public int GetUnitTotalCount(int generatorId) { if (!Units.ContainsKey(generatorId)) { return(0); } return(Units[generatorId].TotalCount); }
private Unit GetUnitForUpdate(UnitUpdate u) { if (!Units.ContainsKey(u.Id)) { Units[u.Id] = new Unit(); } return(Units[u.Id]); }
public static Unit GetUnit(string key) { if (Units == null) { Units = new Dictionary <string, Unit>(); } return(Units.ContainsKey(key) ? Units[key] : null); }
public void AddUnit(HexCorner intersection, Unit unit) { //if something's already there, delete it if (Units.ContainsKey(intersection)) { GameObject.Destroy(Units[intersection]); Units.Remove(intersection); } Units.Add(intersection, unit); }
public void SetLiveUnits(int generatorId, int count) { int oldCount = 0; if (Units.ContainsKey(generatorId)) { oldCount = Units[generatorId].LiveCount; } Units[generatorId].SetLive(count); GameEvents.OnGeneratorUnitsCountChanged(Units[generatorId]); }
public int Repair(int generatorId, int count) { if (Units.ContainsKey(generatorId)) { var unitInfo = Units[generatorId]; int repaired = unitInfo.Repair(count); GameEvents.OnGeneratorUnitsCountChanged(unitInfo); return(repaired); } return(0); }
public TransportUnitInfo GetUnit(int generatorId) { if (Units.ContainsKey(generatorId)) { return(Units[generatorId]); } else { TransportUnitInfo unit = new TransportUnitInfo(generatorId, 0); Units.Add(generatorId, unit); return(unit); } }
public void AddLiveUnits(int generatorId, int count) { int oldCount = 0; if (Units.ContainsKey(generatorId)) { oldCount = Units[generatorId].LiveCount; Units[generatorId].AddLive(count); } else { Units.Add(generatorId, new TransportUnitInfo(generatorId, count)); } GameEvents.OnGeneratorUnitsCountChanged(Units[generatorId]); }
protected void setup_aoe_battle() { In_Battle = true; In_Staff_Use = Staff_Calling; In_Aoe = true; Aoe_Calling = false; Battle_Calling = false; Staff_Calling = false; Global.game_system.Battle_Mode = Constants.Animation_Modes.Map; Skip_Battle = Global.game_state.skip_ai_turn_activating; // Check if should stop skipping AI turn if (Skip_Battle) { // Check for talk events foreach (int target_id in Global.game_system.Aoe_Targets) { if (get_scene_map().check_talk(Units[Global.game_system.Battler_1_Id], Units[target_id], false, true)) { switch_out_of_ai_skip(this, new EventArgs()); Skip_Battle = false; break; } } if (Skip_Battle) { // Check for death quotes etc Global.game_system.save_rns(); set_aoe_data(Global.game_system.Battler_1_Id, Global.game_system.Aoe_Targets); var combat_data = Map_Combat_Data; if (combat_data.is_ally_killed || combat_data.has_death_quote || combat_data.has_item_drop || combat_data.has_promotion || (Units.ContainsKey(Global.game_system.Battler_2_Id) && get_scene_map().check_talk( Units[Global.game_system.Battler_1_Id], Units[Global.game_system.Battler_2_Id], false, true))) { switch_out_of_ai_skip(this, new EventArgs()); Skip_Battle = false; } Global.game_system.readd_saved_rns(); } if (Skip_Battle) { int test = 0; } } Map_Combat_Data = null; }
private IEnumerable <int> GetSupportGainReady(bool ready) { if (!InSupportGain || this.supporter == null) { yield break; } // Check active unit bool activeReady = false; foreach (int id in SupportTargets) { if (!Units.ContainsKey(id)) { continue; } if (this.supporter.actor.is_support_ready(Units[id].actor.id)) { activeReady = true; break; } } if (activeReady ^ !ready) { yield return(Support_Id1); } // Check targets foreach (int id in SupportTargets) { if (!Units.ContainsKey(id)) { continue; } if (this.supporter.actor.is_support_ready(Units[id].actor.id) ^ !ready) { yield return(id); } } }
public bool IsValidRoad(PlayerColor color, HexEdge edge) { if (Roads.ContainsKey(edge)) { return(false); } if (CornerGraph.IsOutOfRange(edge.Start) || CornerGraph.IsOutOfRange(edge.End)) { return(false); } if (coordinator.GameState.State == GameStates.Setup) { //check if there's a settlement on one of the road's corners if (!((Units.ContainsKey(edge.Start) && Units[edge.Start].Color == color) || (Units.ContainsKey(edge.End) && Units[edge.End].Color == color))) { return(false); } } return(true); }
protected override void Update() { foreach (var command in FindUnitCommands.Where(c => c.HasResponses)) { var responses = command.GetResponses(); var ids = responses[responses.Count - 1].Unpack <UpSearchObjectIdListResult>().Result.ToArray(); foreach (var id in ids) { if (!Units.ContainsKey(id)) { _Units.Add(id, new Unit(Bot, id)); } } } foreach (var command in FindAllUnitsCommands.Where(c => c.HasResponses)) { var responses = command.GetResponses(); for (int i = 4; i < responses.Count; i += 3) { var ids = responses[i].Unpack <UpSearchObjectIdListResult>().Result; foreach (var id in ids) { if (!Units.ContainsKey(id)) { _Units.Add(id, new Unit(Bot, id)); } } } } CreateCommands.Clear(); FindUnitCommands.Clear(); FindAllUnitsCommands.Clear(); }
/// <summary> /// Determines whether this <see cref="Army"/> contains any units of the given type. /// </summary> /// <param name="type">The type of unit to check for.</param> /// <returns>True if this <see cref="Army"/> contains any units of the given type; false otherwise.</returns> public bool Contains(UnitType type) { return(Units.ContainsKey(type)); }
private bool is_scene_battle(int id1, int id2, bool fighting, Combat_Data data) { if (Skip_Battle) { return(false); } if (Global.game_temp.scripted_battle) { return(Global.game_temp.scripted_battle_stats.scene_battle); } if (Scene_Map.intro_chapter_options_blocked()) { return(true); } // If map animation forced, for various reasons else if ((In_Staff_Use && ((Staff_Data)data).mode == Staff_Modes.Torch) || Units[id1].trample_activated) // make this not hardcoded //Debug { return(false); } // If either battler is a boss, or it's a scripted battle with animations forced, always go to the full battle scene else if (fighting && (Global.game_temp.scripted_battle || is_boss_anim_forced(id1, id2))) { return(true); } bool scene_battle = true; switch ((Constants.Animation_Modes)Global.game_options.animation_mode) { // If solo animation mode, get the animation mode the fighting units should use case Constants.Animation_Modes.Solo: scene_battle = false; // Healing staff use or Dancing if ((In_Staff_Use || Global.game_state.dance_active) && id2 != -1 && !Units[id1].is_attackable_team(Units[id2])) { foreach (int id in new int[] { id1 }) { if (id != -1 && !scene_battle) { if (Units.ContainsKey(id) && Units[id].is_ally && !Global.game_actors.is_temp_actor(Units[id].actor)) { if (Units[id].actor.individual_animation != (int)Constants.Animation_Modes.Map) { scene_battle = (Constants.Animation_Modes)Units[id].actor.individual_animation == Constants.Animation_Modes.Full; } } } } } // Anything else else { foreach (int id in new int[] { id1, id2 }) { if (id != -1 && !scene_battle) { if (Units.ContainsKey(id) && Units[id].is_ally && !Global.game_actors.is_temp_actor(Units[id].actor)) { if (Units[id].actor.individual_animation != (int)Constants.Animation_Modes.Map) { scene_battle = (Constants.Animation_Modes)Units[id].actor.individual_animation == Constants.Animation_Modes.Full; } } } } } break; case Constants.Animation_Modes.Full: scene_battle = true; break; case Constants.Animation_Modes.Map: scene_battle = false; break; case Constants.Animation_Modes.Player_Only: scene_battle = Constants.Team.PLAYABLE_TEAMS.Contains(Team_Turn); break; } // Switch animation mode if holding L // Also switch modes if pressing on the screen? //Debug if (Global.Input.pressed(Inputs.L) || Global.Input.touch_pressed(false)) { scene_battle = !scene_battle; } return(scene_battle); }
internal override void update() { if (Shop_Suspend > 0) { switch (Shop_Suspend) { case 4: if (Global.game_state.arena) { Game_Unit unit = Units[Global.game_system.Shopper_Id]; if (unit.is_dead) { Global.game_map.add_dying_unit_animation(unit.id); } } else { Global.scene.suspend(); } break; case 3: if (Global.game_state.arena) { Game_Unit unit = Units[Global.game_system.Shopper_Id]; if (unit.is_dead) { unit.update_attack_graphics(); if (unit.changing_opacity()) { return; } } } break; case 2: if (Global.game_state.arena) { Game_Unit unit = Units[Global.game_system.Shopper_Id]; if (unit.is_dead) { unit.kill(); Global.game_map.remove_unit(unit.id); Global.game_system.Selected_Unit_Id = -1; } } break; case 1: if (Units.ContainsKey(Global.game_system.Shopper_Id)) { Game_Unit unit = Units[Global.game_system.Shopper_Id]; if (unit.has_canto() && unit.ready && !Global.game_state.arena) { unit.cantoing = true; unit.open_move_range(); } else if (Global.game_state.arena && !Global.game_system.In_Arena) { unit.start_wait(); } } Global.game_system.Shopper_Id = -1; Global.game_temp.menuing = false; Global.game_state.arena = Global.game_system.In_Arena; break; } Shop_Suspend--; } }
public int GetUnitBrokenedCount(int generatorId) => Units.ContainsKey(generatorId) ? Units[generatorId].BrokenedCount : 0;
private void _loadSimulationButton_Click(object sender, RoutedEventArgs e) { // Show dialog OpenFileDialog dialog = new OpenFileDialog { Filter = "Simulation files (*.balancingsim)|*.balancingsim", Title = "Load simulation..." }; if (!(dialog.ShowDialog() ?? false)) { return; } // Catch errors occuring while reading try { // Load file into buffer RAMBuffer buffer = new RAMBuffer(dialog.FileName); // Check version int version = buffer.ReadInteger(); if (version > Version) { throw new ArgumentException("The given file was created with a newer version of this program, please consider updating."); } // Read civs _civ1ComboBox.SelectedValue = buffer.ReadShort(); _civ2ComboBox.SelectedValue = buffer.ReadShort(); // Merge tech lists int count1 = buffer.ReadInteger(); HashSet <short> res1 = new HashSet <short>(); for (int i = 0; i < count1; i++) { res1.Add(buffer.ReadShort()); } foreach (var res in Researches1) { res.Checked = res1.Contains(res.Id); } int count2 = buffer.ReadInteger(); HashSet <short> res2 = new HashSet <short>(); for (int i = 0; i < count2; i++) { res2.Add(buffer.ReadShort()); } foreach (var res in Researches2) { res.Checked = res2.Contains(res.Id); } // Read duels int count = buffer.ReadInteger(); Duels.Clear(); for (int i = 0; i < count; i++) { short id1 = buffer.ReadShort(); short id2 = buffer.ReadShort(); if (!Units.ContainsKey(id1) || !Units.ContainsKey(id2)) { continue; } Duels.Add(new Duel(id1, Units[id1], id2, Units[id2])); } } catch (Exception ex) { // Error MessageBox.Show($"Unable to load given file: {ex.Message}"); } }
private bool is_boss_anim_forced(int id1, int id2) { return(Constants.Map.FORCE_BOSS_ANIMATIONS && (Units[id1].boss || (Units.ContainsKey(id2) && Units[id2].boss))); }