Ejemplo n.º 1
0
    private void AddOneStock(GoodType good)
    {
        GameObject       go    = ResourceManager.Singleton.LoadResource <GameObject>(elmPath);
        GameObject       elmGO = Instantiate(go, table.content.transform);
        InventoryElement ie    = elmGO.GetComponent <InventoryElement>();

        //if (ie != null)
        {
            elementGOs.Add(elmGO);
            ie.good           = good;
            ie.sold          += SoldByPlayer;
            ie.colorImg.color = InvestmentManager.Singleton.GetGoodColor(good);
        }

        switch (ie.good)
        {
        case GoodType.TOMATO:
            ie.label.text = "番茄";
            break;

        case GoodType.SILK:
            ie.label.text = "絲綢";
            break;

        case GoodType.PADDY:
            ie.label.text = "稻米";
            break;

        case GoodType.JADE:
            ie.label.text = "翠玉";
            break;
        }
    }
    public string GetGoodName(GoodType good)
    {
        string key = good.ToString();

        //return csvData[key][Language];
        return(csvData[key]["Chinese"]);
    }
Ejemplo n.º 3
0
 private void BuildPlayerInventoryView(GoodType good, int numOfGood)
 {
     for (int iGood = 0; iGood < numOfGood; ++iGood)
     {
         AddOneStock(good);
     }
 }
Ejemplo n.º 4
0
 public PresentationAction(GoodType myGoodie)
 {
     this.myGoodie = myGoodie;
     setGoodieDefaults();
     isMistake   = false;
     timeStarted = DateTime.Now.TimeOfDay.TotalMilliseconds;
 }
Ejemplo n.º 5
0
 public bool CanBeSoldBy(GoodType goodType, IPlayer player)
 {
     return(!IsFull &&
            player.Goods.Exists(g => g.Type == goodType) &&
            (!Goods.Exists(g => g.Type == goodType) ||
             player.Buildings.ContainsWorkingOfType <Office>()));
 }
Ejemplo n.º 6
0
 public Good(string type, float stock, float rateMod = 0, float rateMlt = 1)
 {
     this.type    = Types.goods[type];
     this.stock   = stock;
     this.rateMlt = rateMlt;
     this.rateMod = rateMod;
 }
Ejemplo n.º 7
0
        public static IEnumerable <PurchaseItem> GetItemsByTypeAtDateRange(GoodType type, DateTime initialDate, DateTime?finalDate)
        {
            using var db = new PurchaseDBContext();

            if (finalDate.HasValue)
            {
                ApproximateDateToLower(ref initialDate);
                ApproximateDateToUpper(ref finalDate);

                return(DistinctCollections(
                           db.Purchases.ToList().Where(x => x.Date >= initialDate && x.Date <= finalDate.Value)
                           .Select(x => new Purchase(x))
                           .Select(x => x.GetPurchaseItems().Where(x => x.Type.Equals(type))),
                           (item1, item2) => item1.Amount += item2.Amount                                                           //Sum amount of equal items
                           ));
            }
            else
            {
                return(DistinctCollections(
                           db.Purchases.ToList().Where(x => x.Date.Year == initialDate.Year &&
                                                       x.Date.Month == initialDate.Month &&
                                                       x.Date.Day == initialDate.Day)
                           .Select(x => new Purchase(x))
                           .Select(x => x.GetPurchaseItems().Where(x => x.Type.Equals(type))),
                           (item1, item2) => item1.Amount += item2.Amount                                                           //Sum amount of equal items
                           ));
            }
        }
Ejemplo n.º 8
0
 protected WorldCard(CardCategory category, int cost, int pointValue, bool isMilitary, bool isWindfall, GoodType goodType)
     : base(category, cost, pointValue)
 {
     IsMilitary = isMilitary;
     IsWindfall = isWindfall;
     GoodType = goodType;
 }
Ejemplo n.º 9
0
    public void BuyStock(GoodType type, NetworkInstanceId id, int inc)
    {
        for (int i = 0; i < goods.Count; i++)
        {
            var good = goods[i];
            if (good.type == type)
            {
                var positions = good.playerPositions;
                for (int j = 0; j < positions.Length; j++)
                {
                    var pos = positions[j];
                    if (pos.id == id)
                    {
                        // i have you now
                        pos.position   += inc;
                        positions[j]    = pos;
                        good.inventory -= inc;
                        goods[i]        = good;

                        return;
                    }
                }
            }
        }
    }
Ejemplo n.º 10
0
        public void StoreGoods(GoodType goodType, IPlayer player)
        {
            var goodsToStore = player.Goods.Where(g => g.Type == goodType).ToList();

            _storedGoods.AddRange(goodsToStore);
            player.Goods.RemoveAll(g => g.Type == goodType);
        }
Ejemplo n.º 11
0
        //Update user's list of goodTypes by adding new goodType
        public void UpdateUserGoodTypesByAddingType(int id, GoodType goodType)
        {
            var temp = GetById(id);

            //temp.GoodTypes.Add(goodType);
            goodsContext.Users.Update(temp);
            base.Update(id, temp);
        }
Ejemplo n.º 12
0
 public GoodTypeDTO MapGoodType(GoodType value)
 {
     return(new GoodTypeDTO
     {
         Id = value.Id,
         Name = value.Name
     });
 }
Ejemplo n.º 13
0
    private int CalculateGoodPoint(GoodType good)
    {
        int price = InvestmentManager.Singleton.GetSharePrice(good);
        int hNum  = stockDictionary[good][hold];
        int sNum  = stockDictionary[good][sold];

        return((price * hNum) - (15 * sNum));
    }
Ejemplo n.º 14
0
        //Update good's type
        public void UpdateGoodByChangingType(int id, GoodType goodType)
        {
            var temp = GetById(id);

            temp.GoodType = goodType;
            goodsContext.Goods.Update(temp);
            base.Update(id, temp);
        }
Ejemplo n.º 15
0
    private void CreateStockDictionary(GoodType good)
    {
        Dictionary <string, int> d = new Dictionary <string, int>();

        d.Add(hold, 0);
        d.Add(sold, 0);

        stockDictionary.Add(good, d);
    }
Ejemplo n.º 16
0
        public float getLastBuildingProduced(GoodType goodType)
        {
            if (buildingLastProduced.ContainsKey(goodType))
            {
                return(buildingLastProduced[goodType]);
            }

            return(0);
        }
Ejemplo n.º 17
0
        public float getLastConsumption(GoodType good)
        {
            if (lastTickTotConsumed.ContainsKey(good))
            {
                return(lastTickTotConsumed[good]);
            }

            return(0);
        }
Ejemplo n.º 18
0
    public int GetSharePrice(GoodType good)
    {
        if (goodRiseTimes[good] <= 1)
        {
            return(5);
        }

        return(goodsSharePriceTable[good]);
    }
Ejemplo n.º 19
0
        //methods



        public float getConsumed(GoodType good)
        {
            if (baseConsumption.ContainsKey(good))
            {
                return(baseConsumption[good]);
            }

            return(0);
        }
Ejemplo n.º 20
0
        public float getLastPeopleProduced(GoodType goodType)
        {
            if (peopleLastProduced.ContainsKey(goodType))
            {
                return(peopleLastProduced[goodType]);
            }

            return(0);
        }
Ejemplo n.º 21
0
        public float getProduced(GoodType good)
        {
            if (baseProduction.ContainsKey(good))
            {
                return(baseProduction[good]);
            }

            return(0);
        }
Ejemplo n.º 22
0
        public float getLastProduction(GoodType good)
        {
            if (lastTickTotProduced.ContainsKey(good))
            {
                return(lastTickTotProduced[good]);
            }

            return(0);
        }
Ejemplo n.º 23
0
    /// <summary>
    /// InvestmentManager sell a stock to the boss of round.
    /// </summary>
    /// <param name="good">Good.</param>
    public void SellStockToBoss(GoodType good)
    {
        int    price  = goodsSharePriceTable[good];
        Player player = GameManager.Singleton.CurrentPlayer;

        player.Pay(price);
        player.BuyStock(good);
        UIManager.Singleton.ChangePlayerInfo();
    }
		private int ComboBoxContains(GoodType obj)
		{
			for (int i = 0; i < TypeComboBox.Items.Count; i++)
			{
				if (TypeComboBox.Items[i].ToString() == obj.ToString())
					return i;
			}

			return -1;
		}
Ejemplo n.º 25
0
    /// <summary>
    /// InvestmentManager buy a stock from current player in the round.
    /// </summary>
    /// <param name="good">Good.</param>
    public void BuyStockFromPlayer(GoodType good)
    {
        Player player = GameManager.Singleton.CurrentPlayer;
        int    num    = player.SellStock(good);

        if (num > 0)
        {
            player.Earn(12);
        }
    }
Ejemplo n.º 26
0
 public ZFGood(ZFGood goodInfo)
 {
     this.ID           = goodInfo.ID;
     this.name         = goodInfo.name;
     this.description  = goodInfo.description;
     this.typePurchase = goodInfo.typePurchase;
     this.marketInfo   = new MarketInfo(goodInfo.marketInfo);
     this.virtualInfo  = new VirtualInfo(goodInfo.virtualInfo);
     this.goodType     = goodInfo.goodType;
 }
Ejemplo n.º 27
0
        public float calcBuildingProduced(GoodType goodType)
        {
            float buildingProduced = 0;

            foreach (Building building in DistrictBuildings)
            {
                buildingProduced += building.getProduced(goodType) * BuildingProdMod; //To change to work with dictionary of modifiers
            }
            return(buildingProduced);
        }
Ejemplo n.º 28
0
        public float calcBuildingConsumption(GoodType goodType)
        {
            float buildingConsump = 0;

            foreach (Building building in DistrictBuildings)
            {
                buildingConsump += building.getConsumed(goodType) * BuildingConsumpMod; //To change to work with dictionary of modifiers
            }
            return(buildingConsump);
        }
Ejemplo n.º 29
0
    public int GetNumberOfHoldStock(GoodType good)
    {
        //return stockDictionary[good];
        if (!stockDictionary.ContainsKey(good))
        {
            return(-1);
        }

        return(stockDictionary[good][hold]);
    }
Ejemplo n.º 30
0
        static private string GetScriptFileName(GoodType type, int characterLevel)
        {
            var fileName = string.Empty;

            switch (type)
            {
            case GoodType.Weapon:
            case GoodType.Armor:
            case GoodType.Money:
            {
                var level = characterLevel / 12 + 1;
                if (level > 7)
                {
                    level = 7;
                }
                switch (type)
                {
                case GoodType.Weapon:
                    fileName = level + "级武器.txt";
                    break;

                case GoodType.Armor:
                    fileName = level + "级防具.txt";
                    break;

                case GoodType.Money:
                    fileName = level + "级钱.txt";
                    break;
                }
            }
            break;

            case GoodType.Drug:
                if (characterLevel <= 10)
                {
                    fileName = "低级药品.txt";
                }
                else if (characterLevel <= 30)
                {
                    fileName = "中级药品.txt";
                }
                else if (characterLevel <= 60)
                {
                    fileName = "高级药品.txt";
                }
                else
                {
                    fileName = "特级药品.txt";
                }
                break;
            }

            return(fileName);
        }
Ejemplo n.º 31
0
 public Good getGood(GoodType goodToGet)
 {
     if (goodTable.ContainsKey(goodToGet))
     {
         return(goodTable[goodToGet]);
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 32
0
        public byte CustomerBuy(GoodType c, int quantity)
        {
            Good good = _vmAssortment.Goods.FirstOrDefault(x => x.Type == c);
            var Sum = good.Price * quantity;
            if (Sum > _customerBalance) return 0;

            lock (_syncRoot)
            {
                _customerBalance = _customerBalance - Sum;
                _vmAssortment.Goods.FirstOrDefault(x => x.Type == c).Quantity -= quantity;
            }

            return 1;
        }
 public PresentationAction(GoodType myGoodie)
 {
     this.myGoodie = myGoodie;
     setGoodieDefaults();
     isMistake = false;
     timeStarted = DateTime.Now.TimeOfDay.TotalMilliseconds;
 }
Ejemplo n.º 34
0
 public Good(double price, GoodType goodType, bool isImported)
 {
     _price = price;
     _goodType = goodType;
     _isImported = isImported;
 }
Ejemplo n.º 35
0
	public ZFGood(ZFGood goodInfo)
	{
		this.ID = goodInfo.ID;
		this.name = goodInfo.name;
		this.description = goodInfo.description;
		this.typePurchase = goodInfo.typePurchase;
		this.marketInfo = new MarketInfo(goodInfo.marketInfo);
		this.virtualInfo = new VirtualInfo(goodInfo.virtualInfo);
		this.goodType = goodInfo.goodType;
	}
Ejemplo n.º 36
0
 public Good(double price, GoodType goodType)
 {
     _price = price;
     _goodType = goodType;
 }