Exemplo n.º 1
0
    private void PrepareRotator(HexObject aHexObjectManager)
    {
        // rotation has to be made by parenting hex objects under a GameObject whose scale is Vector3.one
        // otherwise, deformations on meshes will be seen due to the localScale of the outLiner
        // so, for this, we will first set rotation pivot, then aHexObjectManager.GetSelectedGridIndexes(),
        // then serch for those indexes in gridsAndContents, and parent the values from gridsAndContents under rotator
        // and set rotator's RotationManager values
        if (rotator == null)
        {
            rotator = new GameObject("Rotator").transform;
            rotator.gameObject.AddComponent <RotationManager>();
        }
        rotator.position = outliner.transform.GetChild(0).position;
        rotator.rotation = outliner.transform.GetChild(0).rotation;

        Transform[] selectedNeighbors = aHexObjectManager.GetSelectedNeighbors();
        selectedNeighbors[0].SetParent(rotator); // this is always original
        selectedNeighbors[1].SetParent(rotator); // this is always wing1
        selectedNeighbors[2].SetParent(rotator); // this is always wing2 ==> the order of the whole is counter-clockwise

        rotator.GetComponent <RotationManager>().SetObjects(selectedNeighbors[0], selectedNeighbors[1], selectedNeighbors[2]);
    }