private void OnCollisionEnter2D(Collision2D coll) { // check to see if it's a pickupable prop if ((coll.gameObject.GetComponent("PropsToPickUp") as PropsToPickUp) != null) { if (coll.gameObject.GetComponent<PropsToPickUp>().CanBePickedUp) { currentProp = coll.gameObject; CurrentPropToPickUp = currentProp.GetComponent<PropsToPickUp>(); readyToPickup = true; } else { currentProp = null; CurrentPropToPickUp = null; readyToPickup = false; return; } } }
private void OnCollisionEnter2D(Collision2D coll) { // check to see if it's a pickupable prop if (coll.gameObject.tag == "CanHideIn") { PropsToHideIn theThingYouCanHideIn = coll.gameObject.GetComponent<PropsToHideIn>() as PropsToHideIn; if(theThingYouCanHideIn.isCar) { finalThiefScore += DepositCash(); } if (theThingYouCanHideIn != null) { if (!coll.gameObject.GetComponent<PropsToHideIn>().SomeoneIsHidingInHere) { SetCurrentPropAndType(coll.gameObject, propTypes.hiding); CurrentPropToHideIn = currentProp.GetComponent<PropsToHideIn>(); readyToHide = true; Vector3 pos = currentProp.transform.position + new Vector3(0, 0, -3f); ActionButton.transform.position = pos; ActionButton.transform.renderer.enabled = true; } else { currentProp = null; CurrentPropToHideIn = null; readyToHide = false; return; } } } else if (coll.gameObject.tag == "CanBePickedUp") { if (coll.gameObject.GetComponent<PropsToPickUp>().CanBePickedUp) { currentProp = coll.gameObject; currentPropType = propTypes.pickup; CurrentPropToPickUp = currentProp.GetComponent<PropsToPickUp>(); readyToPickup = true; Vector3 pos = currentProp.transform.position + new Vector3(0, 0, -3f); ActionButton.transform.position = pos; ActionButton.transform.renderer.enabled = true; } else { currentProp = null; CurrentPropToPickUp = null; readyToPickup = false; return; } } }