private void HandleUserInput()
 {
     if (!_spacebarPressed)
     {
         return;
     }
     if (AntiSpamming.CheckForSpamming(_currentDisplayStatus, _spacebarPressed))
     {
         _spamCounter++;
     }
     if (_iSprite < 0 || !(_reactionTimes[_iSprite] < 0))
     {
         return;
     }
     _reactionTimes[_iSprite] = _passedTime;
 }
示例#2
0
        public void Update()
        {
            _spacebarPressed = Input.GetKeyDown("space");

            CheckSkipping();
            _passedTime += Time.deltaTime * 1000;

            double threshold = UnityClient.Communicator.HandleServerParams();

            if (Math.Abs(threshold) > float.Epsilon)
            {
                _threshold = threshold;
            }

            switch (_currentDisplayStatus)
            {
            case DisplayStatus.DisplayingInfo:
                var limit = _currentInfo.DisplayTime != -1 ? _currentInfo.DisplayTime : _taskSettings.InfoTime;
                if (_passedTime > limit)
                {
                    if (_currentSprite != null)
                    {
                        SpriteHandler.Sh.DestroySprite(_currentSprite);
                    }
                    _currentInfo          = _informationHolder.GetNextInformation();
                    _currentDisplayStatus = _currentInfo.NextDisplayStatus;
                    _panel.GetComponentInChildren <Text>().text = _currentInfo.InfoText;
                    _allowedSkipping = _currentInfo.Skippable;
                    _passedTime      = 0;
                }
                break;

            case DisplayStatus.DisplayResults:
                HandleUserInput();
                if (_passedTime > _spriteSettings.GetTimeSettings(_currentSpriteType).SpriteDelayTime)
                {
                    DisplayInfo();
                    _passedTime = 0;
                }
                break;

            case DisplayStatus.WaitToDisplaySprite:
                AntiSpamming.CheckForSpamming(_currentDisplayStatus, _spacebarPressed);
                HandleUserInput();
                if (_passedTime > _spriteSettings.GetTimeSettings(_upcomingSpriteType).SpriteDelayTime)
                {
                    _panel.GetComponentInChildren <Text>().text = "";
                    ShowSprite();
                    _passedTime = 0;
                }
                break;

            case DisplayStatus.DisplayingSprite:
                if (_passedTime > _spriteSettings.GetTimeSettings(_currentSpriteType).SpriteDisplayTime)
                {
                    AntiSpamming.Clear();
                    RemoveSprite();
                }
                HandleUserInput();
                break;

            case DisplayStatus.WaitingUserInput:
                if (_spacebarPressed)
                {
                    _currentDisplayStatus = DisplayStatus.DisplayingInfo;
                }
                break;

            case DisplayStatus.DisplayBoth:
                limit = _currentInfo.DisplayTime != -1 ? _currentInfo.DisplayTime : _taskSettings.InfoTime;
                if (_passedTime > limit)
                {
                    if (_currentSprite != null)
                    {
                        SpriteHandler.Sh.DestroySprite(_currentSprite);
                    }
                    _currentInfo          = _informationHolder.GetNextInformation();
                    _currentSprite        = SpriteHandler.Sh.CreateSprite(_currentInfo.Type, _panel, Position.Above);
                    _currentDisplayStatus = _currentInfo.NextDisplayStatus;
                    _panel.GetComponentInChildren <Text>().text = _currentInfo.InfoText;
                    _allowedSkipping = _currentInfo.Skippable;
                    _passedTime      = 0;
                }
                break;

            case DisplayStatus.GoToMainMenu:
                if (_passedTime > _taskSettings.InfoTime)
                {
                    UnityClient.Communicator.Disconnect();
                    GuiHandler.GoToMainMenu();
                }
                break;

            case DisplayStatus.GoToNextScene:
                limit = _currentInfo.DisplayTime != -1 ? _currentInfo.DisplayTime : _taskSettings.InfoTime;
                if (_passedTime > limit)
                {
                    if (Randomness.Rand.NextDouble() < 0.5)
                    {
                        _punishmentPanel.SetActive(true);
                    }
                    else
                    {
                        _rewardPanel.SetActive(true);
                    }
                    _panel.SetActive(false);
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }