Пример #1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="x">X-coordinate of this thing</param>
 /// <param name="y">Y-coordinate of this thing</param>
 /// <param name="type">Type of thing</param>
 /// <param name="angle">Direction this thing is facing (east is 0, north is 90, west is 180, south is 270)</param>
 /// <param name="options">Thing options</param>
 public Thing(int x, int y, int type, int angle = 0, ThingOptions options = ThingOptions.AllSkills)
 {
     X       = x;
     Y       = y;
     Angle   = angle;
     Type    = type;
     Options = options;
 }
Пример #2
0
        /// <summary>
        /// Add a certain number of things from an array of thing types to a map.
        /// </summary>
        /// <param name="map">The Doom map on which to add things</param>
        /// <param name="count">The number of things to add</param>
        /// <param name="generationFlags">Special flags for thing generation</param>
        /// <param name="thingTypes">Array of thing types to select from</param>
        private void AddThings(DoomMap map, int count, ThingsGeneratorFlags generationFlags, params int[] thingTypes)
        {
            if ((count < 1) || (thingTypes.Length == 0))
            {
                return;
            }

            for (int i = 0; i < count; i++)
            {
                if (FreeTiles.Count == 0)
                {
                    return;
                }

                ThingOptions options = ThingOptions.AllSkills;

                switch (generationFlags)
                {
                case ThingsGeneratorFlags.MoreThingsInEasyMode:
                    if (Toolbox.RandomInt(4) == 0)
                    {
                        options = ThingOptions.Skill12 | ThingOptions.Skill3;
                    }
                    else if (Toolbox.RandomInt(3) == 0)
                    {
                        options = ThingOptions.Skill12;
                    }
                    break;

                case ThingsGeneratorFlags.MoreThingsInHardMode:
                    if (Toolbox.RandomInt(3) == 0)
                    {
                        options = ThingOptions.Skill3 | ThingOptions.Skill45;
                    }
                    else if (Toolbox.RandomInt(2) == 0)
                    {
                        options = ThingOptions.Skill45;
                    }
                    break;
                }

                int   thingType = Toolbox.RandomFromArray(thingTypes);
                Point pt        = Toolbox.RandomFromList(FreeTiles);
                AddThing(map, pt.X, pt.Y, thingType, Toolbox.RandomInt(360), options);
                FreeTiles.Remove(pt);
            }
        }
Пример #3
0
 /// <summary>
 /// Adds a thing to the map.
 /// </summary>
 /// <param name="map">Doom map the thing should be added to</param>
 /// <param name="x">X coordinate of the tile on which the thing should be spawned</param>
 /// <param name="y">Y coordinate of the tile on which the thing should be spanwed</param>
 /// <param name="thingType">Type of thing</param>
 /// <param name="angle">Angle the thing should face</param>
 /// <param name="options">Thing options</param>
 private void AddThing(DoomMap map, int x, int y, int thingType, int angle = (int)DEFAULT_ANGLE, ThingOptions options = ThingOptions.AllSkills)
 {
     map.Things.Add(
         new Thing(
             (int)((x + .5f) * MapGenerator.TILE_SIZE),
             (int)((y + .5f) * -MapGenerator.TILE_SIZE),
             thingType, angle, options));
 }