public bool GrabObjectAtPosition(Vector3 position) { bool grabSuccessful = true; if (state == States.HoldingObject) { gameObject.GetComponent <ICanGrab>().FinishedAction(false); // TODO failure reason: already holding object return(false); } grabbedObject = GetGrabbableObjectAtPoint(position); if (grabbedObject == null) { // TODO failure reason, no object to grab grabSuccessful = false; } else { grabbedObject.PickedUp(this); state = States.HoldingObject; } gameObject.GetComponent <ICanGrab>().FinishedAction(grabSuccessful); return(grabSuccessful); }
public bool ReceiveObject(IGrabbable grabbableObject) { if (InterfaceAnalyser.TypeMatch <ResourceCube>(grabbableObject)) { grabbedObject = grabbableObject; grabbedObject.PickedUp(this); levelScript.AddObjectToTile((SelectableObject)grabbedObject); state = States.Powered; return(true); } else { return(false); } }
public bool GrabObject(IGrabbable obj) { bool grabSuccessful = true; if (obj == null) { // TODO failure reason, no object to grab grabSuccessful = false; } else { grabbedObject = obj; obj.PickedUp(this); state = States.HoldingObject; } gameObject.GetComponent <ICanGrab>().FinishedAction(grabSuccessful); return(grabSuccessful); }