public void RemoteActivation(Creature _creature, Point _worldCoords) { var creatureLiveCell = _creature[0, 0]; var delta = _worldCoords - creatureLiveCell.WorldCoords; var myCell = _creature[delta.X, delta.Y]; switch (Effect) { case EMagicPlateEffect.RANDOM_MONSTER_APPEAR: if (myCell.Creature == null) { var monster = (AbstractMonster)EssenceHelper.GetRandomFakedCreature <AbstractMonster>(World.Rnd).Essence.Clone(_creature); monster.Behaviour = EMonsterBehaviour.IDLE; World.TheWorld.CreatureManager.AddCreature(monster, myCell.WorldCoords, myCell.LiveCoords); MessageManager.SendMessage(this, new SoundTextMessage("послышался всплеск")); } else { MessageManager.SendMessage(this, new SoundTextMessage("послышался треск")); } break; default: throw new ArgumentOutOfRangeException(); } }
private static void AddCreatures(MapBlock _block, Random _rnd) { var itmcnt = 2 + _rnd.Next(_rnd.Next(2)); for (var i = 0; i < itmcnt; ++i) { var x = _rnd.Next(Constants.MAP_BLOCK_SIZE); var y = _rnd.Next(Constants.MAP_BLOCK_SIZE); var attr = TerrainAttribute.GetAttribute(_block.Map[x, y]); if (attr.IsPassable) { var point = new Point(x, y); if (_block.Creatures.Values.Contains(point)) { continue; } var creature = (AbstractMonster)EssenceHelper.GetRandomFakedCreature <AbstractMonster>(World.Rnd).Essence.Clone(World.TheWorld.Avatar); if (creature.Is <Stair>() && (x == Constants.MAP_BLOCK_SIZE - 1 || y == Constants.MAP_BLOCK_SIZE - 1)) { continue; } if (!_block.Rooms.Any(_room => _room.RoomRectangle.Contains(point) && _room.IsConnected)) { continue; } _block.CreaturesAdd(creature, point); } } }