public PlayerDeathHandler(MatchmakerNotifier matchmakerNotifier, UdpSendUtils udpSendUtils,
                           IpAddressesStorage ipAddressesStorage)
 {
     this.udpSendUtils       = udpSendUtils;
     this.matchmakerNotifier = matchmakerNotifier;
     this.ipAddressesStorage = ipAddressesStorage;
 }
 public RudpMessagesSender(ByteArrayRudpStorage byteArrayRudpStorage, MatchStorage matchStorage,
                           UdpSendUtils udpSendUtils, IpAddressesStorage ipAddressesStorage)
 {
     this.matchStorage         = matchStorage;
     this.udpSendUtils         = udpSendUtils;
     this.ipAddressesStorage   = ipAddressesStorage;
     this.byteArrayRudpStorage = byteArrayRudpStorage;
 }
Exemple #3
0
        //ECS
        public void ConfigureSystems(BattleRoyaleMatchModel matchModelArg, UdpSendUtils udpSendUtils,
                                     IpAddressesStorage ipAddressesStorage)
        {
            log.Info($"Создание нового матча {nameof(matchId)} {matchId}");

            //TODO это нужно убрать в отдельный класс
            Dictionary <int, (int playerId, ViewTypeId type)> possibleKillersInfo = new Dictionary <int, (int playerId, ViewTypeId type)>();


            // var test = new BattleRoyalePlayerModelFactory().Create(matchModelArg).Select(model=>model.AccountId);
            // playersIds = new HashSet<int>(test);

            contexts = ContextsPool.GetContexts();
            contexts.SubscribeId();
            TryEnableDebug();

            playerDeathHandler = new PlayerDeathHandler(matchmakerNotifier, udpSendUtils, ipAddressesStorage);
            var playersViewAreas = new PlayersViewAreas(matchModelArg.GameUnits.Players.Count);

            systems = new Entitas.Systems()
                      .Add(new MapInitSystem(contexts, matchModelArg, udpSendUtils, out var chunks))
                      .Add(new ViewAreasInitSystem(contexts, playersViewAreas))
                      // .Add(new TestEndMatchSystem(contexts))
                      .Add(new PlayerMovementHandlerSystem(contexts))
                      .Add(new PlayerAttackHandlerSystem(contexts))
                      .Add(new PlayerAbilityHandlerSystem(contexts))
                      .Add(new ParentsSystems(contexts))
                      .Add(new AISystems(contexts))
                      .Add(new MovementSystems(contexts))
                      .Add(new GlobalTransformSystem(contexts))
                      .Add(new ShootingSystems(contexts))
                      .Add(new UpdatePositionChunksSystem(contexts, chunks))
                      .Add(new CollisionSystems(contexts, chunks))
                      .Add(new EffectsSystems(contexts))
                      .Add(new TimeSystems(contexts))
                      .Add(new UpdatePossibleKillersSystem(contexts, possibleKillersInfo))

                      .Add(new PlayerExitSystem(contexts, matchModelArg.MatchId, playerDeathHandler, matchRemover))
                      .Add(new FinishMatchSystem(contexts, matchRemover, matchId))
                      .Add(new NetworkKillsSenderSystem(contexts, possibleKillersInfo, matchModelArg.MatchId, playerDeathHandler, udpSendUtils))

                      .Add(new DestroySystems(contexts))
                      // .Add(new MatchDebugSenderSystem(contexts, matchModelArg.MatchId, udpSendUtils))
                      .Add(new NetworkSenderSystems(contexts, matchModelArg.MatchId, udpSendUtils, playersViewAreas))
                      .Add(new MovingCheckerSystem(contexts))

                      .Add(new DeleteSystem(contexts))
                      .Add(new InputDeletingSystem(contexts))
                      .Add(new GameDeletingSystem(contexts))
            ;

            systems.ActivateReactiveSystems();
            systems.Initialize();
            gameStartTime = DateTime.UtcNow;
        }
 public MessageProcessor(InputEntitiesCreator inputEntitiesCreator, ExitEntitiesCreator exitEntitiesCreator,
                         ByteArrayRudpStorage byteArrayRudpStorage,
                         // UdpSendUtils udpSendUtils,
                         IpAddressesStorage ipAddressesStorage)
 {
     pingMessageHandler = new PingMessageHandler(ipAddressesStorage);
     // rudpConfirmationSender = new RudpConfirmationSender(udpSendUtils);
     inputMessageHandler     = new InputMessageHandler(inputEntitiesCreator);
     exitMessageHandler      = new PlayerExitMessageHandler(exitEntitiesCreator);
     rudpConfirmationHandler = new RudpConfirmationReceiver(byteArrayRudpStorage);
 }
 public MatchFactory(MatchRemover matchRemover, UdpSendUtils udpSendUtils,
                     MatchmakerNotifier matchmakerNotifier, IpAddressesStorage ipAddressesStorage,
                     MessageIdFactory messageIdFactory, MessagesPackIdFactory messagesPackIdFactory)
 {
     this.matchRemover          = matchRemover;
     this.udpSendUtils          = udpSendUtils;
     this.messageIdFactory      = messageIdFactory;
     this.messagesPackIdFactory = messagesPackIdFactory;
     this.matchmakerNotifier    = matchmakerNotifier;
     this.ipAddressesStorage    = ipAddressesStorage;
 }
Exemple #6
0
 public MatchRemover(MatchStorage matchStorage, ByteArrayRudpStorage byteArrayRudpStorage,
                     UdpSendUtils udpSendUtils, MatchmakerNotifier matchmakerNotifier, IpAddressesStorage ipAddressesStorage,
                     MessageIdFactory messageIdFactory, MessagesPackIdFactory messagesPackIdFactory)
 {
     this.messagesPackIdFactory = messagesPackIdFactory;
     this.matchStorage          = matchStorage;
     this.byteArrayRudpStorage  = byteArrayRudpStorage;
     this.matchmakerNotifier    = matchmakerNotifier;
     this.ipAddressesStorage    = ipAddressesStorage;
     this.messageIdFactory      = messageIdFactory;
     matchesToRemove            = new ConcurrentQueue <int>();
     playersMatchFinishNotifier = new PlayersMatchFinishNotifier(udpSendUtils, ipAddressesStorage);
 }
 public OutgoingMessagesStorage(SimpleMessagesPacker simpleMessagesPacker, IpAddressesStorage ipAddressesStorage)
 {
     this.simpleMessagesPacker = simpleMessagesPacker;
     this.ipAddressesStorage   = ipAddressesStorage;
 }
Exemple #8
0
        public void Run()
        {
            if (matchmakerListenerCts != null)
            {
                throw new Exception("Сервер уже запущен");
            }

            //Старт уведомления матчмейкера о смертях игроков и окончании матчей
            MatchmakerNotifier notifier = new MatchmakerNotifier();

            matchmakerNotifierCts = notifier.StartThread();

            //Создание структур данных для матчей
            matchStorage = new MatchStorage();


            MessageIdFactory messageIdFactory = new MessageIdFactory();
            MessageFactory   messageFactory   = new MessageFactory(messageIdFactory);

            InputEntitiesCreator inputEntitiesCreator = new InputEntitiesCreator(matchStorage);
            ExitEntitiesCreator  exitEntitiesCreator  = new ExitEntitiesCreator(matchStorage);

            ByteArrayRudpStorage byteArrayRudpStorage = new ByteArrayRudpStorage();

            shittyUdpMediator = new ShittyUdpMediator();

            MessagesPackIdFactory   messagesPackIdFactory   = new MessagesPackIdFactory();
            IpAddressesStorage      ipAddressesStorage      = new IpAddressesStorage();
            SimpleMessagesPacker    simpleMessagesPacker    = new SimpleMessagesPacker(PackingHelper.Mtu, shittyUdpMediator, messagesPackIdFactory);
            OutgoingMessagesStorage outgoingMessagesStorage = new OutgoingMessagesStorage(simpleMessagesPacker, ipAddressesStorage);
            UdpSendUtils            udpSendUtils            = new UdpSendUtils(byteArrayRudpStorage, outgoingMessagesStorage, messageFactory);
            MessageProcessor        messageProcessor        = new MessageProcessor(inputEntitiesCreator, exitEntitiesCreator,
                                                                                   byteArrayRudpStorage,
                                                                                   // udpSendUtils,
                                                                                   ipAddressesStorage);

            shittyUdpMediator.SetProcessor(messageProcessor);

            matchRemover = new MatchRemover(matchStorage, byteArrayRudpStorage, udpSendUtils, notifier, ipAddressesStorage, messageIdFactory, messagesPackIdFactory);
            MatchFactory          matchFactory          = new MatchFactory(matchRemover, udpSendUtils, notifier, ipAddressesStorage, messageIdFactory, messagesPackIdFactory);
            MatchCreator          matchCreator          = new MatchCreator(matchFactory);
            MatchLifeCycleManager matchLifeCycleManager =
                new MatchLifeCycleManager(matchStorage, matchCreator, matchRemover);

            //Старт прослушки матчмейкера
            MatchModelMessageHandler matchModelMessageHandler = new MatchModelMessageHandler(matchCreator, matchStorage);
            MatchmakerListener       matchmakerListener       = new MatchmakerListener(matchModelMessageHandler, HttpPort);
            MonitorListener          monitorListener          = new MonitorListener(HttpPort);

            monitorListenerCts    = monitorListener.StartThread();
            matchmakerListenerCts = matchmakerListener.StartThread();


            //Старт прослушки игроков
            shittyUdpMediator
            .SetupConnection(UdpPort)
            .StartReceiveThread();

            RudpMessagesSender rudpMessagesSender = new RudpMessagesSender(byteArrayRudpStorage, matchStorage, udpSendUtils, ipAddressesStorage);
            GameEngineTicker   gameEngineTicker   = new GameEngineTicker(matchStorage, matchLifeCycleManager,
                                                                         inputEntitiesCreator, exitEntitiesCreator, rudpMessagesSender, outgoingMessagesStorage);

            //Старт тиков
            Chronometer chronometer = ChronometerFactory.Create(gameEngineTicker.Tick);

            chronometer.StartEndlessLoop();
        }
 public PingMessageHandler(IpAddressesStorage ipAddressesStorage)
 {
     this.ipAddressesStorage = ipAddressesStorage;
 }
Exemple #10
0
 public PlayersMatchFinishNotifier(UdpSendUtils udpSendUtils, IpAddressesStorage ipAddressesStorage)
 {
     this.udpSendUtils       = udpSendUtils;
     this.ipAddressesStorage = ipAddressesStorage;
 }