public static SpecialEffect SafeSpawn(SpecialEffect prefab, Vector3 position, Quaternion rotation, Transform parent = null) { if (prefab == null) { return(null); } var instance = PoolService.Spawn(prefab, position, rotation); if (instance == null) { return(null); } if (parent != null) { instance.transform.SetParent(parent); } if (instance.Screenshake.Play) { Debug.Log("implement screenshakes"); } return(instance); }
public void Init() { _poolService = new PoolService(); _pool = Substitute.For <IObjectPool <PoolableEntity> >(); _poolService.AddPool(_pool); }
private void Awake() { LastTrainPos = transform.position; _achievementsService = ServiceLocator.GetService <AchievementsService>(); _audioService = ServiceLocator.GetService <AudioService>(); _levelService = ServiceLocator.GetService <LevelService>(); _adsService = ServiceLocator.GetService <AdsService>(); _skinService = ServiceLocator.GetService <SkinService>(); _gameDataService = ServiceLocator.GetService <GameDataService>(); _uiService = ServiceLocator.GetService <UIService>(); _poolService = ServiceLocator.GetService <PoolService>(); Trains = new List <TrainController>(); spriteRenderer = GetComponent <SpriteRenderer>(); TargetPointList = TargetRail.WayPoints; TargetPoint = TargetPointList[0].localPosition; Trains.Add(this); InputManager.Swipe += InputManagerOnSwipe; _adsService.TrainRevive += ReviveTrain; _uiService.GameRestart += ResetTrain; _skinService.UpdateSkin(spriteRenderer); UpdateTrainPoints(); LockControlls = _uiService.IsFirstTime; IsFirstTime = _uiService.IsFirstTime; }
// Use this for initialization void Start() { PoolService poolService = GameFramework.GetService <PoolService>(); var pool = poolService.CreatePool("Test"); poolService.PreloadPrefab(pool, testPrefab, 3, 5); poolService.Spawn(pool, testPrefab, Vector3.zero, Quaternion.identity, this.gameObject); }
public void Despawn_NotAddedPool_ThrowsException() { var entity = Substitute.For <PoolableEntity>(); _poolService = new PoolService(); Assert.Throws <ArgumentException>(() => _poolService.Despawn(entity)); }
IEnumerator GameobjectDestroyDelay(GameObject _gameObject, float secs) { bustedTankDelaying = false; yield return(new WaitForSeconds(secs)); PoolService.Destroy(_gameObject); bustedTankDelaying = true; }
public void Service_is_created() { var mockLogger = new Mock <ILogger>(); var mockHistoryRepo = new Mock <IHistoryRepository>(); var sut = new PoolService(mockLogger.Object, mockHistoryRepo.Object); Assert.IsInstanceOf <PoolService>(sut); }
void IAttachContext.Attach(Context context) { _context = context; _pool = _context.services.pool; _unitFactory = new UnitFactory(context); }
public void Get_TriggeredPoolEventHandler_OnGet() { var poolEventHandler = new FakePoolEventHandler <TestBehaviour>(); var poolService = new PoolService <TestBehaviour>(poolEventHandler, new FakePoolFactory()); poolService.Get(); Assert.That(poolEventHandler.AddTriggered, Is.True); }
public PoolsController(PoolService poolService, TelemetryService telemetryService, AlarmService alarmService, UserManager <User> userManager, IMapper mapper) { this.poolService = poolService; this.telemetryService = telemetryService; this.alarmService = alarmService; this.userManager = userManager; this.mapper = mapper; }
public void CommenceShellExplosion(Transform tr) { GameObject shellExpl = PoolService.Instantiate(shellExplosion.gameObject, tr.position, tr.rotation); ParticleSystem ps = shellExpl.GetComponent <ParticleSystem>(); ps.Play(); Destroy(ps.gameObject, 1f); StartCoroutine(GameobjectReturnToPoolDelay(shellExpl, 1f)); }
IEnumerator GameobjectReturnToPoolDelay(GameObject _gameObject, float secs) { yield return(new WaitForSeconds(secs)); if (_gameObject != null) { _gameObject.SetActive(false); PoolService.Destroy(_gameObject); } }
public void CommenceTankExplosion(Transform t) { GameObject explosionP = PoolService.Instantiate(tankExplosion.gameObject, t.position, t.rotation); ParticleSystem explosionParticles = explosionP.GetComponent <ParticleSystem>(); //ParticleSystem smokeParticles = Instantiate(explosionSmoke, t.position, t.rotation); explosionParticles.Play(); //smokeParticles.Play(); StartCoroutine(GameobjectReturnToPoolDelay(explosionP, 1f)); }
public void DestroyTank() { UIManager.Instance.playerDead = true; Particles.Instance.CommenceTankExplosion(transform); TankService.Instance.SpawnBustedTank(transform); ServiceEvents.Instance.OnPlayerDeathInVoke(); gameObject.SetActive(false); TankService.Instance.tanks.Remove(this); PoolService.Destroy(gameObject); }
public void DestroyEnemyTank() { Particles.Instance.CommenceTankExplosion(transform); gameObject.SetActive(false); TankService.Instance.SpawnBustedTank(transform); TankService.Instance.IncreamentEnemyDeathCounter(); TankService.Instance.enemyTanks.Remove(this); ServiceEvents.Instance.OnEnemyDeathInvoke(); PoolService.Destroy(gameObject); }
public void SpawnBustedTank(Transform tankPos) { Vector3 pos = new Vector3(tankPos.position.x, 0, tankPos.position.z); GameObject bustedTank = PoolService.Instantiate(BustedTankPrefab, pos, tankPos.rotation); if (bustedTankDelaying) { StartCoroutine(GameobjectDestroyDelay(bustedTank, 2f)); } }
public void Return_TriggeredPoolEventHandler_OnReturn() { var poolEventHandler = new FakePoolEventHandler <TestBehaviour>(); var poolService = new PoolService <TestBehaviour>(poolEventHandler, new FakePoolFactory()); var obj = poolService.Get(); poolService.Return(obj); Assert.That(poolEventHandler.RemoveTriggered, Is.True); }
private void Awake() { _poolService = ServiceLocator.GetService <PoolService>(); _levelService = ServiceLocator.GetService <LevelService>(); _uiService = ServiceLocator.GetService <UIService>(); _railPrefabsDictionary = new Dictionary <RailDirection, RailController>(); foreach (var prefab in RailPrefabs) { _railPrefabsDictionary.Add(prefab.RailDirection, prefab); } DeltaRow = 0; }
internal ServerServices() { ControlCenterService = new ControlCenterService(); UserService = new UserService(); MinerGroupService = new MinerGroupService(); MineWorkService = new MineWorkService(); WalletService = new WalletService(); PoolService = new PoolService(); ColumnsShowService = new ColumnsShowServiceFace(); ClientService = new ClientService(); AppSettingService = new AppSettingServiceFace(); ReportService = new ReportService(); MinerClientService = new WrapperMinerClientService(); }
private IEnumerator DespawnRoutine(float delay) { float elapsed = 0.0f; while (elapsed < delay) { yield return(null); elapsed += Time.deltaTime; } StopAllCoroutines(); PoolService.Despawn(this); OnDespawn(); }
public async void DropoffGroupNotFound(int value) { // Arrange var groupRepositoryMock = new Mock <IGroupRepository>(); groupRepositoryMock.Setup(c => c.GetAsync(value)).Returns(Task.FromResult((Group)null)); var poolService = new PoolService(groupRepositoryMock.Object, null); // Act var result = await poolService.DropoffAsync(value); // Assert Assert.False(result, $"{value} id group should not be founded"); groupRepositoryMock.Verify(c => c.GetAsync(value), Times.Exactly(1)); }
public GameServices(IMessageBrokerService messageBrokerService, ITimeService timeService, IDataSaver dataSaver, IGameLogic gameLogic, IWorldObjectReferenceService worldObjectReference) { var networkService = new GameNetworkService(); NetworkService = networkService; MessageBrokerService = messageBrokerService; TimeService = timeService; WorldObjectReferenceService = worldObjectReference; DataSaver = dataSaver; CommandService = new CommandService <IGameLogic>(gameLogic, networkService); PoolService = new PoolService(); AssetResolverService = new AssetResolverService(); TickService = new TickService(); CoroutineService = new CoroutineService(); }
public void DispatchedUpdate(RawInput input) { if (state.CurrentState == EState.Idle) { if (!input.SpawnItemDown) { return; } state.CurrentState = EState.Spawning; state.SpawnOrigin = input.ManipulatorPositionWorld; state.ItemInstance = PoolService.Spawn(state.PrototypedItemPrefab, state.SpawnOrigin, Quaternion.identity); state.ItemInstance.OnManipulatorBegin(); } else if (state.CurrentState == EState.Spawning) { Time.timeScale = Mathf.MoveTowards(Time.timeScale, 0.01f, Time.unscaledDeltaTime * 6f); var desiredDirection = (state.SpawnOrigin - input.ManipulatorPositionWorld).normalized; var maxRotationDelta = PlayerParams.SpawnRotationSpeed * Mathf.Deg2Rad * Time.unscaledDeltaTime; var newDirection = Vector3.RotateTowards(state.ItemInstance.transform.right, desiredDirection, maxRotationDelta, 0f); state.ItemInstance.transform.right = newDirection; if (!input.SpawnItemUp) { return; } state.CurrentState = EState.Release; } else if (state.CurrentState == EState.Release) { Time.timeScale = 1f; state.ItemInstance.OnManipulatorRelease(); state.ItemInstance = null; state.CurrentState = EState.Idle; } else { Debug.LogError($"Manipulator state {state.CurrentState} is not supported."); } }
public void Despawn(float delay = 0) { if (!m_isSpawned) { return; } if (delay == 0) { StopAllCoroutines(); PoolService.Despawn(this); OnDespawn(); return; } StartCoroutine(DespawnRoutine(delay)); }
public void DoWork_handles_ChangedData() { RacconHistory spiedHistory = null; var mockLogger = new Mock <ILogger>(); var historyRepository = new Mock <IHistoryRepository>(); historyRepository .Setup(h => h.InsertHistory(It.IsAny <RacconHistory>()) ) .Callback <RacconHistory>((h) => { spiedHistory = h; } ) .Returns(1); var sut = new PoolService(mockLogger.Object, historyRepository.Object); var ts = new DateTime(2019, 11, 24, 14, 35, 0); var job = new Job { Entity = eWiftEntity.Pool, SubjectName = "Test Race 1", RaceId = Guid.Parse("C56A4180-65AA-42EC-A945-5FD21DEC0538"), ChangeProperty = "CloseTime", ChangeData = ts, StartTime = ts, DivType = DIVTYPE_WIN, SourceId = TABCORP_VIC }; sut.DoWork(job); Assert.AreEqual("success", spiedHistory.status); Assert.AreEqual("Test Race 1", spiedHistory.subjectname); Assert.AreEqual("C56A4180-65AA-42EC-A945-5FD21DEC0538", spiedHistory.subjectkey.ToString().ToUpper()); dynamic dyn = JsonConvert.DeserializeObject(spiedHistory.data); Assert.AreEqual("2019-11-24T14:35:00Z", dyn.stopSell.ToString("yyyy-MM-ddTHH:mm:ssZ")); }
public async void DropoffGroupWithoutCar(int value) { // Arrange var groupRepositoryMock = new Mock <IGroupRepository>(); groupRepositoryMock.Setup(c => c.GetAsync(value)).Returns(Task.FromResult(new Group { Id = value, People = 3 })); groupRepositoryMock.Setup(c => c.DeleteAsync(value)).Returns(Task.FromResult(1)); // Car repository should not be called var poolService = new PoolService(groupRepositoryMock.Object, null); // Act var result = await poolService.DropoffAsync(value); // Assert Assert.True(result, $"{value} id group should be founded and deleted"); groupRepositoryMock.Verify(c => c.GetAsync(value), Times.Exactly(1)); groupRepositoryMock.Verify(c => c.DeleteAsync(value), Times.Exactly(1)); }
public async void DropoffGroupWithCar(int value) { var group = new Group { Id = value, People = 3, CarId = 1 }; var carToDropOff = new Car { Id = 1, Seats = 6, GroupsAssigned = new List <Group>() }; carToDropOff.GroupsAssigned.Add(group); group.JourneyCar = carToDropOff; // Arrange var groupRepositoryMock = new Mock <IGroupRepository>(); groupRepositoryMock.Setup(c => c.GetAsync(value)).Returns(Task.FromResult(group)); groupRepositoryMock.Setup(c => c.DeleteAsync(value)).Returns(Task.FromResult(1)); var carRepositoryMock = new Mock <ICarRepository>(); carRepositoryMock.Setup(c => c.GetAsync(1)).Returns(Task.FromResult(carToDropOff)); carRepositoryMock.Setup(c => c.UpdateCarAsync(carToDropOff)).Returns(Task.FromResult(carToDropOff)); // Car repository should not be called var poolService = new PoolService(groupRepositoryMock.Object, carRepositoryMock.Object); // Act var result = await poolService.DropoffAsync(value); // Assert Assert.True(result, $"{value} id group should be founded and deleted"); Assert.Empty(carToDropOff.GroupsAssigned); groupRepositoryMock.Verify(c => c.GetAsync(value), Times.Exactly(1)); groupRepositoryMock.Verify(c => c.DeleteAsync(value), Times.Exactly(1)); carRepositoryMock.Verify(c => c.GetAsync(1), Times.Exactly(1)); carRepositoryMock.Verify(c => c.UpdateCarAsync(carToDropOff), Times.Exactly(1)); }
public Pool(PoolService service) { _service = service; }
private void Start() { _activeObjects = new PoolActiveObjects <Bullet>(); _bulletsPool = new PoolService <Bullet>(_activeObjects, _bulletsPoolSetup); }
public TankController(TankView tankPrefab, TankModel tankModel, Vector3 _pos, Quaternion _rotation) { TankView = PoolService.Instantiate(tankPrefab.gameObject, _pos, _rotation); //TankView.SetTankDetails(tankModel); }