Пример #1
0
        public void InitFromPlayer(Player player)
        {
            Id   = player.Id;
            Name = player.Name;
            AvailableAttributePoints = player.AvailableAttributePoints;
            _levelBefore             = player._levelBefore;
            Stats.Set(player.Stats);
            Inventory.Reset();
            Inventory.AddInventory(player.Inventory);
            Position.Set(player.Position.X, player.Position.Y);

            CombatSkills.Clear();
            foreach (int combatSkill in player.CombatSkills)
            {
                CombatSkills.Add(combatSkill);
            }

            MagicSkills.Clear();
            foreach (int magicSkill in player.MagicSkills)
            {
                MagicSkills.Add(magicSkill);
            }

            CurrentAttackSkill = player.CurrentAttackSkill;
            EquippedWeapon     = player.EquippedWeapon;
            for (int i = 0; i < player.EquippedItems.Length; i++)
            {
                EquippedItems[i] = player.EquippedItems[i];
            }
        }
Пример #2
0
    /*
     #pragma warning disable CA2227 // Collection properties should be read only
     *      [JsonInclude, JsonPropertyName("SpellStrengths")]
     *      public IDictionary<string, (bool, ushort)> StringKeyedSpells // Ugh, messy hack to work around System.Text.Json having crappy dictionary key support.
     *      {
     *          get => SpellStrengths.ToDictionary(x => x.Key.ToString(), x => x.Value);
     *          set => SpellStrengths = value.ToDictionary(x => SpellId.Parse(x.Key), x => x.Value);
     *      }
     #pragma warning restore CA2227 // Collection properties should be read only
     */

    public MagicSkills DeepClone()
    {
        var clone = new MagicSkills()
        {
            SpellPoints    = SpellPoints.DeepClone(),
            SpellClasses   = SpellClasses,
            KnownSpells    = KnownSpells.ToList(),
            SpellStrengths = SpellStrengths.ToDictionary(x => x.Key, x => x.Value)
        };

        return(clone);
    }
Пример #3
0
 public CharacterMagicEditor(object asset) : base(asset)
 {
     _magic = asset as MagicSkills ?? throw new ArgumentNullException(nameof(asset));
 }