Пример #1
0
 /// <summary>
 /// Gets the correct player's max points based on an attribute.
 /// </summary>
 /// <param name="player">Player.</param>
 /// <param name="attribute">Attribute.</param>
 /// <returns>Max points based on the given attribute.</returns>
 public static int GetMaxPoints(IPlayerEntity player, DefineAttributes attribute)
 {
     return(attribute switch
     {
         DefineAttributes.HP => GetMaxHP(player),
         DefineAttributes.MP => GetMaxMP(player),
         DefineAttributes.FP => GetMaxFP(player),
         _ => - 1,
     });
Пример #2
0
        /// <inheritdoc />
        public void SendUpdateAttributes(IWorldEntity entity, DefineAttributes attribute, int newValue)
        {
            using var packet = new FFPacket();

            packet.StartNewMergedPacket(entity.Id, SnapshotType.SETPOINTPARAM);
            packet.Write((int)attribute);
            packet.Write(newValue);

            SendToVisible(packet, entity, true);
        }
Пример #3
0
        /// <summary>
        /// Sets the player's points.
        /// </summary>
        /// <param name="player">Player.</param>
        /// <param name="attribute">Attribute to set.</param>
        /// <param name="value">New value to set.</param>
        public static void SetPoints(IPlayerEntity player, DefineAttributes attribute, int value)
        {
            int max = GetMaxPoints(player, attribute);

            if (player.Attributes[attribute] == value)
            {
                return;
            }

            player.Attributes[attribute] = Math.Min(value, max);
        }
Пример #4
0
        public static void SendUpdateAttributes(IPlayerEntity entity, DefineAttributes attribute, int newValue)
        {
            using (var packet = new FFPacket())
            {
                packet.StartNewMergedPacket(entity.Id, SnapshotType.SETPOINTPARAM);
                packet.Write((int)attribute);
                packet.Write(newValue);

                entity.Connection.Send(packet);
                SendToVisible(packet, entity);
            }
        }
Пример #5
0
        /// <summary>
        /// Gets the correct player's point based on an attribute.
        /// </summary>
        /// <param name="player">Player.</param>
        /// <param name="attribute">Attribute</param>
        /// <returns>Points based on the given attribute.</returns>
        public static int GetPoints(IPlayerEntity player, DefineAttributes attribute)
        {
            switch (attribute)
            {
            case DefineAttributes.HP: return(player.Health.Hp + player.Attributes[DefineAttributes.HP]);

            case DefineAttributes.MP: return(player.Health.Mp + player.Attributes[DefineAttributes.MP]);

            case DefineAttributes.FP: return(player.Health.Fp + player.Attributes[DefineAttributes.FP]);

            default: return(-1);
            }
        }
Пример #6
0
        /// <summary>
        /// Gets the correct player's max points based on an attribute.
        /// </summary>
        /// <param name="player">Player.</param>
        /// <param name="attribute">Attribute.</param>
        /// <returns>Max points based on the given attribute.</returns>
        public static int GetMaxPoints(IPlayerEntity player, DefineAttributes attribute)
        {
            switch (attribute)
            {
            case DefineAttributes.HP: return(GetMaxHP(player));

            case DefineAttributes.MP: return(GetMaxMP(player));

            case DefineAttributes.FP: return(GetMaxFP(player));

            default: return(-1);
            }
        }
Пример #7
0
        /// <summary>
        /// Sets the player's points.
        /// </summary>
        /// <param name="player">Player.</param>
        /// <param name="attribute">Attribute to set.</param>
        /// <param name="value">New value to set.</param>
        public static void SetPoints(IPlayerEntity player, DefineAttributes attribute, int value)
        {
            int max     = GetMaxPoints(player, attribute);
            int current = GetPoints(player, attribute);

            if (current == value)
            {
                return;
            }

            switch (attribute)
            {
            case DefineAttributes.HP: player.Health.Hp = Math.Min(value, max); break;

            case DefineAttributes.MP: player.Health.Mp = Math.Min(value, max); break;

            case DefineAttributes.FP: player.Health.Fp = Math.Min(value, max); break;
            }
        }
Пример #8
0
 /// <summary>
 /// Gets or sets the attribute value matching the given key.
 /// </summary>
 /// <param name="attribute">Attribute key.</param>
 /// <returns>Attribute value.</returns>
 public int this[DefineAttributes attribute]
 {
     get => GetAttribute(attribute);
Пример #9
0
 /// <summary>
 /// Gets or sets the value of an attribute.
 /// </summary>
 /// <param name="attr">Attribute to set</param>
 /// <returns></returns>
 public int this[DefineAttributes attr]
 {
     get { return(this.Get((uint)attr)); }
     set { this.Set((uint)attr, value); }
 }
Пример #10
0
 /// <summary>
 /// Gets the attribute value matching the attribute key.
 /// </summary>
 /// <param name="attribute">Attribute.</param>
 /// <returns>Attribute value.</returns>
 public int GetAttribute(DefineAttributes attribute)
 {
     return(this._attributes.TryGetValue(attribute, out int value) ? value : default);
Пример #11
0
 /// <summary>
 /// Decrease an attribute value.
 /// </summary>
 /// <param name="attribute">Attribute to decrease.</param>
 /// <param name="decreaseValue">Decrease value.</param>
 public void DecreaseAttribute(DefineAttributes attribute, int decreaseValue)
 {
     this._attributes[attribute] -= decreaseValue;
 }
Пример #12
0
 /// <summary>
 /// Increases an attribute value.
 /// </summary>
 /// <param name="attribute">Attribute to increase.</param>
 /// <param name="increaseValue">Increase value.</param>
 public void IncreaseAttribute(DefineAttributes attribute, int increaseValue)
 {
     this._attributes[attribute] += increaseValue;
 }
Пример #13
0
 /// <summary>
 /// Resets an attribute to a given value.
 /// </summary>
 /// <param name="attribute">Attribute to reset.</param>
 /// <param name="value">Attribute value.</param>
 public void ResetAttribute(DefineAttributes attribute, int value)
 {
     this._attributes[attribute] = value;
 }
Пример #14
0
 /// <summary>
 /// Gets the attribute value matching the given key.
 /// </summary>
 /// <param name="attribute">Attribute key.</param>
 /// <returns>Attribute value.</returns>
 public int this[DefineAttributes attribute] => this.GetAttribute(attribute);