Exemple #1
0
        /// <summary>
        /// Updates the internal cached values for the modules based on the current tank settings for scale/volume/position;
        /// done separately from updating the actual models so that the values can be used without the models even being present
        /// </summary>
        private void updateModuleStats()
        {
            if (currentTankVerticalScale < currentMainTankModule.minVerticalScale)
            {
                currentTankVerticalScale = currentMainTankModule.minVerticalScale;
                this.updateUIFloatEditControl("currentTankVerticalScale", currentTankVerticalScale);
            }
            else if (currentTankVerticalScale > currentMainTankModule.maxVerticalScale)
            {
                currentTankVerticalScale = currentMainTankModule.maxVerticalScale;
                this.updateUIFloatEditControl("currentTankVerticalScale", currentTankVerticalScale);
            }
            float diameterScale = currentTankDiameter / currentMainTankModule.modelDefinition.diameter;

            currentMainTankModule.updateScale(diameterScale, currentTankVerticalScale * diameterScale);
            currentNoseModule.updateScaleForDiameter(currentTankDiameter * topAdapterRatio);
            currentMountModule.updateScaleForDiameter(currentTankDiameter * bottomAdapterRatio);

            float totalHeight = currentMainTankModule.currentHeight + currentNoseModule.currentHeight + currentMountModule.currentHeight;
            float startY      = totalHeight * 0.5f;//start at the top of the first tank

            startY -= currentNoseModule.currentHeight;
            currentNoseModule.setPosition(startY, ModelOrientation.TOP);

            startY -= currentMainTankModule.currentHeight * 0.5f;
            currentMainTankModule.currentVerticalPosition = startY;

            startY -= currentMainTankModule.currentHeight * 0.5f;
            currentMountModule.setPosition(startY, ModelOrientation.BOTTOM);
        }
        private void updateModulePositions()
        {
            //update for model scale
            topDockModule.updateScale(1);
            topModule.updateScaleForDiameter(topDiameter);
            coreModule.updateScaleForDiameter(coreDiameter);
            bottomModule.updateScaleForDiameter(bottomDiameter);
            bottomDockModule.updateScale(1);

            //calc positions
            float yPos     = topModule.currentHeight + (coreModule.currentHeight * 0.5f);
            float topDockY = yPos;

            yPos -= topModule.currentHeight;
            float topY = yPos;

            yPos -= coreModule.currentHeight;
            float coreY   = yPos;
            float bottomY = coreY;

            yPos -= bottomModule.currentHeight;
            float bottomDockY = yPos;

            //update internal ref of position
            topDockModule.setPosition(topDockY);
            topModule.setPosition(topY);
            coreModule.setPosition(coreY);
            bottomModule.setPosition(bottomY, ModelOrientation.BOTTOM);
            bottomDockModule.setPosition(bottomDockY, ModelOrientation.BOTTOM);

            //update actual model positions and scales
            topDockModule.updateModel();
            topModule.updateModel();
            coreModule.updateModel();
            bottomModule.updateModel();
            bottomDockModule.updateModel();

            solarModule.updateModelPosition(coreModule.currentVerticalPosition);

            Vector3 pos = new Vector3(0, topDockY + topDockModule.currentHeight, 0);

            topDockTransform.localPosition    = pos;
            topControlTransform.localPosition = pos;

            pos = new Vector3(0, bottomDockY - bottomDockModule.currentHeight, 0);
            bottomDockTransform.localPosition    = pos;
            bottomControlTransform.localPosition = pos;
        }