public void SpawnBoss(MapGridTypes.Room room) { var gameState = (IGameState)Game.Services.GetService (typeof(IGameState)); var sprites = (ISpriteSheets)Game.Services.GetService (typeof(ISpriteSheets)); int maxWeight = Globals.BOSSES_SPAWN_WEIGHT [gameState.Level]; var bosses = GetAllEntities ().Where (e => e.Has<State<MonsterType>> () && e.Get<State<MonsterType>> ().EState == MonsterType.Boss); int bossInRoom = bosses.Count (e => e.Get<Tag> ().ID == room.RoomID); if (bossInRoom < Globals.BOSSES_PER_ROOM_MAX [gameState.Level]) { for (int i = 0; i < Globals.BOSSES_SPAWN_PER_ROOM [gameState.Level]; ++i) { Archetypes.Bosses.Shuffle (); foreach (var arch in Archetypes.Bosses) { var w = Utils.ThrowDice (maxWeight); var spriteName = string.Format ("boss_{0:D2}", arch ["sprite_index"]); var pos = new Point (room.Pos.X + Utils.Rand.Next (room.Width), room.Pos.Y + Utils.Rand.Next (room.Height)); if (arch ["spawn_weight"] >= w && arch ["spawn_weight"] <= maxWeight) { var boss = CreateEntity (); boss.Register (new State<MonsterType> (MonsterType.Boss)); boss.Register (new Position (pos.X, pos.Y)); boss.Register (new Health (arch ["health"], () => OnHealthChanged (boss))); boss.Register (new Attack (arch ["attack"], arch ["attack_distance"])); boss.Register (new MoveSpeed (arch ["move_duration_msec"])); boss.Register (new AttackSpeed (arch ["attack_duration_msec"])); boss.Register (new Attackable ((attacker, _, __) => OnAttacked (boss, attacker))); boss.Register (new Execute ()); boss.Register (new Patrol (arch ["patrol_min_steps"], arch ["patrol_max_steps"])); boss.Register (new IFFSystem (Globals.IFF_MONSTER_ID)); boss.Register (new LookDirection (Utils.Direction.Down)); boss.Register (new Perception (arch ["perception"])); boss.Register (new AllowedMapArea (MapGridTypes.ID.Room)); boss.Register (new Sprite (sprites.GetSprite (spriteName))); boss.Register (new Drawable (new Vector2 (pos.X * Globals.CELL_WIDTH, pos.Y * Globals.CELL_HEIGHT))); boss.Register (new Tag (room.RoomID)); if (arch ["poison_chance"] > 0) boss.Register (new Poison (arch ["poison_damage"], arch ["poison_chance"], arch ["poison_effect_delay_msec"])); if (arch ["critical_chance"] > 0) boss.Register (new CriticalHit (arch ["critical_chance"], arch ["critical_damage"])); if (arch ["visible"] == 1) boss.Register (new DirectLight (Color.White)); boss.Get<Execute> ().Add (new ActionEntity (boss, (_) => { StartPatrol (boss); }), "patrol_loop"); break; } } } } }
public void SetID(int x, int y, MapGridTypes.ID id) { if (x >= 0 && y >= 0 && x < Width && y < Height) m_map[x, y].Type = id; }
public void AddRoom(MapGridTypes.Room room) { m_rooms.Add(room); }
public AllowedMapArea(MapGridTypes.ID area) { Area = area; }