コード例 #1
0
        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;
        }
コード例 #2
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()
        {
            float diameterScale = currentTankDiameter / currentMainTankModule.modelDefinition.diameter;

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

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

            startY -= currentNoseModule.currentHeight;

            float offset = currentNoseModule.currentHeightScale * currentNoseModule.modelDefinition.verticalOffset;

            if (currentNoseModule.modelDefinition.invertForTop)
            {
                currentNoseModule.currentVerticalPosition = startY - offset;
            }
            else
            {
                currentNoseModule.currentVerticalPosition = startY + offset;
            }

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

            startY -= currentMainTankModule.currentHeight * 0.5f;
            offset  = currentMountModule.currentHeightScale * currentMountModule.modelDefinition.verticalOffset;
            if (currentMountModule.modelDefinition.invertForBottom)
            {
                currentMountModule.currentVerticalPosition = startY - offset;
            }
            else
            {
                currentMountModule.currentVerticalPosition = startY + offset;
            }
        }