コード例 #1
0
    public void AddLooseBoxStack(BoxStack looseBoxStack)
    {
        bool inList      = false;
        int  inListIndex = -1;

        for (int i = 0; i < looseBoxes.Count; i++)
        {
            BoxStack currentStack = looseBoxes[i];
            if (currentStack.uniqueID == looseBoxStack.uniqueID)
            {
                inList = true;
                int temp = i;
                inListIndex = temp;
            }
        }
        if (!inList)
        {
            looseBoxes.Add(looseBoxStack);
        }
        else
        {
            RemoveLooseBoxStack(looseBoxes[inListIndex]);
            AddLooseBoxStack(looseBoxStack);
        }
    }
コード例 #2
0
    public BoxStack CreateStackPlaceholder(int ignoreIndex)
    {
        GameObject newPlaceholderStack = new GameObject("Placeholder Stack");
        BoxStack   newStack            = newPlaceholderStack.AddComponent <BoxStack>();

        if (boxList.Count > 0)
        {
            newPlaceholderStack.transform.position = boxList[0].transform.position;
            for (int i = 0; i < boxList.Count; i++)
            {
                int        temp          = i;
                Box        currentBox    = boxList[temp];
                StorageBox parentProduct = (StorageBox)currentBox.product;
                boxList[i].product.PlayCloseAnimation();
                if (i != ignoreIndex)
                {
                    Box newBox = Instantiate(boxList[i]);
                    parentProduct.box = newBox.gameObject;
                    newBox.product    = parentProduct;
                    //newBoxObject.product.PlayCloseAnimation();
                    if (newBox.GetComponent <Placeholder>() == null)
                    {
                        newBox.gameObject.AddComponent <Placeholder>();
                    }
                    newStack.AddBox(newBox);
                }
            }
        }
        newStack.SortStack(newStack.transform.position, true, false);
        return(newStack);
    }
コード例 #3
0
ファイル: Box.cs プロジェクト: WesleyHendon/DispensaryTycoon
    public BoxStack CreateBoxStack()
    {
        GameObject newBoxStackGO = new GameObject("BoxStack");

        newBoxStackGO.transform.position = transform.position;
        BoxStack newBoxStack = newBoxStackGO.AddComponent <BoxStack>();

        newBoxStack.AddBox(this);
        return(newBoxStack);
    }
コード例 #4
0
 public MoveProduct(Inventory inventory_, Product toMove_, Vector3 toMoveTo, bool goBackToJobPos, Dispensary.JobType preferredJob) : base(preferredJob, StaffAIAction.ActionType.sequence)
 {
     inventory    = inventory_;
     toMove       = toMove_;
     newPosition  = toMoveTo;
     backToJobPos = goBackToJobPos;
     SetupDictionary();
     oldShelf = null;
     newShelf = null;
     oldStack = null;
     newStack = null;
 }
コード例 #5
0
    public void RemoveLooseBoxStack(BoxStack looseBoxStack)
    {
        List <BoxStack> newList = new List <BoxStack>();

        foreach (BoxStack box in looseBoxes)
        {
            if (box.uniqueID != looseBoxStack.uniqueID)
            {
                newList.Add(box);
            }
        }
        looseBoxes = newList;
    }
コード例 #6
0
    public void MoveProduct(Dispensary.JobType preferredJob, Vector3 newPos, BoxStack newStack)
    { // Not an override
        GameObject  dm        = GameObject.Find("DispensaryManager");
        Inventory   inventory = dm.GetComponent <DispensaryManager>().dispensary.inventory;
        MoveProduct newAction = new MoveProduct(inventory, this, newPos, true, Dispensary.JobType.StoreBudtender);
        Box         box_      = box.GetComponent <Box>();

        if (box_.parentBoxStack != null)
        {
            newAction.SetupBoxStackProduct(box_.parentBoxStack, newStack);
        }
        dm.GetComponent <StaffManager>().AddActionToQueue(newAction);
    }
コード例 #7
0
 public void StartAddingBox(Box newBoxIn)
 { // Displays a temp stack that includes the box that will be added to the stack
     if (tempIncreasedStack != null)
     {
         Destroy(tempIncreasedStack.gameObject);
     }
     newBox = newBoxIn;
     displayingTempIncreasedStack = true;
     originalList       = boxList;
     tempIncreasedStack = CreateStackPlaceholder_IncreasedSize(newBoxIn);
     newBoxIn.gameObject.SetActive(false);
     foreach (Box box in boxList)
     {
         box.gameObject.SetActive(false);
     }
 }
コード例 #8
0
ファイル: Box.cs プロジェクト: pmartin36/LD42
    private void CreateNewBoxStack()
    {
        var boxstacks = GameManager.Instance.BoxStacks;

        if (boxstacks.ContainsKey(StackIndex))
        {
            Debug.Log("Pushing to Stack Index " + this.StackIndex);
            boxstacks[StackIndex].Push(this);
        }
        else
        {
            Debug.Log("Creating new stack with Stack Index " + this.StackIndex);
            var boxStack = new BoxStack();
            boxStack.Push(this);
            GameManager.Instance.BoxStacks.Add(StackIndex, boxStack);
        }
    }
コード例 #9
0
    public void AddProduct(BoxStack boxStack)
    {
        bool inList = false;

        foreach (StoredProduct storedProduct in allProduct)
        {
            if (storedProduct.boxStack != null)
            {
                if (storedProduct.boxStack.uniqueID == boxStack.uniqueID)
                {
                    inList = true;
                }
            }
        }
        if (!inList)
        {
            StoredProduct newStoredProduct = new StoredProduct(boxStack);
            allProduct.Add(newStoredProduct);
        }
    }
コード例 #10
0
    public BoxStack GetStack()
    { // Called to create placeholder, fills the boxStack list
        GameObject newBoxStackGO = new GameObject("BoxStack");
        BoxStack   newBoxStack   = newBoxStackGO.AddComponent <BoxStack>();

        newBoxStack.stackIndex = boxStacks.Count;
        for (int i = 0; i < BOXSTACKSIZE; i++)
        {
            Box newBox = GetBox();
            if (newBox != null)
            {
                if (i == 0)
                {
                    newBoxStackGO.transform.position = newBox.transform.position;
                }
                newBoxStack.AddBox(newBox);
            }
        }
        boxStacks.Add(newBoxStack);
        return(newBoxStack);
    }
コード例 #11
0
    public bool PickupStack()
    {
        action = DriverAction.droppingOffStack;
        if (handTruck == null)
        {
            GameObject handTruckGO = Instantiate(db.GetStoreObject("Hand Truck").gameObject_);
            handTruck        = handTruckGO.GetComponent <Handtruck>();
            handTruck.driver = this;
            handTruckGO.transform.position = handTruckPosition.transform.position;
        }
        BoxStack newStack = truck.UnloadStack();

        currentStack       = newStack;
        newStack.handTruck = handTruck;
        newStack.SetParent(handTruck.gameObject.transform);
        handTruck.LoadBoxes(newStack);
        handTruck.transform.parent = transform;
        handTruck.Tip(true);
        NextAction();
        return(true);
    }
コード例 #12
0
    public static BoxStack CreatePlaceholderStack(BoxStack stack)
    {
        Database   database      = GameObject.Find("Database").GetComponent <Database>();
        GameObject newBoxStackGO = new GameObject("BoxStack_Placeholder");
        BoxStack   newBoxStack   = newBoxStackGO.AddComponent <BoxStack>();
        int        counter       = 0;

        foreach (Box box in stack.boxList)
        {
            GameObject placeholderBox = Instantiate(database.GetStoreObject(box.product.objectID, 1).gameObject_); // Placeholder box is same id but with subid 1
            if (counter == 0)
            {
                newBoxStack.transform.position         = placeholderBox.transform.position;
                placeholderBox.transform.localPosition = new Vector3(0, 0, 0);
                counter++;
            }
            newBoxStack.AddBox(placeholderBox.GetComponent <Box>());
        }
        //newBoxStack.SortStack(stack.transform.position, true);
        return(newBoxStack);
    }
コード例 #13
0
    public void Place(BoxStack newParentStack)
    {
        StorageBox thisStorageBox = (StorageBox)this;

        productGO.GetComponent <ProductGO>().enabled   = true;
        productGO.GetComponent <BoxCollider>().enabled = true;
        if (newParentStack != null)
        {
            newParentStack.FinishAddingBox(thisStorageBox.box.GetComponent <Box>());
        }
        else
        { // no stack
            try
            {
                BoxStack newStack = thisStorageBox.box.GetComponent <Box>().CreateBoxStack();
                thisStorageBox.GetDispensaryManager().dispensary.inventory.AddLooseBoxStack(newStack);
            }
            catch (System.NullReferenceException)
            {
                // Couldnt add to list
            }
        }
    }
コード例 #14
0
    public BoxStack UnloadStack()
    { // Takes a box stack from boxStack
        List <BoxStack> newStackList = new List <BoxStack>();
        int             counter      = 0;
        BoxStack        toReturn     = null;

        foreach (BoxStack stack in boxStacks)
        {
            if (counter == 0)
            {
                toReturn = stack;
                counter++;
            }
            else
            {
                newStackList.Add(stack);
            }
        }
        toReturn.boxStackPosition = UseDropLocation();
        boxStacks = newStackList;
        toReturn.ShowStack();
        return(toReturn);
    }
コード例 #15
0
    public BoxStack CreateStackPlaceholder_IncreasedSize(Box newBox)
    {
        List <Box> tempBoxList = new List <Box>();

        foreach (Box box in boxList)
        {
            tempBoxList.Add(box);
        }
        tempBoxList.Add(newBox);
        tempBoxList.Sort(SortBoxes);
        GameObject newPlaceholderStack = new GameObject("Placeholder Stack");
        BoxStack   newStack            = newPlaceholderStack.AddComponent <BoxStack>();

        if (tempBoxList.Count > 0)
        {
            newPlaceholderStack.transform.position = tempBoxList[0].transform.position;
            for (int i = 0; i < tempBoxList.Count; i++)
            {
                int        temp          = i;
                Box        currentBox    = tempBoxList[temp];
                StorageBox parentProduct = (StorageBox)currentBox.product;
                Box        newBoxObject  = Instantiate(tempBoxList[i]);
                parentProduct.box    = newBoxObject.gameObject;
                newBoxObject.product = parentProduct;
                newBoxObject.gameObject.SetActive(true);
                //newBoxObject.product.PlayCloseAnimation();
                if (newBox.GetComponent <Placeholder>() == null)
                {
                    newBox.gameObject.AddComponent <Placeholder>();
                }
                newStack.AddBox(newBoxObject);
            }
        }
        newStack.SortStack(newStack.transform.position, true, false);
        Destroy(newBox.gameObject); // destory box that was originally sent
        return(newStack);
    }
コード例 #16
0
    public Box StartRemovingBox(ProductManager.CurrentProduct currentProduct, int productID)
    { // Displays a temp stack that doesnt include the box getting removed
        // Returns the box that got removed
        currentProduct.originalStack = this;
        Box toReturn    = null;
        int ignoreIndex = -1;
        int counter     = 0;

        foreach (Box box in boxList)
        {
            if (box.product.uniqueID == productID)
            {
                StoreObjectReference reference = box.product.productReference;
                toReturn = Instantiate(box);
                StorageBox newStorageBox = new StorageBox(reference, toReturn.gameObject);
                newStorageBox.uniqueID = currentProduct.currentProduct.uniqueID;
                toReturn.product       = newStorageBox;
                ignoreIndex            = counter;
            }
            counter++;
        }
        if (toReturn != null)
        {
            BoxCollider collider = toReturn.GetComponent <BoxCollider>();
            collider.enabled = false;
            toReturn.gameObject.SetActive(true);
            toReturn.product.PlayCloseAnimation();
            displayingTempReducedStack = true;
            tempReducedStack           = CreateStackPlaceholder(ignoreIndex);
            foreach (Box box in boxList)
            {
                box.gameObject.SetActive(false);
            }
        }
        return(toReturn);
    }
コード例 #17
0
 public void SetupBoxStackProduct(BoxStack oldStack_, BoxStack newStack_)
 {
     oldStack = oldStack_;
     newStack = newStack_;
 }
コード例 #18
0
 public StoredProduct(BoxStack boxStack_)
 {
     product  = null;
     boxStack = boxStack_;
     quantity = boxStack.boxList.Count;
 }
コード例 #19
0
    IEnumerator MoveProduct()
    {
        while (true)
        {
            currentDisplayShelf = null;
            currentShelf        = null;
            bool movementConflict = false;
            if (currentProduct != null)
            {
                // Raise or lower shelf layer
                if (Input.GetKeyUp(dm.database.settings.GetRaiseShelfLayer()))
                {
                    SetCurrentShelfLayer(currentShelfLayer + 1);
                }
                if (Input.GetKeyUp(dm.database.settings.GetLowerShelfLayer()))
                {
                    SetCurrentShelfLayer(currentShelfLayer - 1);
                }

                // If moving a box
                bool productIsBox = currentProduct.currentProduct.IsBox();
                if (productIsBox)
                { // Moving box
                    print("Moving box");
                }
                if (currentProduct.newStack != null)
                {
                    currentProduct.newStack.CancelAddingBox();
                    currentProduct.newStack = null;
                    if (currentProduct.currentPlaceholder != null)
                    {
                        currentProduct.currentPlaceholder.gameObject.SetActive(true);
                    }
                }

                bool chooseContainerPanelOpen = uiM_v5.chooseContainerPanel.panelOpen;
                bool placingBudPanelOpen      = uiM_v5.packagedBudPlacementPanel.panelOpen;
                // Raycasting
                Ray          ray  = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit[] hits = Physics.RaycastAll(ray.origin, ray.direction);

                if (currentProduct.currentProduct.NeedsContainer())
                {
                    if (Input.GetKeyUp(dm.database.settings.GetOpenChooseContainerPanel().ToLower()))
                    {
                        if (chooseContainerPanelOpen)
                        {
                            uiM_v5.CloseChooseContainerPanel();
                        }
                        else
                        {
                            currentProduct.currentPlaceholder.indicator.OpenChooseContainerPanel(currentProduct);
                        }
                    }
                }
                if (chooseContainerPanelOpen || placingBudPanelOpen)
                {
                    // Dont carry on if either of these windows are open
                    yield return(null);
                }
                else if (currentProduct.currentPlaceholder != null)
                {
                    currentProduct.currentPlaceholder.GetComponent <BoxCollider>().enabled = false;
                    currentProduct.currentPlaceholder.HighlightOff();
                    bool hitShelf = false;
                    foreach (RaycastHit hit in hits)
                    {
                        if (hit.transform.tag == "DisplayShelf" || hit.transform.tag == "CheckoutCounter")
                        {
                            if (hit.transform.tag == "DisplayShelf")
                            {
                                SetCurrentDisplayShelf(hit.transform.gameObject.GetComponent <StoreObjectFunction_DisplayShelf>());
                            }
                            else if (hit.transform.tag == "CheckoutCounter")
                            {
                                StoreObjectFunction_DisplayShelf shelf = hit.transform.gameObject.GetComponent <StoreObjectFunction_DisplayShelf>();
                                if (shelf != null)
                                {
                                    SetCurrentDisplayShelf(shelf);
                                }
                                else
                                {
                                    hitShelf = false;
                                    break;
                                }
                            }
                        }
                        if (hit.transform.gameObject.layer == 21)
                        {
                            currentShelf = hit.transform.gameObject.GetComponent <Shelf>();
                            if (currentShelf.shelfLayer == GetCurrentShelfLayer())
                            {
                                hitShelf = true;
                                currentProduct.currentPlaceholder.transform.position = hit.point;
                            }
                            SetCurrentDisplayShelf(currentShelf.parentShelf);
                        }
                        if (hit.transform.gameObject.layer == 17)
                        {
                            //print("Hitting product");
                        }
                        if (hit.transform.tag == "StorageBox" && productIsBox)
                        {
                            Box        beingMoved           = currentProduct.currentPlaceholder.GetComponent <Box>();
                            StorageBox storageBoxBeingMoved = (StorageBox)beingMoved.product;
                            Box        hitBox = hit.transform.GetComponent <Box>();
                            if (hitBox != null)
                            {
                                BoxStack stack = hitBox.parentBoxStack;
                                if (stack != null)
                                {
                                    if (stack.boxList.Count <= 2)
                                    {
                                        currentProduct.newStack = stack;
                                        Box        toSend        = Instantiate(beingMoved);
                                        StorageBox newStorageBox = new StorageBox(storageBoxBeingMoved.productReference, toSend.gameObject);
                                        newStorageBox.uniqueID = storageBoxBeingMoved.uniqueID;
                                        toSend.product         = newStorageBox;
                                        currentProduct.newStack.StartAddingBox(toSend);
                                        beingMoved.gameObject.SetActive(false);
                                        // need to handle carrying across contents as well
                                    }
                                    else
                                    {
                                        // Stack is full
                                        stack.gameObject.GetComponent <Highlighter>().ConstantOnImmediate(Color.red);
                                    }
                                }
                                else
                                {
                                    print("Need to create a new stack");
                                }
                            }
                        }
                    }
                    if (!hitShelf && hits.Length > 0 && !productIsBox)
                    { // Find the nearest display shelf
                        try
                        {
                            currentDisplayShelf = GetClosestDisplayShelf(hits[0].point);
                            currentShelf        = currentDisplayShelf.GetShelf(GetCurrentShelfLayer(), hits[0].point);
                            Vector3 closestPoint = currentShelf.GetCollider().ClosestPoint(hits[0].point);
                            currentProduct.currentPlaceholder.transform.position = closestPoint;
                        }
                        catch (System.NullReferenceException)
                        {
                            // Failed to find a nearby shelf
                        }
                    }
                    else if (!hitShelf && hits.Length > 0 && productIsBox)
                    {
                        try
                        {
                            RaycastHit       toUse          = hits[0];
                            bool             outdoorHit     = false;
                            ComponentSubGrid closestSubGrid = dm.dispensary.GetClosestSubGrid(toUse.point);
                            ComponentGrid    grid           = closestSubGrid.parentGrid;
                            FloorTile        hitTile        = null;
                            foreach (RaycastHit hit in hits)
                            {
                                if (hit.transform.tag == "Floor")
                                {
                                    hitTile = hit.transform.GetComponent <FloorTile>();
                                }
                            }
                            if (hitTile != null)
                            {
                                outdoorHit = false;
                            }
                            else
                            {
                                outdoorHit = true;
                            }
                            ComponentNode nodeToSnapTo    = null;
                            GameObject    tempTileGO      = Instantiate(dm.database.GetFloorTile(10000).gameObject_);
                            BoxCollider   placeholderTile = tempTileGO.GetComponent <BoxCollider>();
                            if (hitTile != null)
                            {
                                outdoorHit   = false;
                                nodeToSnapTo = hitTile.node;
                            }
                            if (nodeToSnapTo == null)
                            {
                                nodeToSnapTo = GetClosestEdgeNode(grid, toUse, outdoorHit);
                            }
                            Vector3 snapPos = nodeToSnapTo.worldPosition;
                            Vector3 newPos  = new Vector3(snapPos.x, snapPos.y + placeholderTile.bounds.extents.y, snapPos.z);
                            if (!dm.actionManager.snapToGrid)
                            { // If not snapping to grid and didnt hit something outside
                                if (!outdoorHit)
                                {
                                    foreach (RaycastHit hit in hits)
                                    {
                                        if (hit.transform.tag == "Floor")
                                        {
                                            newPos = hit.point;
                                        }
                                    }
                                }
                            }
                            currentProduct.currentPlaceholder.transform.position = newPos;
                            Destroy(tempTileGO.gameObject);
                        }
                        catch (System.NullReferenceException)
                        {
                        }
                    }
                    if (currentDisplayShelf != null && currentShelf != null)
                    {
                        // Disable Colliders
                        currentDisplayShelf.GetComponent <BoxCollider>().enabled = false;
                        currentShelf.GetCollider().enabled = false;

                        // Perform collision check
                        BoxCollider productCollider = currentProduct.currentPlaceholder.GetComponent <BoxCollider>();
                        productCollider.enabled = true;
                        Vector3 size = productCollider.bounds.size; // /14
                        //Vector3 center = productCollider.bounds.center;
                        productCollider.enabled = false;
                        //size.x = Mathf.Abs(size.x);
                        //size.y = Mathf.Abs(size.y);
                        //size.z = Mathf.Abs(size.z);
                        //float oldY = size.y;
                        //size.y = size.z;
                        //size.z = oldY;
                        Vector3    center  = new Vector3(productCollider.transform.position.x, productCollider.transform.position.y + size.y / 2, productCollider.transform.position.z);
                        Collider[] results = Physics.OverlapBox(center, size / 2);

                        if (results.Length > 0)
                        {
                            //print(results.Length);
                            bool conflict = true;

                            /*foreach (Collider col in results)
                             * {
                             *  if (col.tag == "Shelf")
                             *  {
                             *      print("COnflict with shelf 1");
                             *      conflict = true;
                             *      break;
                             *  }
                             *  else if (col.gameObject.layer == 21)
                             *  { // Shelf layer
                             *      print("COnflict with shelf 2");
                             *      conflict = true;
                             *      break;
                             *  }
                             *  else if (col.gameObject.layer == 17)
                             *  { // Product layer
                             *      print("COnflict with product");
                             *      conflict = true;
                             *      break;
                             *  }
                             * }*/
                            if (conflict)
                            {
                                movementConflict = true;
                                currentProduct.currentPlaceholder.HighlightOn(Color.red);
                            }
                            results = null;
                        }

                        // Re-enable colliders
                        currentDisplayShelf.GetComponent <BoxCollider>().enabled = true;
                        currentShelf.GetCollider().enabled = true;
                    }
                    else
                    {
                        //print("Didnt check");
                    }
                    currentProduct.currentPlaceholder.GetComponent <BoxCollider>().enabled = true;
                }
                else
                {
                    print("Placeholder doesnt exist");
                }
                if (Input.GetMouseButtonUp(0) && !dm.PointerOverUI)
                { // Left Click
                    if (!movementConflict)
                    {
                        if (currentProduct.currentProduct.NeedsContainer())
                        {
                            if (currentProduct.currentContainer != null)
                            {
                                Box.PackagedBud packagedBud = currentProduct.GetPackagedBud();
                                if (packagedBud != null)
                                {
                                    currentProduct.currentPlaceholder.indicator.OpenPackagedBudPlacementPanel(currentProduct.currentContainer, packagedBud);
                                }
                            }
                            else
                            {
                                currentProduct.currentPlaceholder.indicator.OpenChooseContainerPanel(currentProduct);
                            }
                        }
                        else if (!productIsBox)
                        {
                            Box.PackagedProduct packagedProduct = null;
                            bool isPackagedProduct = false;
                            try
                            {
                                packagedProduct   = (Box.PackagedProduct)currentProduct.currentProduct;
                                isPackagedProduct = true;
                            }
                            catch (System.InvalidCastException)
                            { // Wasnt a packaged product
                                // Do nothing, allow to carry on
                                isPackagedProduct = false;
                            }
                            if (isPackagedProduct)
                            {
                                if (packagedProduct != null)
                                {
                                    packagedProduct.MoveProduct(Dispensary.JobType.StoreBudtender, currentProduct.currentPlaceholder.transform.position, currentDisplayShelf);
                                    currentProduct.FinishMovement();

                                    // Try moving next packaged product
                                    StartCoroutine(StartMovingNextPackagedProduct());
                                    yield return(new WaitForSeconds(.0125f)); // Needs to last longer than the waitforseconds(.01f)

                                    packagedProduct.parentBox.RemoveProduct(packagedProduct);
                                    uiM_v5.leftBarMainSelectionsPanel.UpdateBoxScrollable();
                                    yield break;

                                    /*Product newProduct = null;
                                     * CurrentProduct oldProduct = currentProduct;
                                     * try
                                     * { // Use packaged product reference
                                     *  newProduct = CreateProduct(packagedProduct.packagedProductReference, packagedProduct.parentBox.transform.position);
                                     * }
                                     * catch (System.NullReferenceException)
                                     * { // Use product reference
                                     *  newProduct = CreateProduct(packagedProduct.productReference, packagedProduct.parentBox.transform.position);
                                     * }
                                     * if (newProduct != null)
                                     * {
                                     *  newProduct.productGO.gameObject.SetActive(false);
                                     *  newProduct.MoveProduct(Dispensary.JobType.StoreBudtender, currentProduct.currentPlaceholder.transform.position, currentDisplayShelf);
                                     *  currentProduct.currentProduct.uniqueID = newProduct.uniqueID;
                                     *  currentProduct.FinishMovement();
                                     *
                                     *  // Try moving next packaged product
                                     *  StartCoroutine(StartMovingNextPackagedProduct());
                                     *  yield return new WaitForSeconds(.0125f); // Needs to last longer than the waitforseconds(.01f)
                                     *  packagedProduct.parentBox.RemoveProduct(packagedProduct);
                                     *  uiM_v5.leftBarMainSelectionsPanel.UpdateBoxScrollable();
                                     *  yield break;
                                     * }*/
                                }
                            }
                            else
                            { // Is not a packaged product0
                                currentProduct.currentProduct.MoveProduct(Dispensary.JobType.StoreBudtender, currentProduct.currentPlaceholder.transform.position, currentDisplayShelf);

                                uiM_v5.leftBarMainSelectionsPanel.RemoveProduct(currentProduct.currentProduct, false);
                                if (moveMode == MoveMode.single)
                                {
                                    FinishedMovingSingleProduct();
                                }
                                else if (moveMode == MoveMode.multiple)
                                {
                                    FinishedMovingMultipleProducts();
                                }
                                yield break;
                            }
                        }
                        else if (productIsBox)
                        {
                            bool       newStackExists = false;
                            StorageBox beingMoved     = (StorageBox)currentProduct.currentProduct;
                            if (currentProduct.newStack != null)
                            {
                                newStackExists = true;
                            }
                            if (newStackExists)
                            {
                                beingMoved.MoveProduct(Dispensary.JobType.StoreBudtender, currentProduct.currentPlaceholder.transform.position, currentProduct.newStack);
                            }
                            else if (currentDisplayShelf != null)
                            {
                                beingMoved.MoveProduct(Dispensary.JobType.StoreBudtender, currentProduct.currentPlaceholder.transform.position, currentDisplayShelf);
                            }
                        }
                    }
                    else
                    {
                        print("Cant move here: wont fit");
                    }
                }
            }
            yield return(null);
        }
    }
コード例 #20
0
 public void LoadBoxes(BoxStack newStack)
 {
     boxStack = newStack;
     boxStack.SortStack(boxSnapPos.transform.position, true, false);
 }
コード例 #21
0
    IEnumerator FollowPath()
    {
        Vector3 currentWaypoint = Vector3.zero;

        try
        {
            currentWaypoint = path[0];
            targetIndex     = 0;
            followingPath   = true;
        }
        catch (IndexOutOfRangeException)
        {
            yield break; // Ends the coroutine;
        }
        while (true)
        {
            if (driver.action == DeliveryDriver.DriverAction.droppingOffStack)
            {
                BoxStack stack = driver.currentStack;
                Vector3  vect1 = stack.boxList[0].transform.position;
                Vector3  vect2 = stack.boxStackPosition;
                if (Vector3.Distance(vect1, vect2) < .35f)
                {
                    followingPath = false;
                    path          = null;
                    if (OnArrival != null)
                    {
                        OnArrival();
                    }
                    else
                    {
                        print("OnArrival is null");
                    }
                    yield break;
                }
            }
            if (path != null)
            {
                if (path.Length > 0 && followingPath)
                {
                    if (transform.position == currentWaypoint)
                    {
                        targetIndex++;
                        if (targetIndex >= path.Length)
                        {
                            followingPath = false;
                            path          = null;
                            if (OnArrival != null)
                            {
                                OnArrival();
                            }
                            else
                            {
                                print("OnArrival is null");
                            }
                            yield break; // Ends the coroutine
                        }
                        currentWaypoint = path[targetIndex];
                    }
                    currentWaypoint    = new Vector3(currentWaypoint.x, .5f, currentWaypoint.z);
                    transform.position = Vector3.MoveTowards(transform.position, currentWaypoint, (driver.handTruck != null) ? pushingSpeed * Time.deltaTime : walkingSpeed * Time.deltaTime);
                    transform.LookAt(currentWaypoint);
                    yield return(null);
                }
                else
                {
                    print("Path was 0");
                    yield break;
                }
            }
        }
    }