Exemple #1
0
        public IHttpActionResult PutPivo(int id, Pivo pivo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != pivo.Id)
            {
                return(BadRequest());
            }

            db.Entry(pivo).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PivoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #2
0
        public IHttpActionResult GetPivo(int id)
        {
            Pivo pivo = db.Pivos.Find(id);

            if (pivo == null)
            {
                return(NotFound());
            }

            return(Ok(pivo));
        }
Exemple #3
0
        public IHttpActionResult PostPivo(Pivo pivo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Pivos.Add(pivo);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = pivo.Id }, pivo));
        }
Exemple #4
0
        public IHttpActionResult DeletePivo(int id)
        {
            Pivo pivo = db.Pivos.Find(id);

            if (pivo == null)
            {
                return(NotFound());
            }

            db.Pivos.Remove(pivo);
            db.SaveChanges();

            return(Ok(pivo));
        }
    private void Update()
    {
        if (!Application.isPlaying || GameController.I.IsPaused)
        {
            return;
        }

        Vector3 myPos = transform.position;

        slotsToSearch.Clear();

        if (heldItem)
        {
            for (int i = 0; i < Slot.all.Length; i++)
            {
                Slot slot = Slot.all[i];

                // skip if slot is occupied
                if (slot.itemInSlot)
                {
                    continue;
                }
                // skip if slot only interacts with an item and this item is not held
                if (slot.onlyInteractsWith && slot.onlyInteractsWith != heldItem)
                {
                    continue;
                }
                // skip if slot uses interaction control and held item does not correspond
                if (slot.useInteractionControl && !InteractionControl.I.CanInteract(heldItem.gameObject, slot.gameObject))
                {
                    continue;
                }
                // special metla slot
                if (heldItem is Metla && slot.name != "MetlaSlot")
                {
                    continue;
                }

                slotsToSearch.Add(Slot.all[i]);
            }
        }

        Slot closestSlot = Util.FindClosest(slotsToSearch, myPos, interactRange, useViewSpaceDistance);


        interactablesToSearch.Clear();
        for (int i = 0; i < Interactable.all.Count; i++)
        {
            Interactable interactable = Interactable.all[i];
            // skip held item
            if (interactable == heldItem)
            {
                continue;
            }
            // don't interact with other player's item
            if (interactable.isHeld)
            {
                continue;
            }
            // prevent coffee interacting with dzezva if dzezva is empty
            if (interactable is Dzezva && heldItem is Coffee && interactable.GetComponent <Container>().amount == 0)
            {
                continue;
            }
            // don't interact with guests if nothing in hands
            if (!heldItem && interactable is Consumer)
            {
                continue;
            }
            // skip flekas if nothing is held or not a metla is held
            if (interactable is Fleka && (!heldItem || (heldItem && !(heldItem is Metla))))
            {
                continue;
            }
            // with metla interact only with doors and flekas
            if (heldItem && heldItem is Metla && !(interactable is Fleka || interactable is Door))
            {
                continue;
            }
            if (!(interactable is Door || interactable is Fleka))
            {
                if (heldItem && !InteractionControl.I.CanInteract(heldItem.gameObject, interactable.gameObject))
                {
                    continue;
                }
            }
            interactablesToSearch.Add(interactable);
        }

        Interactable closestItem = Util.FindClosest(interactablesToSearch, myPos, interactRange, useViewSpaceDistance);

        // Give priority to slot or item depending what's closer
        if (closestSlot && closestItem)
        {
            if (closestItem.IsCloserThan((IProximityFindable)closestSlot, myPos, true))
            {
                closestSlot = null;
            }
            else
            {
                closestItem = null;
            }
        }

        if (closestItem)
        {
            Debug.DrawLine(myPos, closestItem.ProximityPosition, Color.green);

            closestItem.Highlight(true);
        }
        else if (closestSlot)
        {
            Debug.DrawLine(transform.position, closestSlot.ProximityPosition, Color.red);

            closestSlot.Highlight(true);
        }

        if (closestItem != lastClosestItem && lastClosestItem)
        {
            lastClosestItem.Highlight(false);
        }

        if (closestSlot != lastClosestSlot && lastClosestSlot)
        {
            lastClosestSlot.Highlight(false);
        }

        lastClosestItem = closestItem;
        lastClosestSlot = closestSlot;

        DomacinInputManager.Actions p = player == 1 ?
                                        DomacinInputManager.e.p1 :
                                        DomacinInputManager.e.p2;

        bool btn_down = p.interactAction.triggered;
        bool btn_held = p.interactAction.ReadValue <float>() == 1;

        if (closestItem is Gajba && heldItem is Pivo && btn_down)
        {
            Pivo pivo = heldItem as Pivo;
            pivo.Remove();
            (closestItem as Gajba).putClip.Play2D(0.5f);
            Debug.Log("Pivo removed!");
        }
        else if (closestItem is Gajba && !heldItem && btn_down)
        {
            Interactable pivo = Database.e.CreatePivo();
            (closestItem as Gajba).pickupClip.Play2D(0.5f);
            heldItem = pivo.Take(this);
        }
        // Sibice
        else if (heldItem is Matches && closestItem is Candle candle && btn_down)
        {
            if (!candle.isBurning)
            {
                candle.Ignite();
            }
        }
Exemple #6
0
 public void Delete(Pivo pivo)
 {
     db.Pivos.Remove(pivo);
     db.SaveChanges();
 }
Exemple #7
0
 public void Edit(Pivo pivo)
 {
     db.Entry(pivo).State = EntityState.Modified;
     db.SaveChanges();
 }
Exemple #8
0
 public void Create(Pivo pivo)
 {
     db.Pivos.Add(pivo);
     db.SaveChanges();
 }