/// <summary>
        /// Filters an array of StatusEffects depending on whether they will be inflicted on a BattleEntity
        /// depending on the entity's status percentages and the chance of inflicting the StatusEffect.
        /// </summary>
        /// <param name="entity">The BattleEntity to attempt to afflict the StatusEffects with</param>
        /// <param name="statusesToInflict">The original array of StatusChanceHolders.</param>
        /// <returns>An array of StatusEffects that has succeeded in being inflicted on the entity</returns>
        private static StatusChanceHolder[] GetFilteredInflictedStatuses(BattleEntity entity, StatusChanceHolder[] statusesToInflict)
        {
            //Handle null
            if (statusesToInflict == null)
            {
                return(null);
            }

            //Construct a new list
            List <StatusChanceHolder> filteredStatuses = new List <StatusChanceHolder>(statusesToInflict);

            //Look through the list and remove any StatusEffects that fail to be afflicted onto the entity
            for (int i = 0; i < filteredStatuses.Count; i++)
            {
                StatusChanceHolder statusChance = filteredStatuses[i];
                if (entity.EntityProperties.TryAfflictStatus(statusChance.Percentage, statusChance.Status) == false)
                {
                    Debug.Log($"Failed to inflict {statusChance.Status.StatusType} on {entity.Name}");
                    filteredStatuses.RemoveAt(i);
                    i--;
                }
            }

            return(filteredStatuses.ToArray());
        }
Пример #2
0
            private static void PrintInteractionHolder(InteractionHolder interactionHolder, bool attacker)
            {
                string startString = attacker == true ? "Attacker" : "Victim";

                string statuses = string.Empty;

                if (interactionHolder.StatusesInflicted != null)
                {
                    for (int i = 0; i < interactionHolder.StatusesInflicted.Length; i++)
                    {
                        StatusChanceHolder statusHolder = interactionHolder.StatusesInflicted[i];
                        statuses += $"({statusHolder.Percentage}%){statusHolder.Status.StatusType.ToString()} ";
                    }
                }

                Debug.Log($"{startString}: {interactionHolder.Entity?.Name}\n" +
                          $"{startString} Damage: {interactionHolder.TotalDamage}\n" +
                          $"{startString} Element: {interactionHolder.DamageElement}\n" +
                          $"{startString} Element Result: {interactionHolder.ElementResult}\n" +
                          $"{startString} Contact Type: {interactionHolder.ContactType}\n" +
                          $"{startString} Contact Property: {interactionHolder.ContactProperty}\n" +
                          $"{startString} Piercing: {interactionHolder.Piercing}\n" +
                          $"{startString} Statuses: {statuses}\n" +
                          $"{startString} Hit: {interactionHolder.Hit}\n" +
                          $"{startString} Damage Effect(s): {interactionHolder.DamageEffect}\n" +
                          $"{startString} IsPaybackDamage: {interactionHolder.IsPaybackDamage}\n" +
                          $"{startString} Don't Damage: {interactionHolder.DontDamageEntity}\n");
            }