/// <summary> /// Can be overridden to create different dungeon seeds. /// </summary> /// <param name="level"></param> protected void SetupLevelSeed(DungeonLevel level) { level.Add(new Room(0, 0, 5, 5)); level.Add(new Doorway(0, 3, 1, 0, Side.West)); level.Add(new Doorway(5, 3, 1, 0, Side.East)); level.Add(new Doorway(3, 0, 0, 1, Side.South)); level.Add(new Doorway(3, 5, 0, 1, Side.North)); }
/// <summary> /// This method attempts to find a way to fit the candidate into the level without colliding with any existing components. /// </summary> /// <param name="level"></param> /// <param name="entrance"></param> /// <param name="candidate"></param> /// <returns>false if the component could not be placed.</returns> protected bool tryPlaceComponent(DungeonLevel level, Doorway entrance, component candidate) { switch (entrance.SideIn) { case Side.North: candidate.y = entrance.y; break; case Side.South: candidate.y = entrance.y - candidate.Height; break; case Side.West: candidate.x = entrance.x - candidate.Width; break; case Side.East: candidate.x = entrance.x; break; } IList <int> potentialOrigins = new List <int>(); if (entrance.SideIn == Side.North || entrance.SideIn == Side.South) { for (int i = entrance.x - candidate.Width; i < entrance.x; i++) { potentialOrigins.Add(i + 1); } while (potentialOrigins.Count > 0) { int i = DiceBag.getDice().rand.Next(potentialOrigins.Count); candidate.x = potentialOrigins[i]; if (level.Add(candidate)) { return(true); } potentialOrigins.RemoveAt(i); } } else { for (int i = entrance.y - candidate.Height; i < entrance.y; i++) { potentialOrigins.Add(i + 1); } while (potentialOrigins.Count > 0) { int i = DiceBag.getDice().rand.Next(potentialOrigins.Count); candidate.y = potentialOrigins[i]; if (level.Add(candidate)) { return(true); } potentialOrigins.RemoveAt(i); } } return(false); }
/// <summary>Запускает анимацию графического эффекта</summary> private void Play() { m_timer_play.Start(); m_timer_play_is_working = true; ObjectStatus = DungeonObjectStatus.AddedNotDestroyed; DungeonLevel.Add(this); }