public void CreateTerrain() { // Add all nodes to the blueprint this.part.SetNodePositions(nodes); // Create the terrain object GameObject obj = new GameObject() as GameObject; switch (terrainInfo.terrainType) { case TerrainType.Ground: obj.name = "TerrainGround"; TerrainGround terrainGround = obj.AddComponent <TerrainGround>(); terrainGround.Init(edit, !edit); // Pass terrainInfo data to terrainGround terrainGround.style = this.terrainInfo.terrainGroundStyle; terrainGround.segmentLength = this.terrainInfo.terrainGroundSegmentLength; terrainGround.AssignBlueprint(part); break; case TerrainType.Roller: obj.name = "TerrainRoller"; TerrainRoller terrainRoller = obj.AddComponent <TerrainRoller>(); terrainRoller.Init(edit, !edit); // Pass terrainInfo data to terrainRoller terrainRoller.style = this.terrainInfo.terrainRollerStyle; terrainRoller.spacing = this.terrainInfo.terrainRollerSpacing; terrainRoller.isFixed = this.terrainInfo.terrainRollerFixed; terrainRoller.speed = this.terrainInfo.terrainRollerSpeed; //NOTE: Setting speed also sets direction terrainRoller.AssignBlueprint(part); break; } }
public RollerPart(TerrainRoller terrainRoller) : base(terrainRoller.blueprintPart) { this.terrainRoller = terrainRoller; ReloadSprites(); }
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)); }