Esempio n. 1
0
 private void ComponentForm_VisibleChanged(object sender, EventArgs e)
 {
     if (Visible && componentID == -1)
     {
         ComponentGrid.ClearSelection();
     }
 }
 public void CreateRoof(Dictionary <int, int[, ]> roofIDs)
 {
     componentGrid = gameObject.GetComponent <ComponentGrid>();
     foreach (ComponentSubRoof roof in roofs)
     {
         Destroy(roof.gameObject);
     }
     roofs.Clear();
     foreach (ComponentSubGrid grid in componentGrid.grids)
     {
         GameObject newSubRoofGO = new GameObject(gameObject.name + "Roof" + grid.subGridIndex);
         newSubRoofGO.transform.parent   = transform;
         newSubRoofGO.transform.position = grid.transform.position;
         ComponentSubRoof newSubRoof = newSubRoofGO.AddComponent <ComponentSubRoof>();
         int[,] tileIDs = null;
         if (roofIDs.TryGetValue(grid.subGridIndex, out tileIDs))
         {
             newSubRoof.CreateRoof(grid, tileIDs);
         }
         else
         {
             newSubRoof.CreateRoof(grid, null);
         }
         roofs.Add(newSubRoof);
     }
 }
Esempio n. 3
0
        private void ViewProductDetailTab(int id)
        {
            if (id > 0)
            {
                IsWork     = false;
                RibbonMode = RibbonMode.Detail;

                ChangeControlsEnabled(DetailTab.Controls, false, false);

                var product = ProductRepository.GetProduct(id);

                IDTextBox.Text    = product.ID.ToString();
                NameTextBox.Text  = product.Name.ToString();
                ScaleTextBox.Text = product.Scale.ToString();

                ComponentGrid.DataSource = ProductRepository.GetComponents(id);

                ProductTabControl.SelectedTab = DetailTab;

                ComponentGrid.ClearSelection();
            }
            else
            {
                IsWork     = true;
                RibbonMode = RibbonMode.Edit;

                ChangeControlsEnabled(DetailTab.Controls, true, true);

                ProductTabControl.SelectedTab = DetailTab;
            }
        }
 IEnumerator CustomerStatusChecker()
 {
     while (true)
     {
         Debug.DrawRay(transform.position, transform.forward, Color.blue, 1f);
         if (currentGrid == null)
         {
             Ray        ray = new Ray(gameObject.transform.position + new Vector3(0, 5, 0), Vector3.down);
             RaycastHit hit;
             if (Physics.Raycast(ray.origin, ray.direction, out hit, 15))
             {
                 if (hit.transform.tag == "Floor")
                 {
                     currentGrid = hit.transform.parent.GetComponentInParent <ComponentGrid>();
                 }
             }
         }
         if (!outside)
         {
             timeInStore += .25f;
         }
         if (timeInStore >= maxTimeInStore && currentAction != CustomerAction.leavingStore && !leftStore)
         {
             LeaveStore();
             CancelFollowingPaths();
         }
         Vector3 currentPosition = gameObject.transform.position;
         if (currentPosition == lastCheckedPosition)
         {
             if (currentAction == CustomerAction.wandering)
             {
                 WanderClose();
             }
             else if (currentAction == CustomerAction.leavingStore)
             {
                 GeneratePathToExitDoorway();
             }
             else if (currentAction == CustomerAction.bypassingStore)
             {
                 DestroyCustomer();
             }
             if (timeMultiplier > 5)
             {
                 if (currentAction == CustomerAction.performingAction)
                 {
                     DoNext();
                 }
             }
         }
         timeMultiplier++;
         if (timeMultiplier >= 10)
         {
             timeMultiplier = 0;
         }
         lastCheckedPosition = currentPosition;
         yield return(new WaitForSeconds(.25f));
     }
 }
 public ComponentNode GetClosestEdgeNode(ComponentGrid grid, RaycastHit hit, bool outdoor)
 { // Finds an edge tile if hit a wall, or buildable zone, or road, or sidewalk
     if (outdoor)
     {
         return(grid.EdgeNodeFromOutdoorNode(hit.point));
     }
     else
     {
         return(grid.EdgeNodeFromWorldPoint(hit.point));
     }
 }
Esempio n. 6
0
        private void FilterButton_Click(object sender, EventArgs e)
        {
            var filter = new ComponentFilter
            {
                ComponentTypeID   = (FilterComponentTypeDropDown.SelectedValue.AsByte() == 0) ? null : FilterComponentTypeDropDown.SelectedValue.AsByte(),
                Name              = FilterNameTextBox.Text,
                ProductID         = (FilterProductDropDown.SelectedValue.AsInt() == 0) ? null : FilterProductDropDown.SelectedValue.AsInt(),
                IsNotAssignedOnly = FilterIsNotAssignedOnlyCheckBox.Checked
            };

            ComponentGrid.DataSource = ComponentRepository.GetComponents(filter);
            ComponentGrid.ClearSelection();
        }
Esempio n. 7
0
        private void CancelButton_Click(object sender, EventArgs e)
        {
            ComponentErrorProvider.Clear();

            if (componentID > 0)
            {
                ViewComponentDetailTab(componentID);
            }
            else
            {
                ViewComponentListingTab();

                componentID = -1;

                ComponentGrid.ClearSelection();
            }
        }
Esempio n. 8
0
    public int DetermineSubID(ComponentNode node, string side)
    {
        ComponentGrid    componentGrid = parentWalls.gameObject.GetComponent <ComponentGrid>();
        ComponentSubGrid grid          = componentGrid.GetSubGrid(subGridIndex);
        ComponentNode    neighbourNode = GetNeighbouringComponentNode(grid, componentGrid.gameObject.name, node);

        if (node != null)
        {
            if (node.doorway == ComponentNode.DoorwayValue.doorway)
            {
                return(1); // sub index for left side doorway walls
            }
            else if (node.window == ComponentNode.WindowValue.largewindow)
            {
                return(2);
            }
            else if (node.window == ComponentNode.WindowValue.mediumwindow)
            {
                return(3);
            }
            else if (node.window == ComponentNode.WindowValue.smallwindow)
            {
                return(4);
            }
        }
        if (neighbourNode != null)
        {
            if (neighbourNode.doorway == ComponentNode.DoorwayValue.doorway)
            {
                return(1); // sub index for left side doorway walls
            }
            else if (neighbourNode.window == ComponentNode.WindowValue.largewindow)
            {
                return(2);
            }
            else if (neighbourNode.window == ComponentNode.WindowValue.mediumwindow)
            {
                return(3);
            }
            else if (neighbourNode.window == ComponentNode.WindowValue.smallwindow)
            {
                return(4);
            }
        }
        return(0);
    }
Esempio n. 9
0
        private void InventoryItemPopup_Load(object sender, EventArgs e)
        {
            Left = MainForm.Location.X + (MainForm.Width / 2 - Width / 2);
            Top  = MainForm.Location.Y + (MainForm.Height / 2 - Height / 2);

            using (var repository = new ComponentTypeRepository())
            {
                var dropDown = repository.GetComponentTypeForDropDown();
                dropDown.Insert(0, new KeyValuePair <byte, string>());

                FilterComponentTypeDropDown.DataSource = dropDown;
            }
            using (var repository = new ProductRepository())
            {
                var dropDown = repository.GetProductsForDropDown(inventoryID);
                dropDown.Insert(0, new KeyValuePair <int, string>());

                FilterProductDropDown.DataSource = dropDown;
            }

            FilterButton_Click(sender, e);

            ComponentGrid.ClearSelection();
        }
 public void CreateWalls(Dictionary <int, int[, ]> intWallIDs, Dictionary <int, int[, ]> extWallIDs)
 {
     componentGrid = gameObject.GetComponent <ComponentGrid>();
     foreach (ComponentSubWalls subWalls_ in subWalls)
     {
         Destroy(subWalls_.gameObject);
     }
     subWalls.Clear();
     foreach (ComponentSubGrid grid in componentGrid.grids)
     {
         GameObject newWallsGO = new GameObject(gameObject.name + "Walls" + grid.subGridIndex);
         newWallsGO.transform.parent = transform;
         ComponentSubWalls newWalls = newWallsGO.AddComponent <ComponentSubWalls>();
         newWalls.parentWalls  = this;
         newWalls.subGridIndex = grid.subGridIndex;
         int[,] intWallTileIDs = null;
         int[,] extWallTileIDs = null;
         if (intWallIDs.TryGetValue(grid.subGridIndex, out intWallTileIDs))
         {
             // just get the out val
         }
         if (extWallIDs.TryGetValue(grid.subGridIndex, out extWallTileIDs))
         {
             // just get the out val
         }
         if (intWallIDs == null || extWallTileIDs == null)
         {
             newWalls.CreateWalls(grid.subGridIndex, null, null);
         }
         else
         {
             newWalls.CreateWalls(grid.subGridIndex, intWallTileIDs, extWallTileIDs);
         }
         subWalls.Add(newWalls);
     }
 }
Esempio n. 11
0
 private void SelectAllContextMenuItem_Click(object sender, EventArgs e)
 {
     ComponentGrid.SelectAll();
 }
    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);
        }
    }