Exemplo n.º 1
0
    public void OnPickUp(ItemBase item)
    {
        if (!item._isInstantEffect)
        {
            if (CurrentItem != null)
            {
                CurrentItem.transform.parent = CurrentRoom.transform;

                /*
                 * var newPosition = transform.position + new Vector3(1.5f, 0, 0);
                 * if (newPosition.x < -4.7) {
                 *      newPosition = transform.position + new Vector3 (1.5f, 0, 0);
                 * } else if (newPosition.x > 4.6) {
                 *      newPosition = transform.position + new Vector3(-1.5f, 0, 0);
                 * }
                 */
                CurrentItem.transform.position = transform.position + new Vector3(1.5f, 0, 0);
                CurrentItem.Enable();
            }
            //StartCoroutine(PlayPickUpAnimation(item));
            item.transform.parent = transform.parent;
            item.Disable();
            CurrentItem = item;
        }
        else
        {
            var usedItem = item.UseItem(this);

            if (usedItem)
            {
                item.Disable();
                //StartCoroutine (DestroyItem (item));
            }
        }
    }
Exemplo n.º 2
0
    private IEnumerator PlayPickUpAnimation(ItemBase item)
    {
        item.transform.parent        = transform;
        item.transform.localPosition = Vector3.zero + new Vector3(0, 3.0f, 0);
        item.GetComponent <SpriteRenderer>().sortingLayerName = "Player";
        item.GetComponent <SpriteRenderer>().sortingOrder     = 10;
        Animator.Play("PickUpItem");
        _headObject.SetHeadDirection(PlayerHeadController.HeadDirection.Down);
        DisableCharacter();
        yield return(new WaitForSeconds(1f));

        EnableCharacter();
        _headObject.SetHeadDirection(PlayerHeadController.HeadDirection.Down);
        item.Disable();
        yield return(null);
    }
Exemplo n.º 3
0
 public void OnPickUp(ItemBase item)
 {
     if (!item.IsInstantEffect)
     {
         if (CurrentItem != null)
         {
             CurrentItem.transform.parent   = transform.parent;
             CurrentItem.transform.position = transform.position + new Vector3(1.0f, 0, 0);
             CurrentItem.Enable();
         }
         StartCoroutine(PlayPickUpAnimation(item));
         CurrentItem = item;
     }
     else
     {
         item.UseItem(this);
         item.Disable();
         StartCoroutine(DestroyItem(item));
     }
 }