예제 #1
0
 /// <summary>
 /// Called when MouseDrag event is fired.
 /// </summary>
 /// <param name="tile"> the tile we're placing </param>
 /// <param name="materials"> array of materials to apply to tile </param>
 /// <param name="closestCell"> closest cell to mouse position</param>
 /// <param name="archi"> reference to the Archi script </param>
 public override void MouseDrag(GameObject tile, Material[] materials, Vector3Int closestCell, Archi.Core.Archi archi, bool erase) //man I really need a better naming convention...
 {
     mouseEnd = GridUtility.GetCellCenter(closestCell, archi.grid);
 }
예제 #2
0
    /// <summary>
    /// Called when MouseUp event is fired.
    /// </summary>
    /// <param name="tile"> the tile we're placing </param>
    /// <param name="materials"> array of materials to apply to tile </param>
    /// <param name="closestCell"> closest cell to mouse position</param>
    /// <param name="archi"> reference to the Archi script </param>
    public override void MouseUp(GameObject tile, Material[] materials, Vector3Int closestCell, Archi.Core.Archi archi, bool erase) //man I really need a better naming convention...
    {
        mouseEnd = GridUtility.GetCellCenter(closestCell, archi.grid);
        Vector3 size   = (mouseStart - mouseEnd);
        Bounds  bounds = new Bounds(mouseStart - size / 2, vecAbs(size));

        int absXMin = Mathf.Abs((int)bounds.min.x);
        int absXMax = Mathf.Abs((int)bounds.max.x);
        int absYMin = Mathf.Abs((int)bounds.min.y);
        int absYMax = Mathf.Abs((int)bounds.max.y);

        for (int x = (int)bounds.min.x; x <= (int)bounds.max.x; x++)
        {
            for (int y = (int)bounds.min.z; y <= (int)bounds.max.z; y++)
            {
                if (x == (int)bounds.min.x || x == (int)bounds.max.x)
                {
                    Vector3Int cell = archi.grid.WorldToCell(new Vector3(x, 0, y));
                    if (!archi.tiles.ContainsKey(cell) && !erase)
                    {
                        archi.PlaceTile(cell, GridUtility.GetCellCenter(cell, archi.grid), tile);
                    }
                    else if (erase && archi.tiles.ContainsKey(cell))
                    {
                        archi.RemoveTile(cell);
                    }
                }
                if (y == (int)bounds.min.z || y == (int)bounds.max.z)
                {
                    Vector3Int cell = archi.grid.WorldToCell(new Vector3(x, 0, y));
                    if (!archi.tiles.ContainsKey(cell) && !erase)
                    {
                        archi.PlaceTile(cell, GridUtility.GetCellCenter(cell, archi.grid), tile);
                    }
                    else if (erase && archi.tiles.ContainsKey(cell))
                    {
                        archi.RemoveTile(cell);
                    }
                }
            }
        }
        mouseEnd   = Vector3.zero;
        mouseStart = Vector3.zero;
        isDragging = false;
    }
예제 #3
0
 /// <summary>
 /// Called when MouseDrag event is fired.
 /// </summary>
 /// <param name="tile"> the tile we're placing </param>
 /// <param name="materials"> array of materials to apply to tile </param>
 /// <param name="closestCell"> closest cell to mouse position</param>
 /// <param name="archi"> reference to the Archi script </param>
 public override void MouseDrag(GameObject tile, Material[] materials, Vector3Int closestCell, Archi.Core.Archi archi, bool erase)
 {
     if (!archi.tiles.ContainsKey(closestCell) && !erase)
     {
         archi.PlaceTile(closestCell, GridUtility.GetCellCenter(closestCell, archi.grid), tile);
     }
     else if (erase && archi.tiles.ContainsKey(closestCell))
     {
         archi.RemoveTile(closestCell);
     }
 }
예제 #4
0
 /// <summary>
 /// Called when MouseDown event is fired.
 /// </summary>
 /// <param name="tile"> the tile we're placing </param>
 /// <param name="materials"> array of materials to apply to tile </param>
 /// <param name="closestCell"> closest cell to mouse position</param>
 /// <param name="archi"> reference to the Archi script </param>
 public override void MouseDown(GameObject tile, Material[] materials, Vector3Int closestCell, Archi.Core.Archi archi, bool erase)
 {
     mouseStart = GridUtility.GetCellCenter(closestCell, archi.grid);
     mouseEnd   = GridUtility.GetCellCenter(closestCell, archi.grid);
     isDragging = true;
 }
예제 #5
0
 /// <summary>
 /// Called when MouseDown event is fired.
 /// </summary>
 /// <param name="tile"> the tile we're placing </param>
 /// <param name="materials"> array of materials to apply to tile </param>
 /// <param name="closestCell"> closest cell to mouse position</param>
 /// <param name="archi"> reference to the Archi script </param>
 public override void MouseDown(GameObject tile, Material[] materials, Vector3Int closestCell, Archi.Core.Archi archi, bool erase)
 {
 }