void Awake() { _gameManager = TaskSettingsManager.TaskSettings; _taskEngine = FindObjectOfType <TaskEngine>(); _scannerIn = FindObjectOfType <ScannerHandler>(); //bring in task length from config.. int.TryParse(_gameManager.TaskDuration, out _taskLengthLimit); //convert to ms... _taskLengthLimit = _taskLengthLimit * 1000; //take time stamp at task start _taskStartTime = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond); }
List <int> _responseArray = new List <int>(); //holds the user repsonses void Awake() { _gameManager = TaskSettingsManager.TaskSettings; _scannerIn = FindObjectOfType <ScannerHandler>(); _keyInput = FindObjectOfType <KeyboardHandler>(); _timer = FindObjectOfType <TimeHandler>(); if (_gameManager.EnableTriggerOnScanner == true) { CurrentTaskState = TaskState.WaitForTrigger; CurrentTaskType = TaskType.Scanner; CurrentBlockType = BlockType.BaselineBlock; } _spriteFileName = _gameManager.SpriteFileName; int.TryParse(_gameManager.StartingSpan, out _startingSpanLength); int.TryParse(_gameManager.TaskDuration, out _taskTimeLimit); int.TryParse(_gameManager.MaxSpan, out _maxSpanLimit); int.TryParse(_gameManager.ResponseTimeLimit, out _responseTimeLimit); Random.seed = (int)(Time.time * 10000); _currentSpanLength = _startingSpanLength; //makes the current span length equal to the starting span length //IMPORTANT: loads thatever is in the resource's folder to the array _spriteArray = Resources.LoadAll <Sprite>("Sprites/Numbers"); if (CurrentTaskType == TaskType.Scanner) { _spriteArray = Resources.LoadAll <Sprite>("Sprites/NumbersScanner"); } var spritePadding = 15f * (_spriteArray.Length - 1); var spriteWidth = 0f; //setting up the reponse template that user uses? for (int i = 0; i < _spriteArray.Length; i++) { //an object created in memory that is attached to TaskEngineGO var choiceItem = Instantiate(ChoiceTemplate); // Set the choice handler index and response handler var ciHandler = choiceItem.GetComponent <ChoiceHandler>(); ciHandler.ItemIndex = i; ciHandler.ResponseHandler = _responseArray; // Set the sprite var ciSprite = choiceItem.GetComponent <SpriteRenderer>(); ciSprite.sprite = _spriteArray[i]; // Change the collider to fit the sprite var boxCollider = choiceItem.GetComponent <BoxCollider2D>(); boxCollider.size = new Vector2(ciSprite.bounds.size.x, ciSprite.bounds.size.y); boxCollider.offset += new Vector2(ciSprite.bounds.size.x / 2, ciSprite.bounds.size.y / 2); // Move the item to the correct spot in the parent float spriteLeft = spriteWidth + (i * 15); choiceItem.transform.SetParent(Choices.transform, false); choiceItem.transform.localPosition = new Vector3(spriteLeft, 0, 0); // Track how much total width our sprites have spriteWidth += _spriteArray[i].bounds.size.x; } //communicating the starting span length to our new instance of Difficulty _difficulty = new Difficulty(_startingSpanLength); // Change the camera to be the right size based on sprite sheet width var cam = Camera.main; cam.orthographicSize = (spriteWidth + spritePadding) * Screen.height / Screen.width * .5f; float height = 2f * cam.orthographicSize; float width = height * cam.aspect; var cameraLeft = cam.transform.localPosition.x - (width / 2); var cameraBottom = cam.transform.localPosition.y - (height / 2);; Choices.transform.position = new Vector3(cameraLeft, cameraBottom); }