示例#1
0
 // Returns if we consumed the object with our action
 protected bool TryCraft(Takable obj)
 {
     if (containedObjects.Count != 1)
     {
         return(false);
     }
     if (obj.CompareTag("Exacto") && containedObjects[0].TryGetComponent <DeliveryboxBehaviour>(out var deliveryBox))
     {
         var content = Instantiate(deliveryBox.content, depotSpot.position, depotSpot.rotation, transform);
         content.EnsurePlaced();
         containedObjects[0] = content;
         Destroy(deliveryBox.gameObject); // No more box
         return(false);                   // We don't consume the exacto, it was only used to open the box.
     }
     if (containedObjects[0].TryGetComponent <ObjectToBeRepairedBehaviour>(out var repairable))
     {
         int index = repairable.requirements.FindIndex(obj.CompareTag);
         if (index == -1)
         {
             // not part of requirements
             return(false);
         }
         repairable.requirements.RemoveAt(index);
         Destroy(obj.gameObject);
         return(true);
     }
     return(false);
 }
示例#2
0
        /// <summary>
        /// Gets takable by given takable id
        /// </summary>
        /// <param name="takableId">Given takable id</param>
        /// <returns>Information about takable</returns>
        public static Takable GetTakableById(long takableId)
        {
            string  documentType = GetType(takableId);
            Takable takable      = DatabaseHelper.Query <Book>("dbo.spTakable_GetAllById @DocumentId", new { DocumentId = takableId }).ToArray()[0];

            return(takable);
        }
示例#3
0
 protected override bool TryAddObject(Takable gameObject, Interactror interactror)
 {
     if (containedObjects.Count != 0)
     {
         return(TryCraft(gameObject));
     }
     gameObject.transform.position = depotSpot.position;
     gameObject.transform.rotation = depotSpot.rotation;
     return(true);
 }
示例#4
0
    /// <summary>
    /// DO NOT OVERRIDE THIS METHOD
    /// Adds a GameObject to the object container
    /// </summary>
    /// <param name="gameObject"></param>
    public bool PutObject(Takable interactee, Interactror interactror)
    {
        if (TryAddObject(interactee, interactror))
        {
            Debug.Log("Object ADDED to container!");
            containedObjects.Add(interactee);
            return(true);
        }

        return(false);
    }
示例#5
0
 /// <summary>
 /// Returns document in the database
 /// </summary>
 /// <param name="documentId">Id of document that will be returned</param>
 /// <param name="patronId">Id of patron that returns the document</param>
 public static void ReturnDocument(long documentId, long patronId)
 {
     DatabaseHelper.Execute("dbo.spCopies_ReturnDocument @DocumentId, @UserId", new { DocumentId = documentId, UserId = patronId });
     Patron[] patrons = UsersDataManager.GetQueueToDocument(documentId);
     if (patrons.Length != 0)
     {
         Takable takable = GetTakableById(documentId);
         NotificationsDataManager.AddNotification(new Notification()
         {
             PatronId = patrons[0].CardNumber,
             Message  = takable.Title + " now waiting for you."
         });
         DatabaseHelper.Execute("dbo.spQueue_RemovePatronByDocumentId @DocumentId, @PatronId", new { DocumentId = documentId, PatronId = patronId });
     }
 }
示例#6
0
    private string GetRecipe(Takable lastObj)
    {
        if (!lastObj.TryGetComponent <ObjectToBeRepairedBehaviour>(out var repairable))
        {
            return("Not repairable!\n");
        }

        string result = "";

        foreach (var req in repairable.requirements.GroupBy(x => x))
        {
            result += req.Count() + "x " + req.Key + "\n";
        }

        return(result + "\n");
    }
示例#7
0
        /// <summary>
        /// Check out document in database
        /// </summary>
        /// <param name="documentId">Id of document that will be checked out</param>
        /// <param name="patronId">Id of patron that checks out the document</param>
        public static void CheckOutDocument(long documentId, long patronId)
        {
            if (!IsAvailable(documentId, patronId))
            {
                return;
            }

            string patronType = UsersDataManager.GetPatronType(patronId);

            Takable takable = GetTakableById(documentId);

            long returningDate = takable.EvaluateReturnDate(DateManager.GetLong(DateTime.Today), patronType);

            long availableCopyId = DatabaseHelper.Query <long>("dbo.spCopies_GetAvailableCopies @BookId, @UserId", new { BookId = documentId, UserId = patronId }).FirstOrDefault();

            DatabaseHelper.Execute("dbo.spCopies_takeCopyWithReturningDate @CopyId, @UserId, @ReturningDate", new { CopyId = availableCopyId, UserId = patronId, ReturningDate = returningDate });
        }
示例#8
0
    private void AddFinalText(Takable lastObj)
    {
        var text = RecipeResult.gameObject.AddComponent <Text>();

        text.text = "Analyze finished: \n" + GetRecipe(lastObj);

        text.resizeTextForBestFit = true;
        text.verticalOverflow     = VerticalWrapMode.Truncate;
        text.horizontalOverflow   = HorizontalWrapMode.Wrap;
        text.font            = TextFont;
        text.alignByGeometry = true;
        text.material        = TextFont.material;
        text.alignment       = TextAnchor.LowerCenter;
        text.color           = new Color(1, 0, 0.31f);
        Material updatedMaterial = new Material(text.materialForRendering);

        updatedMaterial.SetInt("unity_GUIZTestMode", (int)UnityEngine.Rendering.CompareFunction.Always);
        text.material = updatedMaterial;
    }
示例#9
0
    protected override bool TryAddObject(Takable gameObject, Interactror interactror)
    {
        // Verify if this is the correct script
        // In this case, it the the clien't computer and are all the requirements met
        if (gameObject == computer.takable && computer.requirements.Count == 0)
        {
            Destroy(computer.gameObject);
            MakeCustomerLeave();

            var moneyManager = FindObjectOfType <MoneyManager>();

            if (moneyManager != null)
            {
                moneyManager.CompleteOrder();
            }

            return(true);
        }
        return(false);
    }
示例#10
0
    // Use to process your families.
    protected override void onProcess(int familiesUpdateCount)
    {
        if (Input.GetMouseButtonDown(0))
        {
            // Only one GO could be under the pointer

            // Check if player clics on a GameObject near to the hero
            GameObject go = inGameObjects.First();
            if (go != null)
            {
                Takable             item = go.GetComponent <Takable> ();
                ComponentMonitoring cm   = go.GetComponent <ComponentMonitoring> ();
                // move item to inventory
                GameObjectManager.setGameObjectState(item.linkedWith, true);
                GameObjectManager.setGameObjectState(go, false);
                // trace this action
                MonitoringManager.trace(cm, "perform", MonitoringManager.Source.PLAYER);
            }
        }
    }
示例#11
0
    protected override bool TryAddObject(Takable gameObject, Interactror interactor)
    {
        if (!gameObject.TryGetComponent <Analyzable>(out var analyzable))
        {
            Debug.LogError("Object is not Analyzable!");
            return(false);
        }

        if (containedObjects.Count == 1)
        {
            Debug.Log("There is already an object in the Analyzer!");
            return(false);
        }

        progressBar.Progress = 0;
        progressionUI.SetActive(true);
        analyzable.OnAnalyze(this, interactor);
        typingSound.Play();
        gameObject.transform.position = depotSpot.position;
        gameObject.transform.rotation = depotSpot.rotation;

        return(true);
    }
示例#12
0
        /// <summary>
        /// Renews copy by given document id and patron id
        /// </summary>
        /// <param name="documentId">Given document id</param>
        /// <param name="patronId">Given patron id</param>
        public static void RenewCopy(long documentId, long patronId)
        {
            Copy[] copies = GetCopiesCheckedOutByPatron(patronId);
            Copy   copy   = null;

            foreach (Copy c in copies)
            {
                if (c.DocumentId == documentId && c.PatronId == patronId)
                {
                    copy = c;
                }
            }
            if (copy == null)
            {
                return;
            }
            string patronType = UsersDataManager.GetPatronType(patronId);

            if (copy.IsRenewed && patronType != "Guest")
            {
                return;
            }
            Takable takable = GetTakableById(documentId);

            if (takable.IsOutstanding)
            {
                return;
            }
            long returningDate = takable.EvaluateReturnDate(copy.ReturningDate, patronType);

            DatabaseHelper.Execute("dbo.spCopies_RenewDocument @DocumentId, @PatronId, @ReturningDate", new {
                DocumentId    = documentId,
                PatronId      = patronId,
                ReturningDate = returningDate
            });
        }
示例#13
0
 protected abstract bool TryAddObject(Takable gameObject, Interactror interactror);
示例#14
0
    // Update is called once per frame
    //void Update()
    //{
    //    if(analyzedBy != null)
    //    {
    //        analyzedBy.transform.position = analyzedByInitialPosition;
    //        analyzedBy.transform.rotation = analyzedByInitialRotation;
    //    }
    //}

    void Start()
    {
        takable = GetComponent <Takable>();
    }