// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y); RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero); if (hit.collider != null) { partBase part = hit.transform.gameObject.GetComponent <partBase> (); if (part != null) { //hit an object with a part. if (part.removed) { //if part IS removed if (cs.resting) { cs.attachFromStorage(part); } } else { //if part IS NOT removed if (cs.resting) { cs.sendToStorage(part); } } } } } }
public void sendToStorage(partBase a) { toStorage.Add(a); foreach (screwBase b in a.screws) { us.addUnscrew(b); } }
public bool attachFromStorage(partBase a) { //simple check to see if it is in storage if (storage.Contains(a)) { outOfStorage.Add(a); return(true); } else { return(false); } }