public Equipment(IPropScheme propScheme,
                  IEnumerable <ITacticalActScheme> acts,
                  [NotNull] string name) :
     this(propScheme, acts)
 {
     _name = name ?? throw new ArgumentNullException(nameof(name));
 }
Beispiel #2
0
        /// <inheritdoc />
        /// <summary>
        /// Конструктор.
        /// </summary>
        /// <param name="propScheme"> Схема экипировки. </param>
        /// <param name="acts"> Действия, которые может дать эта экипировка. </param>
        /// <exception cref="T:System.ArgumentException">
        /// Выбрасывает, если на вход подана схема,
        /// не содержащая характеристики экипировки <see cref="P:Zilon.Core.Schemes.PropScheme.Equip" />.
        /// </exception>
        public Equipment(IPropScheme propScheme,
                         IEnumerable <ITacticalActScheme> acts) :
            base(propScheme)
        {
            if (propScheme is null)
            {
                throw new ArgumentNullException(nameof(propScheme));
            }

            if (propScheme.Equip == null)
            {
                throw new ArgumentException("Не корректная схема.", nameof(propScheme));
            }

            if (acts != null)
            {
                Acts = acts.ToArray();
            }
            else
            {
                Acts = Array.Empty <ITacticalActScheme>();
            }

            Durable = new Stat(EQUIPMENT_DURABLE, 0, EQUIPMENT_DURABLE);
        }
Beispiel #3
0
    private string GetPropDisplayName(IPropScheme propScheme)
    {
        var lang = _uiSettingService.CurrentLanguage;
        var name = propScheme.Name;

        return(LocalizationHelper.GetValueOrDefaultNoname(lang, name));
    }
Beispiel #4
0
 public Equipment(IPropScheme propScheme,
                  IEnumerable <ITacticalActScheme> acts,
                  string name) :
     this(propScheme, acts)
 {
     _name = name;
 }
Beispiel #5
0
    private string GetPropDescription(IPropScheme propScheme)
    {
        var lang        = _uiSettingService.CurrentLanguage;
        var description = propScheme.Description;

        return(LocalizationHelper.GetValue(lang, description));
    }
Beispiel #6
0
    private void WriteActs(IPropScheme propScheme, List <string> descriptionLines)
    {
        var currentLanguage = _uiSettingService.CurrentLanguage;

        if (propScheme.Equip.ActSids == null)
        {
            return;
        }

        foreach (var sid in propScheme.Equip.ActSids)
        {
            var act       = _schemeService.GetScheme <ITacticalActScheme>(sid);
            var actName   = LocalizationHelper.GetValue(currentLanguage, act.Name);
            var efficient = GetEfficientString(act);
            switch (act.Stats.Effect)
            {
            case TacticalActEffectType.Damage:
                WriteDamageAct(descriptionLines, act, actName, efficient);
                break;

            case TacticalActEffectType.Heal:
                WriteHealAct(descriptionLines, actName, efficient);
                break;

            case TacticalActEffectType.Undefined:
            default:
                throw new InvalidOperationException($"Неизвестный тип воздействия {act.Stats.Effect}");
            }
        }
    }
Beispiel #7
0
        public Equipment CreateEquipment(IPropScheme scheme)
        {
            if (scheme.Equip == null)
            {
                throw new ArgumentException("Не корректная схема.", nameof(scheme));
            }

            if (scheme.Equip.ActSids == null)
            {
                return(new Equipment(scheme, null));
            }

            var actSchemes    = new List <ITacticalActScheme>();
            var actSchemeSids = scheme.Equip.ActSids;

            foreach (var actSchemeSid in actSchemeSids)
            {
                var actScheme = _schemeService.GetScheme <ITacticalActScheme>(actSchemeSid);

                actSchemes.Add(actScheme);
            }

            var equipment = new Equipment(scheme, actSchemes);

            return(equipment);
        }
Beispiel #8
0
        public Resource(IPropScheme scheme, int count) : base(scheme)
        {
            if (count <= 0)
            {
                throw new ArgumentException("Ресурсов не может быть 0 или меньше.", nameof(count));
            }

            Count = count;
        }
        public static void AddResourceToActor(IPropScheme resourceScheme, int count, IActor actor)
        {
            if (actor is null)
            {
                throw new ArgumentNullException(nameof(actor));
            }

            var resource = new Resource(resourceScheme, count);

            actor.Person.GetModule <IInventoryModule>().Add(resource);
        }
Beispiel #10
0
    private void WriteEquipmentRules(IPropScheme propScheme, List <string> descriptionLines)
    {
        if (propScheme.Equip.Rules == null)
        {
            return;
        }

        foreach (var rule in propScheme.Equip.Rules)
        {
            WriteEquipmentRule(descriptionLines, rule);
        }
    }
Beispiel #11
0
        private static PropClass GetPropClass(IPropScheme scheme)
        {
            if (scheme.Equip != null)
            {
                return(PropClass.Equipment);
            }

            if (scheme.Sid == "conceptual-scheme")
            {
                return(PropClass.Concept);
            }

            return(PropClass.Resource);
        }
Beispiel #12
0
    private void WriteEquipmentStats(IPropScheme propScheme, Equipment equipment)
    {
        var currentLanguage  = _uiSettingService.CurrentLanguage;
        var descriptionLines = new List <string>();

        WriteActs(propScheme, descriptionLines);
        WriteArmors(propScheme, descriptionLines);
        WriteEquipmentRules(propScheme, descriptionLines);

        var durableDisplayName = StaticPhrases.GetValue($"prop-durable", currentLanguage);

        descriptionLines.Add($"{durableDisplayName}: {equipment.Durable.Value}/{equipment.Durable.Range.Max}");

        StatText.text = string.Join("\n", descriptionLines);
    }
Beispiel #13
0
    private void WriteArmors(IPropScheme propScheme, List <string> descriptionLines)
    {
        var currentLanguage = _uiSettingService.CurrentLanguage;

        if (propScheme.Equip.Armors == null)
        {
            return;
        }

        var protectsDisplayName  = StaticPhrases.GetValue("armor-protects", currentLanguage);
        var armorRankDisplayName = StaticPhrases.GetValue("armor-rank", currentLanguage);

        foreach (var armor in propScheme.Equip.Armors)
        {
            WriteArmor(descriptionLines, protectsDisplayName, armorRankDisplayName, armor);
        }
    }
Beispiel #14
0
    /// <summary>
    /// Лже-предметы выдают себя на нормальный указанный предмет.
    /// Но они не могут скрываться, когда их прочность падает ниже 50%.
    /// В рамках этого метода мы возвращаем либо реальную схему предмета,
    /// либо схему, под которую мимикрирует текущий предмет (потому что он мимик и его статы ниже).
    /// </summary>
    private IPropScheme ProcessMimics(IProp prop, IPropScheme propScheme)
    {
        if (propScheme.IsMimicFor != null)
        {
            if (prop is Equipment equipment)
            {
                if (equipment.Durable.ValueShare >= 0.5f)
                {
                    var mimicScheme = _schemeService.GetScheme <IPropScheme>(propScheme.IsMimicFor);
                    Debug.Assert(mimicScheme != null, "Все схемы должны быть согласованы");

                    propScheme = mimicScheme;
                }
            }
        }

        return(propScheme);
    }
Beispiel #15
0
        /// <inheritdoc />
        /// <summary>
        /// Конструктор.
        /// </summary>
        /// <param name="propScheme"> Схема экипировки. </param>
        /// <param name="acts"> Действия, которые может дать эта экипировка. </param>
        /// <exception cref="T:System.ArgumentException">
        /// Выбрасывает, если на вход подана схема,
        /// не содержащая характеристики экипировки <see cref="P:Zilon.Core.Schemes.PropScheme.Equip" />.
        /// </exception>
        public Equipment(IPropScheme propScheme,
                         IEnumerable <ITacticalActScheme> acts) :
            base(propScheme)
        {
            if (propScheme.Equip is null)
            {
                throw new ArgumentException(
                          "The scheme is not valid for equipment. It must has not null Equip subscheme.", nameof(propScheme));
            }

            _name = string.Empty;

            if (acts != null)
            {
                Acts = acts.ToArray();
            }
            else
            {
                Acts = Array.Empty <ITacticalActScheme>();
            }

            Durable = new Stat(EQUIPMENT_DURABLE, 0, EQUIPMENT_DURABLE);
        }
Beispiel #16
0
 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="scheme"> Схема предмета. </param>
 protected PropBase(IPropScheme scheme)
 {
     Scheme = scheme;
 }
Beispiel #17
0
        public Resource CreateResource(IPropScheme scheme, int count)
        {
            var resource = new Resource(scheme, count);

            return(resource);
        }
Beispiel #18
0
 public Concept(IPropScheme scheme, IPropScheme conceptProp) : base(scheme)
 {
     ConceptProp = conceptProp;
 }
Beispiel #19
0
        public void AddResourceToActor(IPropScheme resourceScheme, int count, IActor actor)
        {
            var resource = new Resource(resourceScheme, count);

            actor.Person.Inventory.Add(resource);
        }
Beispiel #20
0
 public Equipment(IPropScheme propScheme) : this(propScheme, new ITacticalActScheme[0])
 {
 }
Beispiel #21
0
 public Equipment(IPropScheme propScheme) : this(propScheme, Array.Empty <ITacticalActScheme>())
 {
 }