Esempio n. 1
0
 private void sendWorldUpdates()
 {
     // send an update to everyone
     lock (players) {
         foreach (var player in players)
         {
             var observedWorld = new ObservedWorld(simulation.world, simulation.empires[player.empireId],
                                                   simulation.time);
             observedWorld.see();
             player.connection.SendAsync(new WorldUpdateMessage {
                 world = observedWorld
             });
         }
     }
 }
Esempio n. 2
0
        private void onJoinMessage(MessageEventArgs <JoinMessage> msg)
        {
            // assign the empire or something
            // TODO: this should properly support picking _your_ empire on a save
            var player = players.First(x => x.connection == msg.Connection);

            player.empireId = player.id;
            var empire = simulation.empires[player.empireId];

            msg.Connection.SendAsync(new GameInfoMessage {
                empireCount = simulation.empires.Count,
                mapSize     = simulation.world.map.size,
                empireId    = player.empireId,
                empires     = simulation.empires.Select(x => new EmpireRef(x)).ToList()
            });
            msg.Connection.SendAsync(new EmpireFetchMessage(empire));
            var observedWorld = new ObservedWorld(simulation.world, empire, simulation.time);

            observedWorld.see();
            msg.Connection.SendAsync(new WorldUpdateMessage {
                world = observedWorld
            });
        }