private void Update() { if (Input.anyKey) { EventsObserver.Publish(new StopTimeEvent(false)); } }
dynamic HandleCursorUpDown(dynamic self, dynamic args) { var isUp = (bool)args [0]; // var isMod = (bool)args [1]; FocusSiblingEditorEvent evnt = null; if (isUp && proseMirror.shouldFocusPreviousEditor()) { evnt = new FocusSiblingEditorEvent( this, FocusSiblingEditorEvent.WhichEditor.Previous); } else if (!isUp && proseMirror.shouldFocusNextEditor()) { evnt = new FocusSiblingEditorEvent( this, FocusSiblingEditorEvent.WhichEditor.Next); } if (evnt == null) { return(false); } EventsObserver.OnNext(evnt); return(true); }
public void EvaluateViaKeyPress() { if (!String.IsNullOrWhiteSpace(Cell.Buffer.Value)) { EventsObserver.OnNext(new EvaluateCodeCellEvent(this, CursorPosition)); } }
protected override void Dispose(bool disposing) { ((CodeCell)Cell).CodeAnalysisBuffer.TextChanged -= HandleBufferTextChanged; EventsObserver.OnNext(new DeleteCellEvent <CodeCell> ((CodeCell)Cell)); preferenceSubscription.Dispose(); codeEditor.dispose(); }
dynamic HandleCursorUpDown(dynamic self, dynamic args) { var isUp = (bool)args [0]; var pos = CursorPosition; var historyEvent = new NavigateReplHistoryEvent(this, pos, isUp); EventsObserver.OnNext(historyEvent); if (historyEvent.Handled) { return(true); } if (isUp && pos.Line == 0) { EventsObserver.OnNext(new FocusSiblingEditorEvent( this, FocusSiblingEditorEvent.WhichEditor.Previous)); return(true); } if (!isUp && pos.Line == codeEditor.getLastLineIndex()) { EventsObserver.OnNext(new FocusSiblingEditorEvent( this, FocusSiblingEditorEvent.WhichEditor.Next)); return(true); } return(false); }
public void Dispose() { EventsObserver.RemoveEventListener <IStartGameplayEvent>(StartGameListener); EventsObserver.RemoveEventListener <IPauseEvent>(PauseListener); EventsObserver.RemoveEventListener <IEndGameEvent>(EndGameListener); EventsObserver.RemoveEventListener <IRestartGameEvent>(RestartListener); }
public void Initialize() { EventsObserver.AddEventListener <IStartGameplayEvent>(StartGameListener); EventsObserver.AddEventListener <IPauseEvent>(PauseListener); EventsObserver.AddEventListener <IEndGameEvent>(EndGameListener); EventsObserver.AddEventListener <IRestartGameEvent>(RestartListener); SetState(_lobbyState); }
private static void ChangeScore(int scoreValue) { score += scoreValue; SetHighestScore(); EventsObserver.Publish(new ChangeScoreEvent(score, highestScore)); }
public void PlayerDamage() { _playerHealth -= 1; if (_playerHealth <= 0) { EventsObserver.Publish(new PlayerDeathEvent()); } }
public void Initialize() { _columns = new Column[_settings.ColumnsCount]; for (int i = 0; i < _settings.ColumnsCount; i++) { _columns[i] = new Column(new Transform[_settings.TransformsYCount]); } EventsObserver.AddEventListener <IRestartGameEvent>(RestartListener); }
public void ChangeScoreTest(int lineCount, string expectedResult) { EventsObserver.Publish(new IStartGameplayEvent()); var scoremanager = Container.Resolve <IScoreManager>(); var settings = Container.Resolve <ScoreManager.Settings>(); var scoreValueLabel = GameObject.Find("ScoreValueText").GetComponent <TextMeshProUGUI>(); settings._lineScore = 100; settings._lineScoreMultiplier = 1.2f; scoremanager.AddLineScore(lineCount); Assert.AreEqual(expectedResult, scoreValueLabel.text); }
void HandleChange(dynamic self, dynamic args) { Cell.Buffer.Value = codeEditor.getText(); // WorkbookCodeEditorChangeEvent var changeEvent = args [0]; var text = changeEvent.text?.ToString() ?? ""; EventsObserver.OnNext(new ChangeEvent(this, text)); UpdateDiagnosticsAsync().Forget(); }
public void AddLineScore(int linesCount) { if (linesCount == 1) { _score += _settings._lineScore; } else { _score += (int)(_settings._lineScore * linesCount * _settings._lineScoreMultiplier); } _lines += linesCount; EventsObserver.Publish(new IUpdateScoreEvent(_score, _lines)); }
dynamic HandleEnter(dynamic self, dynamic args) { var isShift = (bool)args [0]; var isMeta = (bool)args [1]; var isCtrl = (bool)args [2]; var isMod = InteractiveInstallation.Default.IsMac ? isMeta : isCtrl; // Shift+Mod+Enter: new markdown cell if (isShift && isMod) { EventsObserver.OnNext( new InsertCellEvent <MarkdownCell> (Cell)); return(true); } // Mod+Enter: evaluate if (isMod) { EvaluateViaKeyPress(); return(true); } // Shift+Enter: regular newline+indent if (isShift) { return(false); } // Regular enter: evaluate if cell submission complete var shouldSubmit = Prefs.Submissions.ReturnAtEndOfBufferExecutes.GetValue() && !codeEditor.isSomethingSelected() && codeEditor.isCursorAtEnd(); var workspace = state.CompilationWorkspace; var documentId = state.DocumentId; if (shouldSubmit && !String.IsNullOrWhiteSpace(Cell.Buffer.Value) && workspace != null && documentId != null && workspace.IsDocumentSubmissionComplete(documentId)) { EventsObserver.OnNext(new EvaluateCodeCellEvent(this, CursorPosition)); return(true); } return(false); }
public void SetTarget(GameObject shape, float normalSpeed, float fastSpeed) { _normalTransitionInterval = normalSpeed; _fastTransitionInterval = fastSpeed; _shape = shape; currentTransitionInterval = _normalTransitionInterval; _rotationPivot = _shape.transform.Find("Pivot"); if (!_gridManager.IsValidGridPosition(_shape.transform)) { EventsObserver.Publish(new IEndGameEvent()); GameObject.Destroy(_shape.gameObject); } }
public void MoveHorizontal(Vector3 direction) { if (_shape == null) { return; } _shape.transform.position += direction; if (_gridManager.IsValidGridPosition(_shape.transform)) { _gridManager.UpdateGrid(_shape.transform); EventsObserver.Publish(new IPlaySoundEvent("Move")); } else { _shape.transform.position -= direction; } }
void HandleChange(dynamic self, dynamic args) { settingBufferValue = true; Cell.Buffer.Value = codeEditor.getText(); settingBufferValue = false; // WorkbookCodeEditorChangeEvent var changeEvent = args [0]; var text = changeEvent.text?.ToString() ?? ""; dynamic newCursorPosition = changeEvent.newCursorPosition; var linePosition = MonacoExtensions.FromMonacoPosition(newCursorPosition); EventsObserver.OnNext(new ChangeEvent(this, linePosition, text)); UpdateDiagnosticsAsync().Forget(); }
public void RotateShape(bool isClockwise) { if (_shape == null) { return; } float rotationDegree = isClockwise ? 90.0f : -90.0f; _shape.transform.RotateAround(_rotationPivot.position, Vector3.forward, rotationDegree); if (_gridManager.IsValidGridPosition(_shape.transform)) { _gridManager.UpdateGrid(_shape.transform); EventsObserver.Publish(new IPlaySoundEvent("Rotate")); } else { _shape.transform.RotateAround(_rotationPivot.position, Vector3.forward, -rotationDegree); } }
public static IDisposable When <T>(Action <T> when, bool includeTracing = true) where T : class { var observer = new EventsObserver(@event => { var type1 = @event as T; if (type1 != null) { when(type1); } if (includeTracing) { Trace.WriteLine(@event); } }); var old = SystemObserver.Swap(new IObserver <ISystemEvent>[] { observer }); return(new Disposable(() => SystemObserver.Swap(old))); }
private void DeleteRows() { var fullRowsCount = 0; for (int y = 0; y < _settings.TransformsYCount; y++) { if (IsRowFull(y)) { DeleteRow(y); DecreaseRowsAbove(y + 1); y--; fullRowsCount++; } } if (fullRowsCount > 0) { _scoreManager.AddLineScore(fullRowsCount); EventsObserver.Publish(new IPlaySoundEvent("Drop")); } EventsObserver.Publish(new ISpawnEvent()); }
private void OnDisable() { EventsObserver.RemoveEventListener <IUpdateScoreEvent>(UpdateUIScore); }
private void OnEnable() { EventsObserver.AddEventListener <IUpdateScoreEvent>(UpdateUIScore); }
private void StartGameListener(IStartGameplayEvent e) { SetState(_gameplayState); EventsObserver.Publish(new ISpawnEvent()); }
private void OnEnable() { EventsObserver.AddEventListener <PlayerBoostEvent>(BoostListener); }
private void OnDisable() { EventsObserver.RemoveEventListener <PlayerBoostEvent>(BoostListener); }
private void OnDisable() { EventsObserver.RemoveEventListener <IPlaySoundEvent>(Play); }
private void OnEnable() { EventsObserver.AddEventListener <IPlaySoundEvent>(Play); }
public void RestartGame() { EventsObserver.Publish(new IRestartGameEvent()); EventsObserver.Publish(new IPlaySoundEvent("Newgame")); }
public void Dispose() { EventsObserver.AddEventListener <IRestartGameEvent>(RestartListener); }
private static void AddAvoidedAsteroids() { avoidedAsteroids += 1; EventsObserver.Publish(new AvoidAsteroidEvent(avoidedAsteroids)); }