Example #1
0
        public InterfaceTerrainInfo(InterfaceTerrainTool interfaceTerrainTool, InterfaceTerrainGroundStyle interfaceTerrainGroundStyle, InterfaceTerrainGroundGrain interfaceTerrainGroundGrain)
        {
            this.interfaceTerrainTool = interfaceTerrainTool;

            this.interfaceTerrainType = InterfaceTerrainType.Ground;

            this.interfaceTerrainGroundStyle = interfaceTerrainGroundStyle;
            this.interfaceTerrainGroundGrain = interfaceTerrainGroundGrain;
        }
Example #2
0
    string InterfaceTerrainGroundStyleToText(InterfaceTerrainGroundStyle t)
    {
        string s = "";

        switch (t)
        {
        case InterfaceTerrainGroundStyle.Grass:                 s = "Grass";                            break;

        case InterfaceTerrainGroundStyle.Grass2:                s = "Grass2";                           break;

        case InterfaceTerrainGroundStyle.Snow:                  s = "Snow";                                     break;

        case InterfaceTerrainGroundStyle.Desert:                s = "Desert";                           break;

        case InterfaceTerrainGroundStyle.Stonebrick:    s = "Stone Brick";                      break;

        default:                                                                                s = "???";                                      break;
        }
        return(s);
    }
Example #3
0
    protected TerrainGroundStyle InterfaceTerrainGroundStyleToTerrainGroundStyle(InterfaceTerrainGroundStyle interfaceTerrainGroundStyle)
    {
        TerrainGroundStyle terrainGroundStyle;

        switch (interfaceTerrainGroundStyle)
        {
        case InterfaceTerrainGroundStyle.Grass:                 terrainGroundStyle = TerrainGroundStyle.Grass;          break;

        case InterfaceTerrainGroundStyle.Grass2:                terrainGroundStyle = TerrainGroundStyle.Grass2;         break;

        case InterfaceTerrainGroundStyle.Snow:                  terrainGroundStyle = TerrainGroundStyle.Snow;           break;

        case InterfaceTerrainGroundStyle.Desert:                terrainGroundStyle = TerrainGroundStyle.Desert;         break;

        case InterfaceTerrainGroundStyle.Stonebrick:    terrainGroundStyle = TerrainGroundStyle.Stonebrick;     break;

        default:
            Debug.LogError("Cannot find a matching TerrainGroundStyle for InterfaceTerrainGroundStyle [" + interfaceTerrainGroundStyle + "]. Defaulting to InterfaceTerrainGroundStyle.Grass");
            goto case InterfaceTerrainGroundStyle.Grass;
        }

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

        t = "_Current settings_\n" +
            "(QE)      Tool: " + InterfaceTerrainToolToText(terrainTool) + "\n" +
            "(123...) Style: " + InterfaceTerrainGroundStyleToText(terrainGroundStyle) + "\n" +
            "(ZX)     Grain: " + InterfaceTerrainGroundGrainToText(terrainGroundGrain);

        // 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))
        {
            terrainGroundStyle = InterfaceTerrainGroundStyle.Grass;          updateTerrainGroundStyle = true;
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            terrainGroundStyle = InterfaceTerrainGroundStyle.Snow;           updateTerrainGroundStyle = true;
        }
        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            terrainGroundStyle = InterfaceTerrainGroundStyle.Desert;         updateTerrainGroundStyle = true;
        }
        if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            terrainGroundStyle = InterfaceTerrainGroundStyle.Stonebrick;     updateTerrainGroundStyle = true;
        }
        if (Input.GetKeyDown(KeyCode.Alpha5))
        {
            terrainGroundStyle = InterfaceTerrainGroundStyle.Grass2;         updateTerrainGroundStyle = true;
        }

        // Grain
        if (Input.GetKeyDown(KeyCode.Z))
        {
            terrainGroundGrain--;
            if ((int)terrainGroundGrain < 0)
            {
                terrainGroundGrain = (InterfaceTerrainGroundGrain)0;
            }
            updateTerrainGroundGrain = true;
        }
        if (Input.GetKeyDown(KeyCode.X))
        {
            terrainGroundGrain++;
            if ((int)terrainGroundGrain > terrainGroundGrainMax - 1)
            {
                terrainGroundGrain = (InterfaceTerrainGroundGrain)terrainGroundGrainMax - 1;
            }
            updateTerrainGroundGrain = true;
        }

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

        Draw(new InterfaceTerrainInfo(terrainTool, terrainGroundStyle, terrainGroundGrain));

        string t2 = "";

        // Find currently selected object
        if (editorController.currentTerrain is TerrainGround)
        {
            TerrainGround ground = (TerrainGround)editorController.currentTerrain;

            bool regenerate    = false;
            bool reloadSprites = false;

            // Update the roller settings in real-time
            if (updateTerrainGroundStyle)
            {
                updateTerrainGroundStyle = false;
                regenerate    = true;
                reloadSprites = true;
                ground.style  = InterfaceTerrainGroundStyleToTerrainGroundStyle(terrainGroundStyle);
            }

            if (updateTerrainGroundGrain)
            {
                updateTerrainGroundGrain = false;
                regenerate           = true;
                ground.segmentLength = InterfaceTerrainGroundGrainToTerrainSegmentLength(terrainGroundGrain);
            }

            // Apply the updates
            if (reloadSprites)
            {
                ground.groundPart.ReloadSprites();
            }

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

            t2 = "_Selection settings_\n" +
                 "    Style: " + ground.style + "\n" +
                 "Seg. len.: " + ground.segmentLength;
        }

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