Пример #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));
                }
            }
        }
Пример #2
0
        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));
        }