Esempio n. 1
0
    void PushItemtoNextNode()      // must run every like 0.5 sec or something anyway make a another parent function to call this on start
    //maybe check if item has been in list for (InserterSpeed) time and THEN move it to next node
    {
        BeltS         nextB = NextBeltScript;
        MachineScript nextM = NextMachineScript;

        NextNode = GetNextNode();                                                                                                                                   //get nextbelt before every pushitem call

        if (NextType == "Assembly")                                                                                                                                 //pushing from inserter to machine
        {
            if (nextM != null && this.CurrentItemsScript.CurrentItems.Count > 0 && nextM.CurrentItemsScript.CurrentItems.Count < nextM.CurrentItemsScript.Capacity) // && NextMachineScript.CurrentItemsScript.CurrentItems.Count < NextMachineScript.Recipe.NumofRequiremtns) {

            //if(CurrentItemsScript.CurrentItems[0].ID == nextM.Recipe.Requirements.ID){
            {
                if (nextM.Recipe.Requirements.Contains(CurrentItemsScript.CurrentItems[0])) //don't push if its not in requirements
                //push item
                {
                    nextM.InputItems.Add(this.CurrentItemsScript.CurrentItems[0]);
                    this.CurrentItemsScript.CurrentItems.Remove(this.CurrentItemsScript.CurrentItems[0]);
                }
            }
        }
        else if (NextType == "Belt")    //pushing from inserter to belt
        //check stuff before pushing
        {
            if (nextB != null && this.CurrentItemsScript.CurrentItems.Count > 0 && nextB.CurrentItemsScript.CurrentItems.Count < nextB.CurrentItemsScript.Capacity)
            {
                nextB.CurrentItemsScript.CurrentItems.Add(this.CurrentItemsScript.CurrentItems[0]);
                this.CurrentItemsScript.CurrentItems.Remove(this.CurrentItemsScript.CurrentItems[0]);
            }
        }
    }
Esempio n. 2
0
    public GameObject GetNextNode()
    {
        GameObject next;         // next belt

        Debug.DrawRay(Ob.transform.position, Ob.transform.forward, Color.blue, 0.1f);
        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 BELT
        if (Physics.Raycast(ray, out hit, 1f) && hit.collider.transform.tag == "Belt")  //change to include all objects or use layer //stop creating that way
        {
            next           = hit.collider.gameObject;
            NextBeltScript = next.GetComponent <BeltS>();
            NextType       = "Belt";
        }
        else if (Physics.Raycast(ray, out hit, 1f) && hit.collider.transform.tag == "Assembly")
        {
            //IF NEXT OBJECT IS MACHINE
            next = hit.collider.gameObject;
            NextMachineScript = next.GetComponent <MachineScript>();
            NextType          = "Assembly";
        }
        else
        {
            NextBeltScript = null;
            next           = null;
        }

        return(next);
    }
Esempio n. 3
0
 // Use this for initialization
 void Start()
 {
     animator = GetComponent <Animator>();
     machine  = GetComponentInParent <MachineScript>();
 }