Example #1
0
    /**********************************************************/
    /********************** CONSTRUCTORS **********************/
    /**
     * Instantiates, setups and positions all the necessary lines
     */
    public LinesCollection(ItemsCollection itemsCollection)
    {
        GameObject lineObject, itemGameObjectI, itemGameObjectJ;
        LineRenderer lineRenderer;
        int collectionSize, position = 0;

        if (itemsCollection == null) {
            ErrorManager.DisplayErrorMessage("LineCollection: Cannot build LinesCollection from an empty ItemsCollection");
            return;
        }

        referenceMatrix = new ReferenceMatrix (itemsCollection.GetCollectionSize ());

        collectionSize = (itemsCollection.GetCollectionSize() * (itemsCollection.GetCollectionSize() - 1)) / 2;

        this.tabLines = new LineController[collectionSize];

        for (int i = 0; i < itemsCollection.GetCollectionSize(); i++) {
            for (int j = 0; j < itemsCollection.GetCollectionSize(); j++) {
                if (j > i) {
                    itemGameObjectI = itemsCollection.GetItemObject(i);
                    itemGameObjectJ = itemsCollection.GetItemObject(j);
                    lineObject = gameController.InstantiateLine();
                    lineRenderer = lineObject.GetComponent<LineRenderer>();

                    lineRenderer.SetPosition(0, new Vector3( itemGameObjectI.transform.position.x, 0, itemGameObjectI.transform.position.z));
                    lineRenderer.SetPosition(1, new Vector3(itemGameObjectJ.transform.position.x, 0, itemGameObjectJ.transform.position.z));
                    lineRenderer.SetWidth(0.1f, 0.1f);

                    tabLines[position] = lineObject.GetComponent<LineController>();

                    tabLines[position].Deactivate();
                    tabLines[position].SetOwnerOut(j);
                    tabLines[position].SetOwnerIn(i);
                    tabLines[position].SetStartPoint(new Vector3(itemGameObjectI.transform.position.x, 0, itemGameObjectI.transform.position.z));
                    tabLines[position].SetEndPoint(new Vector3(itemGameObjectJ.transform.position.x, 0, itemGameObjectJ.transform.position.z));
                    tabLines[position].ComputeConstants();

                    position++;
                }
            }
        }
    }
Example #2
0
 void Start()
 {
     itemsCollection = new ItemsCollection();
     linesCollection = new LinesCollection (itemsCollection);
     map = new Map (itemsCollection.GetCollectionSize ());
     this.dragDropManager.SendMessage ("SetLines", this.linesCollection);
     referenceMatrix = new ReferenceMatrix()
 }