예제 #1
0
        public void Start(GameObject panel, GameObject rewardPanel, GameObject punishmentPanel, GameObject spammingText)
        {
            if (GlobalSettings.Gs == null)
            {
                GuiHandler.GoToMainMenu();
            }
            else
            {
                switch (_myType)
                {
                case TaskType.Control:
                    _taskSettings = GlobalSettings.Gs.ControlSettings;
                    break;

                case TaskType.Reward:
                    _taskSettings = GlobalSettings.Gs.RewardSettings;
                    break;

                case TaskType.Punishment:
                    _taskSettings = GlobalSettings.Gs.PunishmentSettings;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                _spriteSettings = GlobalSettings.Gs.SpriteSettings;
                _threshold      = GlobalSettings.Gs.Threshold;
            }
            SetPanels(panel, rewardPanel, punishmentPanel, spammingText);
            GetInformation();
            InitValues();
        }
예제 #2
0
 private void Start()
 {
     if (GlobalSettings.Gs == null)
     {
         GuiHandler.GoToMainMenu();
     }
     else
     {
         _timeSettings    = GlobalSettings.Gs.SpriteSettings.BaselineSpriteSettings;
         _infoDisplayTime = GlobalSettings.Gs.BaselineSettings.InfoDisplayTime;
     }
     _panel = gameObject;
     GetInformation();
     InitValues();
 }
예제 #3
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();
            }
        }
예제 #4
0
        private void Update()
        {
            _spacebarPressed = Input.GetKeyDown("space");

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

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

            case DisplayStatus.DisplayResults:
                DisplayResults();
                _passedTime = 0;
                break;

            case DisplayStatus.WaitToDisplaySprite:
                limit = _currentInfo.DisplayTime != -1 ? _currentInfo.DisplayTime : _infoDisplayTime;
                if (_passedTime > limit)
                {
                    _panel.GetComponentInChildren <Text>().text = "";
                    ShowSprite();
                    _waitingForUser = true;
                    _passedTime     = 0;
                }
                break;

            case DisplayStatus.DisplayingSprite:
                if (_passedTime > _timeSettings.SpriteDisplayTime)
                {
                    RemoveSprite();
                }
                HandleUserInput();
                break;

            case DisplayStatus.WaitingUserInput:
                if (_spacebarPressed)
                {
                    HandleUserInput();
                }
                break;

            case DisplayStatus.DisplayBoth:
                break;

            case DisplayStatus.GoToMainMenu:
                if (_passedTime > _infoDisplayTime)
                {
                    GuiHandler.GoToMainMenu();
                }
                break;

            case DisplayStatus.GoToNextScene:
                if (_passedTime > _infoDisplayTime)
                {
                    _panel.SetActive(false);
                    PanelSrt.SetActive(true);
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }