示例#1
0
 internal void Setup(BlockGameBox _box)
 {
     box = _box;
     if (mesh == null)
     {
         mesh = GetComponent <Renderer>();
     }
     if (anchorableBehaviour == null)
     {
         anchorableBehaviour = GetComponent <AnchorableBehaviour>();
     }
     colorLabel    = box.AnchorLabel;
     mesh.material = box.BoxMat;
     anchorableBehaviour.anchorGroup         = box.GroupLabel;
     anchorableBehaviour.OnAttachedToAnchor += OnAttached;
 }
示例#2
0
            /// <summary>
            /// Single instance of a trial - spawns in a set number of blocks, which users must then sort into matching receptacles. Trial ends when no active blocks are left in the scene
            /// </summary>
            /// <returns></returns>
            public IEnumerator Trial()
            {
                resultLabel.gameObject.SetActive(false);
                for (int i = 0; i < blocksToSpawn; i++)
                {
                    Vector3 position = Random.insideUnitSphere * 0.2f;
                    position.z += 0.5f;
                    GameObject b = Instantiate(blockPrefabs[Random.Range(0, blockPrefabs.Length)], transform, true);
                    b.transform.position = position;
                    Block block = b.GetComponent <Block>();
                    activeBlocks.Add(block);
                    AnchorColors colorLabel = (AnchorColors)Random.Range(0, 3);
                    switch (colorLabel)
                    {
                    case AnchorColors.green:
                        block.Setup(greenBox);
                        break;

                    case AnchorColors.magenta:
                        block.Setup(magentaBox);
                        break;

                    case AnchorColors.orange:
                        block.Setup(orangeBox);
                        break;
                    }
                }
                float _time = Time.time;

                while (activeBlocks.Count != 0)
                {
                    yield return(null);
                }
                float finalTime = Time.time - _time;

                Results.Add(new BlockData
                {
                    time = finalTime
                });
                resultLabel.text = "Sucess!";
                resultLabel.gameObject.SetActive(true);
                yield return(new WaitForSeconds(0.2f));
            }