Пример #1
0
    public void DisposeFellow()
    {
        FellowRobot.transform.parent        = FellowRobot.station.transform;
        FellowRobot.transform.localPosition = new Vector3(0, 1.25f, 0);
        FellowRobot.transform.localRotation = Quaternion.identity;

        // FellowRobot.PickedUp = false;
        FellowRobot.disposed = true;
        FellowRobot          = null;
        PickedUpObject       = null;
    }
Пример #2
0
    public void PickUpFellow()
    {
        FellowRobot.transform.parent        = transform;
        FellowRobot.transform.localPosition = new Vector3(0, 1.25f, 0);
        FellowRobot.transform.localRotation = Quaternion.identity;

        FellowRobot.PickedUp = true;
        PickedUpObject       = FellowRobot;

        ColliderList.Remove(FellowRobot.gameObject);
    }
Пример #3
0
    public void PickUpHeavyTrash()
    {
        Debug.Log(name + ": PickUpHeavyTrash");

        formation = new FormationBehaviour(CurrentTrash, this);

        CurrentTrash.PickedUp = true;
        PickedUpObject        = CurrentTrash;

        ColliderList.Remove(CurrentTrash.gameObject);
    }
Пример #4
0
    // pickable-up objects stuff

    public void PickUpLightTrash()
    {
        Debug.Log(name + ": PickUpLightTrash");

        CurrentTrash.transform.parent        = transform;
        CurrentTrash.transform.localPosition = new Vector3(0, 1.25f, 0);
        CurrentTrash.transform.localRotation = Quaternion.identity;

        CurrentTrash.PickedUp = true;
        PickedUpObject        = CurrentTrash;

        ColliderList.Remove(CurrentTrash.gameObject);
    }
Пример #5
0
    public void DisposeLightTrash()
    {
        CurrentTrash.transform.parent        = compactor.transform;
        CurrentTrash.transform.localPosition = new Vector3(0, 1.25f, 0);
        CurrentTrash.transform.localRotation = Quaternion.identity;

        compactor.AddTrash(CurrentTrash);

        CurrentTrash.disposed = true;
        CurrentTrash          = null;
        PickedUpObject        = null;

        DisposedTrash++;
    }
Пример #6
0
    public void DisposeHeavyTrash()
    {
        Debug.Log(name + ": DisposeHeavyTrash");

        CurrentTrash.transform.parent        = compactor.transform;
        CurrentTrash.transform.localPosition = new Vector3(0, 1.25f, 0);
        CurrentTrash.transform.localRotation = Quaternion.identity;

        compactor.AddTrash(CurrentTrash);

        CurrentTrash.disposed = true;
        CurrentTrash          = null;
        PickedUpObject        = null;

        DisposedTrash++;
        // increment score for fellows
    }
Пример #7
0
    void Start()
    {
        // PickableUpObject
        PickedUp = false;
        disposed = false;

        wander   = GetComponent <WanderBehaviour>();
        seek     = GetComponent <SeekBehaviour>();
        avoid    = GetComponent <AvoidBehaviour>();
        steering = GetComponent <DelegatedSteering>();

        behaviour = new RobotBehaviour(this);
        board     = UnityEngine.Object.FindObjectsOfType <BlackBoard>()[0];

        CurrentBattery = FullBattery;

        CurrentTrash   = null;
        PickedUpObject = null;

        behaviour.Start();
    }
Пример #8
0
    public void PutDownPickedUpObject()
    {
        if (PickedUpObject != null)
        {
            Debug.Log(name + ": PutDownPickedUpObject");

            StartCoroutine(PutDown(PickedUpObject));

            switch (PickedUpObject.tag)
            {
            case "Trash":
                CurrentTrash = null;
                break;

            case "Robot":
                FellowRobot = null;
                break;
            }

            PickedUpObject = null;
        }
    }
Пример #9
0
    IEnumerator PutDown(PickableUpObject PickedUpObject)
    {
        PickedUpObject.transform.parent = null;

        Vector3 corner = 0.5f * PickedUpObject.transform.localScale;
        float   offset = 1;
        float   radius = corner.magnitude + offset;

        int LayerMask = ~((1 << UnityEngine.LayerMask.NameToLayer("Room")) | (1 << PickedUpObject.gameObject.layer));

        while (true)
        {
            yield return(new WaitForSeconds(0.001f));

            // check if we hit something in this position
            Collider[] HitColliders = Physics.OverlapSphere(PickedUpObject.transform.position, radius, LayerMask);

            if (HitColliders.Length == 0)
            {
                break;
            }

            string[] tags = new string[] { "Trash", "TrashCompactor", "PowerStation" };

            // check if we hit a power station or the trash compactor or other trash
            if (Enumerable.Any(HitColliders, collider => tags.Contains(collider.gameObject.tag)))
            {
                // move ourselves slightly toward the origin, and check again
                Vector3 direction = new Vector3(0, PickedUpObject.transform.position.y, 0) - PickedUpObject.transform.position;
                PickedUpObject.transform.position += direction.normalized * Time.deltaTime;
            }
        }

        // put down the object
        PickedUpObject.transform.position = new Vector3(PickedUpObject.transform.position.x, 1, PickedUpObject.transform.position.z);
        PickedUpObject.PickedUp           = false;
    }