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 headDropScheme = GetHeads(); FillSlot(person, headDropScheme, HEAD_SLOT_INDEX); var armorDropScheme = GetArmors(); FillSlot(person, armorDropScheme, BODY_SLOT_INDEX); var mainWeaponDropScheme = GetMainWeapons(); FillSlot(person, mainWeaponDropScheme, MAIN_HAND_SLOT_INDEX); var offWeaponDropScheme = GetOffWeapons(); FillSlot(person, offWeaponDropScheme, OFF_HAND_SLOT_INDEX); var startPropDropScheme = GetStartProps(); var startProps = _dropResolver.Resolve(new[] { startPropDropScheme }); foreach (var prop in startProps) { AddPropToInventory(inventory, prop); } AddResource(inventory, "packed-food", 1); AddResource(inventory, "water-bottle", 1); AddResource(inventory, "med-kit", 1); return(person); }
private void FillSlot(HumanPerson person, IDropTableScheme dropScheme, int slotIndex) { // Генерируем предметы. // Выбираем предмет, как экипировку в слот. // Если он может быть экипирован, то устанавливаем в слот. // Остальные дропнутые предметы складываем просто в инвентарь. // Если текущий предмет невозможно экипировать, то его тоже помещаем в инвентарь. var inventory = person.Inventory; var dropedProps = _dropResolver.Resolve(new[] { dropScheme }); var usedEquipment = dropedProps.OfType <Equipment>().FirstOrDefault(); if (usedEquipment != null) { var canBeEquiped = CanBeEquiped(person.EquipmentCarrier, slotIndex, usedEquipment); if (canBeEquiped) { AddEquipment(person.EquipmentCarrier, slotIndex, usedEquipment); var unusedMainWeaponDrops = dropedProps.Where(x => x != usedEquipment).ToArray(); foreach (var prop in unusedMainWeaponDrops) { AddPropToInventory(inventory, prop); } } else { foreach (var prop in dropedProps) { AddPropToInventory(inventory, prop); } } } else { foreach (var prop in dropedProps) { AddPropToInventory(inventory, prop); } } }
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); }