Esempio n. 1
0
    public void PlaceCurrenlySelectedBox(int x, int y)
    {
        if (currentlySelectedScript == null)
        {
            return;
        }

        GameObject prefab   = currentlySelectedScript.boxPrefab;
        float      rotation = currentlySelectedScript.currentRotation;
        int        boxCount = currentlySelectedScript.boxCount;

        grid[x, y]         = prefab.name;
        gridRotation[x, y] = rotation;

        GameObject newBox = Instantiate(prefab) as GameObject;

        newBox.transform.parent        = elements;
        newBox.transform.localScale    = Vector3.one;
        newBox.transform.localPosition = new Vector2(x * tileSideLength, y * tileSideLength);
        newBox.transform.localRotation = Quaternion.Euler(0, 0, rotation);

        currentlySelectedScript.SetCounter(boxCount - 1);
        currentlySelectedScript.SetSelected(false);

        foreach (LaserDrawer drawer in laserDrawers)
        {
            drawer.DrawBeamFromSpawn();
        }
    }