示例#1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public Drug(DrugType type, TimeSpan prepTime)
 {
     Injected = false;
     DrugType = type;
     PrepTime = prepTime;
     Doses    = new List <DrugShot>();
 }
示例#2
0
    public void Init(FactoryRoomInfo factoryRoomInfo)
    {
        productionRate = factoryRoomInfo.consumptionRate;
        drugType       = factoryRoomInfo.drugType;
        switch (drugType)
        {
        case DrugType.Weed:
            storagableDrugType = StoragableType.Weed;
            break;

        case DrugType.Opiate:
            storagableDrugType = StoragableType.Opiate;
            break;

        case DrugType.Psychodelic:
            storagableDrugType = StoragableType.Psychodelic;
            break;

        case DrugType.Stimulator:
            storagableDrugType = StoragableType.Stimulator;
            break;

        default:
            throw new System.ArgumentOutOfRangeException();
        }
        consumptionRate           = factoryRoomInfo.consumptionRate;
        currentProductionProgress = 0f;
    }
示例#3
0
        private async void btnCreateType_Click(object sender, EventArgs e)
        {
            string name = txtCreateTypeName.Text.Trim();

            if (name == "")
            {
                MessageBox.Show("Fill all input", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (_db.DrugTypes.Any(t => t.Name.ToLower() == name.ToLower()))
            {
                MessageBox.Show($"{name} already exist", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            DrugType type = new DrugType()
            {
                Name = name
            };

            _db.DrugTypes.Add(type);
            await _db.SaveChangesAsync();

            MessageBox.Show($"Succussfully added", "Success",
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
            txtCreateTypeName.Text = "";

            _cmb.Items.Clear();
            _cmb.Items.AddRange(_db.DrugTypes.Select(t => new CB_DrugType
            {
                Id   = t.Id,
                Name = t.Name
            }).ToArray());
        }
    private void OpenPlayerInventory()
    {
        Inventory       inventory      = CreateInventory("Inventory");
        List <DrugType> drugTypes      = new List <DrugType>();
        List <int>      drugTypeCounts = new List <int>();

        foreach (Drug drug in drugs)
        {
            if (drugTypes.Contains(drug.Type))
            {
                drugTypeCounts[drugTypes.IndexOf(drug.Type)]++;
            }
            else
            {
                drugTypes.Add(drug.Type);
                drugTypeCounts.Add(1);
            }
        }

        for (int i = 0; i < drugTypes.Count; i++)
        {
            DrugType type  = drugTypes[i];
            int      count = drugTypeCounts[i];

            GameObject inventoryItem = Instantiate(inventoryItemPrefab, inventory.GetContent(), false);
            inventoryItem.transform.name = type.Name;
            inventoryItem.transform.Find("Drug Type").GetComponent <Text>().text = type.Name;
            inventoryItem.transform.Find("Count").GetComponent <Text>().text     = count.ToString();
        }
    }
示例#5
0
        public static Tuple <DrugType, double> GetHighest(this Predictions predictions)
        {
            if (predictions.GetType() != typeof(Predictions))
            {
                throw new InvalidCastException("Pass a Predictions type!");
            }

            var type = predictions.GetType();



            //var list = type.GetProperties().Select(prop => (double)type.GetProperty(prop.Name).GetValue(predictions, null)).ToList();
            //list.Sort();
            //Debug.WriteLine(list);


            double highest = 0;
            string name    = null;

            //Use Reflection
            foreach (var prop in type.GetProperties())
            {
                double current = ((double)type.GetProperty(prop.Name).GetValue(predictions, null));
                if (current >= highest)
                {
                    highest = current;
                    name    = prop.Name;
                }
            }

            return(Tuple.Create(DrugType.FromString(name), highest));
        }
示例#6
0
 public Message(string senderName, DrugType drugType, int amount, int offeredPrice)
 {
     SenderName   = senderName;
     DrugType     = drugType;
     Amount       = amount;
     OfferedPrice = offeredPrice;
     Text         = GenerateText();
 }
示例#7
0
 public static DrugTypeDTO ToDTO(this DrugType drugType)
 {
     return(new DrugTypeDTO()
     {
         DrugTypeId = drugType.DrugTypeId,
         DrugTypeName = drugType.DrugTypeName,
         DrugTypeWeight = drugType.DrugTypeWeight
     });
 }
示例#8
0
        public static bool Delete(DrugType drugType)
        {
            using (_d = new DataRepository <DrugType>())
            {
                _d.Delete(drugType);
                _d.SaveChanges();
            }

            return(true);
        }
示例#9
0
 public Drug(string drugName, int expirationDays, int miligram, string manufacturer,
             DrugType drugType, string imgSrc, string active)
 {
     DrugName       = drugName;
     ExpirationDays = expirationDays;
     Miligram       = miligram;
     Manufacturer   = manufacturer;
     DrugType       = drugType;
     ImgSrc         = imgSrc;
     Active         = active;
 }
示例#10
0
 public ActionResult CreateCategory(DrugType category)
 {
     if (ModelState.IsValid)
     {
         category.IsActive = true;
         unitOfWork.DrugTypeRepository.Insert(category);
         unitOfWork.DrugTypeRepository.SaveChanges();
         return(RedirectToAction("ListCategory"));
     }
     return(View(category));
 }
示例#11
0
 public ActionResult EditCategory(DrugType drugType)
 {
     if (ModelState.IsValid)
     {
         drugType.IsActive = true;
         unitOfWork.DrugTypeRepository.Update(drugType);
         unitOfWork.DrugTypeRepository.SaveChanges();
         return(RedirectToAction("ListCategory"));
     }
     return(View(drugType));
 }
示例#12
0
        private async void btnDeleteType_Click(object sender, EventArgs e)
        {
            int      id   = ((CB_DrugType)cmbDeleteType.SelectedItem).Id;
            DrugType type = _db.DrugTypes.First(t => t.Id == id);

            type.Deleted = false;
            //_db.DrugTypes.Remove(type);
            await _db.SaveChangesAsync();

            MessageBox.Show("Successfully deleted");
            FillCmb(cmbDeleteType);
            FillCmb(_cmb);
        }
 public CornerPedEntity(string name, PedHash pedHash, FullPosition spawnPosition, IEnumerable <FullPosition> nextPositions,
                        DrugType drugType, decimal moneyCount, string greeting, string goodFarewell, string badFarewell, CharacterEntity seller, int botId)
     : base(name, pedHash, spawnPosition)
 {
     BotId         = botId;
     NextPositions = nextPositions.ToList();
     DrugType      = drugType;
     MoneyCount    = moneyCount;
     Greeting      = greeting;
     GoodFarewell  = goodFarewell;
     BadFarewell   = badFarewell;
     Seller        = seller;
 }
示例#14
0
        protected override void Seed(StoreEntities context)
        {
            base.Seed(context);

            GetCountries().ForEach(x => context.Countries.Add(x));
            GetDepots().ForEach(x => context.Depots.Add(x));
            GetDrugTypes().ForEach(x => context.DrugTypes.Add(x));
            GetDrugUnits().ForEach(x => context.DrugUnits.Add(x));
            context.Commit();

            Country country = context.Countries.First(x => x.CountryName.Equals("Romania"));
            Depot   dpt     = context.Depots.First(x => x.DepotName.Equals("Depot-0"));

            country.Depots = new List <Depot>();
            country.Depots.Add(dpt);
            if (dpt.DrugUnits == null)
            {
                dpt.DrugUnits = new List <DrugUnit>();
            }
            DrugUnit du  = context.DrugUnits.First(y => y.PickNumber == 1);
            DrugUnit du1 = context.DrugUnits.First(y => y.PickNumber == 2);
            DrugType dt  = context.DrugTypes.First(t => t.DrugTypeName == "Type-0");

            du.DrugType  = dt;
            du.Quantity  = 4;
            du1.DrugType = dt;
            if (dt.DrugUnits == null)
            {
                dt.DrugUnits = new List <DrugUnit>();
            }
            dt.DrugUnits.Add(du);
            dt.DrugUnits.Add(du1);
            dpt.DrugUnits.Add(du);
            dpt.DrugUnits.Add(du1);
            du          = context.DrugUnits.First(y => y.PickNumber == 8);
            du.Quantity = 3;
            du.DrugType = dt;
            if (dt.DrugUnits == null)
            {
                dt.DrugUnits = new List <DrugUnit>();
            }
            dt.DrugUnits.Add(du);
            dpt.DrugUnits.Add(du);

            context.Commit();
        }
示例#15
0
        private void SaveData()
        {
            try
            {
                DrugType unit = new DrugType();

                unit.Name       = txtName.Text.Trim();
                unit.Code       = txtCode.Text.Trim();
                unit.Decription = txtDescription.Text.Trim();
                unit.Enabled    = checkBox1.Checked;
                if (this.cbxCategory.DataSource != null)
                {
                    unit.DrugCategoryId = Guid.Parse(this.cbxCategory.SelectedValue.ToString());
                }


                string msg = string.Empty;
                if (string.IsNullOrEmpty(selectId))
                {
                    unit.Id = Guid.NewGuid();
                    PharmacyDatabaseService.AddDrugType(out msg, unit);
                }
                else
                {
                    unit.Id = Guid.Parse(selectId);
                    PharmacyDatabaseService.SaveDrugType(out msg, unit);
                }
                if (string.IsNullOrEmpty(msg))
                {
                    this.FormState = FormOperation.Empty;

                    RefreshDataView();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存数据失败!", "错误");
                Log.Error(ex);
            }
        }
    private void OpenMarketInventory()
    {
        Inventory       inventory       = CreateInventory("Buy Drugs");
        List <DrugType> drugTypesSorted = GetDrugTypesSortedByPurchasePrice();

        for (int i = 0; i < drugTypesSorted.Count; i++)
        {
            DrugType   type           = drugTypesSorted[i];
            GameObject drugMarketItem = Instantiate(drugMarketItemPrefab, inventory.GetContent(), false);

            drugMarketItem.transform.Find("Drug Type").GetComponent <Text>().text      = type.Name;
            drugMarketItem.transform.Find("Purchase Price").GetComponent <Text>().text = type.PurchasePrice + " € / gram";

            Button buy = drugMarketItem.transform.Find("Buy").GetComponent <Button>();
            buy.onClick.AddListener(() => {
                if (Money >= type.PurchasePrice)
                {
                    Money -= type.PurchasePrice;
                    drugs.Add(new Drug(type));
                }
            });
        }
    }
    private List <DrugType> GetDrugTypesSortedByPurchasePrice()
    {
        List <DrugType> drugTypes       = new List <DrugType>(DrugType.drugTypes);
        List <DrugType> drugTypesSorted = new List <DrugType>();

        while (drugTypes.Count > 0)
        {
            int lowestNumber = int.MaxValue;
            int lowestIndex  = 0;
            for (int i = 0; i < drugTypes.Count; i++)
            {
                DrugType type = drugTypes[i];
                if (type.PurchasePrice < lowestNumber)
                {
                    lowestNumber = type.PurchasePrice;
                    lowestIndex  = i;
                }
            }
            drugTypesSorted.Add(drugTypes[lowestIndex]);
            drugTypes.RemoveAt(lowestIndex);
        }

        return(drugTypesSorted);
    }
示例#18
0
        public static int Save(DrugType drugType)
        {
            var a = new DrugType
            {
                DrugTypeId   = drugType.DrugTypeId,
                DrugTypeName = drugType.DrugTypeName
            };

            using (_d = new DataRepository <DrugType>())
            {
                if (drugType.DrugTypeId > 0)
                {
                    _d.Update(a);
                }
                else
                {
                    _d.Add(a);
                }

                _d.SaveChanges();
            }

            return(a.DrugTypeId);
        }
示例#19
0
 public ActionResult Create(DrugType model)
 {
     _db.Drugtypes.Add(model);
     _db.SaveChanges();
     return(View());
 }
示例#20
0
 public ActionResult Delete(DrugType model)
 {
     _db.Drugtypes.Remove(_db.Drugtypes.Where(x => x.DrugTypeID == model.DrugTypeID).FirstOrDefault());
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
    public void SellDrugs()
    {
        if (buyer.Message == null)
        {
            Debug.LogError("The buyer's message is null!");
            return;
        }

        List <DrugType> drugTypes      = new List <DrugType>();
        List <int>      drugTypeCounts = new List <int>();

        foreach (Drug drug in drugs)
        {
            if (drugTypes.Contains(drug.Type))
            {
                drugTypeCounts[drugTypes.IndexOf(drug.Type)]++;
            }
            else
            {
                drugTypes.Add(drug.Type);
                drugTypeCounts.Add(1);
            }
        }

        DrugType requestedDrugType = buyer.Message.DrugType;

        if (!drugTypes.Contains(requestedDrugType))
        {
            ShowMessageDialog("Not Enough Stock", "You don't have the requested drug!");
            return;
        }
        int index = drugTypes.IndexOf(requestedDrugType);

        if (drugTypeCounts[index] < buyer.Message.Amount)
        {
            ShowMessageDialog("Not Enough Stock", "You don't have enough of the requested drug!");
            return;
        }

        int numDrugsToRemove = buyer.Message.Amount;

        Drug[] drugsToRemove = new Drug[numDrugsToRemove];
        for (int i = 0; i < drugs.Count; i++)
        {
            Drug drug = drugs[i];
            if (drug.Type == requestedDrugType)
            {
                drugsToRemove[drugsToRemove.Length - numDrugsToRemove] = drug;
                numDrugsToRemove--;
                if (numDrugsToRemove == 0)
                {
                    break;
                }
            }
        }

        foreach (Drug drug in drugsToRemove)
        {
            drugs.Remove(drug);
        }

        int earnedMoney = buyer.Message.OfferedPrice;

        GameController.totalEarnedMoney += earnedMoney;
        if (GameController.totalEarnedMoney >= GameController.MoneyNeededToWin)
        {
            SceneManager.LoadScene("GameOverScene");
            return;
        }
        Money += earnedMoney;
        buyer.DismissBuyer();
    }
示例#22
0
文件: Level.cs 项目: zril/SanityRush
 public void AddDrug(int x, int y, DrugType type)
 {
     TileMatrix[offset + x, offset + y].Drug = type;
     GameObject.Instantiate <GameObject>(Resources.Load <GameObject>("prefab/" + type.ToString()), new Vector3(x, y, -1), Quaternion.identity);
 }
 public DrugType AddDrugType(DrugType drugType)
 {
     _context.DrugTypes.Add(drugType);
     _context.SaveChanges();
     return(drugType);
 }
 public DrugType UpdateDrugType(DrugType drugType)
 {
     return(_drugTypeRepository.UpdateDrugType(drugType));
 }
 public DrugType AddDrugType(DrugType drugType)
 {
     return(_drugTypeRepository.AddDrugType(drugType));
 }
 public DrugType UpdateDrugType(DrugType drugType)
 {
     throw new NotImplementedException();
 }
示例#27
0
 public static int GetDrugMaxPrice(DrugType type)
 {
     return(DrugMaxPrice.ContainsKey(type) ? DrugMaxPrice[type] : 0);
 }
示例#28
0
 public Drug(DrugType type)
 {
     Type = type;
 }
 public static DrugTypeDTO DrugTypeTODrugTypeDTO(DrugType drugType)
 {
     return(new DrugTypeDTO(drugType.Id, drugType.Type, drugType.Purpose));
 }
    private void Update()
    {
        GameController.totalTimer += Time.deltaTime;
        fireTimer       -= Time.deltaTime;
        addMessageTimer -= Time.deltaTime;
        if (addMessageTimer <= 0)
        {
            addMessageTimer = 10f;
            string   name         = names[Random.Range(0, names.Length - 1)];
            DrugType type         = DrugType.drugTypes[Random.Range(0, DrugType.drugTypes.Count)];
            int      amount       = Random.Range(2, 10);
            int      offeredPrice = (int)(type.PurchasePrice * amount * Random.Range(1f, 2f));
            Message  message      = new Message(name, type, amount, offeredPrice);
            messages.Add(message);
            if (messagesInventory != null)
            {
                messagesInventory.Close();
                OpenMessages();
            }
        }
        if (fireTimer < 0)
        {
            fireTimer = 0;
        }
        if (Input.GetMouseButton(0) && weaponShopItem.PurchasedTier > 0)
        {
            if (fireTimer == 0 && !EventSystem.current.IsPointerOverGameObject())
            {
                Vector3 mousePosition         = Input.mousePosition;
                Vector3 centerScreen          = new Vector3(Screen.width / 2, Screen.height / 2);
                Vector3 relativeMousePosition = mousePosition - centerScreen;
                float   angle   = Mathf.Atan2(relativeMousePosition.x, relativeMousePosition.y);
                float   degrees = angle * Mathf.Rad2Deg;
                degrees *= -1;
                GameObject bullet = Instantiate(bulletPrefab, transform.parent, false);
                bullet.tag = "PlayerBullet";
                bullet.transform.Rotate(0, 0, degrees);
                bullet.transform.position = transform.position;
                fireTimer = 1 / FireRate;
            }
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            OpenPlayerInventory();
        }

        if (Input.GetKeyDown(KeyCode.B))
        {
            OpenBuyMenu();
        }

        if (Input.GetKeyDown(KeyCode.M))
        {
            OpenMessages();
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            if (insideGameObjects.Count == 0)
            {
                return;
            }

            GameObject insideGameObject = insideGameObjects[insideGameObjects.Count - 1];

            switch (insideGameObject.tag)
            {
            case "DrugMarket":
                OpenMarketInventory();
                break;

            case "Buyer":
                if (buyer.Message == null)
                {
                    break;
                }
                if (buyer.IsUndercoverPolice)
                {
                    break;
                }
                sellDrugsDialog.gameObject.SetActive(true);
                break;
            }
        }
    }