public bool ApplyAction(LobbyAction Action) { var r = Action.Apply(this); if (r && OnActionApplied != null) { OnActionApplied(this, new ValuedEventArgs <LobbyAction>(Action)); } return(r); }
private void ExecuteLobbyAction(LobbyAction lobbyAction) { if (lobbyAction is TryCreateGameAction) { TryCreateNewGame(lobbyAction); } if (lobbyAction is LobbyChatAction) { SayToLobby(lobbyAction); } if (lobbyAction is JoinGameAction) { TryJoinGame((JoinGameAction)lobbyAction); } }
void Instance_LobbyActionReceived(LobbyAction action) { /* XmlChatItem item = new XmlChatItem(); item.User = GetUser(action.Sender); item.Message = ((LobbyChatAction)action).ChatMessage; _LobbyChatLog.Add(item); //Console.WriteLine("received action: {0}", action.Message); if (action is TryCreateGameAction) { //_GamesPending.Add(((Chat2Action)action).GameSettings); } if (action is GameCreatedAction) { AddGame((GameCreatedAction)action); } /* if (action is MessageFromServerAction) { XmlChatItem chatItem = new XmlChatItem(); chatItem.DateTime = DateTime.Now; chatItem.Message = ((MessageFromServerAction)action).Message; chatItem.User = Core.Instance.ServerUser; chatItem.Type = EChatItemType.System; _LobbyChatLog.Add(chatItem); } */ if (action is GameJoinedAction) { GameJoinedAction gameJoinedAction = action as GameJoinedAction; XmlGame gameToFind = null; foreach (XmlGame game in _GamesPending) { if (game.ID == gameJoinedAction.GameID) { gameToFind = game; break; } } if (gameToFind == null) { throw new Exception("Hmm, game not found... I must have missed a gameaddition update"); } else { gameToFind.AddPlayer(GetUser(action.Sender)); } } }
void OnLobbyActionReceived(LobbyAction action) { if (LobbyActionReceived != null) LobbyActionReceived(action); }
public ApplyLobbyActionRequest(LobbyAction Action) { this.Action = Action; }
public ApplyLobbyActionRequest(SerializationInputStream Stream) : base(Stream) { Action = (LobbyAction)LobbyActionSerializer.Instance.Deserialize(Stream); }