Beispiel #1
0
        public void SetUp()
        {
            GameSceneFactory gameSceneFactory = new GameSceneFactory();
            Scene            matchScene       = gameSceneFactory.Create();

            ArrangeTransformSystem[] arrangeCollidersSystems =
            {
                new WithHpArrangeTransformSystem(contexts)
            };
            PhysicsRollbackManager physicsRollbackManager = new PhysicsRollbackManager(arrangeCollidersSystems);

            PhysicsVelocityManager physicsVelocityManager = new PhysicsVelocityManager();
            PhysicsRotationManager physicsRotationManager = new PhysicsRotationManager();
            SnapshotFactory        snapshotFactory        = new SnapshotFactory(contexts.serverGame);

            playerPredictor = new PlayerPredictor(physicsRollbackManager, matchScene,
                                                  contexts.serverGame, physicsVelocityManager, physicsRotationManager, snapshotFactory);

            playerEntity = contexts.serverGame.CreateEntity();
            ClientPrefabsStorage clientPrefabsStorage = new ClientPrefabsStorage();
            GameObject           warshipPrefab        = clientPrefabsStorage.GetPrefab(ViewTypeEnum.StarSparrow1);
            GameObject           go = Object.Instantiate(warshipPrefab, Vector3.zero, Quaternion.identity);

            SceneManager.MoveGameObjectToScene(go, matchScene);
            ushort playerEntityId = 100;

            playerEntity.AddId(playerEntityId);
            playerEntity.AddView(go);
            playerEntity.AddRigidbody(go.GetComponent <Rigidbody>());

            LogAssert.ignoreFailingMessages = true;
        }
        public void Spawn(ServerGameEntity entity)
        {
            ViewTypeEnum viewType      = entity.viewType.value;
            Vector3      spawnPosition = entity.spawnTransform.position;
            Quaternion   spawnRotation = entity.spawnTransform.rotation;

            GameObject prefab = prefabStorage.GetPrefab(viewType);
            GameObject go     = physicsSpawner.SpawnProjectile(prefab, spawnPosition, spawnRotation);

            go.layer = projectileLayerNumber;
            entity.AddTransform(go.transform);
            Rigidbody rigidbody = go.GetComponent <Rigidbody>();

            entity.AddRigidbody(rigidbody);
            go.Link(entity);
            entity.AddView(go);

            if (entity.hasParentWarship)
            {
                var        projectileCollider = go.GetComponent <Collider>();
                Collider[] warshipColliders   = entity.parentWarship.entity.warshipColliders.colliders;


                Vector3 parentVelocity = entity.parentWarship.entity.rigidbody.value.velocity;
                rigidbody.velocity = parentVelocity;
                physicsSpawner.Ignore(new[] { projectileCollider }, warshipColliders);
            }
        }
Beispiel #3
0
        public void Spawn(ServerGameEntity entity)
        {
            ViewTypeEnum viewType      = entity.viewType.value;
            Vector3      spawnPosition = entity.spawnTransform.position;
            Quaternion   spawnRotation = entity.spawnTransform.rotation;
            GameObject   prefab        = prefabStorage.GetPrefab(viewType);
            GameObject   go            = physicsSpawner.Spawn(prefab, spawnPosition, spawnRotation);

            go.Link(entity);
            entity.AddTransform(go.transform);
            Rigidbody rigidbody = go.GetComponent <Rigidbody>();

            entity.AddRigidbody(rigidbody);
            entity.AddView(go);

            //todo не забыть убрать компонент
            // entity.RemoveSpawnTransform();
        }
Beispiel #4
0
        public void Spawn(ServerGameEntity entity)
        {
            ViewTypeEnum viewType      = entity.viewType.value;
            Vector3      spawnPosition = entity.spawnTransform.position;
            Quaternion   spawnRotation = entity.spawnTransform.rotation;
            GameObject   prefab        = prefabStorage.GetPrefab(viewType);
            GameObject   go            = physicsSpawner.Spawn(prefab, spawnPosition, spawnRotation);

            go.layer = playersLayerNumber;
            go.Link(entity);
            entity.AddView(go);
            entity.AddTransform(go.transform);
            Rigidbody rigidbody = go.GetComponent <Rigidbody>();

            entity.AddRigidbody(rigidbody);
            shootingPointsHelper.AddShootingPoints(go, entity);
            Collider[] colliders = go.GetComponents <Collider>();
            entity.AddWarshipColliders(colliders);
        }