Example #1
0
    public bool AddToExpImpOrders(Order order)
    {
        if (ExpImpOrders.Count < maxAmtOfExpImpOrders)
        {
            if (order.DestinyBuild == "Ship")
            {
                if (ExportsOrders == null)
                {
                    ExportsOrders = new List <Order>();
                }

                ExportsOrders.Add(order);
            }

            ExpImpOrders.Add(order);
            _fresh.Add(order);
            return(true);
        }
        else
        {
            //todo notify
            Debug.Log("Will not handle over 10 Export Import orders at the same time . 10 is the max");
            Dialog.OKDialog(H.Info, Languages.ReturnString("Ten Orders Limit"));
            return(false);
        }
    }
Example #2
0
    /// <summary>
    /// The import handling. Modularity
    /// </summary>
    /// <param name="dock"></param>
    /// <param name="ord"></param>
    void HandleThatImport(Building dock, Order ord)
    {
        var maxAmtCanTake = dock.Inventory.MaxAmtOnKGCanTakeOfAProd(ord.Product);

        AddEvacuationOrderInDock(ord);

        //if can handle the import right away
        //will added to invent and will remove it from ExpImpOrders
        if (maxAmtCanTake > ord.Amount)
        {
            Debug.Log("Imported:" + ord.Product + " . " + ord.Amount + " Done");
            Program.gameScene.ExportImport1.Buy(ord.Product, ord.Amount, dock.Name);

            dock.Inventory.Add(ord.Product, ord.Amount);
            ExpImpOrders.Remove(ord);
        }
        //if cant handle right away will import as much it can and will keep the order there
        //so its handled later
        else
        {
            Debug.Log("Imported:" + ord.Product + " . " + maxAmtCanTake);
            Program.gameScene.ExportImport1.Buy(ord.Product, maxAmtCanTake, dock.Name);

            dock.Inventory.Add(ord.Product, maxAmtCanTake);
            ord.ChangeAmountBy(-maxAmtCanTake);
        }
    }
Example #3
0
    bool RemoveOrderFromAllListByID(string id)
    {
        var res = false;

        for (int i = 0; i < Orders.Count; i++)
        {
            if (Orders[i].ID == id)
            {
                Orders.RemoveAt(i);
                res = true;
            }
        }

        for (int i = 0; i < RecycledOrders.Count; i++)
        {
            if (RecycledOrders[i].ID == id)
            {
                RecycledOrders.RemoveAt(i);
                res = true;
            }
        }

        for (int i = 0; i < ExpImpOrders.Count; i++)
        {
            if (ExpImpOrders[i].ID == id)
            {
                ExpImpOrders.RemoveAt(i);
                res = true;
            }
        }

        if (ExportsOrders != null)
        {
            for (int i = 0; i < ExportsOrders.Count; i++)
            {
                if (ExportsOrders[i].ID == id)
                {
                    ExportsOrders.RemoveAt(i);
                    res = true;
                }
            }
        }

        for (int i = 0; i < _fresh.Count; i++)
        {
            if (_fresh[i].ID == id)
            {
                _fresh.RemoveAt(i);
                res = true;
            }
        }
        return(res);
    }
Example #4
0
    /// <summary>
    /// Will remove the Import order from Dispatch. Import orders are evacuation orders
    ///
    /// Export orders are removed at HandleThatExport()
    /// </summary>
    public void RemoveImportOrder(Building dock, Order ord)
    {
        if (ord.SourceBuild != "Ship")
        {
            return;
        }

        if (!dock.Inventory.IsItemOnInv(ord.Product) && !ExpImpOrders.Contains(ord))
        {
            Debug.Log("Docker removed the evac order:" + ord.Product);
            RemoveEvacuationOrder(ord.ID);
        }
    }
Example #5
0
    /// <summary>
    /// So if is a loaded game will show progress, bz orders are loaded and saved
    /// after loaded will get updated only if done mannually
    /// </summary>
    /// <param name="ord"></param>
    private void UpdateExportsAndImport(Order ord, float amt)
    {
        var f = _fresh.FindIndex(a => a.ID == ord.ID);

        if (f != -1)
        {
            //is a freesh order therefore is referenced and doesnt need to be updated
            return;
        }

        var indImpEx = ExpImpOrders.FindIndex(a => a.ID == ord.ID);

        if (indImpEx != -1)
        {
            ExpImpOrders[indImpEx].AddToFullFilled(amt);
        }

        var indEx = ExportsOrders.FindIndex(a => a.ID == ord.ID);

        if (indEx != -1)
        {
            ExportsOrders[indEx].AddToFullFilled(amt);
        }
    }