private void Update()
 {
     if (Input.anyKey)
     {
         EventsObserver.Publish(new StopTimeEvent(false));
     }
 }
Exemplo n.º 2
0
            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);
            }
Exemplo n.º 3
0
 public void EvaluateViaKeyPress()
 {
     if (!String.IsNullOrWhiteSpace(Cell.Buffer.Value))
     {
         EventsObserver.OnNext(new EvaluateCodeCellEvent(this, CursorPosition));
     }
 }
Exemplo n.º 4
0
 protected override void Dispose(bool disposing)
 {
     ((CodeCell)Cell).CodeAnalysisBuffer.TextChanged -= HandleBufferTextChanged;
     EventsObserver.OnNext(new DeleteCellEvent <CodeCell> ((CodeCell)Cell));
     preferenceSubscription.Dispose();
     codeEditor.dispose();
 }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
 public void Dispose()
 {
     EventsObserver.RemoveEventListener <IStartGameplayEvent>(StartGameListener);
     EventsObserver.RemoveEventListener <IPauseEvent>(PauseListener);
     EventsObserver.RemoveEventListener <IEndGameEvent>(EndGameListener);
     EventsObserver.RemoveEventListener <IRestartGameEvent>(RestartListener);
 }
Exemplo n.º 7
0
 public void Initialize()
 {
     EventsObserver.AddEventListener <IStartGameplayEvent>(StartGameListener);
     EventsObserver.AddEventListener <IPauseEvent>(PauseListener);
     EventsObserver.AddEventListener <IEndGameEvent>(EndGameListener);
     EventsObserver.AddEventListener <IRestartGameEvent>(RestartListener);
     SetState(_lobbyState);
 }
Exemplo n.º 8
0
    private static void ChangeScore(int scoreValue)
    {
        score += scoreValue;

        SetHighestScore();

        EventsObserver.Publish(new ChangeScoreEvent(score, highestScore));
    }
Exemplo n.º 9
0
    public void PlayerDamage()
    {
        _playerHealth -= 1;

        if (_playerHealth <= 0)
        {
            EventsObserver.Publish(new PlayerDeathEvent());
        }
    }
Exemplo n.º 10
0
 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);
 }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        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();
        }
Exemplo n.º 13
0
    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));
    }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
    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);
        }
    }
Exemplo n.º 16
0
 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;
     }
 }
Exemplo n.º 17
0
        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();
        }
Exemplo n.º 18
0
    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);
        }
    }
Exemplo n.º 19
0
        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)));
        }
Exemplo n.º 20
0
    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());
    }
Exemplo n.º 21
0
 private void OnDisable()
 {
     EventsObserver.RemoveEventListener <IUpdateScoreEvent>(UpdateUIScore);
 }
Exemplo n.º 22
0
 private void OnEnable()
 {
     EventsObserver.AddEventListener <IUpdateScoreEvent>(UpdateUIScore);
 }
Exemplo n.º 23
0
 private void StartGameListener(IStartGameplayEvent e)
 {
     SetState(_gameplayState);
     EventsObserver.Publish(new ISpawnEvent());
 }
Exemplo n.º 24
0
 private void OnEnable()
 {
     EventsObserver.AddEventListener <PlayerBoostEvent>(BoostListener);
 }
Exemplo n.º 25
0
 private void OnDisable()
 {
     EventsObserver.RemoveEventListener <PlayerBoostEvent>(BoostListener);
 }
Exemplo n.º 26
0
 private void OnDisable()
 {
     EventsObserver.RemoveEventListener <IPlaySoundEvent>(Play);
 }
Exemplo n.º 27
0
 private void OnEnable()
 {
     EventsObserver.AddEventListener <IPlaySoundEvent>(Play);
 }
Exemplo n.º 28
0
 public void RestartGame()
 {
     EventsObserver.Publish(new IRestartGameEvent());
     EventsObserver.Publish(new IPlaySoundEvent("Newgame"));
 }
Exemplo n.º 29
0
 public void Dispose()
 {
     EventsObserver.AddEventListener <IRestartGameEvent>(RestartListener);
 }
Exemplo n.º 30
0
    private static void AddAvoidedAsteroids()
    {
        avoidedAsteroids += 1;

        EventsObserver.Publish(new AvoidAsteroidEvent(avoidedAsteroids));
    }