public JoinRoomLocalScriptServerForm(string RoomID, PlayerWithID JoinedPlayer, ClientGroup ActiveGroup) : base(ScriptName) { this.RoomID = RoomID; this.JoinedPlayer = JoinedPlayer; this.ActiveGroup = ActiveGroup; }
protected override void Execute(IOnlineConnection Sender) { TextGame NewGame = new TextGame(CreatedGroup); CreatedGroup.CurrentGame = NewGame; foreach (IOnlineConnection ActivePlayer in CreatedGroup.Room.ListOnlinePlayer) { ActivePlayer.Send(new CreateGameScriptServer()); } foreach (IOnlineConnection ActivePlayer in CreatedGroup.Room.ListOnlinePlayer) { PlayerWithID NewGamePlayer = NewGame.AddPlayer(); //Add Game Specific scripts Dictionary <string, OnlineScript> DicNewScript = new Dictionary <string, OnlineScript>(); DicNewScript.Add(SendSquareScriptServer.ScriptName, new SendSquareScriptServer(CreatedGroup, NewGamePlayer)); DicNewScript.Add(SendCircleScriptServer.ScriptName, new SendCircleScriptServer(CreatedGroup, NewGamePlayer)); DicNewScript.Add(FinishedLoadingScriptServer.ScriptName, new FinishedLoadingScriptServer(CreatedGroup, NewGamePlayer)); ActivePlayer.AddOrReplaceScripts(DicNewScript); //Send created Player to all Players. foreach (IOnlineConnection ActivePlayerInRoom in CreatedGroup.Room.ListOnlinePlayer) { ActivePlayerInRoom.Send(new CreatePlayerScriptServer(NewGamePlayer.ID, ActivePlayer == ActivePlayerInRoom)); } } }
public PlayerWithID AddPlayer() { PlayerWithID NewPlayer = new PlayerWithID(NextID); DicPlayerByID.Add(NextID, NewPlayer); ++NextID; return(NewPlayer); }
protected override void OnJoinRoomLocal(IOnlineConnection Sender, string RoomID, ClientGroup ActiveGroup) { foreach (IOnlineConnection ActivePlayer in ActiveGroup.Room.ListOnlinePlayer) { if (ActivePlayer == Sender) { continue; } ActivePlayer.Send(new PlayerJoinedScriptServer(ActiveGroup.Room.GetPlayer(Sender))); } Dictionary <string, OnlineScript> DicNewScript = new Dictionary <string, OnlineScript>(); DicNewScript.Add(LeaveRoomScriptServer.ScriptName, new LeaveRoomScriptServer(ActiveGroup.Room, Owner)); Sender.AddOrReplaceScripts(DicNewScript); PlayerWithID NewGamePlayer = null; if (ActiveGroup.CurrentGame != null) { TextGame CurrentGame = (TextGame)ActiveGroup.CurrentGame; NewGamePlayer = CurrentGame.AddPlayer(); //Add Game Specific scripts DicNewScript = new Dictionary <string, OnlineScript>(); DicNewScript.Add(SendSquareScriptServer.ScriptName, new SendSquareScriptServer(ActiveGroup, NewGamePlayer)); DicNewScript.Add(SendCircleScriptServer.ScriptName, new SendCircleScriptServer(ActiveGroup, NewGamePlayer)); DicNewScript.Add(FinishedLoadingScriptServer.ScriptName, new FinishedLoadingScriptServer(ActiveGroup, NewGamePlayer)); Sender.AddOrReplaceScripts(DicNewScript); foreach (IOnlineConnection ActivePlayer in ActiveGroup.Room.ListOnlinePlayer) { if (ActivePlayer == Sender) { continue; } ActivePlayer.Send(new CreatePlayerScriptServer(NewGamePlayer.ID, false)); } } Sender.Send(new JoinRoomLocalScriptServerForm(RoomID, NewGamePlayer, ActiveGroup)); }
public FinishedLoadingScriptServer(ClientGroup ActiveGroup, PlayerWithID Owner) : base(ScriptName) { this.ActiveGroup = ActiveGroup; this.Owner = Owner; }
public SendSquareScriptServer(ClientGroup ActiveGroup, PlayerWithID Owner) : base(ScriptName) { this.ActiveGroup = ActiveGroup; this.Owner = Owner; }
public ConfirmGameCreationScriptServer(PlayerWithID Owner) : base(ScriptName) { this.Owner = Owner; }