示例#1
0
 public void OnTileUnhover(TileRenderer tileRenderer)
 {
     if (CurrentlyHoveredTile == tileRenderer)
     {
         CurrentlyHoveredTile = null;
     }
 }
示例#2
0
        private void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (CurrentlyHoveredTile != null)
                {
                    IsDragging    = true;
                    DraggingStart = CurrentlyHoveredTile;
                }
            }
            if (Input.GetMouseButtonUp(0))
            {
                if (IsDragging)
                {
                    IsDragging    = false;
                    DraggingStart = null;
                }
            }

            if (IsDragging && DraggingStart != null && CurrentlyHoveredTile != null)
            {
                ThisPlayerSelection.isSelected = true;

                int minPositionX = Mathf.Min(DraggingStart.Position.x, CurrentlyHoveredTile.Position.x);
                int minPositionY = Mathf.Min(DraggingStart.Position.y, CurrentlyHoveredTile.Position.y);
                int maxPositionX = Mathf.Max(DraggingStart.Position.x, CurrentlyHoveredTile.Position.x);
                int maxPositionY = Mathf.Max(DraggingStart.Position.y, CurrentlyHoveredTile.Position.y);

                int width  = minPositionX - maxPositionX;
                int height = minPositionY - maxPositionY;

                if (width > 0)
                {
                    width++;
                }
                else
                {
                    width--;
                }

                if (height > 0)
                {
                    height++;
                }
                else
                {
                    height--;
                }

                width  = Mathf.Abs(width);
                height = Mathf.Abs(height);

                ThisPlayerSelection.x      = minPositionX;
                ThisPlayerSelection.y      = minPositionY;
                ThisPlayerSelection.width  = width;
                ThisPlayerSelection.height = height;
            }
        }
示例#3
0
 public void OnTileHover(TileRenderer tileRenderer)
 {
     CurrentlyHoveredTile = tileRenderer;
 }