示例#1
0
    void OnTriggerEnter(Collider other)
    {
        if (other.GetComponent <TrashIdentity>().identityNum == GetComponent <TrashIdentity>().identityNum)
        {
            PickupableObject po = other.gameObject.GetComponent <PickupableObject> ();
            if (po.pickupObject != null)
            {
                PickupController pc = po.pickupObject.parent.parent.GetComponent <PickupController> ();
                if (pc != null)
                {
                    pc.CmdDrop(other.gameObject);
                }
            }

            if (TrashInBin != null)
            {
                TrashInBin.Play();
            }

            GameObject correctTrash = (Instantiate(trashPS, transform.position, Quaternion.identity) as GameObject);
            correctTrash.transform.eulerAngles = new Vector3(-90f, 0f, 0f);
            Destroy(correctTrash, 2f);

            Destroy(other.gameObject, 0.1f);
        }
        for (int i = 0; i < 4; i++)
        {
            transform.parent.GetChild(i).GetComponent <TrashRoomCTRL> ().trashList.Remove(other.gameObject);
        }
    }
示例#2
0
    void OnTriggerEnter(Collider other)
    {
        PickupableObject po = other.GetComponent <PickupableObject>();

        if (po.pickupObject != null)
        {
            PickupController pc = po.pickupObject.parent.parent.GetComponent <PickupController> ();
            if (pc != null)
            {
                pc.CmdDrop(other.gameObject);
            }
        }

        if (gameObject.tag == "Fish")
        {
            if (other.name == "Fox")
            {
                other.tag = "InterObj";
                //other.transform.parent = transform;
                other.transform.position      = foxTarPos.transform.position;
                other.transform.localRotation = Quaternion.identity;
                if (!inside.Contains(other.gameObject))
                {
                    inside.Add(other.gameObject);
                }
                //foxPlaced = true;
            }
            if (other.name == "Hen")
            {
                other.tag = "InterObj";
                //other.transform.parent = transform;
                other.transform.position      = henTarPos.transform.position;
                other.transform.localRotation = Quaternion.identity;
                if (!inside.Contains(other.gameObject))
                {
                    inside.Add(other.gameObject);
                }
            }
            if (other.name == "Grain")
            {
                other.tag = "InterObj";
                //other.transform.parent = transform;
                other.transform.position      = grainTarPos.transform.position;
                other.transform.localRotation = Quaternion.identity;
                if (!inside.Contains(other.gameObject))
                {
                    inside.Add(other.gameObject);
                }
            }

            if (transform.childCount == 3)
            {
                print("Door open");
                Destroy(checker);
                //winImage.SetActive(true);



                foxObj.GetComponent <SphereCollider> ().enabled   = false;
                henObj.GetComponent <SphereCollider> ().enabled   = false;
                grainObj.GetComponent <SphereCollider> ().enabled = false;
            }
        }
        else
        {
            if (other.name == "Fox")
            {
                other.tag = "InterObj";
                //other.transform.parent = transform;
                other.transform.position = foxStartPos.transform.position;
                other.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
                if (!inside.Contains(other.gameObject))
                {
                    inside.Add(other.gameObject);
                }
            }

            if (other.name == "Hen")
            {
                other.tag = "InterObj";
                //other.transform.parent = transform;
                other.transform.position = henStartPos.transform.position;
                other.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
                if (!inside.Contains(other.gameObject))
                {
                    inside.Add(other.gameObject);
                }
            }

            if (other.name == "Grain")
            {
                other.tag = "InterObj";
                //other.transform.parent = transform;
                other.transform.position = grainStartPos.transform.position;
                other.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
                if (!inside.Contains(other.gameObject))
                {
                    inside.Add(other.gameObject);
                }
            }
        }
    }
示例#3
0
    void placeThing(Transform thing, Transform start, Transform target)
    {
        if (thing.GetComponent <PickupableObject> ().pickupObject != null)
        {
            canPlace = thing.GetComponent <FoxPickUp> ().canPlace;
        }

        if (Vector3.Distance(thing.position, start.position) <= 2)
        {
            if (!canPlace)
            {
                return;
            }
            thing.transform.position = start.transform.position;
            PickupableObject po = thing.gameObject.GetComponent <PickupableObject> ();
            if (po.pickupObject != null)
            {
                PickupController pc = po.pickupObject.parent.parent.GetComponent <PickupController> ();
                if (pc != null)
                {
                    pc.CmdDrop(thing.gameObject);
                }
            }
            if (insideStart.Contains(thing.gameObject))
            {
                return;
            }
            insideStart.Add(thing.gameObject);
        }

        if (Vector3.Distance(thing.position, target.position) <= 2)
        {
            if (!canPlace)
            {
                return;
            }
            thing.transform.position = target.transform.position;
            PickupableObject po = thing.gameObject.GetComponent <PickupableObject> ();
            if (po.pickupObject != null)
            {
                PickupController pc = po.pickupObject.parent.parent.GetComponent <PickupController> ();
                if (pc != null)
                {
                    pc.CmdDrop(thing.gameObject);
                }
            }

            if (insideTarget.Contains(thing.gameObject))
            {
                return;
            }
            insideTarget.Add(thing.gameObject);
        }

        if (Vector3.Distance(thing.position, start.position) >= 2)
        {
            insideStart.Remove(thing.gameObject);
        }

        if (Vector3.Distance(thing.position, target.position) >= 2)
        {
            insideTarget.Remove(thing.gameObject);
        }

        /*if (thing.position != start.position && thing.position != target.position && GetComponent<PickupableObject>().pickupObject == null) {
         *
         *      thing.position = start.position;
         * }*/
    }
示例#4
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.layer == LayerMask.NameToLayer("Interactable"))
        {
            if (insideStart.Count == 3)
            {
                return;
            }

            if (insideStart.Contains(fox.gameObject) && insideStart.Contains(hen.gameObject))
            {
                //Hen Got eaten
                PickupableObject po = other.gameObject.GetComponent <PickupableObject> ();
                if (po.pickupObject != null)
                {
                    PickupController pc = po.pickupObject.parent.parent.GetComponent <PickupController> ();
                    if (pc != null)
                    {
                        pc.CmdDrop(other.gameObject);
                    }
                }
                hen.position   = henStart.transform.position;
                fox.position   = foxStart.transform.position;
                grain.position = grainStart.transform.position;
            }
            if (insideStart.Contains(grain.gameObject) && insideStart.Contains(hen.gameObject))
            {
                //Grain got eaten
                PickupableObject po = other.gameObject.GetComponent <PickupableObject> ();
                if (po.pickupObject != null)
                {
                    PickupController pc = po.pickupObject.parent.parent.GetComponent <PickupController> ();
                    if (pc != null)
                    {
                        pc.CmdDrop(other.gameObject);
                    }
                }
                hen.position   = henStart.transform.position;
                fox.position   = foxStart.transform.position;
                grain.position = grainStart.transform.position;
            }
            if (insideTarget.Contains(fox.gameObject) && insideTarget.Contains(hen.gameObject))
            {
                //Hen got eaten
                PickupableObject po = other.gameObject.GetComponent <PickupableObject> ();
                if (po.pickupObject != null)
                {
                    PickupController pc = po.pickupObject.parent.parent.GetComponent <PickupController> ();
                    if (pc != null)
                    {
                        pc.CmdDrop(other.gameObject);
                    }
                }
                hen.position   = henStart.transform.position;
                fox.position   = foxStart.transform.position;
                grain.position = grainStart.transform.position;
            }

            if (insideTarget.Contains(grain.gameObject) && insideTarget.Contains(hen.gameObject))
            {
                //Grain got eaten
                PickupableObject po = other.gameObject.GetComponent <PickupableObject> ();
                if (po.pickupObject != null)
                {
                    PickupController pc = po.pickupObject.parent.parent.GetComponent <PickupController> ();
                    if (pc != null)
                    {
                        pc.CmdDrop(other.gameObject);
                    }
                }
                hen.position   = henStart.transform.position;
                fox.position   = foxStart.transform.position;
                grain.position = grainStart.transform.position;
            }
        }
    }