Exemplo n.º 1
0
        private ResourceDepositDataItem[] AddNewResourceIfNeed(ResourceDepositDataItem[] items)
        {
            var newRoll = _dice.RollD6();

            if (!items.Any() || newRoll > 3)
            {
                var itemsNew           = new List <ResourceDepositDataItem>(items);
                var availableResources = new List <SectorResourceType> {
                    SectorResourceType.CherryBrushes,
                    SectorResourceType.Iron,
                    SectorResourceType.Stones,
                    SectorResourceType.WaterPuddles
                };

                foreach (var res in availableResources)
                {
                    var roll = _dice.RollD6();
                    if (roll == 6)
                    {
                        itemsNew.Add(new ResourceDepositDataItem(res, START_RESOURCE_SHARE));
                    }
                }

                items = itemsNew.ToArray();
            }

            return(items);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Обновление состояния узлов провинции.
        /// </summary>
        /// <param name="region">Провинция, которая обновляется.</param>
        public void UpdateRegionNodes(GlobeRegion region)
        {
            // Подсчитываем узлы, занятые монстрами.
            // Это делаем для того, чтобы следить за плотностью моснтров в секторе.

            var nodeWithMonsters = region.RegionNodes.Where(x => x.MonsterState != null);

            var monsterLimitIsReached = nodeWithMonsters.Count() >= MONSTER_NODE_LIMIT;

            // Наборы монстров для генерации в узлах.
            var monsterSets = CreateMonsterSets();

            foreach (var node in region.RegionNodes)
            {
                if (node.MonsterState == null)
                {
                    if (!monsterLimitIsReached)
                    {
                        var spawnMonsterRoll = _dice.RollD6();

                        if (spawnMonsterRoll >= SPAWN_SUCCESS_ROLL)
                        {
                            CreateNodeMonsterState(monsterSets, node);
                        }
                    }
                }
                else
                {
                    // В метод передём только состояние, как минимальные данные,
                    // которые там нужны.
                    // Внутри метода он может зануляться, поэтому передаём по ссылке.
                    var monsterState = node.MonsterState;
                    UpdateNodeMonsterState(ref monsterState);
                    node.MonsterState = monsterState;
                }
            }
        }
Exemplo n.º 3
0
        public IDisease Create()
        {
            var roll = _dice.RollD6();

            if (roll <= 1)
            {
                var nameGenerationAttempt = 0;
                do
                {
                    var primaryName = _dice.RollFromList(DiseaseNames.Primary);

                    ILocalizedString prefix = null;

                    var rollPrefix = _dice.RollD6();
                    if (rollPrefix >= 4)
                    {
                        prefix = _dice.RollFromList(DiseaseNames.PrimaryPreffix);
                    }

                    ILocalizedString secondary = null;
                    var rollSecondary          = _dice.RollD6();
                    if (rollSecondary >= 4)
                    {
                        secondary = _dice.RollFromList(DiseaseNames.Secondary);
                    }

                    ILocalizedString subject = null;
                    var rollSubject          = _dice.RollD6();
                    if (rollSubject >= 6)
                    {
                        subject = _dice.RollFromList(DiseaseNames.Subject);
                    }

                    var diseaseName = new DiseaseName(primaryName, prefix, secondary, subject);

                    // Проверяем, была ли уже такая болезнь.

                    var isDuplicate = CheckDuplicates(diseaseName);
                    if (isDuplicate)
                    {
                        nameGenerationAttempt++;
                        continue;
                    }

                    var rolledSymptoms = RolledSymptoms();

                    var progressSpeed = RollDiseaseProgressSpeed();

                    var disease = new Disease(diseaseName, rolledSymptoms, progressSpeed);

                    _usedDiseases.Add(diseaseName);

                    return(disease);
                } while (nameGenerationAttempt < 10);

                // Не удалось сгенерировать уникальное имя. Значит вообще не генерируем болезнь.
                return(null);
            }
            else
            {
                return(null);
            }
        }
        public HumanPerson Create()
        {
            var personScheme = _schemeService.GetScheme <IPersonScheme>("human-person");

            var inventory = new Inventory();

            var evolutionData = new EvolutionData(_schemeService);

            var defaultActScheme = _schemeService.GetScheme <ITacticalActScheme>(personScheme.DefaultAct);

            var person = new HumanPerson(personScheme, defaultActScheme, evolutionData, _survivalRandomSource, inventory);

            var classRoll = _dice.RollD6();

            switch (classRoll)
            {
            case 1:
                AddEquipment(person.EquipmentCarrier, 2, "short-sword");
                AddEquipment(person.EquipmentCarrier, 1, "steel-armor");
                AddEquipment(person.EquipmentCarrier, 3, "wooden-shield");
                break;

            case 2:
                AddEquipment(person.EquipmentCarrier, 2, "battle-axe");
                AddEquipment(person.EquipmentCarrier, 3, "battle-axe");
                AddEquipment(person.EquipmentCarrier, 0, "highlander-helmet");
                break;

            case 3:
                AddEquipment(person.EquipmentCarrier, 2, "bow");
                AddEquipment(person.EquipmentCarrier, 1, "leather-jacket");
                AddEquipment(inventory, "short-sword");
                AddResource(inventory, "arrow", 10);
                break;

            case 4:
                AddEquipment(person.EquipmentCarrier, 2, "fireball-staff");
                AddEquipment(person.EquipmentCarrier, 1, "scholar-robe");
                AddEquipment(person.EquipmentCarrier, 0, "wizard-hat");
                AddResource(inventory, "mana", 15);
                break;

            case 5:
                AddEquipment(person.EquipmentCarrier, 2, "pistol");
                AddEquipment(person.EquipmentCarrier, 0, "elder-hat");
                AddResource(inventory, "bullet-45", 5);

                AddResource(inventory, "packed-food", 1);
                AddResource(inventory, "water-bottle", 1);
                AddResource(inventory, "med-kit", 1);

                AddResource(inventory, "mana", 5);
                AddResource(inventory, "arrow", 3);
                break;
            }

            AddResource(inventory, "packed-food", 1);
            AddResource(inventory, "water-bottle", 1);
            AddResource(inventory, "med-kit", 1);

            return(person);
        }