Ejemplo n.º 1
0
    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);
    }
Ejemplo n.º 2
0
    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);
        }
    }
Ejemplo n.º 3
0
    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);
    }