예제 #1
0
        protected void update_dying_units()
        {
            if (Dying_Units.Count > 0)
            {
                if (Global.scene.is_message_window_active)
                {
                    return;
                }
                if (Waiting_To_Play_Death_Sound)
                {
                    Global.Audio.play_se("Map Sounds", "Death");
                    Waiting_To_Play_Death_Sound = false;
                }
                bool skip_true_dying  = True_Dying_Units.Count < Automated_Dying_Units.Count;
                bool automated_only   = true;
                bool unit_true_killed = false;
                int  i = 0;
                while (i < Dying_Units.Count)
                {
                    Game_Unit dying_unit = this.units[Dying_Units[i]];
                    // Handle all not truly dying units before all truly dying units
                    if (skip_true_dying && True_Dying_Units.Contains(Dying_Units[i]))
                    {
                        i++;
                        continue;
                    }

                    if (Automated_Dying_Units.Contains(Dying_Units[i]))
                    {
                        dying_unit.update_attack_graphics(); //Debug
                    }
                    else
                    {
                        automated_only = false;
                    }

                    if (!dying_unit.changing_opacity())
                    {
                        // If the unit is dying from an event
                        if (Automated_Dying_Units.Contains(Dying_Units[i]))
                        {
                            // If the unit is also actually being killed
                            if (True_Dying_Units.Contains(Dying_Units[i]))
                            {
                                True_Dying_Units.Remove(Dying_Units[i]);
                                dying_unit.kill();
                                unit_true_killed = true;
                            }
                            // Else just remove them from the map as events normally do
                            else
                            {
                                add_unit_move_range_update(dying_unit);
                                remove_unit(Dying_Units[i]);
                            }
                            Automated_Dying_Units.Remove(Dying_Units[i]);
                        }
                        //else if (Units[Dying_Units[i]].is_dead) //Debug
                        //    Units[Dying_Units[i]].kill();
                        Dying_Units.RemoveAt(i);
                    }
                    else
                    {
                        i++;
                    }
                }
                if (unit_true_killed)
                {
                    refresh_move_ranges();
                    Global.game_map.wait_for_move_update();
                    Global.game_state.any_trigger_events();
                }
                //if (Dying_Units.Count == 0 && automated_only) //Debug
                //    refresh_move_ranges();
            }
        }