コード例 #1
0
    void ReleaseItem(GameObject item)
    {
        IndicatorOverlay overlay = item.GetComponent <IndicatorOverlay> ();

        if (overlay != null)
        {
            //For displaying icon over object
            //overlay.display = true;
            overlay.Enable();
        }
        item.transform.parent = null;
        item.GetComponent <Rigidbody>().velocity        = Vector3.zero;
        item.GetComponent <Rigidbody>().angularVelocity = Vector3.zero;
        //pickedUpRight = false;
        //cooldown = PICKUP_DELAY;
        if (item == item1)
        {
            pickedUpRight = false;
            cooldown      = PICKUP_DELAY;
        }
        else
        {
            pickedUpLeft = false;
            cooldownL    = PICKUP_DELAY;
        }

        item = null;
    }
コード例 #2
0
    void OnTriggerExit(Collider other)
    {
        IndicatorOverlay overlay = other.GetComponent <IndicatorOverlay> ();

        if (overlay != null)
        {
            overlay.Disable();
        }
    }
コード例 #3
0
    //run the dialogue tree coroutine
    public IEnumerator run()
    {
        if (whitenoise != null)
        {
            whitenoise.Play();
        }

        if (Enter != null)
        {
            Source.PlayOneShot(Enter);
        }

        //THIS WILL DO FOR NOW
        yield return(new WaitForEndOfFrame());

        yield return(new WaitForEndOfFrame());

        if (animator != null)
        {
            //animator.SetBool("InConversation", true);
            animator.Play("Conversation");
        }

        dialogueWindow.SetActive(true);

        //disable the overhead UI
        IndicatorOverlay overlay = transform.GetComponent <IndicatorOverlay> ();

        if (overlay != null)
        {
            overlay.enabled = false;
        }


        nodeID = dialogue._next;

        Node current;

        //while the node isn't an exit node...
        while (nodeID != -1)
        {
            current = dialogue._nodes[nodeID];
            updateText(current);
            //testing out the execute function
            current._precalls.ForEach((Call c) => c.execute());

            //add accomplishment to dictionary
            if (current._accomplish != null &&
                current._accomplish != "")
            {
                tasks[current._accomplish] = true;
                Debug.Log("ACCOMPLISHED " + current._accomplish);
                checkStatus();
            }

            select = -2;

            int   index = 0;
            int   direction;
            float selCooldown = 0.25f;
            int   j           = numOptions;
            while (select == -2)
            {
                if (!textScroll)
                {
                    //availableOptions[index].GetComponent<Button>().Select();

                    direction = -(int)Input.GetAxisRaw("Vertical");

                    if (selCooldown < 0)
                    {
                        index += direction;

                        //bind the indices
                        if (index < 0)
                        {
                            index = 0;
                        }
                        if (index > j - 1)
                        {
                            index = j - 1;
                        }
                    }

                    //testing
                    if (direction != 0 && selCooldown < 0)
                    {
                        selCooldown = 0.25f;
                    }

                    selCooldown -= Time.deltaTime;

                    if (Input.GetButtonDown("Fire1") && !textScroll && running &&
                        selCooldown < 0)
                    {
                        availableOptions[index].GetComponent <Button>().onClick.Invoke();
                        selCooldown = 0.25f;
                    }
                }
                yield return /*new WaitForEndOfFrame()*/ (null);
            }
            //destroy the buttons
            for (int i = 0; i < current._options.Count; i++)
            {
                Destroy(options[i]);
            }

            current._postcalls.ForEach((Call c) => c.execute());
            dialogue._next = current._reset;
            nodeID         = select;
        }
        //}
        if (Exit != null)
        {
            Source.PlayOneShot(Exit);
        }

        running      = false;
        coolingDown  = true;
        talkCooldown = 0f;
        mainCamera.gameObject.SetActive(true);
        dialogueCamera.gameObject.SetActive(false);
        dialogueWindow.SetActive(false);

        //store the reset node
        ProgressManager.resetNodes[name] = dialogue._next;
        Debug.Log(name + "'s reset node should now be " + ProgressManager.resetNodes[name]);


        if (endEpisode)
        {
            var canvas = GameObject.Find("Canvas");
            canvas.transform.Find("EndDay").gameObject.SetActive(true);
        }

        /*else
         * {
         *      GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerMovement>().enabled = true;
         * }*/

        if (animator != null)
        {
            animator.Play("idle");
        }

        if (overlay != null)
        {
            overlay.enabled = true;
        }
    }
コード例 #4
0
    void OnTriggerStay(Collider other)
    {
        IndicatorOverlay overlay = other.GetComponent <IndicatorOverlay> ();

        if (overlay != null && other.gameObject != item1 && other.gameObject != item2 &&
            overlay.display == false)
        {
            //overlay.Enable();
        }

        if (other.gameObject != item2 &&
            Input.GetButtonDown("Pickup") && !pickedUpRight && cooldown < 0.01f)
        {
            if (other.GetComponent <tmpItem>() != null)
            {
                if (other.GetComponent <tmpItem>().grabbable)
                {
                    if (item1 == null)
                    {
                        item1 = other.gameObject;
                    }
                    //Debug.Log("Grabbed!");
                    Collider childCollider = item1.transform.GetComponentInChildren <Collider> ();
                    //item1.transform.GetChild(0).gameObject.GetComponent<Collider>().enabled = false;
                    Physics.IgnoreCollision(childCollider, parentCollider, true);
                    item1.transform.position      = rightHand.position;
                    item1.transform.parent        = rightHand;
                    item1.transform.localPosition = Vector3.zero;
                    Rigidbody rb = item1.GetComponentInChildren <Rigidbody>();
                    rb.freezeRotation = true;
                    pickedUpRight     = false;
                    cooldown          = PICKUP_DELAY;

                    if (overlay != null)
                    {
                        //For displaying icon over object
                        overlay.Disable();
                    }
                }
            }
        }
        if (other.gameObject != item1 &&
            Input.GetButtonDown("PickupL") && !pickedUpLeft && cooldownL < 0.01f)
        {
            if (other.GetComponent <tmpItem>() != null)
            {
                if (other.GetComponent <tmpItem>().grabbable)
                {
                    if (item2 == null)
                    {
                        item2 = other.gameObject;
                    }
                    //Debug.Log("Grabbed!");
                    Collider childCollider = item2.transform.GetComponentInChildren <Collider> ();
                    //item1.transform.GetChild(0).gameObject.GetComponent<Collider>().enabled = false;
                    Physics.IgnoreCollision(childCollider, parentCollider, true);
                    item2.transform.position      = leftHand.position;
                    item2.transform.parent        = leftHand;
                    item2.transform.localPosition = Vector3.zero;
                    Rigidbody rb = item2.GetComponentInChildren <Rigidbody>();
                    rb.freezeRotation = true;
                    pickedUpLeft      = false;
                    cooldownL         = PICKUP_DELAY;

                    if (overlay != null)
                    {
                        //For displaying icon over object
                        overlay.Disable();
                    }
                }
            }
        }
    }