public void checkPress() { if (isPositioning) { hideButtons(); string name = ElementPlacing.truncateNumbers(placedElem.name); if (ep.getObjectNum(name) < transform.GetComponent <InvOpen>().panel.GetComponent <AvailElemManager>().getCount(name)) { ElementPlacing.currHold = ElementPlacing.truncateNumbers(placedElem.name); ElementPlacing.holding = true; } if (!PlaySimulation.isSimActive) { if (placedElem.name.Contains("ramp")) { BlockHover.showRampGrid(); } else { BlockHover.showGrid(); } } //BlockHover.hideRampGrid (); ep.canPlace = true; placedElem = null; } }
void Awake() { placing = GameObject.Find("Placing"); ep = placing.GetComponent <ElementPlacing> (); availElements = new List <AvailElement>(); availElements.Add(new AvailElement(curve, curveNum, "curve")); availElements.Add(new AvailElement(ramp, rampNum, "ramp")); foreach (AvailElement elem in availElements) { GameObject newElem = Instantiate(elem.go) as GameObject; newElem.transform.SetParent(GameObject.Find("Buttons").transform, false); newElem.GetComponent <RectTransform> ().anchorMin = new Vector2(0.5f, 1); newElem.GetComponent <RectTransform> ().anchorMax = new Vector2(0.5f, 1); newElem.GetComponent <RectTransform> ().pivot = new Vector2(0.5f, 0.5f); newElem.GetComponent <Button> ().onClick.AddListener(delegate { placing.GetComponent <ElementPlacing>().TakeElement(elem.type); }); } }
public void RemoveElem() { if (placedElem.GetComponent <ElementProperties> ().removable) { ElementPlacing.currHold = ElementPlacing.truncateNumbers(placedElem.name); ElementPlacing.holding = true; if (placedElem.name.Contains("ramp")) { BlockHover.showRampGrid(); BlockHover.hideGrid(); } else { BlockHover.showGrid(); BlockHover.hideRampGrid(); } ep.decNum(placedElem.name); Destroy(placedElem); placedElem = null; ep.canPlace = true; } }