public void StartSystem(IGroupAccessor @group) { _updateLoop = Observable.Interval(TimeSpan.FromSeconds(2)).Subscribe(x => { Debug.Log("Outputting: " + _timesOutputted++); }); }
public TurnsSystem(GameConfiguration gameConfiguration, IEventSystem eventSystem, IPoolManager poolManager) { _gameConfiguration = gameConfiguration; _eventSystem = eventSystem; _levelAccessor = poolManager.CreateGroupAccessor(new Group(typeof(LevelComponent))); }
public void AddGroupAccessor(IGroupAccessor groupAccessor) { var groupAccessors = GroupAccessors; Array.Resize(ref groupAccessors, GroupAccessors.Length + 1); GroupAccessors[GroupAccessors.Length] = groupAccessor; }
public void StartSystem(IGroupAccessor group) { _eventSystem.Receive <ComponentRemovedEvent>() .Where(x => x.Component.GetType() == typeof(DestructibleComponent)) .Subscribe(x => _removeDestructible((DestructibleComponent)x.Component)) .AddTo(_subscriptions); _eventSystem.Receive <ComponentRemovedEvent>() .Where(x => x.Component.GetType() == typeof(DestructibleComponent)) .Throttle(TimeSpan.FromMilliseconds(500)) .Subscribe(s => { AstarPath.active.UpdateGraphs(_destructiblesTilemap.localBounds); }) .AddTo(_subscriptions); _eventSystem.Receive <LevelEvent>() .Where(x => x.action == LevelActions.START) .Subscribe(x => { var destructiblesGo = GameObject.Find("Map/Destructibles"); _destructiblesTilemap = destructiblesGo.GetComponent <Tilemap>(); var tilemapGo = GameObject.Find("Map/Tilemap"); _tilemapTilemap = tilemapGo.GetComponent <Tilemap>(); var aStarGo = GameObject.Find("Map/A*"); _aStarAstarPath = aStarGo.GetComponent <AstarPath>(); _createDestructibles(); }) .AddTo(_subscriptions); }
public void StartSystem(IGroupAccessor group) { _eventSystem.Receive <KillEvent>() .Where(x => _isEnemy(x.target)) .Subscribe(x => _reduceEnemies()) .AddTo(_subscriptions); _eventSystem.Receive <LevelEvent>() .Where(x => x.action == LevelActions.STOP) .Subscribe(x => { _subscription.Dispose(); _resetEnemies(); }) .AddTo(_subscriptions); _eventSystem.Receive <LevelEvent>() .Where(x => x.action == LevelActions.START) .Subscribe(x => { _subscription = Observable.FromCoroutine(_createEnemies) .Subscribe(); }) .AddTo(_subscriptions); }
public void StartSystem(IGroupAccessor @group) { _eventSystem.Receive <FoodPickupEvent>().Subscribe(x => { var clips = x.IsSoda ? _drinkSounds.AvailableClips : _foodSounds.AvailableClips; PlayOneOf(clips); }).AddTo(_subscriptions); _eventSystem.Receive <EntityMovedEvent>() .Subscribe(x => PlayOneOf(_walkingSounds.AvailableClips)) .AddTo(_subscriptions); _eventSystem.Receive <EnemyHitEvent>() .Subscribe(x => PlayOneOf(_playerAttackSounds.AvailableClips)) .AddTo(_subscriptions); _eventSystem.Receive <WallHitEvent>() .Subscribe(x => PlayOneOf(_playerAttackSounds.AvailableClips)) .AddTo(_subscriptions); _eventSystem.Receive <PlayerHitEvent>() .Subscribe(x => PlayOneOf(_enemyAttackSounds.AvailableClips)) .AddTo(_subscriptions); _eventSystem.Receive <PlayerKilledEvent>() .Subscribe(x => PlayOneOf(_deathSounds.AvailableClips)) .AddTo(_subscriptions); }
public UIManager(IPoolManager poolManager, IEventSystem eventSystem) { CurrentScreen = new ReactiveProperty <IEntity>(); defaultPool = poolManager.GetPool(); this.eventSystem = eventSystem; uiGroupAccessor = poolManager.CreateGroupAccessor(new Group(typeof(UIComponet))); }
public EnemyMovementSystem(IPoolManager poolManager) { _playersAccessor = poolManager .CreateGroupAccessor(new Group( typeof(PlayerComponent), typeof(ViewComponent) )); }
public void StartSystem(IGroupAccessor @group) { this.WaitForScene().Subscribe(x => { foreach (var player in @group.Entities) { CheckForInteractions(player); } }); }
public void StartSystem(IGroupAccessor @group) { this.WaitForScene() .Subscribe(x => { var level = @group.Entities.First(); _levelComponent = level.GetComponent <LevelComponent>(); SetupSubscriptions(); }); }
public void StartSystem(IGroupAccessor @group) { this.WaitForScene().Subscribe(x => { var player = @group.Entities.First(); _playerComponent = player.GetComponent <PlayerComponent>(); _foodText = GameObject.Find("FoodText").GetComponent <Text>(); SetupSubscriptions(); }); }
public CameraSystem(IEventSystem eventSystem, IPoolManager poolManager) { _eventSystem = eventSystem; _playersAccessor = poolManager .CreateGroupAccessor(new Group( typeof(PlayerComponent), typeof(ViewComponent) )); _subscriptions = new List <IDisposable>(); _camera = Camera.main; _isPaused = false; }
public void StartSystem(IGroupAccessor @group) { this.WaitForScene().Subscribe(x => _level = _levelAccessor.Entities.First()); _updateSubscription = Observable.EveryUpdate().Where(x => IsLevelLoaded()) .Subscribe(x => { if (_isProcessing) { return; } MainThreadDispatcher.StartCoroutine(CarryOutTurns(@group)); }); }
public void StartSystem(IGroupAccessor group) { _eventSystem.Receive <KillEvent>() .Where(x => _isEnemy(x.target)) .Subscribe(x => _totalScore += 100) .AddTo(_subscriptions); _eventSystem.Receive <ScoreEvent>() .Subscribe(x => { var coinComponent = x.target.GetComponent <CoinComponent>(); _totalScore += coinComponent.score; }) .AddTo(_subscriptions); _eventSystem.Receive <KillEvent>() .Where(x => _isPlayer(x.target)) .Subscribe(x => _showRestartPanel(true)) .AddTo(_subscriptions); _pauseToggle.OnValueChangedAsObservable() .Subscribe(x => _pause(x)) .AddTo(_subscriptions); _resetBtnButton.OnClickAsObservable() .Subscribe(x => { _showRestartPanel(false); _restartLevel(); }) .AddTo(_subscriptions); _eventSystem.Receive <LevelEvent>() .Where(x => x.action == LevelActions.START) .Subscribe(x => _resetAll()) .AddTo(_subscriptions); Observable.Interval(TimeSpan.FromMilliseconds(30)) .Subscribe(x => { _updatePlayerHealth(); _updateScore(); }) .AddTo(_subscriptions); this.WaitForScene() .Subscribe(x => { _resetAll(); }); }
public void StartSystem(IGroupAccessor group) { _button.OnClickAsObservable() .Subscribe(x => { _stopGlitch(); _startButton.SetActive(false); _scene.allowSceneActivation = true; }) .AddTo(_subscriptions); this.WaitForScene() .Subscribe(x => { MainThreadDispatcher.StartCoroutine(_loadingScene("Game")); }); }
public BulletCollisionSystem(IPoolManager poolManager, IEventSystem eventSystem) { _pool = poolManager.GetPool(""); _eventSystem = eventSystem; _destructiblesAccessor = poolManager .CreateGroupAccessor(new Group( typeof(DestructibleComponent) )); _subscriptions = new List <IDisposable>(); _eventSystem.Receive <LevelEvent>() .Where(x => x.action == LevelActions.START) .Subscribe(x => { var destructiblesGo = GameObject.Find("Map/Destructibles"); _destructiblesTilemap = destructiblesGo.GetComponent <Tilemap>(); }) .AddTo(_subscriptions); }
public void AddGroupAccessor(IGroupAccessor groupAccessor) { // add to this var groupAccessors = GroupAccessors; var gaLen = GroupAccessors.Length; Array.Resize(ref groupAccessors, gaLen + 1); GroupAccessors = groupAccessors; GroupAccessors[gaLen] = groupAccessor; // check actual connections foreach (var type in groupAccessor.AccessorToken.ComponentTypes) { var typeId = TypeHelper.GetTypeId(type); if (_outConnectionIndex.TryGetValue(typeId, out var connection) && connection.UpReactor == this) { connection.AddGroupAccessor(groupAccessor); } } }
public UISystem(IEventSystem eventSystem, IPoolManager poolManager) { var playerHealthPanelCountGo = GameObject.Find("PlayerHealthPanel/Count"); _playerHealthPanelCount = playerHealthPanelCountGo.GetComponent <Text>(); var scoreCountGo = GameObject.Find("ScorePanel/Count"); _scoreCount = scoreCountGo.GetComponent <Text>(); _totalScore = 0; _pauseButtonGo = GameObject.Find("PauseButton"); _pauseToggle = _pauseButtonGo.GetComponent <Toggle>(); var resetButtonGo = GameObject.Find("ResetButton"); _resetBtnButton = resetButtonGo.GetComponent <Button>(); var pauseGo = GameObject.Find("PauseButton/Pause"); _pauseImage = pauseGo.GetComponent <Image>(); var playGo = GameObject.Find("PauseButton/Play"); _playImage = playGo.GetComponent <Image>(); _directionJoystick = GameObject.Find("DirectionJoystick"); _rotationJoystick = GameObject.Find("RotationJoystick"); _restartPanelGo = GameObject.Find("RestartPanel"); _pauseTextGo = GameObject.Find("PauseText"); var playerHealthBarGo = GameObject.Find("PlayerHealthPanel/Bar"); _playerHealthBarSlider = playerHealthBarGo.GetComponent <Slider>(); _curtainGo = GameObject.Find("Curtain"); _curtainImage = _curtainGo.GetComponent <Image>(); _dashButtonGo = GameObject.Find("DashButton"); var restartPanelScoreCountGo = GameObject.Find("RestartPanel/ScoreCount"); _restartPanelScoreCount = restartPanelScoreCountGo.GetComponent <Text>(); _eventSystem = eventSystem; _subscriptions = new List <IDisposable>(); _playersAccessor = poolManager .CreateGroupAccessor(new Group( typeof(PlayerComponent), typeof(ViewComponent) )); }
public void StartSystem(IGroupAccessor group) { _eventSystem.Receive <DamageEvent>() .Where(x => _isPlayer(x.target)) .Subscribe(x => _startShake()) .AddTo(_subscriptions); _eventSystem.Receive <LevelEvent>() .Where(x => x.action == LevelActions.PAUSE) .Subscribe(x => _isPaused = true) .AddTo(_subscriptions); _eventSystem.Receive <LevelEvent>() .Where(x => x.action != LevelActions.PAUSE) .Subscribe(x => _isPaused = false) .AddTo(_subscriptions); Observable.EveryUpdate() .Subscribe(x => _move()) .AddTo(_subscriptions); }
private IEnumerator CarryOutTurns(IGroupAccessor @group) { _isProcessing = true; yield return(new WaitForSeconds(_gameConfiguration.TurnDelay)); if ([email protected]()) { yield return(new WaitForSeconds(_gameConfiguration.TurnDelay)); } var enemies = @group.Entities; foreach (var enemy in enemies) { _eventSystem.Publish(new EnemyTurnEvent(enemy)); yield return(new WaitForSeconds(_gameConfiguration.MovementTime)); } _eventSystem.Publish(new PlayerTurnEvent()); _isProcessing = false; }
public void StartSystem(IGroupAccessor group) { _eventSystem.Receive <LevelEvent>() .Where(x => x.action == LevelActions.PAUSE) .Subscribe(x => Time.timeScale = 0.00001f) .AddTo(_subscriptions); _eventSystem.Receive <LevelEvent>() .Where(x => x.action == LevelActions.RESUME) .Subscribe(x => Time.timeScale = 1) .AddTo(_subscriptions); _eventSystem.Receive <LevelEvent>() .Where(x => x.action == LevelActions.RESTART) .Subscribe(x => _restartLevel()) .AddTo(_subscriptions); this.WaitForScene() .Subscribe(x => { _startLevel(); }); }
public void StartSystem(IGroupAccessor @group) { var tickSubscription = EventSystem.Receive <EffectTickedEvent>().Subscribe(x => { var logMessage = string.Format("{0} Ticked For {1}", x.ActiveEffect.Effect.Name, x.ActiveEffect.Effect.Potency); UpdateLog(logMessage); }); var effectAddedSubscription = EventSystem.Receive <EffectAddedEvent>().Subscribe(x => { var logMessage = string.Format("{0} Has Been Applied", x.ActiveEffect.Effect.Name); UpdateLog(logMessage); }); var effectRemovedSubscription = EventSystem.Receive <EffectExpiredEvent>().Subscribe(x => { var logMessage = string.Format("{0} Has Expired", x.ActiveEffect.Effect.Name); UpdateLog(logMessage); }); _subscriptions.Add(tickSubscription); _subscriptions.Add(effectAddedSubscription); _subscriptions.Add(effectRemovedSubscription); }
public IObservable <IGroupAccessor> Impact(IGroupAccessor @group) { return(Observable.Interval(TimeSpan.FromSeconds(1)).Select(x => @group)); }
public GroupAccessorAddedEvent(GroupAccessorToken groupAccessorToken, IGroupAccessor groupAccessor) { GroupAccessor = groupAccessor; GroupAccessorToken = groupAccessorToken; }
public IObservable <IGroupAccessor> ReactToGroup(IGroupAccessor group) { return(Observable.EveryUpdate().Select(x => group)); }
public static IEnumerable <IEntity> Query(this IGroupAccessor groupAccesssor, IGroupAccessorQuery query) { return(query.Execute(groupAccesssor)); }
public IObservable <IGroupAccessor> Impact(IGroupAccessor @group) { return(Observable.EveryUpdate().Select(x => @group)); }
public void StopSystem(IGroupAccessor group) { _subscriptions.DisposeAll(); }
public void StopSystem(IGroupAccessor @group) { _foodTriggers.DisposeAll(); _exitTriggers.DisposeAll(); }
public void StopSystem(IGroupAccessor @group) { _updateSubscription.Dispose(); }