Exemplo n.º 1
0
 public static void setActiveMap()
 {
     for (int i = 0; i < MAP_Editor.ref_MapManager.mapList.Count; i++)
     {
         if (MAP_Editor.ref_MapManager.mapList[i] != null)
         {
             MAP_Editor.ref_MapManager.mapList[i].SetActive(true);
         }
     }
     MAP_Editor.ref_MapManager.mapList[MAP_Editor.currentMapIndex].SetActive(true);
     MAP_brushFunctions.updateBrushTile();
 }
Exemplo n.º 2
0
    public static void pickTile(Vector3 position)
    {
        if (MAP_Editor.findTileMapParent())
        {
            GameObject currentLayer = MAP_Editor.mapLayers[MAP_Editor.currentLayer - 1];
            Vector3    tempVec3;
            for (int i = 0; i < currentLayer.transform.childCount; ++i)
            {
                tempVec3 = currentLayer.transform.GetChild(i).transform.position;

                if (position.x == tempVec3.x && position.z == tempVec3.z && tempVec3.y >= position.y && tempVec3.y < position.y + 1)
                {
                    MAP_Editor.currentTile = AssetDatabase.LoadAssetAtPath(AssetDatabase.GetAssetPath(PrefabUtility.GetCorrespondingObjectFromSource(currentLayer.transform.GetChild(i).transform.gameObject)), typeof(GameObject)) as GameObject;

                    float pickRotation  = 0;
                    float pickRotationX = 0;

                    Transform pickTileTransform = currentLayer.transform.GetChild(i).transform;
                    if (pickTileTransform.eulerAngles.y > 0)
                    {
                        pickRotation = pickTileTransform.eulerAngles.y;
                    }

                    if (pickTileTransform.eulerAngles.x > 0)
                    {
                        pickRotationX = pickTileTransform.eulerAngles.x;
                    }

                    MAP_Editor.currentBrushIndex = Array.IndexOf(MAP_Editor.currentTileSetObjects, MAP_Editor.currentTile);
                    MAP_Editor.tileRotation      = pickRotation;
                    MAP_Editor.tileRotationX     = pickRotationX;

                    tempVec3    = pickTileTransform.localScale;
                    tempVec3.x /= MAP_Editor.globalScale;
                    tempVec3.y /= MAP_Editor.globalScale;
                    tempVec3.z /= MAP_Editor.globalScale;

                    MAP_Editor.tileScale = tempVec3;

                    MAP_brushFunctions.updateBrushTile(pickTileTransform.localScale);
                    MAP_Editor.currentBrushType = eBrushTypes.standardBrush;
                    MAP_Editor.selectTool       = eToolIcons.brushTool;
                    return;
                }
            }
        }
    }
Exemplo n.º 3
0
    public static void checkMouseShortcuts(Event mouseEvent)
    {
        if (mouseEvent.type == EventType.ScrollWheel && mouseEvent.shift && !mouseEvent.control && !mouseEvent.alt)
        {
            mouseEvent.Use();
            if (!MAP_Editor.editorPreferences.invertMouseWheel)
            {
                if (!MAP_Editor.editorPreferences.twoPointFiveDMode)
                {
                    if (Event.current.delta.y - Event.current.delta.x >= 0f)
                    {
                        MAP_Editor.gridHeight += MAP_Editor.globalScale * MAP_Editor.editorPreferences.gridLayerHeightScaler;
                    }
                    else
                    {
                        MAP_Editor.gridHeight -= MAP_Editor.globalScale * MAP_Editor.editorPreferences.gridLayerHeightScaler;
                    }
                }
                else
                {
                    if (Event.current.delta.y - Event.current.delta.x >= 0f)
                    {
                        MAP_Editor.gridHeight -= MAP_Editor.globalScale * MAP_Editor.editorPreferences.gridLayerHeightScaler;
                    }
                    else
                    {
                        MAP_Editor.gridHeight += MAP_Editor.globalScale * MAP_Editor.editorPreferences.gridLayerHeightScaler;
                    }
                }
            }
            else
            {
                if (!MAP_Editor.editorPreferences.twoPointFiveDMode)
                {
                    if (Event.current.delta.y - Event.current.delta.x >= 0f)
                    {
                        MAP_Editor.gridHeight -= MAP_Editor.globalScale * MAP_Editor.editorPreferences.gridLayerHeightScaler;
                    }
                    else
                    {
                        MAP_Editor.gridHeight += MAP_Editor.globalScale * MAP_Editor.editorPreferences.gridLayerHeightScaler;
                    }
                }
                else
                {
                    if (Event.current.delta.y - Event.current.delta.x >= 0f)
                    {
                        MAP_Editor.gridHeight += MAP_Editor.globalScale * MAP_Editor.editorPreferences.gridLayerHeightScaler;
                    }
                    else
                    {
                        MAP_Editor.gridHeight -= MAP_Editor.globalScale * MAP_Editor.editorPreferences.gridLayerHeightScaler;
                    }
                }
            }
        }
        if (mouseEvent.type == EventType.ScrollWheel && mouseEvent.shift && mouseEvent.alt && !mouseEvent.control)
        {
            mouseEvent.Use();

            if (!MAP_Editor.editorPreferences.invertMouseWheel)
            {
                if (Event.current.delta.y - Event.current.delta.x >= 0f)
                {
                    MAP_Editor.gridHeight += (MAP_Editor.globalScale * 0.25f);
                }
                else
                {
                    MAP_Editor.gridHeight -= (MAP_Editor.globalScale * 0.25f);
                }
            }
            else
            {
                if (Event.current.delta.y - Event.current.delta.x >= 0f)
                {
                    MAP_Editor.gridHeight -= (MAP_Editor.globalScale * 0.25f);
                }
                else
                {
                    MAP_Editor.gridHeight += (MAP_Editor.globalScale * 0.25f);
                }
            }
        }
        else if (mouseEvent.type == EventType.ScrollWheel && mouseEvent.control && mouseEvent.alt && MAP_Editor.selectTool == eToolIcons.brushTool)
        {
            mouseEvent.Use();

            if (Event.current.delta.y - Event.current.delta.x >= 0f)
            {
                MAP_Editor.tileRotation += 90f;
            }
            else
            {
                MAP_Editor.tileRotation -= 90f;
            }
        }
        else if (mouseEvent.type == EventType.ScrollWheel && mouseEvent.control && mouseEvent.shift == true && MAP_Editor.selectTool == eToolIcons.brushTool)
        {
            mouseEvent.Use();

            MAP_Editor.currentBrushType = eBrushTypes.standardBrush;

            if (!MAP_Editor.editorPreferences.invertMouseWheel)
            {
                if (Event.current.delta.y - Event.current.delta.x > 0f)
                {
                    MAP_Editor.currentBrushIndex++;

                    if (MAP_Editor.currentBrushIndex >= MAP_Editor.currentTileSetObjects.Length)
                    {
                        MAP_Editor.currentBrushIndex = MAP_Editor.currentTileSetObjects.Length - 1;
                    }

                    MAP_Editor.currentTile = MAP_Editor.currentTileSetObjects[MAP_Editor.currentBrushIndex];
                    MAP_Editor.currentTile.transform.eulerAngles = new Vector3(MAP_Editor.tileRotationX, MAP_Editor.tileRotation, 0f);
                    MAP_brushFunctions.updateBrushTile();
                }
                else
                {
                    MAP_Editor.currentBrushIndex--;

                    if (MAP_Editor.currentBrushIndex < 0)
                    {
                        MAP_Editor.currentBrushIndex = 0;
                    }

                    MAP_Editor.currentTile = MAP_Editor.currentTileSetObjects[MAP_Editor.currentBrushIndex];
                    MAP_Editor.currentTile.transform.eulerAngles = new Vector3(MAP_Editor.tileRotationX, MAP_Editor.tileRotation, 0f);
                    MAP_brushFunctions.updateBrushTile();
                }
            }
            else
            {
                if (Event.current.delta.y - Event.current.delta.x < 0f)
                {
                    MAP_Editor.currentBrushIndex++;

                    if (MAP_Editor.currentBrushIndex >= MAP_Editor.currentTileSetObjects.Length)
                    {
                        MAP_Editor.currentBrushIndex = MAP_Editor.currentTileSetObjects.Length - 1;
                    }

                    MAP_Editor.currentTile = MAP_Editor.currentTileSetObjects[MAP_Editor.currentBrushIndex];
                    MAP_Editor.currentTile.transform.eulerAngles = new Vector3(MAP_Editor.tileRotationX, MAP_Editor.tileRotation, 0f);
                    MAP_brushFunctions.updateBrushTile();
                }
                else
                {
                    MAP_Editor.currentBrushIndex--;

                    if (MAP_Editor.currentBrushIndex < 0)
                    {
                        MAP_Editor.currentBrushIndex = 0;
                    }

                    MAP_Editor.currentTile = MAP_Editor.currentTileSetObjects[MAP_Editor.currentBrushIndex];
                    MAP_Editor.currentTile.transform.eulerAngles = new Vector3(MAP_Editor.tileRotationX, MAP_Editor.tileRotation, 0f);
                    MAP_brushFunctions.updateBrushTile();
                }
            }
        }
    }