Esempio n. 1
0
    private void CreateDisplayObjects()
    {
        //Find display center index
        displayCenter = new Vector2Int((displaysAcross - 1) / 2, (displaysWide - 1) / 2);

        for (int j = 0; j < displaysAcross; j++)
        {
            List <GameObject> row = new List <GameObject>();

            for (int i = 0; i < displaysWide; i++)
            {
                //Make new display node, and position it correctly
                GameObject newParent = new GameObject("Display (" + j + ", " + i + ")");
                newParent.transform.parent = parent;
                TranslateDisplay(i, j, newParent.transform);

                //Make new display view
                GameObject  newDisplay = Instantiate(displayTemplate, newParent.transform);
                DisplayData newData    = newDisplay.GetComponent <DisplayData>();

                //Set initial targets/position for new display object
                newData.SetTranslation();
                CentreDisplay(newData);
                newData.SetRotation(-45f);

                //record keeping
                newData.coord = new Vector2Int(j, i);

                //initialize builder.
                newData.builder = new MomentDisplayBuilder(pool, newData.centeringTransform);

                //If parent is on the bounds of the display, it is hidden
                if ((i < 2) || (j < 2) || (i > (displaysAcross - 3)) || (j > (displaysAcross - 3)))
                {
                    newParent.SetActive(false);
                }

                //add parent to array
                row.Add(newParent);
            }

            displays.Add(row);
        }
    }