示例#1
0
 // Update is called once per frame
 void Update()
 {
     mSRender.enabled = visiable;
     if (itemsBox.objPickedUp.Count > 0 && this.gameObject.name == "SceneObjPuzzle")
     {
         //Debug.Log(receiveItems.ToString() + (!showQuiz).ToString() + (itemsBox.objPickedUp.Count > 0).ToString()
         //    + itemsBox.objPickedUp[0].GetComponent<Item>().objToGive.name);
     }
     if (receiveItems && !showQuiz &&
         itemsBox.objPickedUp.Count > 0 &&
         itemsBox.objPickedUp[0].GetComponent <Item>().objToGive == this.gameObject &&
         Common.Utils.ClickedOn(this.gameObject))     // collect item
     {
         var item = itemsBox.objPickedUp[0].GetComponent <Item>();
         var cpy  = Instantiate(item.objCarried);
         relatedQuiz.GetComponent <QuizReception>().AddItem(cpy);
         itemsBox.RemoveItem(item.gameObject);
     }
     else if (hasQuiz && Common.Utils.ClickedOn(this.gameObject)) // focus on quiz
     {
         //itemsBox.gameObject.SetActive(false);
         // don't change quizCamera's layerMask
         Common.Utils.SetActiveLayer("Quiz");
         relatedQuiz.SetActive(true);
         showQuiz = true;
     }
 }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        mSRender.enabled = visiable;
        if (itemsBox.objPickedUp.Count > 0 && this.gameObject.name == "SceneObjPuzzle")
        {
            //Debug.Log(receiveItems.ToString() + (!showQuiz).ToString() + (itemsBox.objPickedUp.Count > 0).ToString()
            //    + itemsBox.objPickedUp[0].GetComponent<Item>().objToGive.name);
        }
        if (receiveItems && !showQuiz &&
            itemsBox.objPickedUp.Count > 0 &&
            itemsBox.objPickedUp[0].GetComponent <Item>().objToGive == this.gameObject &&
            Common.Utils.ClickedOn(this.gameObject))     // collect item
        {
            var item = itemsBox.objPickedUp[0].GetComponent <Item>();
            var cpy  = Instantiate(item.objCarried);
            relatedQuiz.GetComponent <QuizReception>().AddItem(cpy);
            itemsBox.RemoveItem(item.gameObject);
        }
        else if (hasQuiz &&
                 (!showQuiz || relatedQuiz.GetComponent <QuizCamera>() != null) &&
                 Common.Utils.ClickedOn(this.gameObject))  // focus on quiz
        {
            //itemsBox.gameObject.SetActive(false);
            // don't change quizCamera's layerMask
            if (relatedQuiz.GetComponent <QuizCamera>() == null)
            {
                Common.Utils.SetActiveLayer("Quiz");
            }
            relatedQuiz.SetActive(true);
            showQuiz = true;
        }
        else if (hasQuiz && showQuiz &&
                 (!Common.Utils.ClickedOnChildenOf(itemsBox.gameObject)) &&
                 Common.Utils.ClickedAnywhereOut(itemsBox.gameObject) &&
                 Common.Utils.ClickedAnywhereOut(relatedQuizArea) &&
                 relatedQuiz.gameObject.GetComponent <QuizCamera>() == null &&
                 FindObjectOfType <QuizCamera>() == null // if QuizCamera is active it will return nonnull else null
                 )
        // exit quiz, dont influence QuizCamera UI which will exit by itself
        {
            //itemsBox.gameObject.SetActive(true);
            relatedQuiz.SetActive(false);
            mNeedSetLayerMask = true;
            showQuiz          = false;
        }

        if (pickable && Common.Utils.ClickedOn(this.gameObject))
        {
            bool ret = itemsBox.AddItem(relatedItem, picIdle, picPicked, objToGive, objCarried);
            Debug.Assert(ret); // get false only if itemsbox is full, meaning should redesign the itemsbox
            Destroy(this.gameObject);
        }
    }