void Update() { if (Input.GetMouseButtonDown(0)) { Vector2 camPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); if (camPos.y < _mapLimits[0].position.y && camPos.y > _mapLimits[1].position.y && camPos.x <_mapLimits[2].position.x && camPos.x> _mapLimits[3].position.x) { RaycastHit2D hit = Physics2D.Raycast(camPos, Vector2.zero); if (hit && hit.collider) { if (hit.collider.CompareTag("playerUnit") && !_footmanSelection.Contains(hit.collider.gameObject.GetComponent <footman> ())) { _ClearSelection <building> (_buildingSelection); footman ftm = hit.collider.GetComponent <footman> (); if (!Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift)) { _ClearSelection <footman> (_footmanSelection); } ftm._selectedDisplay(true); _footmanSelection.Add(ftm); } else if (hit.collider.CompareTag("building") && !_buildingSelection.Contains(hit.collider.gameObject.GetComponent <building> ())) { _ClearSelection <footman> (_footmanSelection); building bldg = hit.collider.GetComponent <building> (); if (!Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift)) { _ClearSelection <building> (_buildingSelection); } bldg._selectedDisplay(true); _buildingSelection.Add(bldg); } //else if (CompareTag("orc")...) //else if ("obstacle"...) } else { foreach (footman ftm in _footmanSelection) { ftm.IsWalking = true; ftm.FootmanOrientation = _setUnitOrientation(camPos, ftm.transform.position); ftm.TargetPos = camPos; //movePos ftm._setCurrentAnimation(); } } } } else if (Input.GetMouseButtonDown(1)) { _ClearSelection <footman> (_footmanSelection); _ClearSelection <building> (_buildingSelection); } }