Esempio n. 1
0
    /// <summary>
    /// Resi zvednuti itemu ze zeme.
    /// </summary>
    void InputPickup()
    {
        Debug.Log("<<<PICKUP>>>");
        Debug.Log("Last seen tile pos: " + LastSeenTile.Position + " " + LastSeenTile.Timeline);

        if (!LastSeenTile.IsAccessable)
        {
            Debug.Log(">>>No ACCESS");
            return;
        }

        if (CarriingItem != null)
        {
            Debug.Log(">>>WE ARE CARRIING ITEM ALREADY");
            return;
        }

        if (!LastSeenTile.IsOccupied)
        {
            Debug.Log(">>>THERE IS NO ITEM TO PICK UP");
            return;
        }

        MovableObject mo = LastSeenTile.ObjectOnTile as MovableObject;

        if (mo == null)
        {
            Debug.Log(">>>NOT MOVABLE OBJ, YOU CANT PICK THAT");
            return;
        }

        if (mo.gameObject.layer == PTSLayers.NoInteractionWithPlayer)
        {
            Debug.Log(">>>ITEM IS IN ANOTHER TIMELINE... IGNORE");
            return;
        }

        if (!mo.isPickable)
        {
            Debug.Log(">>>Object cannot be picked up.");
            return;
        }

        if (MyLastTile.LaserOnTile != null)
        {
            Debug.Log(">>> Cant pickup object when standing on laser.");
            Debug.Log("///// My TILE: " + MyLastTile.Position);
            return;
        }


        float height = -1;

        if (!CheckItemStackingPickUp(LastSeenTile, out mo, out height))
        {
            return;
        }

        CarriingItem = mo;

        if (mo.Equals(LastSeenTile.ObjectOnTile))
        {
            LastSeenTile.ChangeOccupation();
        }

        karelAnimator.StartPickup();

        if (LastSeenTile.LaserOnTile != null)
        {
            StartCoroutine(LaserActivationCoroutine(LastSeenTile));
        }

        /*
         * CarriingItem.transform.parent = transform;
         * CarriingItem.transform.position = transform.position + new Vector3(0.5f, 1, -0.5f);
         */

        Generator g = CarriingItem as Generator;

        if (g != null)
        {
            if (g.IsOn)
            {
                g.OnActivePickable();
            }

            Generator genInOtherTimeline = LastSeenTile.OtherTimelineRef.ObjectOnTile as Generator;

            if (genInOtherTimeline != null)
            {
                LastSeenTile.OtherTimelineRef.ChangeOccupation();
            }
        }
        else
        {
            CarriingItem.ChangeMaterial(PTSShaderEnum.Stay);
        }
        Debug.Log("   --- Succesfuly picked up");
    }