public void HighlightBuildLocation() { if (dragging) { buildHighlight.gameObject.SetActive(true); Vector2Int gridPos = truck.GetMouseGridPosition(); //Mouse is draging over a grid square if (gridPos.x >= 0) { buildHighlight.gameObject.SetActive(true); int sizeX = currentEquipType.Size.GridSize.x; int sizeY = currentEquipType.Size.GridSize.y; if (sizeX + gridPos.x > 4) { gridPos.x--; } if (sizeY > 1) { gridPos.y = Mathf.Max(gridPos.y - 1, 0); } buildHighlight.localPosition = new Vector3(gridPos.x * buildHighlightOffset.x, gridPos.y * buildHighlightOffset.y, 0); buildHighlight.sizeDelta = new Vector3(buildHighlightSize.x + (sizeX - 1) * buildTileSize.x, buildHighlightSize.y + (sizeY - 1) * buildTileSize.y, 0); } else { buildHighlight.gameObject.SetActive(false); } } }
void Update() { if (Input.GetMouseButtonDown(0) && buying != null) { truck.BuyEquipment(truck.GetMouseGridPosition(), buying); buying = null; } }