public static string MakeTimeDurationMessage(int turns)
        {
            // less than a hour?
            if (turns < WorldTime.TURNS_PER_HOUR)
            {
                return("less than a hour");
            }

            // less than a day?
            if (turns < WorldTime.TURNS_PER_DAY)
            {
                int hours = turns / WorldTime.TURNS_PER_HOUR;
                if (hours == 1)
                {
                    return("about 1 hour");
                }
                else
                {
                    return(string.Format("about {0} hours", hours));
                }
            }

            // day(s).
            WorldTime time = new WorldTime(turns);

            if (time.Day == 1)
            {
                return("about 1 day");
            }
            else
            {
                return(string.Format("about {0} days", time.Day));
            }
        }
Esempio n. 2
0
        public int ZombifyChance(WorldTime timeNow, bool checkDelay = true) // hypothetical AI would want the explicit parameter
        {
            const float CORPSE_ZOMBIFY_NIGHT_FACTOR      = 2f;
            const float CORPSE_ZOMBIFY_DAY_FACTOR        = 0.01f;
            const float CORPSE_ZOMBIFY_INFECTIONP_FACTOR = 1f;
            const int   CORPSE_ZOMBIFY_BASE_CHANCE       = 0;

            int num1 = timeNow.TurnCounter - Turn;

            if (checkDelay && num1 < ZOMBIFY_DELAY)
            {
                return(0);
            }
            int num2 = DeadGuy.InfectionPercent;

            if (checkDelay)
            {
                int num3 = num2 >= 100 ? 1 : 100 / (1 + num2);
                if (timeNow.TurnCounter % num3 != 0)
                {
                    return(0);
                }
            }
            float num4 = CORPSE_ZOMBIFY_BASE_CHANCE + CORPSE_ZOMBIFY_INFECTIONP_FACTOR * (float)num2 - (float)(int)((double)num1 / (double)WorldTime.TURNS_PER_DAY);

            return(Math.Max(0, Math.Min(100, (int)(num4 * (timeNow.IsNight ? CORPSE_ZOMBIFY_NIGHT_FACTOR : CORPSE_ZOMBIFY_DAY_FACTOR)))));
        }
 /// <summary>
 /// Deserialization contructor.
 /// </summary>
 /// <param name="info"></param>
 /// <param name="context"></param>
 protected Map(SerializationInfo info, StreamingContext context)
 {
     //////////////////
     // Primary fields
     //////////////////
     m_Seed                  = (int)info.GetValue("m_Seed", typeof(int));
     m_District              = (District)info.GetValue("m_District", typeof(District));
     m_Name                  = (string)info.GetValue("m_Name", typeof(string));
     m_LocalTime             = (WorldTime)info.GetValue("m_LocalTime", typeof(WorldTime));
     m_Width                 = (int)info.GetValue("m_Width", typeof(int));
     m_Height                = (int)info.GetValue("m_Height", typeof(int));
     m_Rectangle             = (Rectangle)info.GetValue("m_Rectangle", typeof(Rectangle));
     m_Tiles                 = (Tile[, ])info.GetValue("m_Tiles", typeof(Tile[, ]));
     m_Exits                 = (Dictionary <Point, Exit>)info.GetValue("m_Exits", typeof(Dictionary <Point, Exit>));
     m_Zones                 = (List <Zone>)info.GetValue("m_Zones", typeof(List <Zone>));
     m_ActorsList            = (List <Actor>)info.GetValue("m_ActorsList", typeof(List <Actor>));
     m_MapObjectsList        = (List <MapObject>)info.GetValue("m_MapObjectsList", typeof(List <MapObject>));
     m_GroundItemsByPosition = (Dictionary <Point, Inventory>)info.GetValue("m_GroundItemsByPosition", typeof(Dictionary <Point, Inventory>));
     m_CorpsesList           = (List <Corpse>)info.GetValue("m_CorpsesList", typeof(List <Corpse>));
     m_Lighting              = (Lighting)info.GetValue("m_Lighting", typeof(Lighting));
     m_Scents                = (List <OdorScent>)info.GetValue("m_Scents", typeof(List <OdorScent>));
     m_Timers                = (List <TimedTask>)info.GetValue("m_Timers", typeof(List <TimedTask>));
     // alpha10
     m_BgMusic = (string)info.GetValue("m_BgMusic", typeof(string));
 }
Esempio n. 4
0
        public Map(int seed, string name, int width, int height)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (width <= 0)
            {
                throw new ArgumentOutOfRangeException("width <=0");
            }
            if (height <= 0)
            {
                throw new ArgumentOutOfRangeException("height <=0");
            }

            m_Seed        = seed;
            m_Name        = name;
            m_Width       = width;
            m_Height      = height;
            m_Rectangle   = new Rectangle(0, 0, width, height);
            m_LocalTime   = new WorldTime();
            this.Lighting = Lighting.OUTSIDE;
            this.IsSecret = false;

            m_Tiles = new Tile[width, height];
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    m_Tiles[x, y] = new Tile(TileModel.UNDEF);
                }
            }

            m_Exits = new Dictionary <Point, Exit>();

            m_Zones = new List <Zone>(5);

            m_aux_ActorsByPosition = new Dictionary <Point, Actor>(5);
            m_ActorsList           = new List <Actor>(5);

            m_aux_MapObjectsByPosition = new Dictionary <Point, MapObject>(5);
            m_MapObjectsList           = new List <MapObject>(5);

            m_GroundItemsByPosition = new Dictionary <Point, Inventory>(5);
            m_aux_GroundItemsList   = new List <Inventory>(5);

            m_CorpsesList           = new List <Corpse>(5);
            m_aux_CorpsesByPosition = new Dictionary <Point, List <Corpse> >(5);

            m_Scents = new List <OdorScent>(128);
            m_aux_ScentsByPosition = new Dictionary <Point, List <OdorScent> >(128);

            m_Timers = new List <TimedTask>(5);
        }
Esempio n. 5
0
        public static string MakeTimeDurationMessage(int turns)
        {
            if (turns < TURNS_PER_HOUR)
            {
                return("less than a hour");
            }
            if (turns < TURNS_PER_DAY)
            {
                int num = turns / TURNS_PER_HOUR;
                if (num == 1)
                {
                    return("about 1 hour");
                }
                return(string.Format("about {0} hours", (object)num));
            }
            WorldTime worldTime = new WorldTime(turns);

            if (worldTime.Day == 1)
            {
                return("about 1 day");
            }
            return(string.Format("about {0} days", (object)worldTime.Day));
        }
 public WorldTime(WorldTime src)
     : this(src.TurnCounter)
 {
 }