コード例 #1
0
        private void SellPotion(object sender, IntEventArgs e)
        {
            if (World.Instance.Random.Next(0, 100) > 10)
            {
                return;
            }

            Potion potion = null;

            float value = -1;

            foreach (var shopPotion in World.Instance.Shop.PotionsForSale)
            {
                if (shopPotion.Value > value)
                {
                    potion = shopPotion;
                    value  = shopPotion.Value;
                }
            }

            if (potion != null)
            {
                this.potionsSold++;

                World.Instance.Shop.SellPotion(potion, this);
            }
        }
コード例 #2
0
        private void CreatePotion(object sender, IntEventArgs e)
        {
            if (World.Instance.Random.Next(0, 100) > 30)
            {
                return;
            }

            foreach (var potionPrototype in World.Instance.Shop.PotionPrototypes)
            {
                Flask flask = null;

                foreach (var shopFlask in World.Instance.Shop.Flasks)
                {
                    if (shopFlask.Name == potionPrototype.FlaskName)
                    {
                        flask = shopFlask;

                        break;
                    }
                }

                if (flask == null)
                {
                    continue;
                }

                Solvent solvent = null;

                var ingredients = new List <Ingredient>();

                foreach (var herbName in potionPrototype.HerbNames)
                {
                    foreach (var shopHerb in World.Instance.Shop.Herbs)
                    {
                        if (shopHerb.Name == herbName)
                        {
                            ingredients.Add(shopHerb);

                            break;
                        }
                    }
                }

                if (ingredients.Count != potionPrototype.IngredientCount)
                {
                    continue;
                }

                this.potionsCrafted++;

                World.Instance.Shop.CreatePotion(flask, solvent, ingredients.ToArray(), this);

                break;
            }
        }
コード例 #3
0
        private void FindHerb(object sender, IntEventArgs e)
        {
            if (World.Instance.Random.Next(0, 100) > 20)
            {
                return;
            }

            this.excursions++;

            var herbPrototypes = new List <Herb>();

            foreach (var herbPrototype in World.Instance.HerbDatabase)
            {
                // foreach (var region in herb.Regions) {
                //     if (region == regionToSearch) {
                herbPrototypes.Add(herbPrototype);
                //     }
                // }
            }

            if (herbPrototypes.Count > 0)
            {
                this.herbsFound++;

                var herbPrototype = herbPrototypes[World.Instance.Random.Next(herbPrototypes.Count)];
                var herb          = (Herb)herbPrototype.Clone();

                foreach (var effect in herb.Effects)
                {
                    var magnitude = effect.Magnitude * (World.Instance.Random.Next(50, 150) / 100.0f);
                    effect.Magnitude = Mathf.RoundToInt(magnitude);
                }

                World.Instance.Shop.DeliverIngredient(herb);
            }
        }
コード例 #4
0
 private void DayChanged(object sender, IntEventArgs e) => this.daysEmployed++;