public World( Guid id, int version, string title, Player startingPlayer, IEnumerable<Board> boards, IEnumerable<Actor> actors, IEnumerable<Message> messages, IEnumerable<Timer> timers, IEnumerable<SoundEffect> soundEffects, IEnumerable<Song> songs) { title.ThrowIfNull("title"); startingPlayer.ThrowIfNull("startingPlayer"); boards.ThrowIfNull("boards"); actors.ThrowIfNull("actors"); messages.ThrowIfNull("messages"); timers.ThrowIfNull("timers"); soundEffects.ThrowIfNull("soundEffects"); songs.ThrowIfNull("songs"); if (version < 1) { throw new ArgumentOutOfRangeException("version", "Version must be at least 1."); } _id = id; _version = version; _title = title; _startingPlayer = startingPlayer; foreach (Board board in boards) { _boardsById.Add(board.Id, board); } foreach (Actor actor in actors) { _actorsById.Add(actor.Id, actor); } foreach (Message message in messages) { _messagesById.Add(message.Id, message); } foreach (Timer timer in timers) { _timersById.Add(timer.Id, timer); } foreach (SoundEffect soundEffect in soundEffects) { _soundEffectsById.Add(soundEffect.Id, soundEffect); } foreach (Song song in songs) { _songsById.Add(song.Id, song); } }
public XElement Serialize(Player player, string elementName = "player") { player.ThrowIfNull("player"); elementName.ThrowIfNull("elementName"); return new XElement( elementName, CharacterSerializer.Instance.Serialize(player.Character), EventHandlerCollectionSerializer.Instance.Serialize(player.EventHandlerCollection), new XAttribute("id", player.Id), new XAttribute("boardId", player.BoardId), new XAttribute("coordinate", CoordinateSerializer.Instance.Serialize(player.Coordinate))); }
public byte[] Serialize(Player player) { player.ThrowIfNull("player"); var serializer = new CompactSerializer(); serializer[0] = player.Id.ToByteArray(); serializer[1] = player.BoardId.ToByteArray(); serializer[2] = CoordinateSerializer.Instance.Serialize(player.Coordinate); serializer[3] = CharacterSerializer.Instance.Serialize(player.Character); serializer[4] = EventHandlerCollectionSerializer.Instance.Serialize(player.EventHandlerCollection); return serializer.Serialize(); }
public GameForm(Engine.Objects.World world, Player startingPlayer) { world.ThrowIfNull("world"); startingPlayer.ThrowIfNull("startingPlayer"); _world = world; _startingPlayer = startingPlayer; _multimediaPlayer = new MultimediaPlayer(_volumeConfigurationSection); InitializeComponent(); SetNormalViewSize(); fpsToolStripMenuItem.Checked = _fpsConfigurationSection.Visible; logToolStripMenuItem.Checked = _logConfigurationSection.Visible; worldTimeToolStripMenuItem.Checked = _worldTimeConfigurationSection.Visible; soundEffectsToolStripMenuItem.Checked = true; musicToolStripMenuItem.Checked = true; }
public TextAdventureGame( GraphicsDevice graphicsDevice, Engine.Objects.World world, Player player, IMultimediaPlayer multimediaPlayer, IFpsConfiguration fpsConfiguration, ILogConfiguration logConfiguration, IWorldTimeConfiguration worldTimeConfiguration) : base(graphicsDevice, new ContentDirectoryContentManagerProvider()) { world.ThrowIfNull("world"); player.ThrowIfNull("player"); multimediaPlayer.ThrowIfNull("multimediaPlayer"); fpsConfiguration.ThrowIfNull("fpsConfiguration"); logConfiguration.ThrowIfNull("logConfiguration"); worldTimeConfiguration.ThrowIfNull("worldTimeConfiguration"); _world = world; _player = player; _multimediaPlayer = multimediaPlayer; _fpsConfiguration = fpsConfiguration; _logConfiguration = logConfiguration; _worldTimeConfiguration = worldTimeConfiguration; }
protected internal bool ChangeCoordinate(Board board, Player player, Coordinate destinationCoordinate) { board.ThrowIfNull("board"); player.ThrowIfNull("player"); if (board.ActorInstanceLayer[Coordinate] != this) { throw new ArgumentException("Board's actor instance layer does not contain this actor instance.", "board"); } ActorInstance destinationActorInstance = board.ActorInstanceLayer[destinationCoordinate]; Sprite foregroundSprite = board.ForegroundLayer[destinationCoordinate]; if (destinationActorInstance != null || foregroundSprite != null || player.Coordinate == destinationCoordinate) { return destinationActorInstance == this; } board.ActorInstanceLayer.MoveTile(Coordinate, destinationCoordinate); Coordinate = destinationCoordinate; return true; }
public BoardRendererState(Player player) { player.ThrowIfNull("player"); _player = player; }