public void PickupObject(InteractablePickup pickupObject)
    {
        m_PickedUpObject = pickupObject;
        m_PickedUpObject.transform.parent        = m_MovementModel.pickupItemParent;
        m_PickedUpObject.transform.localPosition = Vector3.zero;


        Collider2D pickupObjectCollider = pickupObject.GetComponent <Collider2D>();

        pickupObject.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Kinematic;

        if (pickupObjectCollider != null)
        {
            pickupObjectCollider.enabled = false;
        }
    }
    IEnumerator _ThrowCarryingObject()
    {
        Collider2D pickupObjectCollider = m_PickedUpObject.GetComponent <Collider2D>();

        if (pickupObjectCollider != null)
        {
            Physics2D.IgnoreCollision(m_Collider, pickupObjectCollider);
            pickupObjectCollider.enabled = false;
        }

        m_PickedUpObject.Throw(m_Character);
        yield return(new WaitForSeconds(0.2f));

        pickupObjectCollider.enabled = true;
        Physics2D.IgnoreCollision(m_Collider, pickupObjectCollider, false);
        m_PickedUpObject = null;
    }
Beispiel #3
0
    public void InventoryAction()
    {
        if (m_MovementModel.getIsCarrying() == true)
        {
            pocketItem = m_PickedUpObject.GetComponent <PocketBase>();

            if (pocketItem == null)
            {
                return;
            }

            if (m_PocketModel.GetNumberOfItems() == m_PocketModel.GetMaxSize())
            {
                Debug.Log("Full!");
                return;
            }

            m_PocketModel.AddItem(pocketItem.getType());
            Destroy(m_PickedUpObject.gameObject);
            SetUncarry();
        }
        else
        {
            PocketItemType item = m_PocketModel.GetSelectedItem();

            if (item == PocketItemType.Null)
            {
                return;
            }

            pocketItemData itemData   = Database.pItem.FindItem(item);
            GameObject     gameObject = itemData.TypePrefab;
            InstantiateInventoryItem(gameObject);

            m_PocketModel.RemoveSelectedItem();
        }
    }
Beispiel #4
0
 public void PickupObject(InteractablePickup pickupObject)
 {
     Debug.Log("Item is being picked up");
     m_PickedUpObject = pickupObject;
     m_PickedUpObject.transform.parent        = m_MovementModel.PreviewItemParent;
     m_PickedUpObject.transform.localPosition = Vector3.zero;
     //Hmm so localPosition is supposed to make sure the object is at the parent objects position
     //Altho its the parent im picking up, but it seems to work anyway
     //hmmm...
     m_MovementModel.SetFrozen(true, false, false);
     m_MovementModel.SetIsAbleToAttack(false);
     Helper.SetSortingLayerForAllRenderers(pickupObject.transform, "Characters");
     //Oh now it comes
     Physics2D.IgnoreCollision(m_Collider, pickupObject.GetComponent <Collider2D>());
 }
    public void PickUpObject(InteractablePickup pickUpObject)
    {
        pickedUpObject = pickUpObject;
        pickedUpObject.transform.parent        = movementModel.PickupItemParent;
        pickedUpObject.transform.localPosition = Vector3.zero;
        movementModel.SetAbleToAttack(false);
        Helper.SetSortingLayerToSprites(pickUpObject.transform, "Characters");
        // Physics2D.IgnoreCollision(m_collider, pickUpObject.GetComponent<Collider2D>());
        Collider2D pickupObjectCollider = pickedUpObject.GetComponent <Collider2D>();

        if (pickupObjectCollider != null)
        {
            pickupObjectCollider.enabled = false;
        }
    }
    public void ThrowCarryingObject()
    {
        Collider2D pickupObjectCollider = m_PickedUpObject.GetComponent <Collider2D>();

        if (pickupObjectCollider != null)
        {
            pickupObjectCollider.enabled = true;
            Physics2D.IgnoreCollision(m_Collider, pickupObjectCollider);
        }

        m_PickedUpObject.Throw(m_Character);
        m_PickedUpObject = null;

        //m_MovementModel.SetFrozen( false, false, false );
        m_MovementModel.SetIsAbleToAttack(true);
    }
    public void ThrowObject()
    {
        source.clip = throwSound;
        source.Play();

        Collider2D pickupObjectCollider = pickedUpObject.GetComponent <Collider2D>();

        if (pickupObjectCollider != null)
        {
            pickupObjectCollider.enabled = true;
            Physics2D.IgnoreCollision(m_collider, pickupObjectCollider);
        }

        pickedUpObject.Throw(character);
        pickedUpObject = null;
        movementModel.SetAbleToAttack(true);
    }
Beispiel #8
0
    //Throws the currently being carried object
    public void ThrowCarryingObject()
    {
        Collider2D pickupObjectCollider = m_PickedUpObject.GetComponent <Collider2D>();

        //Re-enable the collider and ignore collisions as your throw it
        if (pickupObjectCollider != null)
        {
            pickupObjectCollider.enabled = true;
            Physics2D.IgnoreCollision(m_Collider, pickupObjectCollider);
        }

        //Throoow it
        m_PickedUpObject.Throw(m_Character);
        m_PickedUpObject = null;

        //No longer carrying, can attack
        m_MovementModel.SetIsAbleToAttack(true);
    }
    public void PickupObject(InteractablePickup pickupObject)
    {
        m_PickedUpObject = pickupObject;

        m_PickedUpObject.transform.parent        = m_MovementModel.PickupItemParent;
        m_PickedUpObject.transform.localPosition = Vector3.zero;

        //m_MovementModel.SetFrozen( true, false, false );
        m_MovementModel.SetIsAbleToAttack(false);

        Helper.SetSortingLayerForAllRenderers(pickupObject.transform, "Characters");

        Collider2D pickupObjectCollider = pickupObject.GetComponent <Collider2D>();

        if (pickupObjectCollider != null)
        {
            pickupObjectCollider.enabled = false;
        }
    }
Beispiel #10
0
    //Pickup and carry an InteractablePickup item
    public void CarryObject(InteractablePickup objectToCarry)
    {
        if (IsCarrying())
        {
            return;
        }
        carriedObject = objectToCarry;
        anim.SetTrigger("DoPickupObject");                         //pickup animation
        anim.SetBool("IsPickingUp", true);                         //special Idle and Walk animation when carrying
        carriedObject.transform.parent        = previewItemParent; //object becomes child of previewItemParent
        carriedObject.transform.localPosition = Vector3.zero;
        layerOfCarriedObject = carriedObject.GetComponentInChildren <SpriteRenderer>().sortingLayerName;
        carriedObject.GetComponentInChildren <SpriteRenderer>().sortingLayerName = "HighObjects"; //rendered above the character
        SetColliders(carriedObject.gameObject, false);                                            //disable all coliders of the carried object
        EnemyBehavior objectBehavior = carriedObject.GetComponent <EnemyBehavior>();

        if (objectBehavior != null)
        {
            objectBehavior.DisableShadow();
        }
        TipsHandler.Recycle();
    }
Beispiel #11
0
    //Pick up an object that can later be thrown
    public void PickupObject(InteractablePickup pickupObject)
    {
        m_PickedUpObject = pickupObject;

        //Positon the object over us
        m_PickedUpObject.transform.parent        = m_MovementModel.PickupItemParent;
        m_PickedUpObject.transform.localPosition = Vector3.zero;

        //We cant attack because we are carrying something
        m_MovementModel.SetIsAbleToAttack(false);

        //Make it on our sorting layer relative to us
        Helper.SetSortingLayerForAllRenderers(pickupObject.transform, "Characters");

        //Turn off the collider for this object
        Collider2D pickupObjectCollider = pickupObject.GetComponent <Collider2D>();

        if (pickupObjectCollider != null)
        {
            pickupObjectCollider.enabled = false;
        }
    }
Beispiel #12
0
    public void DropObject()
    {
        if (!IsCarrying())
        {
            return;
        }

        // Vérification qu'il n'y a pas d'obstacle devant
        Collider2D[] closeColliders = Physics2D.OverlapCircleAll(transform.position + (vectMovement * 0.7f), 0.55f);
        foreach (Collider2D closeCollider in closeColliders)
        {
            if (closeCollider.CompareTag("Obstacle"))
            {
                // L'objet est déposé derrière
                vectMovement = -vectMovement;
                break;
            }
        }

        anim.SetTrigger("DoDrop");  //drop animation
        Vector3 newPosition = vectMovement;

        newPosition.y -= previewItemParent.transform.localPosition.y + 0.2f;
        carriedObject.transform.localPosition = newPosition; //move it in front of character
        carriedObject.transform.parent        = null;        //no parent
        carriedObject.GetComponentInChildren <SpriteRenderer>().sortingLayerName = layerOfCarriedObject;
        if (carriedObject.GetComponentInChildren <SpriteRenderer>().sortingOrder < 200)
        {
            carriedObject.GetComponentInChildren <SpriteRenderer>().sortingOrder += 100;
        }
        SetColliders(carriedObject.gameObject, true); EnemyBehavior objectBehavior = carriedObject.GetComponent <EnemyBehavior>();
        if (objectBehavior != null)
        {
            objectBehavior.EnableShadow();
        }
        carriedObject = null;
        anim.SetBool("IsPickingUp", false);     //go back to normal animations
    }
    public void PickupObject( InteractablePickup pickupObject )
    {
        m_PickedUpObject = pickupObject;

        m_PickedUpObject.transform.parent = m_MovementModel.PickupItemParent;
        m_PickedUpObject.transform.localPosition = Vector3.zero;

        //m_MovementModel.SetFrozen( true, false, false );
        m_MovementModel.SetIsAbleToAttack( false );

        Helper.SetSortingLayerForAllRenderers( pickupObject.transform, "Characters" );

        Collider2D pickupObjectCollider = pickupObject.GetComponent<Collider2D>();

        if( pickupObjectCollider != null )
        {
            pickupObjectCollider.enabled = false;
        }
    }