Esempio n. 1
0
 private void Draw()
 {
     if (squareGrid != null)
     {
         int numberHightlights = (int)Mathf.Pow(pointerSize, 2);
         if (highlight == null || numberHightlights != highlight.Length)
         {
             if (highlight != null)
             {
                 foreach (Transform h in highlight)
                 {
                     Destroy(h.gameObject);
                 }
             }
             highlight = new Transform[numberHightlights];
         }
         for (int x = 0; x < pointerSize; x++)
         {
             for (int z = 0; z < pointerSize; z++)
             {
                 int     index  = z + x * pointerSize;
                 Vector3 offPos = pointerLocation + new Vector3(x, 0, z);
                 if (activeMode == EditMode.elevation)
                 {
                     if (highlight[index])
                     {
                         Destroy(highlight[index].gameObject);
                     }
                     highlight[index] = Instantiate(edgeSelectPrefab);
                     float yOffset = (float)squareGrid.GetCellOffset(pointerLocation, x, z).GetVertexElevations[vertexDirection] * GridMetrics.elevationStep;
                     offPos.y = yOffset;
                     highlight[index].localPosition = offPos;
                 }
                 if (activeMode == EditMode.color || activeMode == EditMode.rivers || activeMode == EditMode.roads ||
                     activeMode == EditMode.water_level || activeMode == EditMode.building || activeMode == EditMode.trees ||
                     activeMode == EditMode.rocks || activeMode == EditMode.mast || activeMode == EditMode.lighthouse || activeMode == EditMode.industry || activeMode == EditMode.town)
                 {
                     if (highlight[index])
                     {
                         Destroy(highlight[index].gameObject);
                     }
                     highlight[index] = Instantiate(tileSelectPrefab);
                     if (squareGrid.GetCellOffset(pointerLocation, x, z).GetVertexElevations[vertexDirection] != null)
                     {
                         float yOffset = (float)squareGrid.GetCellOffset(pointerLocation, x, z).GetMaxElevation() * GridMetrics.elevationStep;
                         offPos.y = yOffset;
                         highlight[index].localPosition = offPos;
                     }
                 }
             }
         }
     }
 }