Esempio n. 1
0
        void INotificationService.Die(Player player)
        {
            foreach (var clientId in player.ClientIds)
            {
                Clients[clientId].receive(new PlayerPacket(new PlayerMessages("You have died...", MessageType.Important)));
                Groups.Remove(clientId, player.RoomReference.Id).Wait();
            }

            // Let everybody know about the death.
            Clients.receive(new PlayerPacket(new PlayerMessages(String.Format("{0} has died.", player.Name), MessageType.Notification)));

            _world.Teleport(player, player.RoomReference);
            player.Reset();

            // The rebirth!
            Clients[player.RoomReference.Id].receive(
                new PlayerPacket(new PlayerMessages(String.Format("{0} is birthed in an orange light!", player.Name),
                                                    MessageType.Important)));

            // Join room 1
            foreach (var clientId in player.ClientIds)
                Groups.Add(clientId, player.RoomReference.Id).Wait();

            // TODO:  Temporary.  Add a javascript .death function to call.
            var cmd = new CommandManager(Context.ConnectionId, player, _world, this);
            cmd.TryHandleCommand("look");
        }
Esempio n. 2
0
        public bool Command(string command)
        {
            var playerClient = (PlayerClient)_cache.Get(Context.ConnectionId);

            if (playerClient == null)
                throw new InvalidOperationException("Your player session has expired.  Please refresh your browser");

            var cmd = new CommandManager(Context.ConnectionId, playerClient.PlayerReference, _world, this);
            return (cmd.TryHandleCommand(command));
        }