コード例 #1
0
        public void Initialize()
        {
            GameSceneFactory gameSceneFactory = new GameSceneFactory();
            Scene            matchScene       = gameSceneFactory.Create();

            physicsSpawner = new PhysicsSpawner(matchScene);
        }
コード例 #2
0
        private Entitas.Systems CreateSystems(UdpSendUtils udpSendUtils, BattleRoyaleClientMatchModel matchModel,
                                              PingStatisticsStorage statisticsStorage)
        {
            GameSceneFactory gameSceneFactory = new GameSceneFactory();
            var            matchScene         = gameSceneFactory.Create();
            PhysicsSpawner physicsSpawner     = new PhysicsSpawner(matchScene);

            contexts = Contexts.sharedInstance;
            var updatePlayersSystem = new UpdatePlayersSystem(contexts, matchModel);

            playersStorage = updatePlayersSystem;
            var healthUpdaterSystem = new HealthUpdaterSystem(contexts);

            healthPointsStorage = healthUpdaterSystem;
            var maxHealthUpdaterSystem = new MaxHealthUpdaterSystem(contexts);

            maxHealthPointsMessagePackStorage = maxHealthUpdaterSystem;
            Vector3 cameraShift = new Vector3(0, 60, -30);
            ushort  playerTmpId = matchModel.PlayerTemporaryId;
            int     matchId     = matchModel.MatchId;
            Text    pingText    = battleUiController.GetPingText();

            pingSystem = new PingSystem(pingText, statisticsStorage);
            ClientInputMessagesHistory clientInputMessagesHistory = new ClientInputMessagesHistory(playerTmpId, matchId);
            ClientPrefabsStorage       clientPrefabsStorage       = new ClientPrefabsStorage();
            PhysicsVelocityManager     physicsVelocityManager     = new PhysicsVelocityManager();

            ArrangeTransformSystem[] arrangeCollidersSystems =
            {
                new WithHpArrangeTransformSystem(contexts)
            };
            PhysicsRollbackManager physicsRollbackManager = new PhysicsRollbackManager(arrangeCollidersSystems);
            PhysicsRotationManager physicsRotationManager = new PhysicsRotationManager();
            SnapshotFactory        snapshotFactory        = new SnapshotFactory(contexts.serverGame);
            PlayerPredictor        playerPredictor        = new PlayerPredictor(physicsRollbackManager, matchScene,
                                                                                contexts.serverGame, physicsVelocityManager, physicsRotationManager, snapshotFactory);
            PlayerEntityComparer      playerEntityComparer      = new PlayerEntityComparer();
            PredictedSnapshotsStorage predictedSnapshotsStorage = new PredictedSnapshotsStorage();
            AverageInputManager       averageInputManager       = new AverageInputManager();
            PredictionChecker         predictionChecker         = new PredictionChecker(playerEntityComparer, predictedSnapshotsStorage);
            SimulationCorrector       simulationCorrector       = new SimulationCorrector(playerPredictor, averageInputManager,
                                                                                          clientInputMessagesHistory, predictedSnapshotsStorage);
            var                predictionManager    = new PredictionManager(predictionChecker, simulationCorrector);
            Joystick           movementJoystick     = battleUiController.GetMovementJoystick();
            Joystick           attackJoystick       = battleUiController.GetAttackJoystick();
            LastInputIdStorage lastInputIdStorage   = new LastInputIdStorage();
            SnapshotBuffer     snapshotBuffer       = new SnapshotBuffer();
            var                snapshotInterpolator = new SnapshotInterpolator(snapshotBuffer);
            var                consoleStub          = new ConsoleNetworkProblemWarningView();
            NetworkTimeManager timeManager          = new NetworkTimeManager(pingStatisticsStorage, snapshotBuffer,
                                                                             consoleStub);
            INetworkTimeManager networkTimeManager = timeManager;
            ITimeUpdater        timeUpdater        = timeManager;

            snapshotManager  = new SnapshotManager(snapshotBuffer, snapshotInterpolator);
            transformStorage = new TransformMessageHandler(snapshotBuffer, timeUpdater);
            MatchTimeSystem   matchTimeSystem  = new MatchTimeSystem(networkTimeManager);
            IMatchTimeStorage matchTimeStorage = matchTimeSystem;
            var          updateTransformSystem = new UpdateTransformSystem(contexts, snapshotManager, matchTimeStorage);
            SpawnManager spawnManager          = new SpawnManager(clientPrefabsStorage, physicsSpawner);

            var killsIndicatorSystem = new KillsIndicatorSystem(battleUiController.GetKillMessage(), battleUiController.GetKillIndicator(),
                                                                battleUiController.GetKillsText(), battleUiController.GetAliveText(), matchModel.PlayerModels.Length,
                                                                new PlayerNameHelper(matchModel));

            killMessageStorage = killsIndicatorSystem;

            systems = new Entitas.Systems()
                      .Add(matchTimeSystem)
                      .Add(new ServerGameStateDebugSystem(snapshotBuffer, clientPrefabsStorage))
                      .Add(new PredictionСheckSystem(snapshotBuffer, predictionManager))
                      .Add(updateTransformSystem)
                      .Add(updatePlayersSystem)

                      .Add(new PrefabSpawnerSystem(contexts, spawnManager))
                      .Add(new InputSystem(movementJoystick, attackJoystick, clientInputMessagesHistory, snapshotManager,
                                           matchTimeStorage, lastInputIdStorage))

                      .Add(new PlayerStopSystem(contexts))
                      .Add(new PlayerPredictionSystem(contexts, clientInputMessagesHistory, playerPredictor))

                      .Add(new CameraMoveSystem(contexts, battleUiController.GetMainCamera(), cameraShift))
                      .Add(new LoadingImageSwitcherSystem(contexts, battleUiController.GetLoadingImage()))

                      .Add(killsIndicatorSystem)

                      .Add(healthUpdaterSystem)
                      .Add(maxHealthUpdaterSystem)

                      .Add(new HealthBarSpawnSystem(contexts, new HealthBarStorage()))
                      .Add(new HealthBarSliderUpdaterSystem(contexts))
                      .Add(new HealthBarPositionUpdaterSystem(contexts))
                      .Add(new HealthBarRotatingSystem(contexts, cameraShift))
                      .Add(new HealthTextUpdatingSystem(contexts))


                      .Add(new HealthBarDestroyHelperSystem(contexts))
                      .Add(new DestroyViewSystem(contexts))



                      .Add(new InputSenderSystem(udpSendUtils, clientInputMessagesHistory))
                      .Add(new RudpMessagesSenderSystem(udpSendUtils))
                      .Add(new GameContextClearSystem(contexts))
                      .Add(new PredictedSnapshotHistoryUpdater(contexts, predictedSnapshotsStorage, matchTimeStorage, lastInputIdStorage))
            ;
            return(systems);
        }