示例#1
0
    //void OnTriggerEnter(Collider other)
    //{
    //    for (int i = 1; i <= 4; i++)
    //    {
    //        if (other.gameObject.tag == "Vacuum" + i.ToString() && other.gameObject.transform.parent.GetComponent<PlayerController>().PlayerVacuum)
    //        {
    //            other.gameObject.GetComponent<BoxCollider>().enabled = false;
    //            scoreOwner = i;
    //            targetLocation = other.gameObject.transform.parent.transform.position;
    //            this.transform.parent.parent.parent.GetComponent<BeltPlateController>().Restock(Random.Range(2f, 8f));
    //            Vector3 temp = transform.position; // world pos
    //            this.gameObject.transform.SetParent(null , true); // *should* not move, but you say...
    //          //  this.transform.position = temp; // restore world position
    //            sucked = true;
    //           // Debug.Log("sucked");
    //            //destroy
    //        }
    //    }

    //}
    void OnTriggerStay(Collider other)
    {
        for (int i = 1; i <= 4; i++)
        {
            if (other.gameObject.tag == "Vacuum" + i.ToString() && other.gameObject.transform.parent.GetComponent <PlayerController>().PlayerVacuum)
            {
                audioManager.playItemHitSound();
                other.gameObject.GetComponent <BoxCollider>().enabled = false;
                scoreOwner     = i;
                targetLocation = other.gameObject.transform.parent.transform.position;
                if (transform.root != this.transform)
                {
                    Transform par = this.transform.parent.parent.parent;
                    if (par)
                    {
                        BeltPlateController bpc = par.GetComponent <BeltPlateController>();
                        if (bpc)
                        {
                            bpc.Restock(Random.Range(respawnMin, respawnMax));
                        }
                    }
                    Vector3 temp = transform.position;               // world pos
                    this.gameObject.transform.SetParent(null, true); // *should* not move.
                                                                     //  this.transform.position = temp; // restore world position
                    sucked = true;
                    // Debug.Log("sucked");
                    //destroy
                }
            }
        }
    }
    public void RequestRestock(GameObject _plateChild, float _delay = 0.0f)
    {
        BeltPlateController bPlate = _plateChild.GetComponentInParent <BeltPlateController>();

        bPlate.Restock(_delay);
    }