Inheritance: BaseObject
Esempio n. 1
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
 public static void Push(PickObject obj)
 {
     obj.Reset();
     //int i=s_InstancePool.IndexOf(obj);
     //if(i==-1) {
     s_InstancePool.Add(obj);
     ++s_NumInstancePool;
     //}
 }
 public virtual void AddPickObject(Transform t)
 {
     if (t != null)
     {
         PickObject obj = PickObject.Pop(t);
         obj.SetParent(m_Container);
         m_PickObjects.Add(obj);
     }
 }
        public static PickObject Pop(Transform transform)
        {
            PickObject obj = null;

            if (s_NumInstancePool > 0)
            {
                obj = s_InstancePool[--s_NumInstancePool];
                s_InstancePool.RemoveAt(s_NumInstancePool);
            }
            else
            {
                obj = new PickObject();
            }
            obj.Set(transform);
            return(obj);
        }
 // Use this for initialization
 void Start()
 {
     mScript = MainCharacter.GetComponent<PickObject>();
 }
Esempio n. 6
0
    public static PickObject GetPickup(PickObject.pickupType Type)
    {
        if (instance)
        {
            PickObject e;
            if (instance.InActivePool.Any(i => i.type == BaseObject.objectType.Pickup && ((PickObject)i).TypePickup == Type))
            {
                e = (PickObject)instance.InActivePool.First(i => i.type == BaseObject.objectType.Pickup && ((PickObject)i).TypePickup == Type);
                instance.InActivePool.Remove(e);
                instance.ActivePool.Add(e);
                e.gameObject.SetActive(true);
            }
            else
            {
                GameObject g = Instantiate(Resources.Load("Object/Pickup/" + Type.ToString()), Vector3.zero, Quaternion.identity) as GameObject;
                g.name = Type.ToString() + " - " + (instance.ActivePool.Count + instance.InActivePool.Count);
                e = g.GetComponent<PickObject>();

                instance.ActivePool.Add(e);
                e.transform.SetParent(instance.transform, false);
            }

            e.gameObject.SendMessage("startBehaviours", SendMessageOptions.DontRequireReceiver);
            return e;
        }
        return null;
    }
Esempio n. 7
0
        /// <summary>
        ///     Allocates an order line.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AllocateButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (orderLineIdInput.Text.Equals(""))
                {
                    MessageBox.Show("Please input the text box.");
                    orderLineIdInput.Focus();
                    return;
                }
                else if (!Regex.IsMatch(orderLineIdInput.Text, "^[0-9]*$"))
                {
                    MessageBox.Show("Please input only numerical characters into the text box.");
                    orderLineIdInput.Focus();
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString());
            }

            OrderLineObject orderLine = businessLogicLayer.CheckOrderLinesByID(int.Parse(orderLineIdInput.Text));


            // Get Order Line Order ID
            OrderLineObject orderLine1       = businessLogicLayer.GetOrderLineOrderID(int.Parse(orderLineIdInput.Text));
            int             orderLineOrderID = orderLine1.order_id;


            // Get Order Line Product ID - Order Line Object
            OrderLineObject orderline2         = businessLogicLayer.GetOrderLineProductIDAndTitleOLObj(int.Parse(orderLineIdInput.Text));
            int             orderLineProductID = orderline2.product_id;

            // Get Order Line Product ID - Product Object
            ProductObject product1 = businessLogicLayer.GetOrderLineProductIDAndTitlePrObj(int.Parse(orderLineIdInput.Text));
            string        orderLineProductTitle = product1.title;


            // Get Product ID from Stock where Product ID = Order Line Product ID
            StockObject stockObject    = businessLogicLayer.GetStockProductID(orderLineProductID);
            int         stockProductID = stockObject.product_id;


            // Get Order Account ID
            OrderObject order1         = businessLogicLayer.GetOrderAccountID(orderLineOrderID);
            int         orderAccountID = order1.account_id;


            // Get Order Warehouse ID
            OrderObject order2           = businessLogicLayer.GetOrderWarehouseID(orderLineOrderID);
            int         orderWarehouseID = order2.warehouse_id;


            // Get Account, Product And Warehouse IDs from Stock By Order AID Order Line PID And Order WID
            StockObject stockObject987 = businessLogicLayer.GetStockAccountProductAndWarehouseID(orderAccountID, orderLineProductID,
                                                                                                 orderWarehouseID);
            int stockAccountID123   = stockObject987.account_id;
            int stockProductID123   = stockObject987.product_id;
            int stockWarehouseID123 = stockObject987.warehouse_id;


            // Get Nearest Available Stock - Stock Object
            StockObject stock1          = businessLogicLayer.GetAvailableStockStObj(orderLineProductID, orderAccountID, orderWarehouseID);
            int         stockID         = stock1.stock_id;
            int         stockLocationID = stock1.location_id;

            // Get Nearest Available Stock - Location Object
            LocationObject location1         = businessLogicLayer.GetAvailableStockLoObj(orderLineProductID, orderAccountID, orderWarehouseID);
            string         stockLocationCode = location1.location_code;


            // Get Order Line Quantity
            OrderLineObject orderLine3        = businessLogicLayer.GetOrderLineQuantity(int.Parse(orderLineIdInput.Text));
            int             orderLineQuantity = orderLine3.quantity;


            // Get Stock Quantity by Stock ID
            StockObject stock4        = businessLogicLayer.GetStockQuantityByID(stockID);
            int         stockQuantity = stock4.quantity;


            // Get Stock Account ID, Product ID And Warehouse ID By Stock ID
            StockObject stockWhatever    = businessLogicLayer.GetStockAccountProductAndWarehouseIDByStockID(stockID);
            int         stockAccountID   = stockWhatever.account_id;
            int         stockProductID2  = stockWhatever.product_id;
            int         stockWarehouseID = stockWhatever.warehouse_id;


            // Get Stock Sum By Product ID
            int stockSum = 0;

            if (!(stockAccountID.Equals(0) && stockProductID2.Equals(0) && stockWarehouseID.Equals(0)))
            {
                StockObject stock5 = businessLogicLayer.GetStockSumByProductID(stockAccountID, stockProductID2, stockWarehouseID);
                stockSum = stock5.quantity;
            }

            try
            {
                // Order Line Does not Exist
                if (!int.Parse(orderLineIdInput.Text).Equals(orderLine.order_line_id))
                {
                    MessageBox.Show("The Order Line ID provided does not exist.");
                    orderLineIdInput.Focus();
                    return;
                }
                // Product Not in Stock
                else if (!orderLineProductID.Equals(stockProductID))
                {
                    MessageBox.Show("The Product pertaining to that Order Line ID is not in Stock.");
                    orderLineIdInput.Focus();
                    return;
                }
                // Account, Product and Warehouse do not match in Stock
                else if (!(orderAccountID.Equals(stockAccountID123) && orderLineProductID.Equals(stockProductID123) && orderWarehouseID.Equals(stockWarehouseID123)))
                {
                    MessageBox.Show("The Order Line Provided does not have a matching Account, Product and Warehouse in Stock.");
                    orderLineIdInput.Focus();
                    return;
                }
                // Not Enough Stock
                else if (stockSum < orderLineQuantity)
                {
                    MessageBox.Show("There is not enough Stock of the Product pertaining to that Order Line ID to fully allocate the Order Line.");
                    orderLineIdInput.Focus();
                    return;
                }
                else
                {
                    // Implement if time permits
                    // If stock matches exact then go to that one (i.e. 50 to 50 or 25 to 25) instead of just nearest - Change query used and more if statements
                    if (orderLineQuantity > stockQuantity)
                    {
                        int orderLineQuantityRemaining = 0;
                        while (orderLineQuantityRemaining < orderLineQuantity)
                        {
                            // Get Nearest Available Stock - Stock ID & Location ID
                            StockObject stock123           = businessLogicLayer.GetAvailableStockStObj(orderLineProductID, orderAccountID, orderWarehouseID);
                            int         stockID2           = stock123.stock_id;
                            int         stockLocationID123 = stock123.location_id;


                            // Get Nearest Available Stock - Location Code
                            LocationObject location123        = businessLogicLayer.GetAvailableStockLoObj(orderLineProductID, orderAccountID, orderWarehouseID);
                            string         stockLocationCode2 = location123.location_code;


                            // Get Stock Quantity by Stock ID
                            StockObject stock12345        = businessLogicLayer.GetStockQuantityByID(stockID2);
                            int         stockQuantityTest = stock12345.quantity;


                            // Nearest Available Stock - Set Availability Status to False - Locking it in for this order
                            StockObject stock1234 = businessLogicLayer.SetAvailabilityFalse(stockID2);


                            if (stockQuantityTest < orderLineQuantity - orderLineQuantityRemaining)
                            {
                                // Generate Pick
                                PickObject pickTest = businessLogicLayer.GeneratePick(orderLineOrderID, int.Parse(orderLineIdInput.Text), stockLocationID123, stockLocationCode2,
                                                                                      orderLineProductID, orderLineProductTitle, stockQuantityTest);


                                // Update Stock Quantity - stockQuantity
                                StockObject stockTest = businessLogicLayer.UpdateStockQuantity(stockQuantityTest, stockID2);
                            }
                            else
                            {
                                // Generate Pick
                                PickObject pickTest123 = businessLogicLayer.GeneratePick(orderLineOrderID, int.Parse(orderLineIdInput.Text), stockLocationID123, stockLocationCode2,
                                                                                         orderLineProductID, orderLineProductTitle, orderLineQuantity - orderLineQuantityRemaining);


                                // Update Stock Quantity - orderLineQuantity - orderLineQuantityRemaining
                                StockObject stockTest2 = businessLogicLayer.UpdateStockQuantity(orderLineQuantity - orderLineQuantityRemaining, stockID2);
                            }


                            // Nearest Available Stock - Set Availability Status to True - Opening it up for future orders
                            StockObject stock12345678      = businessLogicLayer.GetStockQuantityByID(stockID2);
                            int         stockQuantityTest2 = stock12345678.quantity;
                            if (stockQuantityTest2 > 0)
                            {
                                StockObject stock6 = businessLogicLayer.SetAvailabilityTrue(stockID2);
                            }


                            // Update Location 'allocated' if Stock Availability Status equals 0 (By Stock ID)
                            StockObject stockWhat = businessLogicLayer.GetStockAvailabilityStatus(stockID2);
                            bool        stockAvailabilityStatus = stockWhat.availability_status;
                            if (stockAvailabilityStatus.Equals(false))
                            {
                                LocationObject location2 = businessLogicLayer.SetLocationAllocatedFalse(stockLocationID123);
                                MessageBox.Show("All Stock from Location ID: " + stockLocationID123 + " has been taken and as such, it has been set to Available again.");
                            }


                            // Get Pick Quantity by Order Line ID + Set orderLineQuantityRemaining = pickQuantity
                            PickObject pickTest2    = businessLogicLayer.GetPickQuantityByOrderLineID(int.Parse(orderLineIdInput.Text));
                            int        pickQuantity = pickTest2.quantity;
                            orderLineQuantityRemaining = pickQuantity;
                        }

                        // Update Orders Status to Allocated (if Order Line Quantity matches that of Pick Quantity where Order Line Matches)
                        OrderLineObject orderLine123       = businessLogicLayer.GetOrderLineQuantityByOLIDAndOID(orderLineOrderID, orderLineOrderID);
                        int             orderLineQuantity2 = orderLine123.quantity;

                        PickObject pickTest3     = businessLogicLayer.GetPickQuantityByOrderID(orderLineOrderID);
                        int        pickQuantity2 = pickTest3.quantity;

                        if (pickQuantity2.Equals(orderLineQuantity2))
                        {
                            OrderObject order3 = businessLogicLayer.SetOrderStatusAllocated(orderLineOrderID);
                            MessageBox.Show("All Order Lines belonging to Order: " + orderLineOrderID + " have now been Allocated.");
                        }


                        // Message Box
                        MessageBox.Show("Order Line: " + orderLineIdInput.Text + " has been allocated. \n\nA pick has been created, please see the Picks table for more information.");
                        return;
                    }
                    else
                    {
                        // Set Nearest Available Stock - Availability Status to false - Locking it in for this order
                        StockObject stock2 = businessLogicLayer.SetAvailabilityFalse(stockID);


                        // Generate Pick
                        PickObject pick1 = businessLogicLayer.GeneratePick(orderLineOrderID, int.Parse(orderLineIdInput.Text), stockLocationID, stockLocationCode,
                                                                           orderLineProductID, orderLineProductTitle, orderLineQuantity);


                        // Update Stock Quantity - orderLineQuantity
                        StockObject stock3 = businessLogicLayer.UpdateStockQuantity(orderLineQuantity, stockID);


                        // Nearest Available Stock - Set Availability Status to True - Opening it up for future orders
                        StockObject stock12345     = businessLogicLayer.GetStockQuantityByID(stockID);
                        int         stockQuantity2 = stock12345.quantity;
                        if (stockQuantity2 != 0)
                        {
                            StockObject stock6 = businessLogicLayer.SetAvailabilityTrue(stockID);
                        }


                        // Update Location 'allocated' to false if Stock Availability Status equals 0 (empty)
                        StockObject stockWhat = businessLogicLayer.GetStockAvailabilityStatus(stockID);
                        bool        stockAvailabilityStatus = stockWhat.availability_status;
                        if (stockAvailabilityStatus.Equals(false))
                        {
                            LocationObject location2 = businessLogicLayer.SetLocationAllocatedFalse(stockLocationID);
                            MessageBox.Show("All Stock from Location ID: " + stockLocationID + " has been taken and as such, it has been set to Available again.");
                        }


                        // Update Orders Status to Allocated (if Order Line Quantity matches that of Pick Quantity where Order Line Matches)
                        OrderLineObject orderLine123       = businessLogicLayer.GetOrderLineQuantityByOLIDAndOID(orderLineOrderID, orderLineOrderID);
                        int             orderLineQuantity2 = orderLine123.quantity;

                        PickObject pickTest3     = businessLogicLayer.GetPickQuantityByOrderID(orderLineOrderID);
                        int        pickQuantity2 = pickTest3.quantity;

                        if (pickQuantity2.Equals(orderLineQuantity2))
                        {
                            OrderObject order3 = businessLogicLayer.SetOrderStatusAllocated(orderLineOrderID);
                            MessageBox.Show("All Order Lines belonging to Order: " + orderLineOrderID + " have now been Allocated.");
                        }


                        // Message Box
                        MessageBox.Show("Order Line: " + orderLineIdInput.Text + " has been allocated. \n\nA pick has been created, please see the Picks table for more information.");
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString());
            }
        }
        /// <summary>
        ///     Deletes a pick from the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (pickIdInput.Text.Equals(""))
                {
                    MessageBox.Show("Please input the text box.");
                    pickIdInput.Focus();
                    return;
                }
                else if (!Regex.IsMatch(pickIdInput.Text, "^[0-9]*$"))
                {
                    MessageBox.Show("Please input only numerical characters into the text box.");
                    pickIdInput.Focus();
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString());
            }

            // Check Picks by Pick ID
            PickObject pick1 = businessLogicLayer.CheckPicksByPickID(int.Parse(pickIdInput.Text));

            // Select Picks Order Line ID and Location ID And Quantity by Pick ID
            PickObject pick2           = businessLogicLayer.SelectPicksOrderLineLocationIDAndQuantityByPickID(int.Parse(pickIdInput.Text));
            int        pickOrderLineID = pick2.order_line_id;
            int        pickLocationID  = pick2.location_id;
            int        pickQuantity    = pick2.quantity;

            // Get Order Line Order ID
            OrderLineObject orderLine1       = businessLogicLayer.GetOrderLineOrderID(pickOrderLineID);
            int             orderLineOrderID = orderLine1.order_id;

            // Select Stock ID by Picks Location ID
            StockObject stock1  = businessLogicLayer.SelectStockIDByPicksLocationID(pickLocationID);
            int         stockID = stock1.stock_id;

            // Select Stock Location by Stock ID
            StockObject stock6        = businessLogicLayer.SelectStockLocationIDByID(stockID);
            int         stockLocation = stock6.location_id;

            try
            {
                if (!int.Parse(pickIdInput.Text).Equals(pick1.pick_id))
                {
                    MessageBox.Show("The Pick ID provided does not exist.");
                    pickIdInput.Focus();
                    return;
                }
                else
                {
                    // Undo Stock Quantity
                    StockObject stock2 = businessLogicLayer.UndoStockQuantity(pickQuantity, stockLocation);


                    // Undo Stock Availability Status
                    StockObject stock4        = businessLogicLayer.SelectStockQuantityByLocationID(stockLocation);
                    int         stockQuantity = stock4.quantity;

                    if (stockQuantity > 0)
                    {
                        StockObject stockObject3 = businessLogicLayer.UndoStockAvailabilityStatus(stockLocation);
                    }


                    // Undo Location Allocation
                    StockObject stock5 = businessLogicLayer.SelectStockAvailabilityStatusByStockLocation(stockLocation);
                    bool        stockAvailabilityStatus = stock5.availability_status;
                    if (stockAvailabilityStatus.Equals(true))
                    {
                        LocationObject location1 = businessLogicLayer.SetLocationAllocatedTrue(stockLocation);
                    }


                    // Undo Stock Allocated Quantity
                    StockObject stock3 = businessLogicLayer.UndoStockAllocatedQuantity(pickQuantity, stockLocation);


                    // Delete Current Pick
                    PickObject pick = businessLogicLayer.DeleteCurrentPick(int.Parse(pickIdInput.Text));


                    // Undo Order Status
                    OrderLineObject orderLine2        = businessLogicLayer.GetOrderLineQuantityByOLIDAndOID(orderLineOrderID, orderLineOrderID);
                    int             orderLineQuantity = orderLine2.quantity;

                    PickObject pick3         = businessLogicLayer.GetPickQuantityByOrderID(orderLineOrderID);
                    int        pickQuantity2 = pick3.quantity;

                    if (!pickQuantity2.Equals(orderLineQuantity))
                    {
                        OrderObject order = businessLogicLayer.SetOrderStatusCreated(orderLineOrderID);
                    }


                    // Message Box
                    MessageBox.Show("Pick: " + pickIdInput.Text + " has been deleted from the system. \n\nThe Pick Quantity has been unallocated in Stock. \n\nThe Stock Availability Status has been set back to True where relevant. \n\nThe Order Status has been set back to Created where relevant. \n\nThe Location Allocation has been set back to Allocated where relevant.");
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString());
            }
        }
 void Awake()
 {
     mainChar = GameObject.FindGameObjectWithTag("MainCharacter");
     mScript = PickObject.GetComponent<PickObject>();
 }
Esempio n. 10
0
    void Update()
    {
        if (GameController.mMainPlayer == null)
        {
            return;
        }
        Vector3 touchPos   = Input.mousePosition;
        bool    touchBegin = false;
        bool    touchEnd   = false;

        if (Input.touchCount > 0)
        {
            if (Input.touches[0].phase == TouchPhase.Began)
            {
                touchBegin = true;
            }
            if (Input.touches[0].phase == TouchPhase.Ended)
            {
                touchEnd = true;
            }
            touchPos = Input.touches[0].position;
        }
        if (Input.GetMouseButtonDown(0))
        {
            touchBegin = true;
        }
        if (Input.GetMouseButtonUp(0))
        {
            touchEnd = true;
        }

        if (touchBegin)
        {
            if (touchPos.y > (float)(Screen.height / 2) ||
                touchPos.x > (float)(Screen.width / 2))
            {
                return;
            }
            mStartPos = touchPos;

            joystick.gameObject.SetActive(true);
            Vector3 pos = joystick.position;
            pos.x             = mStartPos.x;
            pos.y             = mStartPos.y;
            joystick.position = pos;
            mDraging          = true;
        }

        if (touchEnd)
        {
            if (!mDraging)
            {
                PickObject.Pick(touchPos);
            }
            mStartPos = Vector2.zero;
            joystick.gameObject.SetActive(false);
            mDraging = false;

            if (GameController.mMainPlayer != null)
            {
                GameController.mMainPlayer.MoveSpeed = 0.0f;
            }
        }

        if (mDraging)
        {
            Vector2 delta = (Vector2)touchPos - mStartPos;

            float length = delta.magnitude;
            if (length > joystickRadius)
            {
                delta  = delta.normalized * joystickRadius;
                length = joystickRadius;
            }

            Vector3 pos = bar.localPosition;
            pos.x             = delta.x;
            pos.y             = delta.y;
            bar.localPosition = pos;

            if (GameController.mMainPlayer != null && MobaMainCamera.MainCamera != null &&
                !GameController.mMainPlayer.IsCannotFlag(CannotFlag.CannotControl))
            {
                float      strength    = 1.0f; //length / joystickRadius;
                Vector3    joystickDir = new Vector3(delta.x, 0.0f, delta.y);
                Quaternion rot         = MobaMainCamera.MainCamera.transform.rotation;
                Vector3    dir         = rot * joystickDir;

                GameController.mMainPlayer.Direction = dir;
                GameController.mMainPlayer.MoveSpeed = 3.0f * strength;
                GameController.mMainPlayer.IsControl = true;
            }
        }
        else
        {
            if (!GameController.mMainPlayer.IsCannotFlag(CannotFlag.CannotControl))
            {
                GameController.mMainPlayer.IsControl = false;
            }
        }
    }
Esempio n. 11
0
 private void Start()
 {
     pickBj = GetComponent <PickObject>();
     rb     = GetComponent <Rigidbody>();
 }