/* * void updateCursor () * { * tileUnderMouse = WorldController.Instance.getTileAtWorldCoord (currFramePosition); * if (tileUnderMouse != null) { * cursor.SetActive (true); * cursorPosition = new Vector3 (tileUnderMouse.X, tileUnderMouse.Y, 0); * cursor.transform.position = cursorPosition; * } else { * cursor.SetActive (false); * } * } */ void updateDrag() { if (EventSystem.current.IsPointerOverGameObject()) { return; } while (dragCursors.Count > 0) { go = dragCursors [0]; dragCursors.RemoveAt(0); SimplePool.despawn(go); } if (currentMode != MouseMode.BUILD) { return; } if (Input.GetMouseButtonDown(0)) { dragStartPosition = currFramePosition; isDragging = true; } else if (!isDragging) { dragStartPosition = currFramePosition; } if (Input.GetMouseButtonUp(1) || Input.GetKeyUp(KeyCode.Escape)) { isDragging = false; } if (!buildModeController.IsObjectDraggable()) { dragStartPosition = currFramePosition; } calculateAreaDrag(); for (int x = start_x; x <= end_x; x++) { for (int y = start_y; y <= end_y; y++) { tile = WorldController.Instance.world.getTileAt(x, y); if (tile != null) { if (buildModeController.buildMode == BuildMode.FURNITURE) { ShowFurnitureSpriteAtTile(buildModeController.objectType, tile); } else { go = SimplePool.spawn(cursorPrefab, new Vector3(x, y, 0), Quaternion.identity); go.transform.SetParent(this.transform, true); dragCursors.Add(go); } } } } if (isDragging && Input.GetMouseButtonUp(0)) { calculateAreaDrag(); isDragging = false; for (int x = start_x; x <= end_x; x++) { for (int y = start_y; y <= end_y; y++) { tile = WorldController.Instance.world.getTileAt(x, y); if (tile != null) { buildModeController.doBuild(tile); } } } } }