Exemplo n.º 1
0
        /// <summary>
        /// after changing out the social map we need to see if the current residents
        /// still have enough area to survive.
        /// </summary>
        /// <param name="newSocialMap">The new map to check area against</param>
        private void resetResidentsHomeRange(Map newSocialMap)
        {
            try
            {
                MapManager      mm = MapManager.GetUniqueInstance();
                List <Resident> r  = this.getResidents();
                mLog.Debug("inside resetResidentsHomeRange we are going to loop through " + r.Count.ToString() + " residents");
                foreach (Resident a in r)
                {
                    mLog.Debug("my animals location is " + a.HomeRangeCenter.X.ToString() + " " + a.HomeRangeCenter.Y.ToString());
                    mLog.Debug("now going to try and build a home range with the map manager");
                    if (mm.BuildHomeRange(a))
                    {
                        mLog.Debug("built it ");
                    }
                    else
                    {
                        mLog.Debug("could not create one");
                        a.TextFileWriter.addLine("Not enough suitable habitat after map switch.");
                        mLog.Debug("calling changeToDeadAnimal");
                        this.changeToDeadAnimal(a);
                        mLog.Debug("new animal type is " + a.GetType());
                        //now reset the social map to not occupied for that resident.
                        AdjustMapForDeadAnimal(newSocialMap, a);
                    }
                }
                mLog.Debug("leaving resetResidentsHomeRange");
            }
            catch (System.Exception ex)
            {
#if (DEBUG)
                System.Windows.Forms.MessageBox.Show(ex.Message);
#endif
                eLog.Debug(ex);
            }
        }