// Start is called before the first frame update void Start() { placeUnitController = GameObject.FindWithTag("Placer").GetComponent <PlaceUnitController>(); selectedUnits = new Stack <GameObject>(); objects = GameObject.FindWithTag("Placer").GetComponent <PlaceUnitController>().objectList; SelectionImage.gameObject.SetActive(false); }
private void ReleaseSelectionBox() { SelectionImage.gameObject.SetActive(false); _hotMin = SelectionImage.anchoredPosition - (SelectionImage.sizeDelta / 2); _hotMax = SelectionImage.anchoredPosition + (SelectionImage.sizeDelta / 2); if (Input.GetKey(KeyCode.S)) { List <Vector2> locs = Grid.Instance.CheckSelectionArea(Camera.main.ScreenToWorldPoint(_hotMin), Camera.main.ScreenToWorldPoint(_hotMax)); PlaceUnitController.PassToBuilders(locs); } else { foreach (var ob in objects) { Vector3 unitPos = Camera.main.WorldToScreenPoint(ob.transform.position); if (unitPos.x > _hotMin.x && unitPos.x < _hotMax.x && unitPos.y > _hotMin.y && unitPos.y < _hotMax.y) { selectedUnits.Push(ob); ob.GetComponent <SpriteRenderer>().color = new Color(0, 250, 248); } } } selectedBlocks.Clear(); _selectionBlocks.Clear(); PoolingManager.Instance.DeactivateSelectionBlocks(); }
private void OnEnable() { puc = GameObject.FindWithTag("Placer").GetComponent <PlaceUnitController>(); }