public Equipment(IPropScheme propScheme, IEnumerable <ITacticalActScheme> acts, [NotNull] string name) : this(propScheme, acts) { _name = name ?? throw new ArgumentNullException(nameof(name)); }
/// <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); }
private string GetPropDisplayName(IPropScheme propScheme) { var lang = _uiSettingService.CurrentLanguage; var name = propScheme.Name; return(LocalizationHelper.GetValueOrDefaultNoname(lang, name)); }
public Equipment(IPropScheme propScheme, IEnumerable <ITacticalActScheme> acts, string name) : this(propScheme, acts) { _name = name; }
private string GetPropDescription(IPropScheme propScheme) { var lang = _uiSettingService.CurrentLanguage; var description = propScheme.Description; return(LocalizationHelper.GetValue(lang, description)); }
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}"); } } }
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); }
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); }
private void WriteEquipmentRules(IPropScheme propScheme, List <string> descriptionLines) { if (propScheme.Equip.Rules == null) { return; } foreach (var rule in propScheme.Equip.Rules) { WriteEquipmentRule(descriptionLines, rule); } }
private static PropClass GetPropClass(IPropScheme scheme) { if (scheme.Equip != null) { return(PropClass.Equipment); } if (scheme.Sid == "conceptual-scheme") { return(PropClass.Concept); } return(PropClass.Resource); }
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); }
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); } }
/// <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); }
/// <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); }
/// <summary> /// Конструктор. /// </summary> /// <param name="scheme"> Схема предмета. </param> protected PropBase(IPropScheme scheme) { Scheme = scheme; }
public Resource CreateResource(IPropScheme scheme, int count) { var resource = new Resource(scheme, count); return(resource); }
public Concept(IPropScheme scheme, IPropScheme conceptProp) : base(scheme) { ConceptProp = conceptProp; }
public void AddResourceToActor(IPropScheme resourceScheme, int count, IActor actor) { var resource = new Resource(resourceScheme, count); actor.Person.Inventory.Add(resource); }
public Equipment(IPropScheme propScheme) : this(propScheme, new ITacticalActScheme[0]) { }
public Equipment(IPropScheme propScheme) : this(propScheme, Array.Empty <ITacticalActScheme>()) { }