Exemplo n.º 1
0
 /// <summary>
 /// Add a feature to the dungeon at a certain place. May fail if something is already there.
 /// </summary>
 /// <param name="feature"></param>
 /// <param name="level"></param>
 /// <param name="location"></param>
 bool AddFeatureToDungeon(Feature feature, int level, Point location)
 {
     return dungeon.AddFeature(feature, level, location);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Add feature to the dungeon
        /// </summary>
        /// <param name="feature"></param>
        /// <param name="level"></param>
        /// <param name="location"></param>
        /// <returns></returns>
        public bool AddFeature(Feature feature, int level, Point location)
        {
            //Try to add a creature at the requested location
            //This may fail due to something else being there or being non-walkable
            try
            {
                Map featureLevel = levels[level];

                //Check square is accessable
                if (!MapSquareCanBeEntered(level, location))
                {
                    LogFile.Log.LogEntry("AddFeature: map square can't be entered");
                    return false;
                }

                //Check another feature isn't there
                foreach (Feature otherFeature in features)
                {
                    if (otherFeature.LocationLevel == feature.LocationLevel &&
                        otherFeature.LocationMap == feature.LocationMap)
                    {
                        LogFile.Log.LogEntry("AddFeature: other feature already there");
                        return false;
                    }
                }

                //Otherwise OK
                feature.LocationLevel = level;
                feature.LocationMap = location;

                features.Add(feature);
                return true;
            }
            catch (Exception ex)
            {
                LogFile.Log.LogEntry(String.Format("AddItem: ") + ex.Message);
                return false;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add a feature to the dungeon. Guarantees an acceptable placement.
        /// Might loop forever if all squares in the dungeon are already taken up
        /// </summary>
        /// <param name="feature"></param>
        /// <param name="level"></param>
        /// <param name="location"></param>
        void AddFeatureToDungeonRandomPoint(Feature feature, MapGeneratorBSP mapGen, int level)
        {
            Point location;
            //Loop until we find an acceptable location and the add works
            do
            {
                location = mapGen.RandomWalkablePoint();

            }
            while (!dungeon.AddFeature(feature, level, location));
        }