public void RemoveAndResetExpired(AbilityDurationData[] expiredAbilitiesRef)
        {
            if (expiredAbilitiesRef.Length != MAX_APPLIED_ABILITIES)
            {
                throw new Exception("Input length must == " + MAX_APPLIED_ABILITIES);
            }
            int expiredIndex = 0;

            for (int i = 0; i < MAX_APPLIED_ABILITIES; i++)
            {
                AbilityDurationData abilityDurationData = abilityDurationDatas[i];
                if (isActive[i] && (abilityDurationData.NumTurnsElapsed / abilityDurationData.TurnsPerTick == abilityDurationData.MaxTicks))
                {
                    isActive[i] = false;
                    expiredAbilitiesRef[expiredIndex++] = abilityDurationDatas[i];
                    abilityDurationDatas[i].Reset();
                    abilityDurationDatas[i] = null;
                }
            }

            // Clear out remainder of array
            for (; expiredIndex < MAX_APPLIED_ABILITIES; expiredIndex++)
            {
                expiredAbilitiesRef[expiredIndex] = null;
            }
        }
 public void FromObjectArray(object[] properties)
 {
     Clear();
     for (int i = 0; i < properties.Length; i++)
     {
         AbilityDurationData aDurDat = new AbilityDurationData();
         aDurDat.FromObjectArray(properties[i] as object[]);
         Add(aDurDat);
     }
 }
 public void Add(AbilityDurationData abilityDurationData)
 {
     for (int i = 0; i < MAX_APPLIED_ABILITIES; i++)
     {
         if (nextIndex == MAX_APPLIED_ABILITIES)
         {
             nextIndex = 0;
         }
         if (!isActive[nextIndex])
         {
             abilityDurationDatas[nextIndex] = abilityDurationData;
             isActive[nextIndex]             = true;
             nextIndex++;
             return;
         }
         nextIndex++;
     }
     throw new Exception("Maximum reached.");
 }
        public AbilityDurationData Clone(bool reset)
        {
            AbilityDurationData clone = new AbilityDurationData();

            clone.OriginAbilityID   = OriginAbilityID;
            clone.OwnerCombatantID  = OwnerCombatantID;
            clone.PerTickAmount     = PerTickAmount;
            clone.TurnsPerTick      = TurnsPerTick;
            clone.MaxTicks          = MaxTicks;
            clone.NumTurnsElapsed   = NumTurnsElapsed;
            clone.AbilityEffectType = AbilityEffectType;
            clone.AbilityTargetType = AbilityTargetType;
            clone.IsCrit            = IsCrit;

            if (reset)
            {
                clone.Reset();
            }

            return(clone);
        }
        protected override void copyExtendedProperties(ItemModel sourceItemModel)
        {
            AbilityItemModel abilityItemModel = sourceItemModel as AbilityItemModel;

            if (abilityItemModel == null)
            {
                throw new InvalidCastException("Invalid type.");
            }
            AbilityEffectType    = abilityItemModel.AbilityEffectType;
            AbilityTargetType    = abilityItemModel.AbilityTargetType;
            AbilityDurationType  = abilityItemModel.AbilityDurationType;
            CastTurns            = abilityItemModel.CastTurns;
            CoolDownTurns        = abilityItemModel.CoolDownTurns;
            CoolDownTurnsElapsed = abilityItemModel.CoolDownTurnsElapsed;
            ImmediateAmout       = abilityItemModel.ImmediateAmout;
            IsSpellBased         = abilityItemModel.IsSpellBased;

            if (AbilityDurationType == AbilityDurationType.MultiTurn)
            {
                AbilityDurationData = abilityItemModel.AbilityDurationData.Clone(false);
            }
        }
        public AbilityItemModel(int ID, string name, string description, RarityType rarityType, int stackedCount, int level,
                                AbilityEffectType abilityEffectType, AbilityTargetType abilityTargetType, AbilityDurationType abilityDurationType,
                                int castTurns, int coolDownTurns, int immediateAmount, bool isSpellBased, int perTickAmount, int turnsPerTick, int maxTicks) : base(ID, name, description, level, rarityType, stackedCount)
        {
            this.AbilityEffectType   = abilityEffectType;
            this.AbilityTargetType   = abilityTargetType;
            this.AbilityDurationType = abilityDurationType;
            this.CastTurns           = castTurns;
            this.CoolDownTurns       = coolDownTurns;
            this.ImmediateAmout      = immediateAmount;
            this.IsSpellBased        = isSpellBased;

            if (abilityDurationType == AbilityDurationType.MultiTurn)
            {
                this.AbilityDurationData = new AbilityDurationData();
                this.AbilityDurationData.OriginAbilityID   = ID;
                this.AbilityDurationData.PerTickAmount     = perTickAmount;
                this.AbilityDurationData.TurnsPerTick      = turnsPerTick;
                this.AbilityDurationData.MaxTicks          = maxTicks;
                this.AbilityDurationData.AbilityEffectType = abilityEffectType;
                this.AbilityDurationData.AbilityTargetType = abilityTargetType;
            }
        }