示例#1
0
        /// Over time, new monsters will appear in unexplored areas of the dungeon.
        /// This is to encourage players to not waste time: the more they linger, the
        /// more dangerous the remaining areas become.
        public void TrySpawnMonster()
        {
            if (!Rng.Instance.OneIn(Option.SpawnMonsterChance))
            {
                return;
            }

            // Try to place a new monster in unexplored areas.
            VectorBase pos = Rng.Instance.vectorInRect(CurrentStage.Bounds());

            var tile = CurrentStage[pos];

            if (tile.Visible || tile.IsExplored || !tile.IsPassable)
            {
                return;
            }
            if (CurrentStage.ActorAt(pos) != null)
            {
                return;
            }
            var breedForMonster = MonsterFactory.GenerateBreedOfMonster(CurrentStage.StageNumber);

            CurrentStage.SpawnMonster(this, breedForMonster, pos);
        }