Newer
Older
TheVengeance-Project-IADE-Unity2D / Assets / Scripts / Player / Stats / BasicStatModifier.cs
@Rackday Rackday on 29 Oct 810 bytes Major Update
using MyCollections.Stats;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace MyCollections.Stats
{
    public class BasicStatModifier : StatModifier
    {
        private readonly StatType type;
        private readonly Func<int, int> operation;

        //Constructor
        public BasicStatModifier(StatType type, float duration, Func<int, int> operation) : base(duration)
        {
            this.type = type;
            this.operation = operation;
        }

        public override void Handle(object sender, Query query)
        {
            //Check the stat type
            if (query.statType == type)
            {
                //Perform operation
                query.value = operation((int)query.value);
            }
        }
    }
}