Example #1
0
        public InterfaceTerrainInfo(InterfaceTerrainTool interfaceTerrainTool, InterfaceTerrainRollerStyle interfaceTerrainRollerStyle, InterfaceTerrainRollerRotationDirection interfaceTerrainRollerRotationDirection, InterfaceTerrainRollerRotationSpeed interfaceTerrainRollerRotationSpeed, InterfaceTerrainRollerSpacing interfaceTerrainRollerSpacing)
        {
            this.interfaceTerrainTool = interfaceTerrainTool;

            this.interfaceTerrainType = InterfaceTerrainType.Roller;

            this.interfaceTerrainRollerStyle             = interfaceTerrainRollerStyle;
            this.interfaceTerrainRollerRotationDirection = interfaceTerrainRollerRotationDirection;
            this.interfaceTerrainRollerRotationSpeed     = interfaceTerrainRollerRotationSpeed;
            this.interfaceTerrainRollerSpacing           = interfaceTerrainRollerSpacing;
        }
Example #2
0
    string InterfaceTerrainRollerSpacingToText(InterfaceTerrainRollerSpacing r)
    {
        string s = "";

        switch (r)
        {
        case InterfaceTerrainRollerSpacing.VeryPacked:                  s = "Very packed";                      break;

        case InterfaceTerrainRollerSpacing.Packed:                              s = "Packed";                           break;

        case InterfaceTerrainRollerSpacing.Normal:                              s = "Normal";                           break;

        case InterfaceTerrainRollerSpacing.Sparse:                              s = "Sparse";                           break;

        case InterfaceTerrainRollerSpacing.VerySparse:                  s = "Very sparse";                      break;

        default:                                                                                                s = "???";                                      break;
        }
        return(s);
    }
Example #3
0
    protected float InterfaceTerrainRollerSpacingToTerrainRollerSpacing(InterfaceTerrainRollerSpacing interfaceTerrainRollerSpacing)
    {
        float terrainRollerSpacing;

        switch (interfaceTerrainRollerSpacing)
        {
        case InterfaceTerrainRollerSpacing.VeryPacked:          terrainRollerSpacing = 1f;              break;

        case InterfaceTerrainRollerSpacing.Packed:                      terrainRollerSpacing = 1.375f;  break;

        case InterfaceTerrainRollerSpacing.Normal:                      terrainRollerSpacing = 1.75f;   break;

        case InterfaceTerrainRollerSpacing.Sparse:                      terrainRollerSpacing = 2.5f;    break;

        case InterfaceTerrainRollerSpacing.VerySparse:          terrainRollerSpacing = 4f;              break;

        default:
            Debug.LogWarning("Invalid InterfaceTerrainRollerSpacing [" + interfaceTerrainRollerSpacing + "]. Defaulting to InterfaceTerrainRollerSpacing.Normal");
            goto case InterfaceTerrainRollerSpacing.Normal;
        }

        return(terrainRollerSpacing);
    }
Example #4
0
    override public TextMenuText Text()
    {
        string t;

        t = "_Current settings_\n" +
            "(QE)      Tool: " + InterfaceTerrainToolToText(terrainTool) + "\n" +
            "(123...) Style: " + InterfaceTerrainRollerStyleToText(terrainRollerStyle) + "\n" +
            "(ZX)   Spacing: " + InterfaceTerrainRollerSpacingToText(terrainRollerSpacing) + "\n" +
            "(CV)     Speed: " + InterfaceTerrainRollerRotationSpeedToText(terrainRollerRotationSpeed) + "\n" +
            "(B)  Direction: " + InterfaceTerrainRollerRotationDirectionToText(terrainRollerRotationDirection) + "\n";

        // Tool
        if (Input.GetKeyDown(KeyCode.Q))
        {
            terrainTool--;
            if ((int)terrainTool < 0)
            {
                terrainTool = 0;
            }
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            terrainTool++;
            if ((int)terrainTool >= terrainToolMax)
            {
                terrainTool = (InterfaceTerrainTool)terrainToolMax - 1;
            }
        }

        // Style
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            terrainRollerStyle = InterfaceTerrainRollerStyle.General; updateTerrainRollerStyle = true;
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            terrainRollerStyle = InterfaceTerrainRollerStyle.Clouds;  updateTerrainRollerStyle = true;
        }
        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            terrainRollerStyle = InterfaceTerrainRollerStyle.Bubbles; updateTerrainRollerStyle = true;
        }

        // Spacing
        if (Input.GetKeyDown(KeyCode.Z))
        {
            terrainRollerSpacing--;
            if ((int)terrainRollerSpacing < 0)
            {
                terrainRollerSpacing = (InterfaceTerrainRollerSpacing)0;
            }
            updateTerrainRollerSpacing = true;
        }
        if (Input.GetKeyDown(KeyCode.X))
        {
            terrainRollerSpacing++;
            if ((int)terrainRollerSpacing >= terrainRollerSpacingMax)
            {
                terrainRollerSpacing = (InterfaceTerrainRollerSpacing)terrainRollerSpacingMax - 1;
            }
            updateTerrainRollerSpacing = true;
        }

        // Speed
        if (Input.GetKeyDown(KeyCode.C))
        {
            terrainRollerRotationSpeed--;
            if ((int)terrainRollerRotationSpeed < 0)
            {
                terrainRollerRotationSpeed = (InterfaceTerrainRollerRotationSpeed)0;
            }
            updateTerrainRollerRotationSpeed = true;
        }
        if (Input.GetKeyDown(KeyCode.V))
        {
            terrainRollerRotationSpeed++;
            if ((int)terrainRollerRotationSpeed >= terrainRollerRotationSpeedMax)
            {
                terrainRollerRotationSpeed = (InterfaceTerrainRollerRotationSpeed)terrainRollerRotationSpeedMax - 1;
            }
            updateTerrainRollerRotationSpeed = true;
        }

        // Direction
        if (Input.GetKeyDown(KeyCode.B))
        {
            terrainRollerRotationDirection       = terrainRollerRotationDirection == InterfaceTerrainRollerRotationDirection.Clockwise ? InterfaceTerrainRollerRotationDirection.AntiClockwise : InterfaceTerrainRollerRotationDirection.Clockwise;
            updateTerrainRollerRotationDirection = true;
        }

        // Return to previous menu
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            SetMenu(TextMenu.Terrain);
        }

        Draw(new InterfaceTerrainInfo(terrainTool, terrainRollerStyle, terrainRollerRotationDirection, terrainRollerRotationSpeed, terrainRollerSpacing));

        string t2 = "";

        // Find currently selected object
        if (editorController.currentTerrain is TerrainRoller)
        {
            TerrainRoller roller = (TerrainRoller)editorController.currentTerrain;

            bool regenerate    = false;
            bool reloadSprites = false;

            // Update the roller settings in real-time
            if (updateTerrainRollerStyle)
            {
                updateTerrainRollerStyle = false;
                regenerate    = true;
                reloadSprites = true;
                roller.style  = InterfaceTerrainRollerStyleToTerrainRollerStyle(terrainRollerStyle);
            }

            if (updateTerrainRollerSpacing)
            {
                updateTerrainRollerSpacing = false;
                regenerate     = true;
                roller.spacing = InterfaceTerrainRollerSpacingToTerrainRollerSpacing(terrainRollerSpacing);
            }

            if (updateTerrainRollerRotationSpeed && updateTerrainRollerRotationDirection)
            {
                updateTerrainRollerRotationDirection = false;
                regenerate   = true;
                roller.speed = InterfaceTerrainRollerRotationSpeedAndInterfaceTerrainRollerRotationToTerrainRollerSpeed(terrainRollerRotationSpeed, terrainRollerRotationDirection);
            }

            if (updateTerrainRollerRotationSpeed)
            {
                updateTerrainRollerRotationSpeed = false;
                regenerate     = true;
                roller.isFixed = InterfaceTerrainRollerRotationSpeedToTerrainRollerFixed(terrainRollerRotationSpeed);
            }

            // Apply the updates
            if (reloadSprites)
            {
                roller.rollerPart.ReloadSprites();
            }

            if (regenerate)
            {
                roller.Regenerate();
            }

            t2 = "_Selection settings_\n" +
                 "    Style: " + roller.style + "\n" +
                 "  Spacing: " + roller.spacing + "\n" +
                 "    Speed: " + roller.speed + "\n" +
                 "Direction: " + roller.direction + "\n" +
                 " Is fixed: " + roller.isFixed + "\n" +
                 "Seg. len.: " + roller.segmentLength;
        }

        return(new TextMenuText(t, t2));
    }