public void RecalculateLayout()
        {
            List <LayoutCalculator.TileCountPair> tiles =
                LayoutCalculator.CalculateSurfaceTiles(Reactor.SurfaceTiles, InternalLength, InternalWidth);

            int interiorX   = InternalWidth;
            int interiorY   = InternalLength;
            int totalX      = interiorX + 2;
            int totalY      = interiorY + 2;
            int totalHeight = InternalHeight + 2;

            int controlRodCount = 0;

            ReactorCosts.ClearItems();

            foreach (LayoutCalculator.TileCountPair surfacePair in tiles)
            {
                if (surfacePair.Tile == TileType.BlockReactorControlRod)
                {
                    controlRodCount = surfacePair.Count;
                    ReactorCosts.AddSingleCostable(surfacePair.Tile, surfacePair.Count);
                    ReactorCosts.AddCostableHeight(TileType.BlockReactorFuelRod, InternalHeight * surfacePair.Count);
                }
                else
                {
                    ReactorCosts.AddCostableHeight(surfacePair.Tile, InternalHeight * surfacePair.Count);
                }
            }
            ReactorCosts.AddCasingReactor(totalY, totalX, totalHeight, 3, controlRodCount);
        }
    public void setUpButtonLayout(GameObject button)
    {
        ButtonInfo buttonInfo = button.GetComponent <ButtonInfo>();
        Vector2    pos        = buttonInfo.PositionOnSphere;
        Vector2    size       = buttonInfo.ButtonSize;

        //calculate the button's center angle on sphere
        //It will be the mean off all the occupy grid
        List <Vector2> angleList = new List <Vector2>();

        for (int i = 0; i < size.y; i++)
        {
            for (int j = 0; j < size.x; j++)
            {
                Vector2 angle = Vector2.zero;

                angle.x = pos.x * buttonAngle;
                angle.y = pos.y * buttonAngle;

                angleList.Add(angle);
            }
        }
        Vector2 buttonCenter = LayoutCalculator.meanAngle(angleList);

        //calculate button length
        float width  = size.x * buttonLength;
        float height = size.y * buttonLength;

        //Setup the button
        button.GetComponent <ButtonCurvedEffect>().setButton(buttonManager.gameObject, width, height, buttonCenter.y + VerticalAngle, buttonCenter.x + HorizontalAngle + forwardAngle);
    }
    private void calculateGridSize()
    {
        float horizontalLength = LayoutCalculator.partialLength(HorizontalRange / 2, radius);
        float verticalLength   = LayoutCalculator.partialLength(VerticalRange / 2, radius);

        GridWidth  = (int)(horizontalLength / buttonLength) * 2;
        GridHeight = (int)(verticalLength / buttonLength) * 2;
    }
    public void setUp(float length, float radius, float forwardAngle)
    {
        this.buttonLength = length;
        this.radius       = radius;
        this.forwardAngle = forwardAngle;

        calculateGridSize();
        buttonAngle = LayoutCalculator.paritalAngle(buttonLength, radius);
        for (int i = 0; i < buttonManager.Button.Length; i++)
        {
            setUpButtonLayout(buttonManager.Button[i]);
        }
    }
 public override IEnumerable <PositionInfo <IDiagramItem> > RelayoutGraphNodesPosition(Graph <IDiagramItem> graph)
 {
     Tree = MsaglGeometryGraphHelpers.CreatePhyloTrees(graph);
     LayoutCalculator.CalculateLayout(Tree);
     return(MsaglGeometryGraphHelpers.GetGetNodesPositionInfo(Tree));
 }