示例#1
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            byte version = reader.ReadByte();

            switch (version)
            {
            case 0:
            {
                _interestingGoods = (TradeGoods)reader.ReadInt();

                if (reader.ReadBool())
                {
                    int capacity = reader.ReadInt();
                    _interestLevelTable = new Dictionary <TradeGoods, TradeGoodInterest>(capacity);

                    for (int i = 0; i < capacity; i++)
                    {
                        _interestLevelTable.Add((TradeGoods)reader.ReadInt(), (TradeGoodInterest)reader.ReadByte());
                    }
                }
                break;
            }
            }
        }
示例#2
0
        /// <summary>
        /// Determines if this vendor is interested in a good type
        /// </summary>
        /// <param name="goodType">TradeGoods type to check</param>
        public bool IsInterestedIn(TradeGoods goodType, out TradeGoodInterest currentInterest)
        {
            currentInterest = TradeGoodInterest.None;

            if ((interestingGoods & goodType) != 0)
            {
                currentInterest = interestLevelTable[goodType];
                return(true);
            }

            return(false);
        }
示例#3
0
        /// <summary>
        /// Sets the level of interest this vendor has for a given good type
        /// </summary>
        /// <param name="goodType">TradeGoods type to apply the interest level to</param>
        /// <param name="interestLevel">new interest level for the given good type</param>
        public void SetInterestLevel(TradeGoods goodType, TradeGoodInterest interestLevel)
        {
            if (interestLevel == TradeGoodInterest.None)
            {
                interestingGoods &= ~goodType;
            }
            else
            {
                interestingGoods |= goodType;
            }

            interestLevelTable[goodType] = interestLevel;
        }
示例#4
0
    // Good Scripts
    public Good AddGoodScript(TradeGoods good, GameObject parent)
    {
        switch (good)
        {
        case TradeGoods.GOOD_FOOD:
            return(parent.AddComponent <Food>());

        case TradeGoods.GOOD_MEDICINE:
            return(parent.AddComponent <Medicine>());

        default:
            return(parent.AddComponent <Good>());
        }
    }
        public override void Load()
        {
            TradeGoods?.Items.Reset(
                from good in mDataProvider?.GetAll <Good>() ?? new Good[0]
                orderby good.TradeValue - good.ProductionCost descending
                select new TradableGoodViewModel
            {
                Model     = good,
                Owner     = TradeGoods,
                IsVisible = true
            });

            TradeGoods?.UpdateValues();
        }
示例#6
0
        public List <ResourceAmount> GenerateTradeItems(WorldManager world)
        {
            var toReturn = new Dictionary <String, ResourceAmount>();

            Resource.ResourceTags[] blacklistTags = { Resource.ResourceTags.Money, Resource.ResourceTags.Corpse };

            foreach (var tags in TradeGoods)
            {
                int num = MathFunctions.RandInt(tags.Value - 5, tags.Value + 5);

                var resources = Library.EnumerateResourceTypesWithTag(tags.Key);

                if (resources.Count() <= 0)
                {
                    continue;
                }

                for (int i = 0; i < num; i++)
                {
                    var randResource = Datastructures.SelectRandom(resources);

                    if (randResource.Tags.Any(blacklistTags.Contains))
                    {
                        continue;
                    }

                    if (tags.Key == Resource.ResourceTags.Craft)
                    {
                        var craftTag        = Datastructures.SelectRandom(Crafts);
                        var availableCrafts = Library.EnumerateResourceTypesWithTag(craftTag);
                        var trinket         = Library.CreateTrinketResourceType(Datastructures.SelectRandom(availableCrafts).Name, MathFunctions.Rand(0.1f, 3.0f));

                        if (MathFunctions.RandEvent(0.3f) && Encrustings.Count > 0)
                        {
                            randResource = Library.CreateEncrustedTrinketResourceType(trinket.Name, Datastructures.SelectRandom(Library.EnumerateResourceTypesWithTag(Datastructures.SelectRandom(Encrustings))).Name);
                        }
                        else
                        {
                            randResource = trinket;
                        }
                    }

                    if (!toReturn.ContainsKey(randResource.Name))
                    {
                        toReturn[randResource.Name] = new ResourceAmount(randResource.Name, 1);
                    }
                    else
                    {
                        toReturn[randResource.Name].Count += 1;
                    }
                }
            }

            for (int i = 0; i < NumFurniture; i++)
            {
                var randomObject = Datastructures.SelectRandom(Library.EnumerateCraftables().Where(type => type.Type == CraftItem.CraftType.Object && type.RequiredResources.All((tags) =>
                                                                                                                                                                                 TradeGoods.Any(good => good.Key == tags.Type))));
                if (randomObject == null)
                {
                    continue;
                }

                var selectedResources = new List <ResourceAmount>();
                foreach (var requirement in randomObject.RequiredResources)
                {
                    selectedResources.Add(new ResourceAmount(Datastructures.SelectRandom(Library.EnumerateResourceTypesWithTag(requirement.Type)), requirement.Count));
                }

                var randResource = randomObject.ToResource(world, selectedResources, Posessive + " ");
                if (!toReturn.ContainsKey(randResource.Name))
                {
                    toReturn[randResource.Name] = new ResourceAmount(randResource.Name, 1);
                }
                else
                {
                    toReturn[randResource.Name].Count += 1;
                }
            }

            return(toReturn.Select(amount => amount.Value).ToList());
        }
示例#7
0
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			byte version = reader.ReadByte();

			switch( version )
			{
				case 0:
					{
						_interestingGoods = (TradeGoods)reader.ReadInt();

						if( reader.ReadBool() )
						{
							int capacity = reader.ReadInt();
							_interestLevelTable = new Dictionary<TradeGoods, TradeGoodInterest>( capacity );

							for( int i = 0; i < capacity; i++ )
							{
								_interestLevelTable.Add( (TradeGoods)reader.ReadInt(), (TradeGoodInterest)reader.ReadByte() );
							}
						}
						break;
					}
			}
		}
示例#8
0
		/// <summary>
		/// Sets the level of interest this vendor has for a given good type
		/// </summary>
		/// <param name="goodType">TradeGoods type to apply the interest level to</param>
		/// <param name="interestLevel">new interest level for the given good type</param>
		public void SetInterestLevel( TradeGoods goodType, TradeGoodInterest interestLevel )
		{
			if( interestLevel == TradeGoodInterest.None )
				interestingGoods &= ~goodType;
			else
				interestingGoods |= goodType;

			interestLevelTable[goodType] = interestLevel;
		}
示例#9
0
		/// <summary>
		/// Determines if this vendor is interested in a good type
		/// </summary>
		/// <param name="goodType">TradeGoods type to check</param>
		public bool IsInterestedIn( TradeGoods goodType, out TradeGoodInterest currentInterest )
		{
			currentInterest = TradeGoodInterest.None;

			if( (interestingGoods & goodType) != 0 )
			{
				currentInterest = interestLevelTable[goodType];
				return true;
			}

			return false;
		}
示例#10
0
 public ItemClass(TradeGoods type)
 {
     this.Type = 7;
     this.Id   = (int)type;
 }