/// <summary> /// Increases action points for a CombatEntity based on its action point regeneration. /// </summary> /// <param name="entity">The CombatEntity whose action points should be increased.</param> private ActionPointData IncreaseActionPoints(CombatEntity entity) { lock (_key) { if (entity == null) { return(null); } if (entity.Resources.CurrentHealth <= 0 || entity.StatusEffects.Any(se => se.BaseStatus.IsStunned)) { return(null); } int randPoints = _seed.Next(0, entity.SecondaryStats.BonusActionPoints); int total = GameplayConstants.ActionPointsPerTurn + randPoints; total += total * entity.SecondaryStats.BonusActionPointsPercentage / 100; entity.Resources.CurrentActionPoints += total; return(new ActionPointData { EntityId = entity.Id, CurrentActionPoints = entity.Resources.CurrentActionPoints }); } }
private void OnInputTarget(CombatEntity combatEntity) { var abilityExecution = PreviewingAbility.CreateAbilityExecution(); abilityExecution.InputCombatEntity = combatEntity; abilityExecution.BeginExecute(); }
protected override void Consume(GameObject player) { //Debug.Log("Player consumed a caffeine"); CombatEntity combatEntity = player.GetComponent <CombatEntity>(); combatEntity.ChangeCombatStat(CombatStatType.CombatPoint, enhancedValue); }
public override void Initialize(float statusDuration, CombatEntity caster, CombatEntity target) { base.Initialize(statusDuration, caster, target); var d = (caster.GetStat(StatType.Strength) * strengthScaling) + (caster.GetStat(StatType.Magic) * magicScaling); totalDamage = (int)d; }
/// <summary> /// Called to make a CombatEntity perform the defend command. /// </summary> /// <param name="actor">The CombatEntity performing the defend command.</param> /// <param name="actorFormation">The Formation of the CombatEntity performing the defend command.</param> /// <param name="nextActiveEntity">Contains the next active CombatEntity, if any.</param> /// <returns>An IEnumerable of CombatEntity containing the CombatEntity performing the defend command.</returns> private IEnumerable <CombatEntity> PerformDefend(CombatEntity actor, Formation actorFormation, out CombatEntity nextActiveEntity) { IEnumerable <CombatEntity> affectedEntities = null; var task = _statusEffectRepo.GetDataAsync(); task.Wait(); var statusEffects = task.Result; var defendStatus = statusEffects.FirstOrDefault(se => se.Id == GameplayConstants.DefendingStatusEffectId); lock (_key) { // Apply status effect _statusEffectManager.Apply(actor, actor, defendStatus); _battle.ActionsLeftPerFormation[actorFormation].Remove(actor); affectedEntities = new List <CombatEntity> { actor }; // Choose next active entity nextActiveEntity = GetNextActiveEntity(actorFormation, _battle.ActionsLeftPerFormation[actorFormation]); if (nextActiveEntity != null) { _battle.ActionsLeftPerFormation[actorFormation].Add(nextActiveEntity); } } return(affectedEntities); }
/// <summary> /// Equips an item onto a CombatEntity and applys its effects. Will unequip any items that also belong to the /// same EquipPosition as the item being applied. /// </summary> /// <param name="entity">The CombatEntity to equip the item on to.</param> /// <param name="item">The item to equip.</param> /// <returns>Returns true if the operation was successful. Will fail if the item is unequippable.</returns> public bool Equip(CombatEntity entity, Item item) { if (!item.IsEquippable) { return(false); } if (string.IsNullOrEmpty(item.Type.EquipPosition)) { return(false); } var oldItem = entity.EquippedItems.FirstOrDefault(i => i.Type.EquipPosition == item.Type.EquipPosition); Unequip(entity, oldItem); entity.PlayerInventory.Items.Remove(item); var tracking = entity.PlayerInventory.TrackedItems.FirstOrDefault(i => i.BaseItemId == item.Id); if (tracking != null) { entity.PlayerInventory.TrackedItems.Remove(tracking); entity.TrackedItems.Add(tracking); } entity.EquippedItems.Add(item); entity.Abilities.AddRange(item.EquippedAbilities); entity.SecondaryStats += item.SecondaryStats; entity.Stats += item.Stats; _statusEffectManager.Apply(entity, entity, item.SelfAppliedStatusEffects); ChangeIconUri(entity, item.Type.EquipPosition, item.EquipIconUri); return(true); }
public override void ApplyAbilityEffectsTo(CombatEntity targetEntity) { List <Effect> Effects = null; #if EGAMEPLAY_EXCEL Effects = new List <Effect>(); var effect = ParseEffect(SkillConfig.Effect1); if (effect != null) { Effects.Add(effect); } effect = ParseEffect(SkillConfig.Effect2); if (effect != null) { Effects.Add(effect); } effect = ParseEffect(SkillConfig.Effect3); if (effect != null) { Effects.Add(effect); } #else Effects = SkillConfig.Effects; #endif if (Effects == null) { return; } foreach (var effectItem in Effects) { ApplyEffectTo(targetEntity, effectItem); } }
/// <summary> /// Returns a string indicating that the entity cannot use an ability because it doesn't have enough /// health. /// </summary> /// <param name="entity">The CombatEntity of focus.</param> /// <param name="ability">The ability being used.</param> public static string WriteInsufficientHealth(CombatEntity entity, Ability ability) { int totalHealthCost = ResourceCalculator.GetTotalHealthCost(entity, ability); return($"{entity.Name} does not have enough Health to use {ability.Name}. {ability.Name} " + $"requires {totalHealthCost} Health, {entity.Name} has {entity.Resources.CurrentHealth}."); }
private void ExecuteAction(CombatEntity e) { var ability = e.Character.PrimaryAbility; foreach (var action in ability.Actions) { var target = this.GetTarget(e, action.TargetType); if (action.Type == AbilityActionType.PhysicalAttack) { var physAttack = e.Character.Strength; // TODO: + equipment var physDefense = e.Character.Strength; // TODO: + equipment // TODO: Affinity multiplier var defensiveMultiplier = ((float)(physAttack + target.Character.Level * 3) / (physDefense + (target.Character.Level * 2))); var minDamage = (int)(physAttack * action.MinMultiplier * defensiveMultiplier); var maxDamage = (int)(physAttack * action.MaxMultiplier * defensiveMultiplier); var damage = this.Random.Next(minDamage, maxDamage + 1); target.RemainingHp -= System.Math.Max(damage, 1); Console.WriteLine("{0} [{1}] attacked {2} [{3}] with {4} for {5} damage!", e.Character.Name, e.RemainingHp, target.Character.Name, target.RemainingHp, ability.Name, damage); } else { throw new NotImplementedException(); } } e.ActionBar = 0; }
/// <summary> /// Returns a string indicating that the entity cannot use an ability because it doesn't have enough /// action points. /// </summary> /// <param name="entity">The CombatEntity of focus.</param> /// <param name="ability">The ability being used.</param> public static string WriteInsufficientActionPoints(CombatEntity entity, Ability ability) { int totalActionPointCost = ResourceCalculator.GetTotalActionPointCost(entity, ability); return($"{entity.Name} does not have enough Action Points to use {ability.Name}. {ability.Name} " + $"requires {totalActionPointCost} Action Points, {entity.Name} has {entity.Resources.CurrentActionPoints}."); }
// Start is called before the first frame update void Start() { CombatEntity = EntityFactory.Create <CombatEntity>(); CombatEntity.Initialize(); CombatEntity.AddComponent <CombatSkillComponent>(); AnimTimer.MaxTime = AnimTime; }
/*************** ** SPELL LIST ** ***************/ //offensive aoe spell public void ConeOfCold() { //spell stats string spellName = "cone of cold"; int manaCost = 10; SpellType spellType = SpellType.DamageAll; float damage = CombatEntity.DamageAmount((int)Math.Round(casterObj.attributes.magicTotal * 0.25f), (int)Math.Round(casterObj.attributes.magicTotal * 1.0f), casterObj.attributes.magicTotal, 1.0f); //cast spell if in combat, else learn the spell if (GameManager.IsCombat()) { SpellTemplate(spellName, damage, manaCost, spellType); } else { //learn spell if not already learned try { spellDictionary.Add(spellName, new spell(ConeOfCold)); Console.WriteLine("You have learned the spell " + spellName); } catch (ArgumentException) { Console.WriteLine("You already know the spell " + spellName); } } }
public void DisplayCustomTextAbove(CombatEntity entity, string text, bool bUseUnscaleTime = true, Color customColor = default(Color), int fontSize = -1) { if (_dmgTextPrefab == null) { _dmgTextPrefab = Resources.Load <GameObject>("Prefab/DamageText"); } entity.FindCharacterSprite(); if (entity.CharacterSprite != null) { Vector2 rendererPosition = entity.CharacterSprite.RendererPosition; rendererPosition.y += 1.8f; GameObject gameObject = UnityEngine.Object.Instantiate(_dmgTextPrefab, rendererPosition, Quaternion.identity); DamageText damageText = gameObject.GetComponent <DamageText>(); damageText.SetText(text); if (customColor.a > 0f) { damageText.SetColor(customColor); } if (fontSize >= 0) { damageText.SetSize(fontSize); } if (!bUseUnscaleTime) { gameObject.GetComponentInChildren <UI2DFloatyText>()._useUnscaleTime = false; return; } } else { Debug.LogError("Missing CharacterSprite"); } }
/// <summary> /// Reduces the amount of charges in an item. If the item has no charges left and DestroyedWhenOutOfCharges is true, /// will remove the item from existence. /// </summary> /// <param name="entity">The entity who used the item.</param> /// <param name="item">The item to reduce charges of.</param> public void ReduceCharges(CombatEntity entity, Item item) { bool isInPlayerInventory = true; if (item.ConsumableCharges == null || item.IsConsumable) { return; } var track = entity.PlayerInventory.TrackedItems .FirstOrDefault(i => i.BaseItemId == item.Id && i.CurrentCharges > 0); if (track == null) { entity.TrackedItems.FirstOrDefault(i => i.BaseItemId == item.Id); isInPlayerInventory = false; } if (track == null) { throw new Exception("The item " + item.Name + " is not being tracked."); } track.CurrentCharges--; if (item.DestroyedWhenOutOfCharges && track.CurrentCharges == 0) { if (!isInPlayerInventory) { Unequip(entity, item); } entity.PlayerInventory.TrackedItems.Remove(track); entity.PlayerInventory.Items.Remove(item); } }
/// <summary> /// Updates an existing combat entity with the template given asynchronously. /// <para>Will return null if the operation failed.</para> /// </summary> /// <param name="entity">The CombatEntity to update.</param> /// <param name="template">The template to use to update the entity with.</param> /// <returns>Returns the modified combat entity or null if no entity was modified.</returns> public async Task <CombatEntity> UpdateAsync(CombatEntity entity, CharacterTemplate template) { if (!await IsValidTemplateAsync(template)) { return(null); } var hairData = await _characterHairRepo.GetDataAsync(); var baseData = await _characterBaseRepo.GetDataAsync(); try { // Find the corresponding iconUris and arrange them in the correct order var hair = hairData.First(h => h.Id == template.HairId).IconUri; entity.IconUris.HairIconUri = hair; } catch (ArgumentException e) { Console.WriteLine(e.Message); return(null); } entity.Name = template.Name; entity.GroupId = template.GroupId; entity.GrowthPoints = template.AllocatedStats; return(entity); }
//offensive target spell public void Fireball() { string spellName = "fireball"; int manaCost = 5; SpellType spellType = SpellType.DamageTarget; float damage = CombatEntity.DamageAmount((int)Math.Round(casterObj.attributes.magicTotal * 0.5f), (int)Math.Round(casterObj.attributes.magicTotal * 1.5f), casterObj.attributes.magicTotal, 1.0f); //cast spell if in combat, else learn the spell if (GameManager.IsCombat()) { SpellTemplate(spellName, damage, manaCost, spellType); } else { //learn spell try { spellDictionary.Add(spellName, new spell(Fireball)); } catch (ArgumentException) { Console.WriteLine("You already know the spell " + spellName); } } }
/// <summary> /// Unequips an item from a CombatEntity, removing all bonuses and abilities granted by the item. /// </summary> /// <param name="entity">The CombatEntity to unequip the item from.</param> /// <param name="item">The Item to unequip.</param> public void Unequip(CombatEntity entity, Item item) { if (item == null) { return; } var index = entity.EquippedItems.FindIndex(i => i.Type.EquipPosition == item.Type.EquipPosition); if (index != -1) { var oldItem = entity.EquippedItems[index]; entity.PlayerInventory.Items.Add(oldItem); var tracking = entity.TrackedItems.FirstOrDefault(i => i.BaseItemId == item.Id); if (tracking != null) { entity.TrackedItems.Remove(tracking); entity.PlayerInventory.TrackedItems.Add(tracking); } entity.Abilities.RemoveAll(ability => oldItem.EquippedAbilities.Contains(ability)); entity.SecondaryStats -= oldItem.SecondaryStats; entity.Stats -= oldItem.Stats; foreach (var status in oldItem.SelfAppliedStatusEffects) { _statusEffectManager.Remove(entity, status); } ChangeIconUri(entity, oldItem.Type.EquipPosition, null); entity.EquippedItems.RemoveAt(index); } }
public void Attack(CombatEntity attacker) { // THIS IS TEMPORARY, FOR TESTING PURPOSES CombatEntity attacked = attacker == fighters[0] ? fighters[1] : fighters[0]; attacked.TakeDamage(attacker.attack); }
/// <summary> /// Returns true if the provided CombatEntity has enough resources to use an Ability. /// </summary> /// <param name="attacker">The attacking CombatEntity.</param> /// <param name="ability">The ability being used by the CombatEntity.</param> /// <returns></returns> private bool HasEnoughResources(CombatEntity attacker, Ability ability, out string failureReason) { failureReason = ""; int actionPointCost = ResourceCalculator.GetTotalActionPointCost(attacker, ability); int manaCost = ResourceCalculator.GetTotalManaCost(attacker, ability); int healthCost = ResourceCalculator.GetTotalHealthCost(attacker, ability); if (attacker.Resources.CurrentActionPoints < actionPointCost) { failureReason = BattleErrorWriter.WriteInsufficientActionPoints(attacker, ability); return(false); } if (attacker.Resources.CurrentMana < manaCost) { failureReason = BattleErrorWriter.WriteInsufficientMana(attacker, ability); return(false); } if (attacker.Resources.CurrentHealth < healthCost) { failureReason = BattleErrorWriter.WriteInsufficientHealth(attacker, ability); return(false); } return(true); }
public virtual void Attack(CombatEntity target) { if (AttackReady) { if (target.Health <= 0.0f) { Debug.Log("Enemy is defeated"); inCombat = false; return; } AttackReady = false; prevTime = Time.time; target.TakeDamage(Damage); Debug.Log(ID + " did " + Damage + " Damage to " + target.ID); log[1].text = log[0].text; log[0].text = ID + " did " + Damage + " Damage to " + target.ID; } else { if (ID != "Squid") { Debug.Log(ID + " Attack Cooldown: " + (FireRate - (Time.time - prevTime))); } } }
/// <summary> /// Applies the effects of the ability being used on all of it's targets. /// </summary> /// <param name="attacker">The entity performing the ability.</param> /// <param name="ability">The ability to apply the effects of.</param> /// <param name="targets">The targets of the ability.</param> private void ApplyEffects(CombatEntity attacker, Ability ability, IEnumerable <CombatEntity> targets) { bool isCrit = IsCritical(attacker, ability); foreach (var target in targets) { var damage = DamageCalculator.GetTotalDamage(attacker, target, ability, isCrit); var healing = DamageCalculator.GetHeal(attacker, ability, isCrit); healing += target.Resources.MaxHealth * ability.PercentHeal / 100; target.Resources.CurrentHealth += healing; target.Resources.CurrentHealth -= DamageCalculator.GetDamageTypesAsInt(damage); if (target.Resources.CurrentHealth > 0) { _statusEffectManager.Apply(target, attacker, ability.AppliedStatusEffects, isCrit); if (target.Resources.CurrentHealth > target.Resources.MaxHealth) { target.Resources.CurrentHealth = target.Resources.MaxHealth; } } else { _statusEffectManager.RemoveAll(target); target.Resources.CurrentHealth = 0; } } if (ability.SelfAppliedStatusEffects.Any()) { _statusEffectManager.Apply(attacker, attacker, ability.SelfAppliedStatusEffects, isCrit); } }
private void OnRemoveStatus(RemoveStatusEvent eventData) { if (name == "Monster") { var trm = CombatObjectData.StatusSlotsTrm.Find(eventData.StatusId.ToString()); if (trm != null) { GameObject.Destroy(trm.gameObject); } } var statusConfig = eventData.Status.StatusConfigObject; if (statusConfig.ID == "Vertigo") { CombatEntity.GetComponent <MotionComponent>().Enable = true; CombatObjectData.AnimationComponent.AnimancerComponent.Play(CombatObjectData.AnimationComponent.IdleAnimation); if (CombatObjectData.vertigoParticle != null) { GameObject.Destroy(CombatObjectData.vertigoParticle); } } if (statusConfig.ID == "Weak") { if (CombatObjectData.weakParticle != null) { GameObject.Destroy(CombatObjectData.weakParticle); } } }
/// <summary> /// Applies a StatusEffect onto a CombatEntity. /// </summary> /// <param name="recipient">The CombatEntity who is receiving the StatusEffect.</param> /// <param name="applicator">The CombatEntity applying the StatusEffect on the receiver.</param> /// <param name="statusEffect">The StatusEffect to apply onto the receiver.</param> /// <param name="isCrit">If true, will include critical damage in the calculations.</param> public void Apply(CombatEntity recipient, CombatEntity applicator, StatusEffect statusEffect, bool isCrit) { var status = recipient.StatusEffects.FirstOrDefault(se => se.BaseStatus.Id == statusEffect.Id); if (status == null) { var appliedStatusEffect = CreateAppliedStatus(applicator, recipient, statusEffect); ApplyStatEffects(recipient, statusEffect); recipient.StatusEffects.Add(appliedStatusEffect); } else { // Apply another stack of StatusEffect if (statusEffect.StackSize > 1 && status.CurrentStacks < statusEffect.StackSize) { status.CumulativeDamage += DamageCalculator.GetDamage(applicator, statusEffect, isCrit); status.CumulativeHeal += DamageCalculator.GetHeal(applicator, statusEffect, isCrit); status.CurrentStacks++; status.Duration = statusEffect.Duration; } // Can't apply another stack, refresh duration instead else { status.Duration = statusEffect.Duration; } } }
/// <summary> /// Applies damage and healing from all StatusEffects afflicting a CombatEntity and reduces their timers by 1. /// Removes any StatusEffects that are expired. /// </summary> /// <param name="entity">The CombatEntity to apply damage and healing to.</param> public void ApplyEffects(CombatEntity entity) { var removeStatuses = new List <AppliedStatusEffect>(); foreach (var statusEffect in entity.StatusEffects) { var damage = DamageCalculator.GetTotalDamage(statusEffect.CumulativeDamage, entity); var totalChange = DamageCalculator.GetDamageTypesAsInt(damage) - statusEffect.CumulativeHeal; entity.Resources.CurrentHealth -= totalChange; statusEffect.Duration--; if (statusEffect.Duration == 0) { removeStatuses.Add(statusEffect); } } if (entity.Resources.CurrentHealth <= 0) { RemoveAll(entity); } else { if (entity.Resources.CurrentHealth > entity.Resources.MaxHealth) { entity.Resources.CurrentHealth = entity.Resources.MaxHealth; } entity.StatusEffects = entity.StatusEffects.Except(removeStatuses).ToList(); } }
// Start is called before the first frame update void Start() { Instance = this; AnimancerComponent.Animator.fireEvents = false; AnimancerComponent.States.CreateIfNew(IdleAnimation); AnimancerComponent.States.CreateIfNew(RunAnimation); AnimancerComponent.States.CreateIfNew(JumpAnimation); AnimancerComponent.States.CreateIfNew(AttackAnimation); AnimancerComponent.States.CreateIfNew(SkillAnimation); CombatEntity = EntityFactory.Create <CombatEntity>(); CombatEntity.AddComponent <SkillPreviewComponent>(); SkillConfigObject config = Resources.Load <SkillConfigObject>("SkillConfigs/Skill_1001_黑火球术"); AbilityEntity abilityA = CombatEntity.AttachSkill <Skill1001Entity>(config); CombatEntity.BindAbilityInput(abilityA, KeyCode.Q); config = Resources.Load <SkillConfigObject>("SkillConfigs/Skill_1002_炎爆"); abilityA = CombatEntity.AttachSkill <Skill1002Entity>(config); CombatEntity.BindAbilityInput(abilityA, KeyCode.W); config = Resources.Load <SkillConfigObject>("SkillConfigs/Skill_1004_血红激光炮"); abilityA = CombatEntity.AttachSkill <Skill1004Ability>(config); CombatEntity.BindAbilityInput(abilityA, KeyCode.E); AnimTimer.MaxTime = AnimTime; }
protected override void Consume(GameObject player) { //Debug.Log("Player consumed an oxygen crystal"); CombatEntity combatEntity = player.GetComponent <CombatEntity>(); combatEntity.ChangeCombatStat(CombatStatType.HealthPoint, healingValue); }
public void Setup(int seat) { if (transform.parent.name.Contains("Hero")) { CombatEntity = CombatContext.Instance.AddHeroEntity(seat); } if (transform.parent.name.Contains("Monster")) { CombatEntity = CombatContext.Instance.AddMonsterEntity(seat); } CombatEntity.CurrentHealth.SetMaxValue(999); CombatEntity.CurrentHealth.Reset(); CombatObjectData = GetComponent <CombatObjectData>(); SeatPoint = transform.position; CombatEntity.ModelObject = gameObject; CombatEntity.ListenActionPoint(ActionPointType.PreJumpTo, OnPreJumpTo); CombatEntity.ListenActionPoint(ActionPointType.PreGiveAttack, OnPreAttack); CombatEntity.ListenActionPoint(ActionPointType.PostGiveAttack, OnPostAttack); CombatEntity.ListenActionPoint(ActionPointType.PostReceiveDamage, OnReceiveDamage); CombatEntity.ListenActionPoint(ActionPointType.PostReceiveCure, OnReceiveCure); CombatEntity.ListenActionPoint(ActionPointType.PostReceiveStatus, OnReceiveStatus); CombatEntity.Subscribe <RemoveStatusEvent>(OnRemoveStatus); CombatEntity.Subscribe <DeadEvent>(OnDead); //var config = Resources.Load<StatusConfigObject>("StatusConfigs/Status_Tenacity"); //var Status = CombatEntity.AttachStatus<StatusTenacity>(config); //Status.Caster = CombatEntity; //Status.TryActivateAbility(); }
/// <summary> /// Returns true if the total critical chance for an attacker is greater than a random number /// generated between 1 and 100. /// </summary> /// <param name="attacker">The attacking CombatEntity.</param> /// <param name="ability">The ability used by the attacker.</param> /// <returns></returns> private bool IsCritical(CombatEntity attacker, Ability ability) { var totalCritChance = attacker.SecondaryStats.CritChance * attacker.SecondaryStats.CritChancePercentage / 100; totalCritChance += attacker.SecondaryStats.CritChance; return(_seed.Next(0, 101) <= totalCritChance); }
/// <summary> /// Gets the total amount of damage an ability will do to a target. /// </summary> /// <param name="attacker">The CombatEntity performing the ability.</param> /// <param name="defender">The CombatEntity who will be damaged by the ability.</param> /// <param name="ability">The ability to calculate damage from.</param> /// <param name="isCrit">If true, will include critical damage in the calculations.</param> /// <returns></returns> public static DamageTypes GetTotalDamage(CombatEntity attacker, CombatEntity defender, Ability ability, bool isCrit = false) { var damage = GetDamage(attacker, ability, isCrit); damage += GetPercentageDamage(defender, ability); return(GetTotalDamage(damage, defender)); }
public void Setup(GameObject spellVFX, CombatEntity target, ProjectileSpell castedSpell, float projectileSpeed) { this.spellVFX = Instantiate(spellVFX, transform.position, Quaternion.identity); this.spellVFX.transform.SetParent(transform); this.target = target; this.castedSpell = castedSpell; speed = projectileSpeed; }
private CombatEntity LocateEntity( string id, string name ) { if( !this.entities.ContainsKey( id ) ) { if( name == null ) return null; CombatEntity entity = new CombatEntity(); entity.Id = id; entity.Name = name; this.entities.Add( id, entity ); } return this.entities[id]; }
private CombatEntity CountEntity( CombatId entityId, string entityName, CombatId parentId ) { CombatEntity entity = this.FindEntityById( entityId.Value ); if( entity == null ) { entity = new CombatEntity(); entity.Id = entityId; entity.Name = entityName; entity.Analyzer = new CombatLogAnalyzer( entityId.Value ); this.entities.Add( entityId.Value, entity ); if( this.EntityFound != null && entity.IsPlayerCharacter ) this.EntityFound( this, new EntityFoundArgs() { Entity = entity } ); } entity.Name = entityName; // overwrite any existing name entity.NumMentions++; if( !parentId.IsNull ) { // If a pet, establish relationship with parent entity.IsPet = true; CombatEntity parent = this.FindEntityById( parentId.Value ); if( parent == null ) { parent = new CombatEntity(); parent.Id = parentId; parent.Name = "(pet owner)"; parent.Analyzer = new CombatLogAnalyzer( entityId.Value ); this.entities.Add( parent.Id.Value, parent ); } if( !parent.Pets.Contains( entity ) ) parent.Pets.Add( entity ); entity.Parent = parent; } return entity; }
private void PopulateEncounters( CombatEntity entity ) { this.encounterListBox.SelectedItem = null; this.encounterListBox.Items.Clear(); foreach( CombatEncounter encounter in this.parser.Encounters ) { if( !encounter.ContainsEntity( entity ) ) continue; ListBoxItem item = new ListBoxItem(); item.Tag = encounter; item.Content = string.Format( "{0:00}:{1:00} {3} - {2} participants", encounter.Elapsed.Minutes, encounter.Elapsed.Seconds, encounter.Entities.Count, encounter.EncounterName ); this.encounterListBox.Items.Add( item ); } if( encounterListBox.Items.Count > 0 ) ((ListBoxItem)encounterListBox.Items[0]).BringIntoView(); }