Ejemplo n.º 1
0
    public CurrentItemsScript GetPrevNode()
    {
        GameObject prev;         // next belt

        Debug.DrawRay(Ob.transform.position, -Ob.transform.forward, Color.yellow, 0.5f);
        Debug.DrawRay(Ob.transform.position, Vector3.up, Color.red, 0.3f);

        RaycastHit hit;
        Ray        ray = new Ray(Ob.transform.position, -Ob.transform.forward);

        //IF NEXT OBJECT IS a MACHINE OF ANY TYPE
        if (Physics.Raycast(ray, out hit, 1f) && hit.collider.transform.gameObject.layer == 9)  //change to include all objects or use layer

        //stop creating that way
        {
            prev            = hit.collider.gameObject;
            PrevItemsScript = prev.GetComponent <CurrentItemsScript>();
        }
        else
        {
            PrevItemsScript = null;
            prev            = null;
        }

        return(PrevItemsScript);
    }
Ejemplo n.º 2
0
    void PullItemFromPrevNode()
    {
        //maybe check if item has been in list for (beltspeed) time and THEN move it to next node
        CurrentItemsScript prev = GetPrevNode();         //Get the CurrentItemsScript Attached to every PrevNode

        //check stuff before pushing
        if (prev != null && this.CurrentItemsScript.CurrentItems.Count < this.CurrentItemsScript.Capacity && prev.CurrentItems.Count > 0)
        {
            this.CurrentItemsScript.CurrentItems.Add(prev.CurrentItems[0]);
            prev.CurrentItems.Remove(prev.CurrentItems[0]);
        }
    }
Ejemplo n.º 3
0
    private List <int> ReqOut      = new List <int>(); //change layta

    void Start()
    {
        Ob = this.gameObject;
        CurrentItemsScript = Ob.GetComponent <CurrentItemsScript>();
    }
Ejemplo n.º 4
0
    /*
     *      ----------------------------------------------------
     *      this should be the universal move between objects script all other object should move between eachother (belt) or not move at all (machine)
     *      ----------------------------------------------------
     *
     */


    void Start()
    {
        Ob = this.gameObject;
        CurrentItemsScript = Ob.GetComponent <CurrentItemsScript>();
        StartCoroutine(MoveItems()); //running push item func every 2 sec using internal loop
    }