Beispiel #1
0
        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));
                }
            }
        }
Beispiel #2
0
        protected override void Execute(IOnlineConnection Sender)
        {
            OnlineServer.ListPlayer.Add(Sender);
            Owner.RemovePlayer(Sender);
            OnlineServer.Database.UpdatePlayerCountInRoom(Owner.RoomID, Owner.ListOnlinePlayer.Count);

            if (Owner.ListOnlinePlayer.Count == 0)
            {
                OnlineServer.ListLocalRoomToRemove.Add(Owner.RoomID);
            }

            //Send created Player to all Players.
            foreach (IOnlineConnection ActivePlayerInRoom in Owner.ListOnlinePlayer)
            {
                ActivePlayerInRoom.Send(new PlayerLeftScriptServer(Sender.ID, 0));
            }
        }