public void ShowAndMovePreview() { if (!preview) { return; } preview.transform.position = ZetanUtility.PositionToGrid(GetMovePosition(), gridSize, preview.CenterOffset); if (preview.ColliderCount > 0) { if (preview.SpriteRenderer) { preview.SpriteRenderer.color = Color.red; } } else { if (preview.SpriteRenderer) { preview.SpriteRenderer.color = Color.white; } } if (ZetanUtility.IsMouseInsideScreen) { if (Input.GetMouseButtonDown(0)) { Build(); } if (Input.GetMouseButtonDown(1)) { FinishPreview(); } } }
public void MovePreview() { if (isDraging) { return; } var horizontal = InputManager.GetAsix("Horizontal"); var vertical = InputManager.GetAsix("Vertical"); var input = new Vector2(horizontal, vertical).normalized; if (input.sqrMagnitude > 0.25) { moveTime += Time.deltaTime; } if (moveTime >= 0.1f) { moveTime = 0; preview.transform.position = ZetanUtility.PositionToGrid((Vector2)preview.transform.position + input, gridSize, preview.CenterOffset); CameraMovement2D.Instance.MoveTo(preview.transform.position); } }
public void ShowAndMovePreview() { if (!preview || !isDraging) { return; } preview.transform.position = ZetanUtility.PositionToGrid(GetMovePosition(), gridSize, preview.CenterOffset); #if UNITY_STANDALONE if (ZetanUtility.IsMouseInsideScreen) { if (InputManager.GetMouseButtonDown(0)) { DoPlace(); } if (InputManager.GetMouseButtonDown(1)) { FinishPreview(); } } #endif }