Exemplo n.º 1
0
 private void Update()
 {
     if (!EditorTerrainHeight.isTerraforming)
     {
         return;
     }
     if (!EditorInteract.isFlying && GUIUtility.hotControl == 0)
     {
         if (Input.GetKeyDown(ControlsSettings.tool_0))
         {
             if (EditorTerrainHeight.brushMode == EPaintMode.ADJUST_UP)
             {
                 EditorTerrainHeight.brushMode = EPaintMode.ADJUST_DOWN;
             }
             else
             {
                 EditorTerrainHeight.brushMode = EPaintMode.ADJUST_UP;
             }
         }
         if (Input.GetKeyDown(ControlsSettings.tool_1))
         {
             EditorTerrainHeight.brushMode = EPaintMode.SMOOTH;
         }
         if (Input.GetKeyDown(ControlsSettings.tool_2))
         {
             EditorTerrainHeight.brushMode = EPaintMode.FLATTEN;
         }
         if (Input.GetKeyDown(122) && Input.GetKey(306))
         {
             if (EditorTerrainHeight.map2)
             {
                 LevelGround.undoHeight2();
             }
             else
             {
                 LevelGround.undoHeight();
             }
         }
         if (Input.GetKeyDown(120) && Input.GetKey(306))
         {
             if (EditorTerrainHeight.map2)
             {
                 LevelGround.redoHeight2();
             }
             else
             {
                 LevelGround.redoHeight();
             }
         }
         if (EditorInteract.groundHit.transform != null)
         {
             if (EditorTerrainHeight.brushMode == EPaintMode.FLATTEN)
             {
                 EditorTerrainHeight.brush.position = new Vector3(EditorInteract.groundHit.point.x, EditorTerrainHeight.brushHeight * Level.TERRAIN, EditorInteract.groundHit.point.z);
             }
             else
             {
                 EditorTerrainHeight.brush.position = EditorInteract.groundHit.point;
             }
         }
         if (Input.GetKeyUp(ControlsSettings.primary) && EditorTerrainHeight.wasTerraforming)
         {
             if (EditorTerrainHeight.map2)
             {
                 LevelGround.registerHeight2();
             }
             else
             {
                 LevelGround.registerHeight();
             }
         }
         if (Input.GetKey(ControlsSettings.primary) && EditorInteract.groundHit.transform != null)
         {
             if (EditorTerrainHeight.brushMode == EPaintMode.ADJUST_UP)
             {
                 LevelGround.adjust(EditorInteract.groundHit.point, (int)EditorTerrainHeight.brushSize, EditorTerrainHeight.brushStrength, EditorTerrainHeight.brushNoise, EditorTerrainHeight.map2);
             }
             else if (EditorTerrainHeight.brushMode == EPaintMode.ADJUST_DOWN)
             {
                 LevelGround.adjust(EditorInteract.groundHit.point, (int)EditorTerrainHeight.brushSize, -EditorTerrainHeight.brushStrength, EditorTerrainHeight.brushNoise, EditorTerrainHeight.map2);
             }
             else if (EditorTerrainHeight.brushMode == EPaintMode.SMOOTH)
             {
                 LevelGround.smooth(EditorInteract.groundHit.point, (int)EditorTerrainHeight.brushSize, EditorTerrainHeight.brushStrength, EditorTerrainHeight.brushNoise, EditorTerrainHeight.map2);
             }
             else if (EditorTerrainHeight.brushMode == EPaintMode.FLATTEN)
             {
                 LevelGround.flatten(EditorInteract.groundHit.point, (int)EditorTerrainHeight.brushSize, EditorTerrainHeight.brushHeight, EditorTerrainHeight.brushStrength, EditorTerrainHeight.brushNoise, EditorTerrainHeight.map2);
             }
             EditorTerrainHeight.wasTerraforming = true;
         }
         else
         {
             EditorTerrainHeight.wasTerraforming = false;
         }
         if (Input.GetKeyDown(ControlsSettings.tool_2) && EditorInteract.groundHit.transform != null)
         {
             EditorTerrainHeight.brushHeight = EditorInteract.groundHit.point.y / Level.TERRAIN;
             if (EditorTerrainHeight.brushHeight < 0f)
             {
                 EditorTerrainHeight.brushHeight = 0f;
             }
             else if (EditorTerrainHeight.brushHeight > 1f)
             {
                 EditorTerrainHeight.brushHeight = 1f;
             }
             EditorTerrainHeightUI.heightValue.state = EditorTerrainHeight.brushHeight;
         }
     }
 }