void GetLeftButtonDown() { //casting a ray to our pointer RaycastHit hit; ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { ObjectInfo objectInfo = hit.transform.GetComponent <ObjectInfo>(); if (hit.collider.CompareTag("Ground")) { if (movingFlag) { MoveFlag(hit.point); } else if (isBuilding) { builder.PlaceBuilding(buildingproto, new Vector3(hit.point.x, 0.5f, hit.point.z)); isBuilding = false; buildingproto = null; } else { if (Input.GetMouseButtonDown(0) && Input.GetKey(KeyCode.LeftShift)) { Debug.Log("Starting selection"); startPos = hit.point; box.baseMinimum = startPos; isSelecting = true; } else { if (selectedObjects.Count != 0) { ClearSelection(); } } } } else if (Input.GetMouseButtonDown(0) && hit.collider.CompareTag("Selectable")) { if (selectedObjects.Count != 0) { ClearSelection(); } Select(hit.collider.GetComponent <ObjectInfo>()); } else { //TODO make a separate branch for these Trainer trainer = hit.transform.gameObject.GetComponent <Trainer>(); rallyPointMoved = hit.transform.gameObject.GetComponent <RallyPoint>(); if (trainer != null && Input.GetMouseButtonDown(0)) { //TODO add task queue to buildings trainer.TrainNew(); } else if (hit.transform.gameObject.CompareTag("RallyFlag") && rallyPointMoved != null) { movingFlag = true; } } } if (isSelecting) { dragPos = hit.point; box.baseMaximum = dragPos; } }