Beispiel #1
0
 internal static string GetPlayerName(Player player, string connectionId = null)
 {
     string name = null;
     if (player != null)
     {
         name = player.Tank.Name;
     }
     if (string.IsNullOrEmpty(name) && player != null)
     {
         name = player.ConnectionId;
     }
     if (string.IsNullOrEmpty(name))
     {
         name = connectionId;
     }
     return name;
 }
 public void PushPlayerStatus(Player player)
 {
     IHubContext context = GlobalHost.ConnectionManager.GetHubContext<GamepadHub>();
     _Log.Info("Informing '{0}' they are status={1}", GamepadHub.GetPlayerName(player), player.Status);
     context.Clients.Client(player.ConnectionId).receivePlayerStatus(player.Status.ToString());
 }
Beispiel #3
0
 private void SetPlayerStatus(Player player, PlayerStatus status)
 {
     player.Status = status;
     GetGamepadClients().PushPlayerStatus(player);
 }
Beispiel #4
0
 public void PlayerReady(Player player)
 {
     if (new []{GameStatus.WaitingForPlayers, GameStatus.Countdown, GameStatus.GameOver}.Contains(State.Status))
     {
         SetPlayerStatus(player, PlayerStatus.GameInCountdown);
         BroadcastMessage("'{0}' is ready, countdown starting from {1}!", player, _countDown);
         StartOrContinueCountdown();
     }
     else
     {
         SetPlayerStatus(player, PlayerStatus.WaitingForNextGame);
         BroadcastMessage("'{0}' is waiting for the next game", player);
     }
 }
Beispiel #5
0
        public Player PlayerJoined(string connectionId)
        {
            var player = new Player {ConnectionId = connectionId};
            State.Players.Add(player);

            player.Tank.Id = State.Players.Count;

            BroadcastMessage("Player {0} has connected", connectionId);
            return player;
        }
Beispiel #6
0
        public void PlayerFire(Player player)
        {
            var shell = new Shell { Id = _shellCounter++, LaunchTime= _time};
            shell.Origin = Deep.Clone(player.Tank.ToDto());

            // make the shell appear to come from the correct side of the tank
            shell.Origin.Point.X += Convert.ToInt32(player.Tank.Turret.Angle*Tank.Width/180);

            player.Shells.Add(shell);
            player.Tank.IsFiring = true;
        }