Ejemplo n.º 1
0
    public void OnMouseUp()
    {
        if (UIMenuController.IsActiveMenu(uiMapEditor))
        {
            var   gridPos = MouseToGridAPI.GetGridCoordinate(Input.mousePosition);
            Point point   = new Point((int)gridPos.x, (int)gridPos.y);
            switch (currentTool)
            {
            case ToolType.LINE:
                DrawLine(startPoint, point, paintCurrent.ID);
                MapDisplayAPI.FinishOperation();
                break;

            case ToolType.SHAPE:
                int   distance = (int)(Math.Sqrt(Math.Pow(startPoint.x - point.x, 2) + Math.Pow(startPoint.y - point.y, 2)));
                int   deltaX   = Convert.ToInt32(startPoint.x) - Convert.ToInt32(point.x);
                int   deltaY   = Convert.ToInt32(startPoint.y) - Convert.ToInt32(point.y);
                Point center   = new Point(startPoint.x - (deltaX / 2), startPoint.y - (deltaY / 2));
                DrawWithBrush(center, distance / 2, paintCurrent.ID);
                MapDisplayAPI.FinishOperation();
                break;

            case ToolType.BRUSH:
                previous = null;
                break;

            default:
                break;
            }
            operationManager.EndDraw();
        }
    }
Ejemplo n.º 2
0
    // TODO: Look into right mouse

    /*void OnMouseOver() {
     *  if (MapMenu.activeSelf) {
     *      //Debug.Log(Input.GetMouseButton(1) + ", " + Input.GetMouseButtonDown(1) + ", " + Input.GetMouseButtonUp(1));
     *  }
     * }*/

    public void OnMouseDown()
    {
        if (tiles == null)
        {
            tiles = World.Instance.Tiles;
        }

        if (UIMenuController.IsActiveMenu(uiMapEditor))
        {
            Debug("Left: " + Input.GetMouseButton(0) + "  Right: " + Input.GetMouseButton(1));
            Debug("Should be doing something.");
            operationManager.BeginDraw();
            var   gridPos = MouseToGridAPI.GetGridCoordinate(Input.mousePosition);
            Point point   = new Point((int)gridPos.x, (int)gridPos.y);
            switch (currentTool)
            {
            case ToolType.FILL:
                Fill(point, paintCurrent.ID, tiles[Convert.ToInt32(point.x), Convert.ToInt32(point.y)]);
                MapDisplayAPI.FinishOperation();
                break;

            case ToolType.LINE:
            case ToolType.SHAPE:
                startPoint = point;
                break;

            case ToolType.BRUSH:
                previous = point;
                break;

            default:
                break;
            }
        }
    }
 public static void Redo(Operation operation)
 {
     ////Debug.Log("Changing (" + operation.x + "," + operation.y + ") to " + operation.newTileId);
     tiles[operation.x, operation.y] ^= tiles[operation.x, operation.y];
     tiles[operation.x, operation.y] |= operation.newTileId;
     MapDisplayAPI.ApplySinglePixel(operation.x, operation.y, operation.newTileId);
 }
Ejemplo n.º 4
0
 public void DeleteSelectedTerrain()
 {
     Terrain.Remove(SelectedTerrain);
     Debugger.Log("Still exists: " + Terrain.Exists(SelectedTerrain.ID));
     ChangeTerrainSelectedByID(1);
     RefreshTerrainList();
     MapDisplayAPI.ApplyOnceEditor();
 }
Ejemplo n.º 5
0
 public void Reset(string filename)
 {
     tiles = World.Instance.Tiles;
     MapDisplayAPI.ApplyOnceEditor();
     operationManager.Reset();
     if (filename != null)
     {
         mapName = filename;
     }
 }
    public void changeTile(int x, int y, byte newTileId)
    {
        byte prevId = tiles[x, y];

        if (prevId != newTileId)
        {
            tiles[x, y] ^= tiles[x, y];
            tiles[x, y] |= newTileId;
            MapDisplayAPI.ApplySinglePixel(x, y, newTileId);
            OperationList[currentPosition].AddLast(new Operation(x, y, prevId, newTileId));
        }
    }
Ejemplo n.º 7
0
    public void Commit()
    {
        Debugger.Log("Committing Color: {0}", new Color(SelectedTerrainCache.colorR, SelectedTerrainCache.colorG, SelectedTerrainCache.colorB, SelectedTerrainCache.enableAlpha ? SelectedTerrainCache.colorA : 1));

        if (SelectedTerrainCache.Commit())
        {
            Debugger.Log("Color was dirty.");
            MapDisplayAPI.ApplyOnceEditor();
        }

        Debugger.Log("Committed Color: {0}", Terrain.Get(SelectedTerrainCache.id).Color);
    }
Ejemplo n.º 8
0
    public void ResizeMap()
    {
        //GameObject startX = GameObject.Find ("MapStartXInput");
        //GameObject startY = GameObject.Find ("MapStartYInput");
        //GameObject scale = GameObject.Find ("MapScaleInput");
        GameObject width  = GameObject.Find("MapWidthInput");
        GameObject height = GameObject.Find("MapHeightInput");


        //double sX = startX.GetComponent<Text> ().text;
        //double sY = startY.GetComponent<Text> ().text;
        //double s = scale.GetComponent<Text> ().text;
        int w = int.Parse(width.GetComponentInChildren <Text> ().text);
        int h = int.Parse(height.GetComponentInChildren <Text> ().text);


        World.Instance.Resize(w, h);
        MapDisplayAPI.ApplyOnceEditor();
    }
Ejemplo n.º 9
0
    public void OnMouseDrag()
    {
        if (UIMenuController.IsActiveMenu(uiMapEditor))
        {
            var   gridPos = MouseToGridAPI.GetGridCoordinate(Input.mousePosition);
            Point point   = new Point((int)gridPos.x, (int)gridPos.y);
            switch (currentTool)
            {
            case ToolType.BRUSH:
                DrawLine(previous, point, paintCurrent.ID);
                previous = point;
                MapDisplayAPI.FinishOperation();
                break;

            default:
                break;
            }
        }
    }
Ejemplo n.º 10
0
 public void Redo()
 {
     operationManager.Redo();
     MapDisplayAPI.FinishOperation();
 }