コード例 #1
0
 private void AddEquipmentToActor(Inventory inventory, string equipmentSid)
 {
     try
     {
         var equipmentScheme = _schemeService.GetScheme <IPropScheme>(equipmentSid);
         var equipment       = _propFactory.CreateEquipment(equipmentScheme);
         inventory.Add(equipment);
     }
     catch (KeyNotFoundException)
     {
         Debug.LogError($"Не найден объект {equipmentSid}");
     }
 }
コード例 #2
0
 private void AddEquipment(Inventory inventory, string equipmentSid)
 {
     try
     {
         var equipmentScheme = _schemeService.GetScheme <IPropScheme>(equipmentSid);
         var equipment       = _propFactory.CreateEquipment(equipmentScheme);
         inventory.Add(equipment);
     }
     catch (KeyNotFoundException exception)
     {
         throw new CreatePersonException($"Не найден объект {equipmentSid}", exception);
     }
 }
コード例 #3
0
ファイル: DropResolver.cs プロジェクト: nf2g/Zilon_Roguelike
        private IProp GenerateProp(IDropTableRecordSubScheme record)
        {
            try
            {
                var scheme    = _schemeService.GetScheme <IPropScheme>(record.SchemeSid);
                var propClass = GetPropClass(scheme);

                switch (propClass)
                {
                case PropClass.Equipment:
                    var equipment = _propFactory.CreateEquipment(scheme);
                    return(equipment);

                case PropClass.Resource:
                    var rolledCount = _randomSource.RollResourceCount(record.MinCount, record.MaxCount);
                    var resource    = _propFactory.CreateResource(scheme, rolledCount);
                    return(resource);

                case PropClass.Concept:

                    var propScheme = _schemeService.GetScheme <IPropScheme>("record.Concept");

                    return(new Concept(scheme, propScheme));

                default:
                    throw new ArgumentException($"Неизвестный класс {propClass} объекта {scheme}.");
                }
            }
            catch (Exception exception)
            {
                //TODO Оборачивать в доменное исключение. Создать собственный тип.
                throw new Exception($"Ошибка при обработке записи дропа {record.SchemeSid}", exception);
            }
        }
コード例 #4
0
        private IProp GenerateProp(IDropTableRecordSubScheme record)
        {
            var scheme    = _schemeService.GetScheme <IPropScheme>(record.SchemeSid);
            var propClass = GetPropClass(scheme);

            switch (propClass)
            {
            case PropClass.Equipment:
                var equipment = _propFactory.CreateEquipment(scheme);
                return(equipment);

            case PropClass.Resource:
                var rolledCount = _randomSource.RollResourceCount(record.MinCount, record.MaxCount);
                var resource    = _propFactory.CreateResource(scheme, rolledCount);
                return(resource);

            case PropClass.Concept:

                throw new ArgumentException($"Пока концепты не поддерживаются.");

                var propScheme = _schemeService.GetScheme <IPropScheme>("record.Concept");

                return(new Concept(scheme, propScheme));

            default:
                throw new ArgumentException($"Неизвестный класс {propClass} объекта {scheme}.");
            }
        }
コード例 #5
0
        private IProp GenerateProp(DropTableRecordSubScheme record)
        {
            var scheme    = _schemeService.GetScheme <PropScheme>(record.SchemeSid);
            var propClass = GetPropClass(scheme);

            switch (propClass)
            {
            case PropClass.Equipment:
                //TODO Вынести в отдельный метод. Чтобы можно было использовать в крафте.

                var power = _randomSource.RollEquipmentPower(record.MinPower, record.MaxPower);

                var equipment = _propFactory.CreateEquipment(scheme);
                equipment.Power = power;
                return(equipment);

            case PropClass.Resource:
                var rolledCount = _randomSource.RollResourceCount(record.MinCount, record.MaxCount);
                return(new Resource(scheme, rolledCount));

            case PropClass.Concept:

                var propScheme = _schemeService.GetScheme <PropScheme>(record.Concept);

                return(new Concept(scheme, propScheme));

            default:
                throw new ArgumentException($"Неизвестный класс {propClass} объекта {scheme}.");
            }
        }
コード例 #6
0
        protected void AddEquipment(IInventoryModule inventory, string sid)
        {
            var scheme = SchemeService.GetScheme <IPropScheme>(sid);
            var prop   = _propFactory.CreateEquipment(scheme);

            AddPropToInventory(inventory, prop);
        }
コード例 #7
0
        private void AddEquipment(Inventory inventory, string sid)
        {
            var scheme = _schemeService.GetScheme <IPropScheme>(sid);
            var prop   = _propFactory.CreateEquipment(scheme);

            AddPropToInventory(inventory, prop);
        }
コード例 #8
0
    private void AddEquipmentToActor(Inventory inventory, string equipmentSid)
    {
        var equipmentScheme = _schemeService.GetScheme <PropScheme>(equipmentSid);
        var equipment       = _propFactory.CreateEquipment(equipmentScheme);

        inventory.Add(equipment);
    }
コード例 #9
0
 private static void AddEquipmentToActor(Inventory inventory, string equipmentSid,
                                         ISchemeService schemeService, IPropFactory propFactory)
 {
     try
     {
         var equipmentScheme = schemeService.GetScheme <IPropScheme>(equipmentSid);
         var equipment       = propFactory.CreateEquipment(equipmentScheme);
         inventory.Add(equipment);
     }
     catch (KeyNotFoundException)
     {
         Debug.WriteLine($"Не найден объект {equipmentSid}");
     }
 }
コード例 #10
0
 private static void AddEquipmentToActor(IEquipmentCarrier equipmentCarrier, int slotIndex, string equipmentSid,
                                         ISchemeService schemeService, IPropFactory propFactory)
 {
     try
     {
         var equipmentScheme = schemeService.GetScheme <IPropScheme>(equipmentSid);
         var equipment       = propFactory.CreateEquipment(equipmentScheme);
         equipmentCarrier[slotIndex] = equipment;
     }
     catch (KeyNotFoundException)
     {
         Debug.WriteLine($"Не найден объект {equipmentSid}");
     }
 }
コード例 #11
0
        public HumanPerson Restore(ISchemeService schemeService,
                                   ISurvivalRandomSource survivalRandomSource,
                                   IPropFactory propFactory)
        {
            if (schemeService is null)
            {
                throw new ArgumentNullException(nameof(schemeService));
            }

            if (survivalRandomSource is null)
            {
                throw new ArgumentNullException(nameof(survivalRandomSource));
            }

            if (propFactory is null)
            {
                throw new ArgumentNullException(nameof(propFactory));
            }

            var storedPerson = this;

            var personScheme = schemeService.GetScheme <IPersonScheme>("human-person");

            var inventory = new InventoryModule();

            var evolutionData = new EvolutionModule(schemeService);

            RestoreEvolutionData(schemeService, storedPerson, evolutionData);

            var person = new HumanPerson(personScheme);

            //TODO Создать необходимые модули и заполнить их.

            foreach (var survivalStoredItem in storedPerson.Survival)
            {
                var normalizedValueShare = RangeHelper.NormalizeShare(survivalStoredItem.Value);

                var stat = person.GetModule <ISurvivalModule>().Stats.Single(x => x.Type == survivalStoredItem.Type);

                stat.SetShare(normalizedValueShare);
            }

            foreach (var storedProp in storedPerson.Inventory)
            {
                var   propScheme = schemeService.GetScheme <IPropScheme>(storedProp.Sid);
                IProp prop;
                switch (storedProp.Type)
                {
                case PropType.Resource:
                    prop = propFactory.CreateResource(propScheme, storedProp.Count);
                    break;

                case PropType.Equipment:
                    var equipment = propFactory.CreateEquipment(propScheme);
                    equipment.Durable.Value = storedProp.Durable;
                    prop = equipment;

                    break;

                default:
                    throw new Exception();
                }

                inventory.Add(prop);
            }

            for (var i = 0; i < storedPerson.Equipments.Length; i++)
            {
                var storedEquipment = storedPerson.Equipments[i];

                if (storedEquipment == null)
                {
                    continue;
                }

                var equipmentScheme = schemeService.GetScheme <IPropScheme>(storedEquipment.Sid);

                var equipment = propFactory.CreateEquipment(equipmentScheme);
                equipment.Durable.Value = storedEquipment.Durable;

                person.GetModule <IEquipmentModule>()[i] = equipment;
                //TODO Уменьшать прочность согласно сохранённым данным
            }

            return(person);
        }
コード例 #12
0
        public HumanPerson Restore(ISchemeService schemeService,
                                   ISurvivalRandomSource survivalRandomSource,
                                   IPropFactory propFactory)
        {
            var storedPerson = this;

            var personScheme = schemeService.GetScheme <IPersonScheme>("human-person");

            var inventory = new Inventory();

            var evolutionData = new EvolutionData(schemeService);

            RestoreEvolutionData(schemeService, storedPerson, evolutionData);

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

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

            foreach (var survivalStoredItem in storedPerson.Survival)
            {
                var normalizedValueShare = RangeHelper.NormalizeShare(survivalStoredItem.Value);

                var stat = person.Survival.Stats.Single(x => x.Type == survivalStoredItem.Type);

                stat.SetShare(normalizedValueShare);
            }

            foreach (var storedProp in storedPerson.Inventory)
            {
                var   propScheme = schemeService.GetScheme <IPropScheme>(storedProp.Sid);
                IProp prop;
                switch (storedProp.Type)
                {
                case PropType.Resource:
                    prop = propFactory.CreateResource(propScheme, storedProp.Count);
                    break;

                case PropType.Equipment:
                    var equipment = propFactory.CreateEquipment(propScheme);
                    equipment.Durable.Value = storedProp.Durable;
                    prop = equipment;

                    break;

                default:
                    throw new Exception();
                }

                inventory.Add(prop);
            }

            for (var i = 0; i < storedPerson.Equipments.Length; i++)
            {
                var storedEquipment = storedPerson.Equipments[i];

                if (storedEquipment == null)
                {
                    continue;
                }

                var equipmentScheme = schemeService.GetScheme <IPropScheme>(storedEquipment.Sid);

                var equipment = propFactory.CreateEquipment(equipmentScheme);
                equipment.Durable.Value = storedEquipment.Durable;

                person.EquipmentCarrier[i] = equipment;
                //TODO Уменьшать прочность согласно сохранённым данным
            }

            return(person);
        }