private void NewCommodityInventoryDataObject(
     CommodityDataObject CommodityItem,
     int Quantity,
     int PricePaid
     )
 {
     this.CommodityItem = CommodityItem;
     this.Quantity      = Quantity;
     this.PricePaid     = PricePaid;
 }
 private void NewCommodityInventoryDataObject(
     CommodityDataObject CommodityItem,
     int Quantity,
     int PricePaid
     )
 {
     this.CommodityItem = CommodityItem;
     this.Quantity = Quantity;
     this.PricePaid = PricePaid;
 }
Exemplo n.º 3
0
    /***************************************************************************
     * w$ = (Base$ * (Base$ * (% Demand/100)))
     * $PI = ((w$ * (Qty - (Tx Qty/Qty))) + w$)
     **************************************************************************/

    public int CurrentPrice(int SectorID, int StationID, int CommodityID)
    {
        int ppi = 0;

        //Provides class modifiers
        SectorDataObject sdo = (from sl in DataController.DataAccess.SectorList where sl.sectorID.Equals(SectorID) select sl).FirstOrDefault();
        //Provides qty and price property
        CommodityShopInventoryDataObject csi = (from cs in DataController.DataAccess.CommodityShopInventoryList where cs.stationID.Equals(StationID) && cs.commodityID.Equals(CommodityID) select cs).FirstOrDefault();
        //Provides class of item
        CommodityDataObject cdo = (from c in DataController.DataAccess.commodityMasterList where c.commodityID.Equals(CommodityID) select c).FirstOrDefault();

        int demandPercent = 0;

        switch (cdo.commodityClass)
        {
        case CommodityDataObject.COMMODITYCLASS.Common:
            demandPercent = sdo.common;
            break;

        case CommodityDataObject.COMMODITYCLASS.Luxury:
            demandPercent = sdo.luxury;
            break;

        case CommodityDataObject.COMMODITYCLASS.Food:
            demandPercent = sdo.food;
            break;

        case CommodityDataObject.COMMODITYCLASS.Minerals:
            demandPercent = sdo.minerals;
            break;

        case CommodityDataObject.COMMODITYCLASS.Medical:
            demandPercent = sdo.medical;
            break;

        case CommodityDataObject.COMMODITYCLASS.Military:
            demandPercent = sdo.military;
            break;

        case CommodityDataObject.COMMODITYCLASS.Industrial:
            demandPercent = sdo.industrial;
            break;

        default:
            break;
        }

        int workingPrice = (cdo.commodityBasePrice * (cdo.commodityBasePrice * (demandPercent / 100)));

        ppi = ((workingPrice * (csi.commodityQuantity - (csi.commodityLastQuantity / csi.commodityQuantity))) + workingPrice);


        return(ppi);
    }
    private void DisplayEditArea()
    {
        EditorGUI.BeginDisabledGroup(enableEditArea == false);

        EditorGUILayout.BeginHorizontal(GUILayout.Width(Screen.width));

        editImage     = (Texture2D)EditorGUILayout.ObjectField(editImage, typeof(Texture2D), false, GUILayout.Height(64), GUILayout.Width(64));
        editID        = int.Parse(TextField("ID:", editID.ToString(), GUILayout.Width(75)));
        editName      = TextField("Name:", editName, GUILayout.Width(200)).ToString();
        editBasePrice = int.Parse(TextField("Base Price:", editBasePrice.ToString(), GUILayout.Width(125)));
        editClass     = CommodityClassPopup("Class:", editClass, GUILayout.Width(175));

        if (GUILayout.Button("Save", GUILayout.Width(100)))
        {
            //Save this, either as a new item, or an edit
            if (isEdit)
            {
                CommodityDataObject cib = db.GetCommodity(editID);
                cib.commodityImage     = editImage;
                cib.commodityName      = editName;
                cib.commodityBasePrice = int.Parse(editBasePrice.ToString());
                cib.commodityClass     = editClass;
                EditorUtility.SetDirty(db);
            }
            else
            {
                CommodityDataObject cib = new CommodityDataObject(editID, editName, editBasePrice, 0, 0, editImage, editClass);
                db.Add(cib);
                EditorUtility.SetDirty(db);
            }

            //Clear and disable the editor section
            ResetForm();
        }

        if (GUILayout.Button("Cancel", GUILayout.Width(100)))
        {
            ResetForm();
        }

        EditorGUILayout.EndHorizontal();

        EditorGUI.EndDisabledGroup();
    }
 public CommodityInventoryDataObject(CommodityDataObject CommodityItem, int Quantity, int PricePaid)
 {
     NewCommodityInventoryDataObject(CommodityItem, Quantity, PricePaid);
 }
 public CommodityInventoryDataObject(CommodityDataObject CommodityItem, int Quantity, int PricePaid)
 {
     NewCommodityInventoryDataObject(CommodityItem, Quantity, PricePaid);
 }
    private void DisplayEditArea()
    {
        EditorGUI.BeginDisabledGroup(enableEditArea == false);

        EditorGUILayout.BeginHorizontal(GUILayout.Width(Screen.width));

        editImage = (Texture2D)EditorGUILayout.ObjectField(editImage, typeof(Texture2D), false, GUILayout.Height(64), GUILayout.Width(64));
        editID = int.Parse(TextField("ID:", editID.ToString(), GUILayout.Width(75)));
        editName = TextField("Name:", editName, GUILayout.Width(200)).ToString();
        editBasePrice = int.Parse(TextField("Base Price:", editBasePrice.ToString(), GUILayout.Width(125)));
        editClass = CommodityClassPopup("Class:", editClass, GUILayout.Width(175));

        if (GUILayout.Button("Save", GUILayout.Width(100)))
        {
            //Save this, either as a new item, or an edit
            if (isEdit)
            {
                CommodityDataObject cib = db.GetCommodity(editID);
                cib.commodityImage = editImage;
                cib.commodityName = editName;
                cib.commodityBasePrice = int.Parse(editBasePrice.ToString());
                cib.commodityClass = editClass;
                EditorUtility.SetDirty(db);
            }
            else
            {
                CommodityDataObject cib = new CommodityDataObject(editID, editName, editBasePrice, 0, 0, editImage, editClass);
                db.Add(cib);
                EditorUtility.SetDirty(db);
            }

            //Clear and disable the editor section
            ResetForm();
        }

        if (GUILayout.Button("Cancel", GUILayout.Width(100)))
        {
            ResetForm();
        }

        EditorGUILayout.EndHorizontal();

        EditorGUI.EndDisabledGroup();
    }
 public static CommodityDataObject.COMMODITYCLASS CommodityClassPopup(string label, CommodityDataObject.COMMODITYCLASS commodityClass, params GUILayoutOption[] args)
 {
     Vector2 textDimensions = GUI.skin.label.CalcSize(new GUIContent(label));
     EditorGUIUtility.labelWidth = textDimensions.x;
     return (CommodityDataObject.COMMODITYCLASS)EditorGUILayout.EnumPopup(label, commodityClass, args);
 }
 public void Remove(CommodityDataObject dataObject)
 {
     database.Remove(dataObject);
 }
 public void Add(CommodityDataObject dataObject)
 {
     database.Add(dataObject);
 }
Exemplo n.º 11
0
    /// <summary>
    /// Adds an item or quantity to the cargo hold collection
    /// </summary>
    /// <param name="ItemID"></param>
    /// <param name="ItemClass"></param>
    /// <param name="ItemType"></param>
    /// <param name="Quantity"></param>
    public void AddItem(int ItemID, PlayerInventoryDataObject.INVENTORY_CLASS ItemClass, PlayerInventoryDataObject.INVENTORY_TYPE ItemType, int Quantity)
    {
        //Make sure we have room. Check the property plus the intended addition
        if (CurrentCargoLoad + Quantity < CargoCapacity)
        {
            //We have room
            PlayerInventoryDataObject pido = InventoryItemList
                                             .Where(i => i.inventoryObjectID.Equals(ItemID) && i.inventoryObjectClass.Equals(ItemClass) && i.inventoryObjectType.Equals(ItemType))
                                             .First();

            //Is this an existing item or a new item?
            if (pido != null)
            {
                //Existing. We have already made sure we can fit it, so increment current quantity
                pido.inventoryQuantity += Quantity;
            }
            else
            {
                //A new item! Need to determine if it's a commodity or equipment
                PlayerInventoryDataObject npido = new PlayerInventoryDataObject();

                switch (ItemClass)
                {
                case PlayerInventoryDataObject.INVENTORY_CLASS.Commodity:
                    //This is a commodity, so all we need is commodity info
                    CommodityDataObject cmdo = DataController.DataAccess.commodityMasterList.Where(c => c.commodityID.Equals(ItemID)).First();
                    npido.inventoryObjectID    = cmdo.commodityID;
                    npido.inventoryObjectClass = PlayerInventoryDataObject.INVENTORY_CLASS.Commodity;
                    npido.inventoryObjectType  = ItemType;
                    npido.inventoryQuantity    = Quantity;
                    break;

                case PlayerInventoryDataObject.INVENTORY_CLASS.ShipEquipment:
                    //This is ship equipment. We need to know which DB to query for the details.
                    //Some items are commented out because it doesn't make sense to be able to carry them around
                    //  Like a hull inside a cargo hold.
                    //Commented these because I might need to move them elsewhere, like for station storage
                    switch (ItemType)
                    {
                    //case PlayerInventoryDataObject.INVENTORY_TYPE.Hull:
                    //    HullDataObject hdo = DataController.dataController.hullMasterList.Where(h => h.iD.Equals(ItemID)).First();
                    //    npido.inventoryObjectID = hdo.iD;
                    //    npido.inventoryObjectClass = PlayerInventoryDataObject.INVENTORY_CLASS.ShipEquipment;
                    //    npido.inventoryObjectType = ItemType;
                    //    npido.inventoryQuantity = Quantity;
                    //    break;
                    case PlayerInventoryDataObject.INVENTORY_TYPE.Engine:
                        EngineDataObject edo = DataController.DataAccess.engineMasterList.Where(e => e.iD.Equals(ItemID)).First();
                        npido.inventoryObjectID    = edo.iD;
                        npido.inventoryObjectClass = PlayerInventoryDataObject.INVENTORY_CLASS.ShipEquipment;
                        npido.inventoryObjectType  = ItemType;
                        npido.inventoryQuantity    = Quantity;
                        break;

                    //case PlayerInventoryDataObject.INVENTORY_TYPE.Cargo:
                    //    CargoDataObject crdo = DataController.dataController.cargoHoldMasterList.Where(c => c.iD.Equals(ItemID)).First();
                    //    npido.inventoryObjectID = crdo.iD;
                    //    npido.inventoryObjectClass = PlayerInventoryDataObject.INVENTORY_CLASS.ShipEquipment;
                    //    npido.inventoryObjectType = ItemType;
                    //    npido.inventoryQuantity = Quantity;
                    //    break;
                    case PlayerInventoryDataObject.INVENTORY_TYPE.Shield:
                        ShieldDataObject shdo = DataController.DataAccess.shieldMasterList.Where(s => s.iD.Equals(ItemID)).First();
                        npido.inventoryObjectID    = shdo.iD;
                        npido.inventoryObjectClass = PlayerInventoryDataObject.INVENTORY_CLASS.ShipEquipment;
                        npido.inventoryObjectType  = ItemType;
                        npido.inventoryQuantity    = Quantity;
                        break;

                    case PlayerInventoryDataObject.INVENTORY_TYPE.Cannon:
                        CannonDataObject cndo = DataController.DataAccess.cannonMasterList.Where(c => c.iD.Equals(ItemID)).First();
                        npido.inventoryObjectID    = cndo.iD;
                        npido.inventoryObjectClass = PlayerInventoryDataObject.INVENTORY_CLASS.ShipEquipment;
                        npido.inventoryObjectType  = ItemType;
                        npido.inventoryQuantity    = Quantity;
                        break;

                    case PlayerInventoryDataObject.INVENTORY_TYPE.MissileLauncher:
                        MissileLauncherDataObject mldo = DataController.DataAccess.missileLauncherMasterList.Where(m => m.iD.Equals(ItemID)).First();
                        npido.inventoryObjectID    = mldo.iD;
                        npido.inventoryObjectClass = PlayerInventoryDataObject.INVENTORY_CLASS.ShipEquipment;
                        npido.inventoryObjectType  = ItemType;
                        npido.inventoryQuantity    = Quantity;
                        break;

                    case PlayerInventoryDataObject.INVENTORY_TYPE.Scanner:
                        ScannerDataObject scdo = DataController.DataAccess.scannerMasterList.Where(s => s.iD.Equals(ItemID)).First();
                        npido.inventoryObjectID    = scdo.iD;
                        npido.inventoryObjectClass = PlayerInventoryDataObject.INVENTORY_CLASS.ShipEquipment;
                        npido.inventoryObjectType  = ItemType;
                        npido.inventoryQuantity    = Quantity;
                        break;

                    case PlayerInventoryDataObject.INVENTORY_TYPE.FighterBay:
                        FighterBayDataObject fbdo = DataController.DataAccess.figherBayMasterList.Where(f => f.iD.Equals(ItemID)).First();
                        npido.inventoryObjectID    = fbdo.iD;
                        npido.inventoryObjectClass = PlayerInventoryDataObject.INVENTORY_CLASS.ShipEquipment;
                        npido.inventoryObjectType  = ItemType;
                        npido.inventoryQuantity    = Quantity;
                        break;

                    case PlayerInventoryDataObject.INVENTORY_TYPE.Plating:
                        PlatingDataObject pdo = DataController.DataAccess.platingMasterList.Where(p => p.iD.Equals(ItemID)).First();
                        npido.inventoryObjectID    = pdo.iD;
                        npido.inventoryObjectClass = PlayerInventoryDataObject.INVENTORY_CLASS.ShipEquipment;
                        npido.inventoryObjectType  = ItemType;
                        npido.inventoryQuantity    = Quantity;
                        break;

                    default:
                        break;
                    }
                    break;

                default:
                    break;
                }

                InventoryItemList.Add(npido);
            }
        }
        else
        {
            Debug.Log("Not enough room to add more items to cargo");
        }
    }
Exemplo n.º 12
0
 public void Remove(CommodityDataObject dataObject)
 {
     database.Remove(dataObject);
 }
Exemplo n.º 13
0
 public void Add(CommodityDataObject dataObject)
 {
     database.Add(dataObject);
 }