Example #1
0
    /// <summary>
    /// Zkontroluje, jestli objekt, ktery prave pokladame na zem, urci, ktery tile (v min nebo pritomnosti)
    /// mame pouzit pro umisteni predmetu a kterou veryi predmetu umistujeme
    /// </summary>
    /// <param name="t"></param>
    public Tile CheckTimeLineDrop(Tile t, MovableObject o)
    {
        List <Generator> gens = GetGeneratorsAffectingTile(t);

        //Nevypiname, pokud Objekt muze byt jen v pritomnosti a tile neovlivnuji zadne generatory
        if (gens.Count == 0)
        {
            Debug.Log("<<<DROP ON PRESENT>>>");
            o.ChangeMaterial(PTSShaderEnum.Present);
            return(PresentLevelTiles[-t.Position.x, t.Position.y]);
        }
        else
        {
            foreach (Generator g in gens)
            {
                if (g.IsOn)
                {
                    Debug.Log("<<<DROP ON PAST>>>");
                    o.ChangeMaterial(PTSShaderEnum.Past);
                    return(PastLevelTiles[-t.Position.x, t.Position.y]);
                }
            }
            Debug.Log("<<<DROP ON PRESENT>>>");
            o.ChangeMaterial(PTSShaderEnum.Present);
            return(PresentLevelTiles[-t.Position.x, t.Position.y]);
        }
    }
Example #2
0
    /// <summary>
    /// Kontrola toho, zda chceme polozit objekt na zem a nasledne polozeni
    /// </summary>
    bool InputDrop()
    {
        Debug.Log("<<<DROP>>>");
        bool  stackingItem = false;
        Box   b            = null;
        float height       = -1;

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

        if (CarriingItem == null)
        {
            Debug.Log(">>>WE ARE NOT CARRIING ANY ITEM");
            return(false);
        }

        if (CarriingItem.JustPickedUp)
        {
            Debug.Log(">>>WE JUST PICKED THE ITEM... IGNORE");
            return(false);
        }

        if (LastSeenTile.IsOccupied)
        {
            stackingItem = CheckItemStackingDrop(LastSeenTile, out b, out height);
            if (!stackingItem)
            {
                Debug.Log(">>>TILE ALREADY HAS SOME ITEM");
                return(false);
            }
        }

        Tile[] myTile = Level.GetTile(transform.position);

        if (myTile[0] == LastSeenTile || myTile[1] == LastSeenTile)
        {
            Debug.Log(">>>PLAYER IS STANDINDG ON THE TILE! CANT DROP");
            return(false);
        }

        //CarriingItem.transform.parent = null;

        if (LastSeenTile.Timeline.Equals(TimelineObject.Present))
        {
            CarriingItem.ChangeMaterial(PTSShaderEnum.Present);
        }
        else
        {
            CarriingItem.ChangeMaterial(PTSShaderEnum.Past);
        }

        if (stackingItem)
        {
            //Debug.Log("Its stacking time...");
            //Debug.Log(b + " " + height);
            karelAnimator.StartDrop(new Vector3(0, 1, 0), b.gameObject.transform.rotation, b.gameObject.transform, false);

            /*
             * CarriingItem.transform.parent = b.gameObject.transform;
             *
             *
             * CarriingItem.transform.localPosition = new Vector3(0, 1, 0);
             * CarriingItem.transform.rotation = b.gameObject.transform.rotation;
             */
            b.ItemOnTop = CarriingItem;
        }
        else
        {
            /*
             * PreassurePlate pp = LastSeenTile.ActivatorOnTile as PreassurePlate;
             * if (pp != null)
             *  pp.OnActivate();
             */

            LastSeenTile.ChangeOccupation(CarriingItem);
            karelAnimator.StartDrop(new Vector3(LastSeenTile.Position.x, LastSeenTile.Height, LastSeenTile.Position.y),
                                    new Quaternion(0, -180, 0, 0), null, true);
        }

        //Tile t = Level.Instance.CheckTimeLineDrop(LastSeenTile, CarriingItem);
        Generator g = CarriingItem as Generator;

        if (g != null)
        {
            g.UpdateEffectedTiles();

            if (g.IsOn)
            {
                g.OnActiveDropable();
            }

            if (CheckTileInOtherTimeline() && !stackingItem)
            {
                LastSeenTile.OtherTimelineRef.ObjectOnTile = g;
                LastSeenTile.OtherTimelineRef.IsOccupied   = true;
            }

            g.ChangeMaterial(PTSShaderEnum.Stay);
        }

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

        CarriingItem = null;
        Debug.Log("   --- Succesfully dropped");
        SoundsManager.instance.PlayDrop();
        return(true);
    }
Example #3
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");
    }