Beispiel #1
0
    // to be discarded
    private void Stab()
    {
        StabberComponent stabber;

        if (stabber = heldObject.TheHeldObject.GetComponent <StabberComponent>())
        {
            RaycastHit hit;
            Ray        ray = GetComponent <Camera>().ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit, 10000))
            {
                GameObject  target          = hit.transform.gameObject;
                AnchorPoint CurrAnchorPoint = target.GetComponent <AnchorPoint>();
                if (CurrAnchorPoint)
                {
                    if (!CurrAnchorPoint.IsOccupied && CurrAnchorPoint.canObjectBePlacedHere(heldObject.TheHeldObject) && CurrAnchorPoint.Equals(stabber.DetectLodgeTarget()))
                    {
                        heldObject.TheHeldObject.GetComponent <BaseObject>().isHeld = false;
                        stabber.Lodge();
                        heldObject.PlaceObject(target);
                        previousObject = null;
                    }
                }
            }
        }
    }
Beispiel #2
0
    private void MoveHeldObject()
    {
        Ray        ray = GetComponent <Camera>().ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;
        LayerMask  layermask = 1 << (int)BaseObject.Layers.IgnoreRaycast | 1 << (int)BaseObject.Layers.HoldingObject;

        layermask = ~layermask;
        if (Physics.Raycast(ray, out hit, 10000, layermask))
        {
            GameObject  target          = hit.transform.gameObject;
            AnchorPoint CurrAnchorPoint = target.GetComponent <AnchorPoint>();
            if (CurrAnchorPoint)
            {
                DisplayCursor(CurrAnchorPoint.canObjectBePlacedHere(heldObject.TheHeldObject));
                anchorPoint = CurrAnchorPoint;
            }

            heldObject.MoveObject(target);
        }
    }
Beispiel #3
0
    private void DropHeldObject()
    {
        AnchorPoint CurrAnchorPoint = anchorPoint;

        if (CurrAnchorPoint)
        {
            if (!CurrAnchorPoint.IsOccupied && CurrAnchorPoint.canObjectBePlacedHere(heldObject.TheHeldObject) /*&& !heldObject.TheHeldObject.GetComponent<BaseObject>().isColliding*/)
            {
                if (heldObject.TheHeldObject.GetComponent <WWisePlaceTrigger>())
                {
                    heldObject.TheHeldObject.GetComponent <WWisePlaceTrigger>().Place();
                }
                else
                {
                    print("Warning: WWISE not attatched to " + heldObject.TheHeldObject.name);
                }

                SetLayerRecursive(heldObject.TheHeldObject.transform.parent.gameObject, (int)BaseObject.Layers.Default);

                // for stabber
                StabberComponent stabber;
                if (stabber = heldObject.TheHeldObject.GetComponent <StabberComponent>())
                {
                    if (CurrAnchorPoint.Equals(stabber.DetectLodgeTarget()))
                    {
                        stabber.Lodge();
                    }
                }

                heldObject.TheHeldObject.GetComponent <BaseObject>().isHeld = false;
                heldObject.PlaceObject(CurrAnchorPoint.gameObject);
                previousObject = null;
                HideAllStackableObjects();
                objectisHeld = false;
                prevCanPlace = null;
                ChangeCursor(true);
            }
        }
    }